diff options
author | hop311 <hop3114@gmail.com> | 2023-12-23 19:26:05 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2023-12-23 19:26:05 +0100 |
commit | 8a33982e543b7fb8c09be90ebadb33fe7f99b52f (patch) | |
tree | 0fb82e22b383996606ef6adc3e92c42d85bc6777 /src/openvic-simulation/interface | |
parent | 14e47d58b85f657ec1fed8abf88219f09bd3efbb (diff) |
Fixed TGC compatibility + misc cleanup
Diffstat (limited to 'src/openvic-simulation/interface')
-rw-r--r-- | src/openvic-simulation/interface/GFX.cpp | 16 | ||||
-rw-r--r-- | src/openvic-simulation/interface/GFX.hpp | 20 | ||||
-rw-r--r-- | src/openvic-simulation/interface/GUI.cpp | 6 | ||||
-rw-r--r-- | src/openvic-simulation/interface/GUI.hpp | 3 |
4 files changed, 39 insertions, 6 deletions
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<std::unique_ptr<Sprite>&&> call "LineChartType", ZERO_OR_MORE, _expect_instance<Sprite, LineChart>(callback), "textSpriteType", ZERO_OR_MORE, _expect_instance<Sprite, TextureSprite>(callback), "maskedShieldType", ZERO_OR_MORE, _expect_instance<Sprite, MaskedFlag>(callback), + "tileSpriteType", ZERO_OR_MORE, _expect_instance<Sprite, TileTextureSprite>(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<TileTextureSprite> std::make_unique<TileTextureSprite>(); + + 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<ProgressBar> std::make_unique<ProgressBar>(); 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<OverlappingElementsBox> std::make_unique<OverlappingElementsBox>(); fvec2_t PROPERTY(size); - - // TODO - spacing + fixed_point_t PROPERTY(spacing); protected: OverlappingElementsBox(); |