aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/interface
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/interface')
-rw-r--r--src/openvic-simulation/interface/GFXObject.cpp175
-rw-r--r--src/openvic-simulation/interface/GFXObject.hpp70
2 files changed, 135 insertions, 110 deletions
diff --git a/src/openvic-simulation/interface/GFXObject.cpp b/src/openvic-simulation/interface/GFXObject.cpp
index 05527e6..bd23cce 100644
--- a/src/openvic-simulation/interface/GFXObject.cpp
+++ b/src/openvic-simulation/interface/GFXObject.cpp
@@ -11,34 +11,10 @@ node_callback_t Object::expect_objects(length_callback_t length_callback, callba
"EMFXActorType", ZERO_OR_MORE, _expect_instance<Object, Actor>(callback),
/* arrows.gfx */
- "arrowType", ZERO_OR_MORE, expect_dictionary_keys(
- "name", ONE_EXACTLY, success_callback,
- "size", ONE_EXACTLY, success_callback,
- "textureFile", ONE_EXACTLY, success_callback,
- "bodytexture", ONE_EXACTLY, success_callback,
- "color", ONE_EXACTLY, success_callback,
- "colortwo", ONE_EXACTLY, success_callback,
- "endAt", ONE_EXACTLY, success_callback,
- "height", ONE_EXACTLY, success_callback,
- "type", ONE_EXACTLY, success_callback,
- "heading", ONE_EXACTLY, success_callback,
- "effect", ONE_EXACTLY, success_callback
- ),
+ "arrowType", ZERO_OR_MORE, _expect_instance<Object, ArrowType>(callback),
/* battlearrow.gfx */
- "battlearrow", ZERO_OR_MORE, expect_dictionary_keys(
- "name", ONE_EXACTLY, success_callback,
- "textureFile", ONE_EXACTLY, success_callback,
- "textureFile1", ONE_EXACTLY, success_callback,
- "start", ONE_EXACTLY, success_callback,
- "stop", ONE_EXACTLY, success_callback,
- "x", ONE_EXACTLY, success_callback,
- "y", ONE_EXACTLY, success_callback,
- "font", ONE_EXACTLY, success_callback,
- "scale", ONE_EXACTLY, success_callback,
- "nofade", ZERO_OR_ONE, success_callback,
- "textureloop", ZERO_OR_ONE, success_callback
- ),
+ "battlearrow", ZERO_OR_MORE, _expect_instance<Object, BattleArrow>(callback),
"mapinfo", ZERO_OR_MORE, _expect_instance<Object, MapInfo>(callback),
/* mapitems.gfx */
@@ -48,20 +24,8 @@ node_callback_t Object::expect_objects(length_callback_t length_callback, callba
"unitstatsBillboardType", ZERO_OR_MORE, _expect_instance<Object, UnitStatsBillboard>(callback),
/* core.gfx */
- "animatedmaptext", ZERO_OR_MORE, expect_dictionary_keys(
- "name", ONE_EXACTLY, success_callback,
- "speed", ONE_EXACTLY, success_callback,
- "position", ZERO_OR_ONE, success_callback,
- "scale", ZERO_OR_ONE, success_callback,
- "textblock", ONE_EXACTLY, expect_dictionary_keys(
- "text", ONE_EXACTLY, success_callback,
- "color", ONE_EXACTLY, success_callback,
- "font", ONE_EXACTLY, success_callback,
- "position", ONE_EXACTLY, success_callback,
- "size", ONE_EXACTLY, success_callback,
- "format", ONE_EXACTLY, success_callback
- )
- ),
+ "animatedmaptext", ZERO_OR_MORE, _expect_instance<Object, AnimatedMapText>(callback),
+
"flagType", ZERO_OR_MORE, expect_dictionary_keys(
"name", ONE_EXACTLY, success_callback,
"size", ONE_EXACTLY, success_callback
@@ -172,51 +136,54 @@ bool Actor::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) {
return ret;
}
- /* arrows.gfx */
- /*"arrowType", ZERO_OR_MORE, expect_dictionary_keys(
- "name", ONE_EXACTLY, success_callback,
- "size", ONE_EXACTLY, success_callback,
- "textureFile", ONE_EXACTLY, success_callback,
- "bodytexture", ONE_EXACTLY, success_callback,
- "color", ONE_EXACTLY, success_callback,
- "colortwo", ONE_EXACTLY, success_callback,
- "endAt", ONE_EXACTLY, success_callback,
- "height", ONE_EXACTLY, success_callback,
- "type", ONE_EXACTLY, success_callback,
- "heading", ONE_EXACTLY, success_callback,
- "effect", ONE_EXACTLY, success_callback
- ),*/
-
-BattleArrow::BattleArrow() : texture_file {}, scale { 1 } {}
+/* arrows.gfx */
+//todo: verify the texture files labels are correct
+ArrowType::ArrowType() : size { 5 }, texture_file {}, body_texture_file {},
+back_colour {}, progress_colour {}, end_at { 1 }, height { 1 }, arrow_type { 0 },
+heading { 1 }, effect_file {} {}
-bool BattleArrow::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) {
+bool ArrowType::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) {
bool ret = Object::_fill_key_map(key_map);
- /*ret &= add_key_map_entries(key_map,
- "textureFile", ZERO_OR_ONE, expect_string(assign_variable_callback_string(texture_file)),
- "textureFile2", ZERO_OR_ONE, expect_string(assign_variable_callback_string(back_texture_file)),
- "scale", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(scale))
- );*/
+ ret &= add_key_map_entries(key_map,
+ "size", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(size)),
+ "textureFile", ONE_EXACTLY, expect_string(assign_variable_callback_string(texture_file)),
+ "bodytexture", ONE_EXACTLY, expect_string(assign_variable_callback_string(body_texture_file)),
+ "color", ONE_EXACTLY, expect_colour(assign_variable_callback(back_colour)),
+ "colortwo", ONE_EXACTLY, expect_colour(assign_variable_callback(progress_colour)),
+ "endAt", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(end_at)),
+ "height", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(height)),
+ "type", ONE_EXACTLY, expect_int64(assign_variable_callback(arrow_type)),
+ "heading", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(heading)),
+ "effect", ONE_EXACTLY, expect_string(assign_variable_callback_string(effect_file))
+ );
return ret;
}
-/*
- battlearrow.gfx
- "battlearrow", ZERO_OR_MORE, expect_dictionary_keys(
- "name", ONE_EXACTLY, success_callback,
- "textureFile", ONE_EXACTLY, success_callback,
- "textureFile1", ONE_EXACTLY, success_callback,
- "start", ONE_EXACTLY, success_callback,
- "stop", ONE_EXACTLY, success_callback,
- "x", ONE_EXACTLY, success_callback,
- "y", ONE_EXACTLY, success_callback,
- "font", ONE_EXACTLY, success_callback,
- "scale", ONE_EXACTLY, success_callback,
- "nofade", ZERO_OR_ONE, success_callback,
- "textureloop", ZERO_OR_ONE, success_callback
- ),
-*/
+/* battlearrow.gfx */
+//todo: verify textureFile and textureFile1
+BattleArrow::BattleArrow() : texture_file {}, back_texture_file {}, start { 1 }, stop { 1 },
+ x { 1 }, y { 1 }, font {}, scale { 1 }, no_fade { false }, texture_loop {} {}
+
+bool BattleArrow::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) {
+ bool ret = Object::_fill_key_map(key_map);
+
+ ret &= add_key_map_entries(key_map,
+ "textureFile", ONE_EXACTLY, expect_string(assign_variable_callback_string(texture_file)),
+ "textureFile1", ONE_EXACTLY, expect_string(assign_variable_callback_string(back_texture_file)),
+ "start", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(start)),
+ "stop", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(stop)),
+ "x", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(x)),
+ "y", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(y)),
+ "font", ONE_EXACTLY, expect_string(assign_variable_callback_string(font)),
+ "scale", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(scale)),
+ "nofade", ZERO_OR_ONE, expect_bool(assign_variable_callback(no_fade)),
+ "textureloop", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(texture_loop))
+ );
+
+ return ret;
+}
MapInfo::MapInfo() : texture_file {}, scale { 1 } {}
@@ -258,13 +225,10 @@ bool Projection::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) {
return ret;
}
-Billboard::Offset::Offset(fixed_point_t x, fixed_point_t y, fixed_point_t z) :
- x { 0 }, y { 0 }, z { 0 } {}
Billboard::Billboard() :
texture_file {}, scale { 1 }, no_of_frames { 1 }, font_size { 7 },
- offset {0,0,0},
- font {} {}
+ offset {}, font {} {}
//TODO: billboard was a <StringMapCaseInsensitive> on its dictionnary, how do we preserve this?
bool Billboard::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) {
@@ -280,15 +244,7 @@ bool Billboard::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) {
"noOfFrames", ZERO_OR_ONE, expect_int64(assign_variable_callback(no_of_frames)),
"scale", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(scale)),
"font_size", ZERO_OR_ONE, expect_int64(assign_variable_callback(font_size)),
- "offset2", ZERO_OR_ONE,expect_list_of_length(3, expect_fixed_point(
- [&components,&x,&y,&z](fixed_point_t val) -> bool {
- if(components == 0) x = val;
- else if(components == 1) y = val;
- else z = val;
- components++;
- return true;
- })
- ),
+ "offset2", ZERO_OR_ONE, expect_v2_vector3(assign_variable_callback(offset)),
"font", ZERO_OR_ONE, expect_string(assign_variable_callback_string(font))
);
@@ -299,7 +255,6 @@ bool Billboard::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) {
return ret;
}
-// Projection type
UnitStatsBillboard::UnitStatsBillboard() :
texture_file {}, mask_file {}, effect_file {}, scale { 1 },
no_of_frames { 1 }, font_size { 7 }, font {} {}
@@ -323,7 +278,6 @@ bool UnitStatsBillboard::_fill_key_map(NodeTools::case_insensitive_key_map_t& ke
}
-// Projection type
ProgressBar3d::ProgressBar3d() : back_colour {}, progress_colour {}, size {}, effect_file {} {}
//TODO: Verify there aren't more, unused properties?
@@ -339,3 +293,38 @@ bool ProgressBar3d::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map
return ret;
}
+
+
+/* core.gfx */
+AnimatedMapText::TextBlock::TextBlock() :
+text {}, colour {}, font {}, text_position {}, size {}, format {} {}
+
+AnimatedMapText::AnimatedMapText() :
+speed { 1 }, scale { 1 }, position {}, textblock {} {}
+
+//TODO: Verify there aren't more, unused properties?
+bool AnimatedMapText::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) {
+ bool ret = Object::_fill_key_map(key_map);
+
+ //TODO: we should probably extract format_t to a datatype file for both here and GFXSprite to interit from
+ using enum format_t;
+ static const string_map_t<format_t> format_map = {
+ { "left", left }, { "right", right }, { "centre", centre }, { "center", centre }, { "justified", justified }
+ };
+
+ ret &= add_key_map_entries(key_map,
+ "speed", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(speed)),
+ "position", ZERO_OR_ONE, expect_v2_vector3(assign_variable_callback(position)),
+ "scale", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(scale)),
+ "textblock", ONE_EXACTLY, expect_dictionary_keys(
+ "text", ONE_EXACTLY, expect_string(assign_variable_callback_string(textblock.text)),
+ "color", ONE_EXACTLY, expect_colour(assign_variable_callback(textblock.colour)),
+ "font", ONE_EXACTLY, expect_string(assign_variable_callback_string(textblock.font)),
+ "position", ONE_EXACTLY, expect_fvec2(assign_variable_callback(textblock.text_position)),
+ "size", ONE_EXACTLY, expect_fvec2(assign_variable_callback(textblock.size)),
+ "format", ONE_EXACTLY, expect_identifier(expect_mapped_string(format_map, assign_variable_callback(textblock.format)))
+ )
+ );
+
+ return ret;
+} \ No newline at end of file
diff --git a/src/openvic-simulation/interface/GFXObject.hpp b/src/openvic-simulation/interface/GFXObject.hpp
index a633cb5..233a1fd 100644
--- a/src/openvic-simulation/interface/GFXObject.hpp
+++ b/src/openvic-simulation/interface/GFXObject.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "openvic-simulation/interface/LoadBase.hpp"
+#include <openvic-simulation/types/unlabelledVec.hpp>
namespace OpenVic::GFX {
@@ -118,11 +119,11 @@ namespace OpenVic::GFX {
fixed_point_t PROPERTY(start);
fixed_point_t PROPERTY(stop);
- uint64_t PROPERTY(x);
- uint64_t PROPERTY(y);
+ fixed_point_t PROPERTY(x);
+ fixed_point_t PROPERTY(y);
std::string PROPERTY(font);
- uint64_t PROPERTY(scale);
+ fixed_point_t PROPERTY(scale);
bool PROPERTY(no_fade);
fixed_point_t PROPERTY(texture_loop);
@@ -191,26 +192,13 @@ namespace OpenVic::GFX {
friend std::unique_ptr<Billboard> std::make_unique<Billboard>();
public:
- struct Offset {
- friend class Billboard;
-
- private:
- fixed_point_t PROPERTY(x);
- fixed_point_t PROPERTY(y);
- fixed_point_t PROPERTY(z);
-
- Offset(fixed_point_t new_x, fixed_point_t new_y, fixed_point_t new_z);
-
- public:
- Offset(Offset&&) = default;
- };
private:
std::string PROPERTY(texture_file);
fixed_point_t PROPERTY(scale);
int64_t PROPERTY(no_of_frames);
int64_t PROPERTY(font_size); //TODO: is this fixed point?
- Offset PROPERTY(offset);
+ V2Vector3 PROPERTY(offset);
std::string PROPERTY(font);
protected:
@@ -275,6 +263,54 @@ namespace OpenVic::GFX {
};
/* Core.gfx */
+ class AnimatedMapText final : public Object {
+ friend std::unique_ptr<AnimatedMapText> std::make_unique<AnimatedMapText>();
+
+ //TODO: This format_t enum is the same as in GFXSprite, should this all be extracted
+ //to another datatype file?
+ enum class format_t {
+ left, centre, right, justified
+ };
+
+ public:
+ struct TextBlock {
+ friend class AnimatedMapText;
+ //format_t taken from GUI's AlignedElement, this is overall very similar
+
+
+ private:
+ std::string PROPERTY(text);
+ colour_t PROPERTY(colour);
+ std::string PROPERTY(font);
+
+ fvec2_t PROPERTY(text_position);
+ fvec2_t PROPERTY(size);
+ //expect_fvec2(assign_variable_callback(position)),
+
+ format_t PROPERTY(format);
+ TextBlock();
+
+ public:
+ TextBlock(TextBlock&&) = default;
+ };
+
+ private:
+ fixed_point_t PROPERTY(speed);
+ fixed_point_t PROPERTY(scale);
+ V2Vector3 PROPERTY(position);
+ TextBlock PROPERTY(textblock);
+
+ protected:
+ AnimatedMapText();
+
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) override;
+
+ public:
+ AnimatedMapText(AnimatedMapText&&) = default;
+ virtual ~AnimatedMapText() = default;
+
+ OV_DETAIL_GET_TYPE
+ };
} \ No newline at end of file