Skip to content

Commit 7fcd370

Browse files
committed
Game/Menu: Load font only once
1 parent b24e155 commit 7fcd370

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

src/Game/States/MenuState.cpp

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,14 @@
33
// For conditions of distribution and use, see copyright notice in LICENSE
44

55
#include <Game/States/MenuState.hpp>
6-
#include <CommonLib/GameConstants.hpp>
7-
#include <CommonLib/InternalConstants.hpp>
8-
#include <CommonLib/UpdaterAppComponent.hpp>
9-
#include <CommonLib/Version.hpp>
10-
#include <Game/GameConfigAppComponent.hpp>
11-
#include <Game/States/ConnectionState.hpp>
126
#include <Game/States/GameState.hpp>
137
#include <Game/States/PlayState.hpp>
14-
#include <Game/States/UpdateState.hpp>
158
#include <Nazara/Widgets.hpp>
169
#include <Nazara/Core/ApplicationBase.hpp>
1710
#include <Nazara/Core/FilesystemAppComponent.hpp>
1811
#include <Nazara/Core/StateMachine.hpp>
19-
#include <Nazara/Core/StringExt.hpp>
20-
#include <Nazara/Graphics/PredefinedMaterials.hpp>
2112
#include <Nazara/Graphics/TextureAsset.hpp>
22-
#include <Nazara/Network/Algorithm.hpp>
23-
#include <Nazara/Network/IpAddress.hpp>
24-
#include <Nazara/Network/Network.hpp>
2513
#include <Nazara/TextRenderer/SimpleTextDrawer.hpp>
26-
#include <fmt/color.h>
27-
#include <fmt/format.h>
28-
#include <nlohmann/json.hpp>
2914
#include <optional>
3015

3116
namespace tsom
@@ -46,24 +31,23 @@ namespace tsom
4631

4732
m_title = CreateWidget<Nz::SimpleLabelWidget>();
4833

34+
auto& filesystem = GetStateData().app->GetComponent<Nz::FilesystemAppComponent>();
35+
std::shared_ptr<Nz::Font> titleFont = filesystem.Open<Nz::Font>("assets/fonts/axaxax bd.otf");
36+
4937
m_title->UpdateDrawer([&](Nz::SimpleTextDrawer& textDrawer)
5038
{
51-
auto& filesystem = GetStateData().app->GetComponent<Nz::FilesystemAppComponent>();
52-
5339
textDrawer.SetTextOutlineColor(Nz::Color::White());
5440
textDrawer.SetText("This Space Of Mine");
55-
textDrawer.SetTextFont(filesystem.Open<Nz::Font>("assets/fonts/axaxax bd.otf"));
41+
textDrawer.SetTextFont(titleFont);
5642
textDrawer.SetTextStyle(Nz::TextStyle::OutlineOnly);
5743
});
5844

5945
m_titleBackground = m_title->Add<Nz::SimpleLabelWidget>();
6046
m_titleBackground->UpdateDrawer([&](Nz::SimpleTextDrawer& textDrawer)
6147
{
62-
auto& filesystem = GetStateData().app->GetComponent<Nz::FilesystemAppComponent>();
63-
6448
textDrawer.SetTextOutlineColor(Nz::Color(1.f, 1.f, 1.f, 0.3f));
6549
textDrawer.SetText("This Space Of Mine");
66-
textDrawer.SetTextFont(filesystem.Open<Nz::Font>("assets/fonts/axaxax bd.otf"));
50+
textDrawer.SetTextFont(titleFont);
6751
textDrawer.SetTextStyle(Nz::TextStyle::OutlineOnly);
6852
});
6953
m_titleBackground->SetPosition({ 7.f, -7.f });

0 commit comments

Comments
 (0)