aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/interface/GFX.cpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-02-04 15:09:06 +0100
committer hop311 <hop3114@gmail.com>2024-02-04 15:09:06 +0100
commit87fa1c74281a651b23089079c4c1621d4fb66d73 (patch)
tree4e343f81b13f166ad4a478962348d4734ea7e11b /src/openvic-simulation/interface/GFX.cpp
parent3f6d7351816b0e089495b2f15dc1c956f3151f5a (diff)
Added support for loading all gui filesgui-loading
Diffstat (limited to 'src/openvic-simulation/interface/GFX.cpp')
-rw-r--r--src/openvic-simulation/interface/GFX.cpp35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/openvic-simulation/interface/GFX.cpp b/src/openvic-simulation/interface/GFX.cpp
index ca31419..ff2737c 100644
--- a/src/openvic-simulation/interface/GFX.cpp
+++ b/src/openvic-simulation/interface/GFX.cpp
@@ -4,8 +4,11 @@ using namespace OpenVic;
using namespace OpenVic::GFX;
using namespace OpenVic::NodeTools;
-Font::Font(std::string_view new_identifier, colour_argb_t new_colour, std::string_view new_fontname)
- : HasIdentifierAndAlphaColour { new_identifier, new_colour, false }, fontname { new_fontname } {}
+Font::Font(
+ std::string_view new_identifier, colour_argb_t new_colour, std::string_view new_fontname, std::string_view new_charset,
+ uint32_t new_height
+) : HasIdentifierAndAlphaColour { new_identifier, new_colour, false }, fontname { new_fontname }, charset { new_charset },
+ height { new_height } {}
node_callback_t Sprite::expect_sprites(length_callback_t length_callback, callback_t<std::unique_ptr<Sprite>&&> callback) {
return expect_dictionary_keys_and_length(
@@ -17,8 +20,9 @@ node_callback_t Sprite::expect_sprites(length_callback_t length_callback, callba
"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,
+ "corneredTileSpriteType", ZERO_OR_MORE, _expect_instance<Sprite, CorneredTileTextureSprite>(callback),
+
+ /* Each only has one vanilla instance which isn't used anywhere. */
"BarChartType", ZERO_OR_MORE, success_callback,
"scrollingSprite", ZERO_OR_MORE, success_callback
);
@@ -47,8 +51,8 @@ TileTextureSprite::TileTextureSprite() : texture_file {}, size {} {}
bool TileTextureSprite::_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)),
- "size", ZERO_OR_ONE, expect_ivec2(assign_variable_callback(size)),
+ "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
@@ -56,7 +60,22 @@ bool TileTextureSprite::_fill_key_map(case_insensitive_key_map_t& key_map) {
return ret;
}
-ProgressBar::ProgressBar() : back_colour {}, progress_colour {} {}
+CorneredTileTextureSprite::CorneredTileTextureSprite() : texture_file {}, size {}, border_size {} {}
+
+bool CorneredTileTextureSprite::_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)),
+ "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
+ );
+ return ret;
+}
+
+ProgressBar::ProgressBar() : back_colour {}, back_texture_file {}, progress_colour {}, progress_texture_file {}, size {} {}
bool ProgressBar::_fill_key_map(case_insensitive_key_map_t& key_map) {
bool ret = Sprite::_fill_key_map(key_map);
@@ -90,6 +109,7 @@ bool LineChart::_fill_key_map(case_insensitive_key_map_t& key_map) {
ret &= add_key_map_entries(key_map,
"size", ONE_EXACTLY, expect_ivec2(assign_variable_callback(size)),
"linewidth", ONE_EXACTLY, expect_uint(assign_variable_callback(linewidth)),
+
"allwaystransparent", ZERO_OR_ONE, success_callback
);
return ret;
@@ -102,6 +122,7 @@ bool MaskedFlag::_fill_key_map(case_insensitive_key_map_t& key_map) {
ret &= add_key_map_entries(key_map,
"textureFile1", ONE_EXACTLY, expect_string(assign_variable_callback_string(overlay_file)),
"textureFile2", ONE_EXACTLY, expect_string(assign_variable_callback_string(mask_file)),
+
"effectFile", ONE_EXACTLY, success_callback,
"allwaystransparent", ZERO_OR_ONE, success_callback,
"flipv", ZERO_OR_ONE, success_callback