From 7fcd370d541e3318c8a841ffb5ac88572af57440 Mon Sep 17 00:00:00 2001 From: SirLynix Date: Sun, 27 Oct 2024 00:31:36 +0200 Subject: [PATCH] Game/Menu: Load font only once --- src/Game/States/MenuState.cpp | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/Game/States/MenuState.cpp b/src/Game/States/MenuState.cpp index 164478b..8cfe761 100644 --- a/src/Game/States/MenuState.cpp +++ b/src/Game/States/MenuState.cpp @@ -3,29 +3,14 @@ // For conditions of distribution and use, see copyright notice in LICENSE #include -#include -#include -#include -#include -#include -#include #include #include -#include #include #include #include #include -#include -#include #include -#include -#include -#include #include -#include -#include -#include #include namespace tsom @@ -46,24 +31,23 @@ namespace tsom m_title = CreateWidget(); + auto& filesystem = GetStateData().app->GetComponent(); + std::shared_ptr titleFont = filesystem.Open("assets/fonts/axaxax bd.otf"); + m_title->UpdateDrawer([&](Nz::SimpleTextDrawer& textDrawer) { - auto& filesystem = GetStateData().app->GetComponent(); - textDrawer.SetTextOutlineColor(Nz::Color::White()); textDrawer.SetText("This Space Of Mine"); - textDrawer.SetTextFont(filesystem.Open("assets/fonts/axaxax bd.otf")); + textDrawer.SetTextFont(titleFont); textDrawer.SetTextStyle(Nz::TextStyle::OutlineOnly); }); m_titleBackground = m_title->Add(); m_titleBackground->UpdateDrawer([&](Nz::SimpleTextDrawer& textDrawer) { - auto& filesystem = GetStateData().app->GetComponent(); - textDrawer.SetTextOutlineColor(Nz::Color(1.f, 1.f, 1.f, 0.3f)); textDrawer.SetText("This Space Of Mine"); - textDrawer.SetTextFont(filesystem.Open("assets/fonts/axaxax bd.otf")); + textDrawer.SetTextFont(titleFont); textDrawer.SetTextStyle(Nz::TextStyle::OutlineOnly); }); m_titleBackground->SetPosition({ 7.f, -7.f });