aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/interface/GFXObject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/interface/GFXObject.cpp')
-rw-r--r--src/openvic-simulation/interface/GFXObject.cpp287
1 files changed, 210 insertions, 77 deletions
diff --git a/src/openvic-simulation/interface/GFXObject.cpp b/src/openvic-simulation/interface/GFXObject.cpp
index 67abc4d..bd720c3 100644
--- a/src/openvic-simulation/interface/GFXObject.cpp
+++ b/src/openvic-simulation/interface/GFXObject.cpp
@@ -1,4 +1,5 @@
#include "GFXObject.hpp"
+#include "openvic-simulation/dataloader/NodeTools.hpp"
using namespace OpenVic;
using namespace OpenVic::GFX;
@@ -11,93 +12,38 @@ 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
- ),
- "mapinfo", ZERO_OR_MORE, expect_dictionary_keys(
- "name", ONE_EXACTLY, success_callback,
- "textureFile", ZERO_OR_ONE, success_callback,
- "scale", 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 */
- "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(
- "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
),
- "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 +136,190 @@ bool Actor::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) {
return ret;
}
+
+/* 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 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,
+ "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 */
+//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 } {}
+
+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::Billboard() :
+ texture_file {}, scale { 1 }, no_of_frames { 1 }, font_size { 7 },
+ 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) {
+ 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_v2_vector3(assign_variable_callback(offset)),
+ "font", ZERO_OR_ONE, expect_string(assign_variable_callback_string(font))
+ );
+
+ offset.x = x;
+ offset.y = y;
+ offset.z = z;
+
+ return ret;
+}
+
+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;
+}
+
+
+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;
+}
+
+
+/* core.gfx */
+AnimatedMapText::TextBlock::TextBlock() :
+text {}, colour {}, font {}, text_position {}, size {}, format { text_format_t::left } {}
+
+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);
+
+ 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_text_format_t(assign_variable_callback(textblock.format))
+ )
+ );
+
+ return ret;
+} \ No newline at end of file