diff options
author | Hop311 <Hop3114@gmail.com> | 2024-02-19 22:09:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-19 22:09:17 +0100 |
commit | 147e0a772dc768bd90fdccdd2536f14c11238d57 (patch) | |
tree | aef9a168b1e4ce5b15797bca460abda5edf465c0 /src/openvic-simulation/interface/GFX.cpp | |
parent | 35e5f7828a41736194362186ad4f946fad5964d1 (diff) | |
parent | 31a3521643dbf4bd218a6af10025f99ac3bf7e98 (diff) |
Merge pull request #149 from OpenVicProject/fp-rounding+texture-sprites
Fixed point rounding and Texture Sprites
Diffstat (limited to 'src/openvic-simulation/interface/GFX.cpp')
-rw-r--r-- | src/openvic-simulation/interface/GFX.cpp | 42 |
1 files changed, 22 insertions, 20 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; } |