aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nemrav <>2024-08-25 04:14:54 +0200
committer Nemrav <>2024-08-25 04:14:54 +0200
commit31c9050bc15a208e73e406bc52aa5d1b3200f2e0 (patch)
treedd1a9c3779226aa8bfef6c213f510055c5418549
parent53bf0ac14be0fd7a049306d6e20c01030916fdc6 (diff)
map item defines loaded
-rw-r--r--src/openvic-simulation/interface/GFXObject.cpp223
-rw-r--r--src/openvic-simulation/interface/GFXObject.hpp205
2 files changed, 390 insertions, 38 deletions
diff --git a/src/openvic-simulation/interface/GFXObject.cpp b/src/openvic-simulation/interface/GFXObject.cpp
index 67abc4d..05527e6 100644
--- a/src/openvic-simulation/interface/GFXObject.cpp
+++ b/src/openvic-simulation/interface/GFXObject.cpp
@@ -39,41 +39,13 @@ node_callback_t Object::expect_objects(length_callback_t length_callback, callba
"nofade", ZERO_OR_ONE, success_callback,
"textureloop", ZERO_OR_ONE, success_callback
),
- "mapinfo", ZERO_OR_MORE, expect_dictionary_keys(
- "name", ONE_EXACTLY, success_callback,
- "textureFile", ZERO_OR_ONE, success_callback,
- "scale", ZERO_OR_ONE, success_callback
- ),
+ "mapinfo", ZERO_OR_MORE, _expect_instance<Object, MapInfo>(callback),
/* mapitems.gfx */
- "projectionType", ZERO_OR_MORE, success_callback,
- "progressbar3dType", ZERO_OR_MORE, expect_dictionary_keys(
- "name", ONE_EXACTLY, success_callback,
- "color", ONE_EXACTLY, success_callback,
- "colortwo", ONE_EXACTLY, success_callback,
- "size", ONE_EXACTLY, success_callback,
- "effectFile", ONE_EXACTLY, success_callback
- ),
- "billboardType", ZERO_OR_MORE, expect_dictionary_keys<StringMapCaseInsensitive>(
- "name", ONE_EXACTLY, success_callback,
- "texturefile", ONE_EXACTLY, success_callback,
- "noOfFrames", ZERO_OR_ONE, success_callback,
- "scale", ONE_EXACTLY, success_callback,
- "font_size", ZERO_OR_ONE, success_callback,
- "offset2", ZERO_OR_ONE, success_callback,
- "font", ZERO_OR_ONE, success_callback
- ),
-
- "unitstatsBillboardType", ZERO_OR_MORE, expect_dictionary_keys(
- "name", ONE_EXACTLY, success_callback,
- "textureFile", ONE_EXACTLY, success_callback,
- "mask", ONE_EXACTLY, success_callback,
- "effectFile", ONE_EXACTLY, success_callback,
- "scale", ONE_EXACTLY, success_callback,
- "noOfFrames", ONE_EXACTLY, success_callback,
- "font_size", ONE_EXACTLY, success_callback,
- "font", ONE_EXACTLY, success_callback
- ),
+ "projectionType", ZERO_OR_MORE, _expect_instance<Object, Projection>(callback),
+ "progressbar3dType", ZERO_OR_MORE, _expect_instance<Object, ProgressBar3d>(callback),
+ "billboardType", ZERO_OR_MORE, _expect_instance<Object, Billboard>(callback),
+ "unitstatsBillboardType", ZERO_OR_MORE, _expect_instance<Object, UnitStatsBillboard>(callback),
/* core.gfx */
"animatedmaptext", ZERO_OR_MORE, expect_dictionary_keys(
@@ -94,10 +66,19 @@ node_callback_t Object::expect_objects(length_callback_t length_callback, callba
"name", ONE_EXACTLY, success_callback,
"size", ONE_EXACTLY, success_callback
),
- "provinceType", ZERO_OR_ONE, success_callback,
- "provinceWaterType", ZERO_OR_ONE, success_callback,
- "mapTextType", ZERO_OR_MORE, success_callback,
- "meshType", ZERO_OR_MORE, success_callback
+ "provinceType", ZERO_OR_MORE, expect_dictionary_keys(
+ "name", ONE_EXACTLY, success_callback
+ ),
+ "provinceWaterType", ZERO_OR_MORE, expect_dictionary_keys(
+ "name", ONE_EXACTLY, success_callback
+ ),
+ "mapTextType", ZERO_OR_MORE, expect_dictionary_keys(
+ "name", ONE_EXACTLY, success_callback
+ ),
+ "meshType", ZERO_OR_MORE, expect_dictionary_keys(
+ "name", ONE_EXACTLY, success_callback,
+ "xfile", ONE_EXACTLY, success_callback
+ )
);
}
@@ -190,3 +171,171 @@ 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 } {}
+
+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", 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))
+ );*/
+
+ 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
+ ),
+*/
+
+MapInfo::MapInfo() : texture_file {}, scale { 1 } {}
+
+bool MapInfo::_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)),
+ "scale", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(scale))
+ );
+
+ return ret;
+}
+
+/* MapItems.gfx */
+Projection::Projection() :
+ texture_file {}, size { 1 }, spin { 1 },
+ pulsating { false }, pulse_lowest { 1 }, pulse_speed { 1 },
+ additative { false }, expanding { 1 }, duration {}, fadeout {} {}
+
+//TODO: Verify whether size, pulseSpeed, duration, fadeout are fixedpoint_t or int
+//TODO: Verify there aren't more, unused properties?
+bool Projection::_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)),
+ "size", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(size)),
+ "spin", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(spin)),
+ "pulsating", ONE_EXACTLY, expect_bool(assign_variable_callback(pulsating)),
+ "pulseLowest", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(pulse_lowest)),
+ "pulseSpeed", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(pulse_speed)),
+ "additative", ONE_EXACTLY, expect_bool(assign_variable_callback(additative)),
+ "expanding", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(expanding)),
+ "duration", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(duration)),
+ "fadeout", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(fadeout))
+ );
+
+ 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 {} {}
+
+//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) {
+ bool ret = Object::_fill_key_map(key_map);
+
+ int components = 0;
+ fixed_point_t x = 0;
+ fixed_point_t y = 0;
+ fixed_point_t z = 0;
+
+ ret &= add_key_map_entries(key_map,
+ "texturefile", ONE_EXACTLY, expect_string(assign_variable_callback_string(texture_file)),
+ "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;
+ })
+ ),
+ "font", ZERO_OR_ONE, expect_string(assign_variable_callback_string(font))
+ );
+
+ offset.x = x;
+ offset.y = y;
+ offset.z = z;
+
+ return ret;
+}
+
+// Projection type
+UnitStatsBillboard::UnitStatsBillboard() :
+ texture_file {}, mask_file {}, effect_file {}, scale { 1 },
+ no_of_frames { 1 }, font_size { 7 }, font {} {}
+
+//TODO: Verify font_size is int
+//TODO: Verify there aren't more, unused properties?
+bool UnitStatsBillboard::_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)),
+ "mask", ONE_EXACTLY, expect_string(assign_variable_callback_string(mask_file)),
+ "effectFile", ONE_EXACTLY, expect_string(assign_variable_callback_string(effect_file)),
+ "scale", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(scale)),
+ "noOfFrames", ONE_EXACTLY, expect_int64(assign_variable_callback(no_of_frames)),
+ "font_size", ONE_EXACTLY, expect_int64(assign_variable_callback(font_size)),
+ "font", ONE_EXACTLY, expect_string(assign_variable_callback_string(font))
+ );
+
+ return ret;
+}
+
+
+// Projection type
+ProgressBar3d::ProgressBar3d() : back_colour {}, progress_colour {}, size {}, effect_file {} {}
+
+//TODO: Verify there aren't more, unused properties?
+bool ProgressBar3d::_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,
+ "color", ONE_EXACTLY, expect_colour(assign_variable_callback(progress_colour)),
+ "colortwo", ONE_EXACTLY, expect_colour(assign_variable_callback(back_colour)),
+ "size", ONE_EXACTLY, expect_ivec2(assign_variable_callback(size)),
+ "effectFile", ONE_EXACTLY, expect_string(assign_variable_callback_string(effect_file))
+ );
+
+ return ret;
+}
diff --git a/src/openvic-simulation/interface/GFXObject.hpp b/src/openvic-simulation/interface/GFXObject.hpp
index db15096..a633cb5 100644
--- a/src/openvic-simulation/interface/GFXObject.hpp
+++ b/src/openvic-simulation/interface/GFXObject.hpp
@@ -74,4 +74,207 @@ namespace OpenVic::GFX {
OV_DETAIL_GET_TYPE
};
-}
+
+ /* arrows.gfx */
+ class ArrowType final : public Object {
+ friend std::unique_ptr<ArrowType> std::make_unique<ArrowType>();
+
+ private:
+ //Named<> already handles the name property
+ fixed_point_t PROPERTY(size);
+ std::string PROPERTY(texture_file);
+ std::string PROPERTY(body_texture_file);
+ colour_t PROPERTY(back_colour);
+ colour_t PROPERTY(progress_colour);
+
+ fixed_point_t PROPERTY(end_at); //how should float be repd? >> fixed_point handles it
+ fixed_point_t PROPERTY(height);
+ uint64_t PROPERTY(arrow_type);
+ fixed_point_t PROPERTY(heading); //also float
+
+ std::string PROPERTY(effect_file);
+
+ protected:
+ ArrowType();
+
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) override;
+
+ public:
+ ArrowType(ArrowType&&) = default;
+ virtual ~ArrowType() = default;
+
+ OV_DETAIL_GET_TYPE
+ };
+
+ /* battlearrow.gfx */
+ class BattleArrow final : public Object {
+ friend std::unique_ptr<BattleArrow> std::make_unique<BattleArrow>();
+
+ private:
+ //Named<> already handles the name property
+ //TODO verify the texture places
+ std::string PROPERTY(texture_file);
+ std::string PROPERTY(back_texture_file);
+
+ fixed_point_t PROPERTY(start);
+ fixed_point_t PROPERTY(stop);
+ uint64_t PROPERTY(x);
+ uint64_t PROPERTY(y);
+
+ std::string PROPERTY(font);
+ uint64_t PROPERTY(scale);
+ bool PROPERTY(no_fade);
+ fixed_point_t PROPERTY(texture_loop);
+
+ protected:
+ BattleArrow();
+
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) override;
+
+ public:
+ BattleArrow(BattleArrow&&) = default;
+ virtual ~BattleArrow() = default;
+
+ OV_DETAIL_GET_TYPE
+ };
+
+ class MapInfo final : public Object {
+ friend std::unique_ptr<MapInfo> std::make_unique<MapInfo>();
+
+ private:
+ std::string PROPERTY(texture_file);
+ fixed_point_t PROPERTY(scale);
+
+ protected:
+ MapInfo();
+
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) override;
+
+ public:
+ MapInfo(MapInfo&&) = default;
+ virtual ~MapInfo() = default;
+
+ OV_DETAIL_GET_TYPE
+ };
+
+ /* mapitems.gfx */
+ class Projection final : public Object {
+ friend std::unique_ptr<Projection> std::make_unique<Projection>();
+
+ private:
+ //Named<> already handles the name property
+ std::string PROPERTY(texture_file);
+ //TODO: should size, pulseSpeed, duration, fadeout be ints or fixed points? assume fixed_point_t to start
+ fixed_point_t PROPERTY(size);
+ fixed_point_t PROPERTY(spin);
+ bool PROPERTY(pulsating);
+ fixed_point_t PROPERTY(pulse_lowest);
+ fixed_point_t PROPERTY(pulse_speed);
+ bool PROPERTY(additative);
+ fixed_point_t PROPERTY(expanding);
+ std::optional<fixed_point_t> PROPERTY(duration);
+ std::optional<fixed_point_t> PROPERTY(fadeout);
+
+ protected:
+ Projection();
+
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) override;
+
+ public:
+ Projection(Projection&&) = default;
+ virtual ~Projection() = default;
+
+ OV_DETAIL_GET_TYPE
+ };
+
+ class Billboard final : public Object {
+ 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);
+ std::string PROPERTY(font);
+
+ protected:
+ Billboard();
+
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) override;
+
+ public:
+ Billboard(Billboard&&) = default;
+ virtual ~Billboard() = default;
+
+ OV_DETAIL_GET_TYPE
+ };
+
+
+ class UnitStatsBillboard final : public Object {
+ friend std::unique_ptr<UnitStatsBillboard> std::make_unique<UnitStatsBillboard>();
+
+ private:
+ //Named<> already handles the name property
+ std::string PROPERTY(texture_file);
+ std::string PROPERTY(effect_file);
+ std::string PROPERTY(mask_file);
+ fixed_point_t PROPERTY(scale);
+ int64_t PROPERTY(no_of_frames);
+ int64_t PROPERTY(font_size); //TODO: is this fixed point?
+ std::string PROPERTY(font);
+
+ protected:
+ UnitStatsBillboard();
+
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) override;
+
+ public:
+ UnitStatsBillboard(UnitStatsBillboard&&) = default;
+ virtual ~UnitStatsBillboard() = default;
+
+ OV_DETAIL_GET_TYPE
+ };
+
+ class ProgressBar3d final : public Object {
+ friend std::unique_ptr<ProgressBar3d> std::make_unique<ProgressBar3d>();
+
+ private:
+ //Named<> already handles the name property
+ //TODO: are there any other properties which are unused
+ colour_t PROPERTY(back_colour);
+ colour_t PROPERTY(progress_colour);
+ ivec2_t PROPERTY(size);
+ std::string PROPERTY(effect_file);
+
+ protected:
+ ProgressBar3d();
+
+ bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) override;
+
+ public:
+ ProgressBar3d(ProgressBar3d&&) = default;
+ virtual ~ProgressBar3d() = default;
+
+ OV_DETAIL_GET_TYPE
+ };
+
+ /* Core.gfx */
+
+
+} \ No newline at end of file