aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/interface
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-01-25 00:28:09 +0100
committer hop311 <hop3114@gmail.com>2024-01-25 21:31:04 +0100
commit14ba9531d118fab87b360db4aae765807fca3cec (patch)
tree97a1bff45f91d4b02ef62c4dd9a8e584699e5fdd /src/openvic-simulation/interface
parent3e2ee2cd3553cb0a5949d7a34c5ef2f10ff5c949 (diff)
Added StringMapCase and case insensitive expect_dictionary_keyscase-rework
Diffstat (limited to 'src/openvic-simulation/interface')
-rw-r--r--src/openvic-simulation/interface/GFX.cpp13
-rw-r--r--src/openvic-simulation/interface/GFX.hpp12
-rw-r--r--src/openvic-simulation/interface/GUI.cpp27
-rw-r--r--src/openvic-simulation/interface/GUI.hpp24
-rw-r--r--src/openvic-simulation/interface/LoadBase.hpp6
5 files changed, 40 insertions, 42 deletions
diff --git a/src/openvic-simulation/interface/GFX.cpp b/src/openvic-simulation/interface/GFX.cpp
index 0ec2954..ca31419 100644
--- a/src/openvic-simulation/interface/GFX.cpp
+++ b/src/openvic-simulation/interface/GFX.cpp
@@ -26,11 +26,10 @@ node_callback_t Sprite::expect_sprites(length_callback_t length_callback, callba
TextureSprite::TextureSprite() : texture_file {}, no_of_frames { NO_FRAMES } {}
-bool TextureSprite::_fill_key_map(key_map_t& key_map) {
+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)),
- "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,
@@ -45,7 +44,7 @@ bool TextureSprite::_fill_key_map(key_map_t& key_map) {
TileTextureSprite::TileTextureSprite() : texture_file {}, size {} {}
-bool TileTextureSprite::_fill_key_map(key_map_t& key_map) {
+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)),
@@ -59,7 +58,7 @@ bool TileTextureSprite::_fill_key_map(key_map_t& key_map) {
ProgressBar::ProgressBar() : back_colour {}, progress_colour {} {}
-bool ProgressBar::_fill_key_map(key_map_t& key_map) {
+bool ProgressBar::_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,
"color", ONE_EXACTLY, expect_colour(assign_variable_callback(progress_colour)),
@@ -78,7 +77,7 @@ bool ProgressBar::_fill_key_map(key_map_t& key_map) {
PieChart::PieChart() : size {} {}
-bool PieChart::_fill_key_map(key_map_t& key_map) {
+bool PieChart::_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, "size", ONE_EXACTLY, expect_uint(assign_variable_callback(size)));
return ret;
@@ -86,7 +85,7 @@ bool PieChart::_fill_key_map(key_map_t& key_map) {
LineChart::LineChart() : size {}, linewidth {} {}
-bool LineChart::_fill_key_map(key_map_t& key_map) {
+bool LineChart::_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,
"size", ONE_EXACTLY, expect_ivec2(assign_variable_callback(size)),
@@ -98,7 +97,7 @@ bool LineChart::_fill_key_map(key_map_t& key_map) {
MaskedFlag::MaskedFlag() : overlay_file {}, mask_file {} {}
-bool MaskedFlag::_fill_key_map(key_map_t& key_map) {
+bool MaskedFlag::_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,
"textureFile1", ONE_EXACTLY, expect_string(assign_variable_callback_string(overlay_file)),
diff --git a/src/openvic-simulation/interface/GFX.hpp b/src/openvic-simulation/interface/GFX.hpp
index efd2293..21baa85 100644
--- a/src/openvic-simulation/interface/GFX.hpp
+++ b/src/openvic-simulation/interface/GFX.hpp
@@ -52,7 +52,7 @@ namespace OpenVic::GFX {
protected:
TextureSprite();
- bool _fill_key_map(NodeTools::key_map_t& key_map) override;
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) override;
public:
TextureSprite(TextureSprite&&) = default;
@@ -70,7 +70,7 @@ namespace OpenVic::GFX {
protected:
TileTextureSprite();
- bool _fill_key_map(NodeTools::key_map_t& key_map) override;
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) override;
public:
TileTextureSprite(TileTextureSprite&&) = default;
@@ -93,7 +93,7 @@ namespace OpenVic::GFX {
protected:
ProgressBar();
- bool _fill_key_map(NodeTools::key_map_t& key_map) override;
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) override;
public:
ProgressBar(ProgressBar&&) = default;
@@ -110,7 +110,7 @@ namespace OpenVic::GFX {
protected:
PieChart();
- bool _fill_key_map(NodeTools::key_map_t& key_map) override;
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) override;
public:
PieChart(PieChart&&) = default;
@@ -128,7 +128,7 @@ namespace OpenVic::GFX {
protected:
LineChart();
- bool _fill_key_map(NodeTools::key_map_t& key_map) override;
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) override;
public:
LineChart(LineChart&&) = default;
@@ -146,7 +146,7 @@ namespace OpenVic::GFX {
protected:
MaskedFlag();
- bool _fill_key_map(NodeTools::key_map_t& key_map) override;
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) override;
public:
MaskedFlag(MaskedFlag&&) = default;
diff --git a/src/openvic-simulation/interface/GUI.cpp b/src/openvic-simulation/interface/GUI.cpp
index 23a577c..7aebfe8 100644
--- a/src/openvic-simulation/interface/GUI.cpp
+++ b/src/openvic-simulation/interface/GUI.cpp
@@ -8,7 +8,7 @@ using namespace OpenVic::NodeTools;
Element::Element() : position {}, orientation { orientation_t::UPPER_LEFT } {}
-bool Element::_fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) {
+bool Element::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) {
bool ret = Named::_fill_key_map(key_map, ui_manager);
using enum orientation_t;
static const string_map_t<orientation_t> orientation_map = {
@@ -18,14 +18,13 @@ bool Element::_fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_m
};
ret &= add_key_map_entries(key_map,
"position", ONE_EXACTLY, expect_fvec2(assign_variable_callback(position)),
- "orientation", ZERO_OR_ONE, expect_string(expect_mapped_string(orientation_map, assign_variable_callback(orientation))),
- "Orientation", ZERO_OR_ONE, expect_string(expect_mapped_string(orientation_map, assign_variable_callback(orientation)))
+ "orientation", ZERO_OR_ONE, expect_string(expect_mapped_string(orientation_map, assign_variable_callback(orientation)))
);
return ret;
}
bool Element::_fill_elements_key_map(
- NodeTools::key_map_t& key_map, callback_t<std::unique_ptr<Element>&&> callback, UIManager const& ui_manager
+ NodeTools::case_insensitive_key_map_t& key_map, callback_t<std::unique_ptr<Element>&&> callback, UIManager const& ui_manager
) {
bool ret = true;
ret &= add_key_map_entries(key_map,
@@ -42,7 +41,7 @@ bool Element::_fill_elements_key_map(
return ret;
}
-bool Scene::_fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) {
+bool Scene::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) {
return Element::_fill_elements_key_map(key_map, [this](std::unique_ptr<Element>&& element) -> bool {
return scene_elements.add_item(std::move(element));
}, ui_manager);
@@ -59,7 +58,7 @@ node_callback_t Scene::expect_scene(
Window::Window() : moveable { false }, fullscreen { false } {}
-bool Window::_fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) {
+bool Window::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) {
bool ret = Element::_fill_elements_key_map(key_map, [this](std::unique_ptr<Element>&& element) -> bool {
return window_elements.add_item(std::move(element));
}, ui_manager);
@@ -78,7 +77,7 @@ bool Window::_fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_ma
Icon::Icon() : sprite { nullptr }, frame { GFX::NO_FRAMES } {}
-bool Icon::_fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) {
+bool Icon::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) {
bool ret = Element::_fill_key_map(key_map, ui_manager);
ret &= add_key_map_entries(key_map,
"spriteType", ONE_EXACTLY, expect_string(ui_manager.expect_sprite_str(assign_variable_callback_pointer(sprite))),
@@ -89,7 +88,7 @@ bool Icon::_fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_mana
BaseButton::BaseButton() : sprite { nullptr } {}
-bool BaseButton::_fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) {
+bool BaseButton::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) {
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,
@@ -104,7 +103,7 @@ bool BaseButton::_fill_key_map(NodeTools::key_map_t& key_map, UIManager const& u
Button::Button() : text {}, font { nullptr} {}
-bool Button::_fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) {
+bool Button::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) {
bool ret = BaseButton::_fill_key_map(key_map, ui_manager);
ret &= add_key_map_entries(key_map,
"buttonText", ZERO_OR_ONE, expect_string(assign_variable_callback_string(text), true),
@@ -118,14 +117,14 @@ bool Button::_fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_ma
return ret;
}
-bool Checkbox::_fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) {
+bool Checkbox::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) {
bool ret = BaseButton::_fill_key_map(key_map, ui_manager);
return ret;
}
AlignedElement::AlignedElement() : format { format_t::left } {}
-bool AlignedElement::_fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) {
+bool AlignedElement::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) {
bool ret = Element::_fill_key_map(key_map, ui_manager);
using enum format_t;
static const string_map_t<format_t> format_map = {
@@ -139,7 +138,7 @@ bool AlignedElement::_fill_key_map(NodeTools::key_map_t& key_map, UIManager cons
Text::Text() : text {}, font { nullptr } {}
-bool Text::_fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) {
+bool Text::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) {
bool ret = AlignedElement::_fill_key_map(key_map, ui_manager);
ret &= add_key_map_entries(key_map,
"text", ZERO_OR_ONE, expect_string(assign_variable_callback_string(text), true),
@@ -158,7 +157,7 @@ bool Text::_fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_mana
OverlappingElementsBox::OverlappingElementsBox() : size {} {}
-bool OverlappingElementsBox::_fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) {
+bool OverlappingElementsBox::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) {
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)),
@@ -169,7 +168,7 @@ bool OverlappingElementsBox::_fill_key_map(NodeTools::key_map_t& key_map, UIMana
ListBox::ListBox() : size {} {}
-bool ListBox::_fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) {
+bool ListBox::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) {
bool ret = Element::_fill_key_map(key_map, ui_manager);
ret &= add_key_map_entries(key_map,
"backGround", ZERO_OR_ONE, success_callback,
diff --git a/src/openvic-simulation/interface/GUI.hpp b/src/openvic-simulation/interface/GUI.hpp
index d658adf..96bb2a2 100644
--- a/src/openvic-simulation/interface/GUI.hpp
+++ b/src/openvic-simulation/interface/GUI.hpp
@@ -23,9 +23,9 @@ namespace OpenVic::GUI {
protected:
Element();
- bool _fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) override;
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;
static bool _fill_elements_key_map(
- NodeTools::key_map_t& key_map, NodeTools::callback_t<std::unique_ptr<Element>&&> callback,
+ NodeTools::case_insensitive_key_map_t& key_map, NodeTools::callback_t<std::unique_ptr<Element>&&> callback,
UIManager const& ui_manager
);
@@ -45,7 +45,7 @@ namespace OpenVic::GUI {
protected:
Scene() = default;
- bool _fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) override;
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;
public:
Scene(Scene&&) = default;
@@ -72,7 +72,7 @@ namespace OpenVic::GUI {
protected:
Window();
- bool _fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) override;
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;
public:
Window(Window&&) = default;
@@ -90,7 +90,7 @@ namespace OpenVic::GUI {
protected:
Icon();
- bool _fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) override;
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;
public:
Icon(Icon&&) = default;
@@ -106,7 +106,7 @@ namespace OpenVic::GUI {
protected:
BaseButton();
- bool _fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) override;
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;
public:
BaseButton(BaseButton&&) = default;
@@ -126,7 +126,7 @@ namespace OpenVic::GUI {
protected:
Button();
- bool _fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) override;
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;
public:
Button(Button&&) = default;
@@ -141,7 +141,7 @@ namespace OpenVic::GUI {
protected:
Checkbox() = default;
- bool _fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) override;
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;
public:
Checkbox(Checkbox&&) = default;
@@ -162,7 +162,7 @@ namespace OpenVic::GUI {
protected:
AlignedElement();
- bool _fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) override;
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;
public:
AlignedElement(AlignedElement&&) = default;
@@ -183,7 +183,7 @@ namespace OpenVic::GUI {
protected:
Text();
- bool _fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) override;
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;
public:
Text(Text&&) = default;
@@ -201,7 +201,7 @@ namespace OpenVic::GUI {
protected:
OverlappingElementsBox();
- bool _fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) override;
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;
public:
OverlappingElementsBox(OverlappingElementsBox&&) = default;
@@ -220,7 +220,7 @@ namespace OpenVic::GUI {
protected:
ListBox();
- bool _fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) override;
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;
public:
ListBox(ListBox&&) = default;
diff --git a/src/openvic-simulation/interface/LoadBase.hpp b/src/openvic-simulation/interface/LoadBase.hpp
index 3363651..10b0169 100644
--- a/src/openvic-simulation/interface/LoadBase.hpp
+++ b/src/openvic-simulation/interface/LoadBase.hpp
@@ -10,14 +10,14 @@ namespace OpenVic {
protected:
LoadBase() = default;
- virtual bool _fill_key_map(NodeTools::key_map_t&, Context...) = 0;
+ virtual bool _fill_key_map(NodeTools::case_insensitive_key_map_t&, Context...) = 0;
public:
LoadBase(LoadBase&&) = default;
virtual ~LoadBase() = default;
bool load(ast::NodeCPtr node, Context... context) {
- NodeTools::key_map_t key_map;
+ NodeTools::case_insensitive_key_map_t key_map;
bool ret = _fill_key_map(key_map, context...);
ret &= NodeTools::expect_dictionary_key_map(std::move(key_map))(node);
return ret;
@@ -45,7 +45,7 @@ namespace OpenVic {
protected:
Named() = default;
- virtual bool _fill_key_map(NodeTools::key_map_t& key_map, Context...) override {
+ virtual bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, Context...) override {
using namespace OpenVic::NodeTools;
return add_key_map_entries(key_map, "name", ONE_EXACTLY, expect_string(assign_variable_callback_string(name)));
}