From 8a33982e543b7fb8c09be90ebadb33fe7f99b52f Mon Sep 17 00:00:00 2001 From: hop311 Date: Sat, 23 Dec 2023 18:26:05 +0000 Subject: Fixed TGC compatibility + misc cleanup --- src/openvic-simulation/interface/GFX.cpp | 16 +++++++++++++++- src/openvic-simulation/interface/GFX.hpp | 20 +++++++++++++++++++- src/openvic-simulation/interface/GUI.cpp | 6 ++++-- src/openvic-simulation/interface/GUI.hpp | 3 +-- 4 files changed, 39 insertions(+), 6 deletions(-) (limited to 'src/openvic-simulation/interface') diff --git a/src/openvic-simulation/interface/GFX.cpp b/src/openvic-simulation/interface/GFX.cpp index 927b832..f9ae56b 100644 --- a/src/openvic-simulation/interface/GFX.cpp +++ b/src/openvic-simulation/interface/GFX.cpp @@ -15,9 +15,9 @@ node_callback_t Sprite::expect_sprite(callback_t&&> call "LineChartType", ZERO_OR_MORE, _expect_instance(callback), "textSpriteType", ZERO_OR_MORE, _expect_instance(callback), "maskedShieldType", ZERO_OR_MORE, _expect_instance(callback), + "tileSpriteType", ZERO_OR_MORE, _expect_instance(callback), // TODO - add the rest of the sprite types "corneredTileSpriteType", ZERO_OR_MORE, success_callback, - "tileSpriteType", ZERO_OR_MORE, success_callback, "BarChartType", ZERO_OR_MORE, success_callback, "scrollingSprite", ZERO_OR_MORE, success_callback ); @@ -42,6 +42,20 @@ bool TextureSprite::_fill_key_map(key_map_t& key_map) { return ret; } +TileTextureSprite::TileTextureSprite() : texture_file {}, size {} {} + +bool TileTextureSprite::_fill_key_map(key_map_t& key_map) { + bool ret = Sprite::_fill_key_map(key_map); + ret &= add_key_map_entries(key_map, + "texturefile", ZERO_OR_ONE, expect_string(assign_variable_callback_string(texture_file)), + "size", ZERO_OR_ONE, expect_ivec2(assign_variable_callback(size)), + + "norefcount", ZERO_OR_ONE, success_callback, + "loadType", ZERO_OR_ONE, success_callback + ); + return ret; +} + ProgressBar::ProgressBar() : back_colour {}, progress_colour {} {} bool ProgressBar::_fill_key_map(key_map_t& key_map) { diff --git a/src/openvic-simulation/interface/GFX.hpp b/src/openvic-simulation/interface/GFX.hpp index ff27613..c7523b3 100644 --- a/src/openvic-simulation/interface/GFX.hpp +++ b/src/openvic-simulation/interface/GFX.hpp @@ -45,7 +45,7 @@ namespace OpenVic::GFX { std::string PROPERTY(texture_file); frame_t PROPERTY(no_of_frames); - // TODO - norefcount, effectFile, allwaystransparent + // TODO - effectFile, allwaystransparent protected: TextureSprite(); @@ -59,6 +59,24 @@ namespace OpenVic::GFX { OV_DETAIL_GET_TYPE }; + class TileTextureSprite final : public Sprite { + friend std::unique_ptr std::make_unique(); + + std::string PROPERTY(texture_file); + ivec2_t PROPERTY(size); + + protected: + TileTextureSprite(); + + bool _fill_key_map(NodeTools::key_map_t& key_map) override; + + public: + TileTextureSprite(TileTextureSprite&&) = default; + virtual ~TileTextureSprite() = default; + + OV_DETAIL_GET_TYPE + }; + class ProgressBar final : public Sprite { friend std::unique_ptr std::make_unique(); diff --git a/src/openvic-simulation/interface/GUI.cpp b/src/openvic-simulation/interface/GUI.cpp index 244909e..23a577c 100644 --- a/src/openvic-simulation/interface/GUI.cpp +++ b/src/openvic-simulation/interface/GUI.cpp @@ -93,7 +93,9 @@ bool BaseButton::_fill_key_map(NodeTools::key_map_t& key_map, UIManager const& u bool ret = Element::_fill_key_map(key_map, ui_manager); // look up sprite registry for texture sprite with name... ret &= add_key_map_entries(key_map, - "quadTextureSprite", ONE_EXACTLY, + "quadTextureSprite", ZERO_OR_ONE, + expect_string(ui_manager.expect_sprite_str(assign_variable_callback_pointer(sprite)), true), + "spriteType", ZERO_OR_ONE, expect_string(ui_manager.expect_sprite_str(assign_variable_callback_pointer(sprite)), true), "shortcut", ZERO_OR_ONE, success_callback // TODO - load and use shortcuts (how to integrate with custom keybinds?) ); @@ -160,7 +162,7 @@ bool OverlappingElementsBox::_fill_key_map(NodeTools::key_map_t& key_map, UIMana bool ret = AlignedElement::_fill_key_map(key_map, ui_manager); ret &= add_key_map_entries(key_map, "size", ONE_EXACTLY, expect_fvec2(assign_variable_callback(size)), - "spacing", ONE_EXACTLY, success_callback + "spacing", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(spacing)) ); return ret; } diff --git a/src/openvic-simulation/interface/GUI.hpp b/src/openvic-simulation/interface/GUI.hpp index 47bd57d..d658adf 100644 --- a/src/openvic-simulation/interface/GUI.hpp +++ b/src/openvic-simulation/interface/GUI.hpp @@ -196,8 +196,7 @@ namespace OpenVic::GUI { friend std::unique_ptr std::make_unique(); fvec2_t PROPERTY(size); - - // TODO - spacing + fixed_point_t PROPERTY(spacing); protected: OverlappingElementsBox(); -- cgit v1.2.3-56-ga3b1