diff options
author | hop311 <hop3114@gmail.com> | 2024-02-19 21:36:58 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-02-19 21:36:58 +0100 |
commit | 22b30266a431de0b0b60cf9c0aed5a364da6ab43 (patch) | |
tree | de006dc90bc57d7719265ef55c70f05b7c9af0ba /src/openvic-simulation/interface | |
parent | f5eb9a282891dfee0cfedd5533615448fed2528c (diff) |
Add TextureSprite base classfp-rounding+texture-sprites
Diffstat (limited to 'src/openvic-simulation/interface')
-rw-r--r-- | src/openvic-simulation/interface/GFX.cpp | 42 | ||||
-rw-r--r-- | src/openvic-simulation/interface/GFX.hpp | 31 | ||||
-rw-r--r-- | src/openvic-simulation/interface/GUI.cpp | 4 | ||||
-rw-r--r-- | src/openvic-simulation/interface/GUI.hpp | 6 |
4 files changed, 48 insertions, 35 deletions
diff --git a/src/openvic-simulation/interface/GFX.cpp b/src/openvic-simulation/interface/GFX.cpp index ff2737c..06d4cd3 100644 --- a/src/openvic-simulation/interface/GFX.cpp +++ b/src/openvic-simulation/interface/GFX.cpp @@ -13,11 +13,11 @@ Font::Font( node_callback_t Sprite::expect_sprites(length_callback_t length_callback, callback_t<std::unique_ptr<Sprite>&&> callback) { return expect_dictionary_keys_and_length( length_callback, - "spriteType", ZERO_OR_MORE, _expect_instance<Sprite, TextureSprite>(callback), + "spriteType", ZERO_OR_MORE, _expect_instance<Sprite, IconTextureSprite>(callback), "progressbartype", ZERO_OR_MORE, _expect_instance<Sprite, ProgressBar>(callback), "PieChartType", ZERO_OR_MORE, _expect_instance<Sprite, PieChart>(callback), "LineChartType", ZERO_OR_MORE, _expect_instance<Sprite, LineChart>(callback), - "textSpriteType", ZERO_OR_MORE, _expect_instance<Sprite, TextureSprite>(callback), + "textSpriteType", ZERO_OR_MORE, _expect_instance<Sprite, IconTextureSprite>(callback), "maskedShieldType", ZERO_OR_MORE, _expect_instance<Sprite, MaskedFlag>(callback), "tileSpriteType", ZERO_OR_MORE, _expect_instance<Sprite, TileTextureSprite>(callback), "corneredTileSpriteType", ZERO_OR_MORE, _expect_instance<Sprite, CorneredTileTextureSprite>(callback), @@ -28,49 +28,51 @@ node_callback_t Sprite::expect_sprites(length_callback_t length_callback, callba ); } -TextureSprite::TextureSprite() : texture_file {}, no_of_frames { NO_FRAMES } {} +TextureSprite::TextureSprite() : texture_file {} {} bool TextureSprite::_fill_key_map(case_insensitive_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)), - "noOfFrames", ZERO_OR_ONE, expect_uint(assign_variable_callback(no_of_frames)), "norefcount", ZERO_OR_ONE, success_callback, - "effectFile", ZERO_OR_ONE, success_callback, "allwaystransparent", ZERO_OR_ONE, success_callback, + "loadType", ZERO_OR_ONE, success_callback + ); + return ret; +} + +IconTextureSprite::IconTextureSprite() : no_of_frames { NO_FRAMES } {} + +bool IconTextureSprite::_fill_key_map(case_insensitive_key_map_t& key_map) { + bool ret = TextureSprite::_fill_key_map(key_map); + ret &= add_key_map_entries(key_map, + "noOfFrames", ZERO_OR_ONE, expect_uint(assign_variable_callback(no_of_frames)), + + "effectFile", ZERO_OR_ONE, success_callback, "transparencecheck", ZERO_OR_ONE, success_callback, - "loadType", ZERO_OR_ONE, success_callback, "clicksound", ZERO_OR_ONE, success_callback ); return ret; } -TileTextureSprite::TileTextureSprite() : texture_file {}, size {} {} +TileTextureSprite::TileTextureSprite() : size {} {} bool TileTextureSprite::_fill_key_map(case_insensitive_key_map_t& key_map) { - bool ret = Sprite::_fill_key_map(key_map); + bool ret = TextureSprite::_fill_key_map(key_map); ret &= add_key_map_entries(key_map, - "texturefile", ONE_EXACTLY, expect_string(assign_variable_callback_string(texture_file)), - "size", ONE_EXACTLY, expect_ivec2(assign_variable_callback(size)), - - "norefcount", ZERO_OR_ONE, success_callback, - "loadType", ZERO_OR_ONE, success_callback + "size", ONE_EXACTLY, expect_ivec2(assign_variable_callback(size)) ); return ret; } -CorneredTileTextureSprite::CorneredTileTextureSprite() : texture_file {}, size {}, border_size {} {} +CorneredTileTextureSprite::CorneredTileTextureSprite() : size {}, border_size {} {} bool CorneredTileTextureSprite::_fill_key_map(case_insensitive_key_map_t& key_map) { - bool ret = Sprite::_fill_key_map(key_map); + bool ret = TextureSprite::_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", ONE_EXACTLY, expect_ivec2(assign_variable_callback(size)), - "borderSize", ONE_EXACTLY, expect_ivec2(assign_variable_callback(border_size)), - - "allwaystransparent", ZERO_OR_ONE, success_callback, - "loadType", ZERO_OR_ONE, success_callback + "borderSize", ONE_EXACTLY, expect_ivec2(assign_variable_callback(border_size)) ); return ret; } diff --git a/src/openvic-simulation/interface/GFX.hpp b/src/openvic-simulation/interface/GFX.hpp index 108ecb6..49691c1 100644 --- a/src/openvic-simulation/interface/GFX.hpp +++ b/src/openvic-simulation/interface/GFX.hpp @@ -46,13 +46,8 @@ namespace OpenVic::GFX { ); }; - class TextureSprite final : public Sprite { - friend std::unique_ptr<TextureSprite> std::make_unique<TextureSprite>(); - + class TextureSprite : public Sprite { std::string PROPERTY(texture_file); - frame_t PROPERTY(no_of_frames); - - // TODO - effectFile, allwaystransparent protected: TextureSprite(); @@ -63,13 +58,30 @@ namespace OpenVic::GFX { TextureSprite(TextureSprite&&) = default; virtual ~TextureSprite() = default; + OV_DETAIL_GET_BASE_TYPE(TextureSprite) OV_DETAIL_GET_TYPE }; - class TileTextureSprite final : public Sprite { + class IconTextureSprite final : public TextureSprite { + friend std::unique_ptr<IconTextureSprite> std::make_unique<IconTextureSprite>(); + + frame_t PROPERTY(no_of_frames); + + protected: + IconTextureSprite(); + + bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) override; + + public: + IconTextureSprite(IconTextureSprite&&) = default; + virtual ~IconTextureSprite() = default; + + OV_DETAIL_GET_TYPE + }; + + class TileTextureSprite final : public TextureSprite { friend std::unique_ptr<TileTextureSprite> std::make_unique<TileTextureSprite>(); - std::string PROPERTY(texture_file); ivec2_t PROPERTY(size); protected: @@ -84,10 +96,9 @@ namespace OpenVic::GFX { OV_DETAIL_GET_TYPE }; - class CorneredTileTextureSprite final : public Sprite { + class CorneredTileTextureSprite final : public TextureSprite { friend std::unique_ptr<CorneredTileTextureSprite> std::make_unique<CorneredTileTextureSprite>(); - std::string PROPERTY(texture_file); ivec2_t PROPERTY(size); ivec2_t PROPERTY(border_size); diff --git a/src/openvic-simulation/interface/GUI.cpp b/src/openvic-simulation/interface/GUI.cpp index 94e1fe3..ae4cf0e 100644 --- a/src/openvic-simulation/interface/GUI.cpp +++ b/src/openvic-simulation/interface/GUI.cpp @@ -240,7 +240,7 @@ bool TextEditBox::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, Scrollbar::Scrollbar() : slider_button_name {}, track_button_name {}, less_button_name{}, more_button_name {}, size {}, border_size {}, - min_value {}, max_value {}, step_size {}, start_value {}, horizontal { false }, use_range_limit { false }, + min_value {}, max_value {}, step_size {}, start_value {}, horizontal { false }, range_limited { false }, range_limit_min {}, range_limit_max {}, range_limit_min_icon_name {}, range_limit_max_icon_name {} { scrollbar_elements.reserve(4); /* Space for 4 buttons, might need 2 more for range limit icons. */ } @@ -262,7 +262,7 @@ bool Scrollbar::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UI "stepSize", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(step_size)), "startValue", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(start_value)), "horizontal", ONE_EXACTLY, expect_int_bool(assign_variable_callback(horizontal)), - "useRangeLimit", ZERO_OR_ONE, expect_bool(assign_variable_callback(use_range_limit)), + "useRangeLimit", ZERO_OR_ONE, expect_bool(assign_variable_callback(range_limited)), "rangeLimitMin", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(range_limit_min)), "rangeLimitMax", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(range_limit_max)), "rangeLimitMinIcon", ZERO_OR_ONE, expect_string(assign_variable_callback_string(range_limit_min_icon_name)), diff --git a/src/openvic-simulation/interface/GUI.hpp b/src/openvic-simulation/interface/GUI.hpp index f044f7d..7551d1a 100644 --- a/src/openvic-simulation/interface/GUI.hpp +++ b/src/openvic-simulation/interface/GUI.hpp @@ -296,7 +296,7 @@ namespace OpenVic::GUI { fixed_point_t PROPERTY(start_value); bool PROPERTY_CUSTOM_PREFIX(horizontal, is) - bool PROPERTY(use_range_limit); + bool PROPERTY_CUSTOM_PREFIX(range_limited, is); fixed_point_t PROPERTY(range_limit_min); fixed_point_t PROPERTY(range_limit_max); std::string PROPERTY(range_limit_min_icon_name); @@ -314,8 +314,8 @@ namespace OpenVic::GUI { Scrollbar(Scrollbar&&) = default; virtual ~Scrollbar() = default; - Button const* get_slider_button() const; - Button const* get_track_button() const; + Button const* get_slider_button() const; /* The button you grab and move up and down the scrollbar. */ + Button const* get_track_button() const; /* The track/background the slider button moves along. */ Button const* get_less_button() const; Button const* get_more_button() const; |