diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/openvic-simulation/interface/UI.cpp | 12 | ||||
-rw-r--r-- | src/openvic-simulation/interface/UI.hpp | 1 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/openvic-simulation/interface/UI.cpp b/src/openvic-simulation/interface/UI.cpp index db7e78a..03166b1 100644 --- a/src/openvic-simulation/interface/UI.cpp +++ b/src/openvic-simulation/interface/UI.cpp @@ -23,10 +23,20 @@ bool UIManager::add_font( Logger::error("Invalid fontname for font ", identifier, " - empty!"); return false; } - return fonts.add_item( + const bool ret = fonts.add_item( { identifier, colour, fontname, charset, height, std::move(colour_codes) }, duplicate_warning_callback ); + + if (universal_colour_codes.empty() && ret) { + GFX::Font::colour_codes_t const& loaded_colour_codes = get_fonts().back().get_colour_codes(); + if (!loaded_colour_codes.empty()) { + universal_colour_codes = loaded_colour_codes; + Logger::info("Loaded universal colour codes from font: \"", identifier, "\""); + } + } + + return ret; } bool UIManager::_load_font(ast::NodeCPtr node) { diff --git a/src/openvic-simulation/interface/UI.hpp b/src/openvic-simulation/interface/UI.hpp index 32dba9c..8ba7745 100644 --- a/src/openvic-simulation/interface/UI.hpp +++ b/src/openvic-simulation/interface/UI.hpp @@ -8,6 +8,7 @@ namespace OpenVic { class UIManager { NamedInstanceRegistry<GFX::Sprite> IDENTIFIER_REGISTRY(sprite); IdentifierRegistry<GFX::Font> IDENTIFIER_REGISTRY(font); + GFX::Font::colour_codes_t PROPERTY(universal_colour_codes); NamedInstanceRegistry<GFX::Object> IDENTIFIER_REGISTRY(object); NamedInstanceRegistry<GUI::Scene, UIManager const&> IDENTIFIER_REGISTRY(scene); |