diff options
author | BrickPi <49528459+BrickPi@users.noreply.github.com> | 2023-10-03 23:54:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-03 23:54:16 +0200 |
commit | b62e4d1b83f25c4ceb59455f953b6d32514ab726 (patch) | |
tree | 84a818a1b3e5bca43a7f117ece16b9f084302784 | |
parent | eb49a207014da4f60617453c4d6a3ca355c661df (diff) | |
parent | f47e9ca8d7c711ba6e8befd318dd5fb600e93359 (diff) |
Merge pull request #40 from OpenVicProject/load-positions
Implement Province Positions Loading
-rw-r--r-- | src/openvic-simulation/map/Province.cpp | 29 | ||||
-rw-r--r-- | src/openvic-simulation/map/Province.hpp | 19 |
2 files changed, 45 insertions, 3 deletions
diff --git a/src/openvic-simulation/map/Province.cpp b/src/openvic-simulation/map/Province.cpp index fa514eb..5b1a130 100644 --- a/src/openvic-simulation/map/Province.cpp +++ b/src/openvic-simulation/map/Province.cpp @@ -34,9 +34,32 @@ Province::life_rating_t Province::get_life_rating() const { } bool Province::load_positions(BuildingManager const& building_manager, ast::NodeCPtr root) { - // TODO - implement province position loading - // (root is the dictionary after the province identifier) - return true; + return expect_dictionary_keys( + "text_position", ZERO_OR_ONE, expect_fvec2(assign_variable_callback(positions.text)), + "text_rotation", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(positions.text_rotation)), + "text_scale", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(positions.text_scale)), + "unit", ZERO_OR_ONE, expect_fvec2(assign_variable_callback(positions.unit)), + "town", ZERO_OR_ONE, expect_fvec2(assign_variable_callback(positions.city)), + "city", ZERO_OR_ONE, expect_fvec2(assign_variable_callback(positions.city)), + "factory", ZERO_OR_ONE, expect_fvec2(assign_variable_callback(positions.factory)), + "building_construction", ZERO_OR_ONE, expect_fvec2(assign_variable_callback(positions.building_construction)), + "military_construction", ZERO_OR_ONE, expect_fvec2(assign_variable_callback(positions.military_construction)), + "building_position", ZERO_OR_ONE, expect_dictionary_keys( + "fort", ZERO_OR_ONE, expect_fvec2(assign_variable_callback(positions.fort)), + "railroad", ZERO_OR_ONE, expect_fvec2(assign_variable_callback(positions.railroad)), + "naval_base", ZERO_OR_ONE, expect_fvec2(assign_variable_callback(positions.navalbase)) + ), + "building_rotation", ZERO_OR_ONE, expect_dictionary_keys( + "fort", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(positions.fort_rotation)), + "railroad", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(positions.railroad_rotation)), + "naval_base", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(positions.navalbase_rotation)), + "aeroplane_factory", ZERO_OR_ONE, success_callback /* see below */ + ), + /* the below are esoteric clausewitz leftovers that either have no impact or whose functionality is lost to time */ + "spawn_railway_track", ZERO_OR_ONE, success_callback, + "railroad_visibility", ZERO_OR_ONE, success_callback, + "building_nudge", ZERO_OR_ONE, success_callback + )(root); } bool Province::add_building(BuildingInstance&& building_instance) { diff --git a/src/openvic-simulation/map/Province.hpp b/src/openvic-simulation/map/Province.hpp index e15d8d3..31b5d4c 100644 --- a/src/openvic-simulation/map/Province.hpp +++ b/src/openvic-simulation/map/Province.hpp @@ -39,6 +39,24 @@ namespace OpenVic { flags_t get_flags() const; }; + struct province_positions_t { + fvec2_t text; + fixed_point_t text_rotation; + fixed_point_t text_scale; + fvec2_t unit; + fvec2_t city; + fvec2_t factory; + fvec2_t building_construction; + fvec2_t military_construction; + fvec2_t fort; + fixed_point_t fort_rotation; + fvec2_t railroad; + fixed_point_t railroad_rotation; + fvec2_t navalbase; + fixed_point_t navalbase_rotation; + }; + + static constexpr index_t NULL_INDEX = 0, MAX_INDEX = std::numeric_limits<index_t>::max(); private: @@ -55,6 +73,7 @@ namespace OpenVic { distribution_t pop_types, cultures, religions; std::vector<adjacency_t> adjacencies; + province_positions_t positions; TerrainType const* terrain_type = nullptr; |