aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation')
-rw-r--r--src/openvic-simulation/map/Province.cpp54
-rw-r--r--src/openvic-simulation/map/Province.hpp20
2 files changed, 71 insertions, 3 deletions
diff --git a/src/openvic-simulation/map/Province.cpp b/src/openvic-simulation/map/Province.cpp
index fa514eb..b0717b9 100644
--- a/src/openvic-simulation/map/Province.cpp
+++ b/src/openvic-simulation/map/Province.cpp
@@ -34,9 +34,57 @@ 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, [this](ast::NodeCPtr node) -> bool {
+ return expect_fvec2(assign_variable_callback(positions.text))(node);
+ },
+ "text_rotation", ZERO_OR_ONE, [this](ast::NodeCPtr node) -> bool {
+ return expect_fixed_point(assign_variable_callback(positions.text_rotation))(node);
+ },
+ "text_scale", ZERO_OR_ONE, [this](ast::NodeCPtr node) -> bool {
+ return expect_fixed_point(assign_variable_callback(positions.text_scale))(node);
+ },
+ "unit", ZERO_OR_ONE, [this](ast::NodeCPtr node) -> bool {
+ return expect_fvec2(assign_variable_callback(positions.unit))(node);
+ },
+ "town", ZERO_OR_ONE, [this](ast::NodeCPtr node) -> bool {
+ return expect_fvec2(assign_variable_callback(positions.city))(node);
+ },
+ "city", ZERO_OR_ONE, [this](ast::NodeCPtr node) -> bool {
+ return expect_fvec2(assign_variable_callback(positions.city))(node);
+ },
+ "factory", ZERO_OR_ONE, [this](ast::NodeCPtr node) -> bool {
+ return expect_fvec2(assign_variable_callback(positions.factory))(node);
+ },
+ "building_construction", ZERO_OR_ONE, [this](ast::NodeCPtr node) -> bool {
+ return expect_fvec2(assign_variable_callback(positions.building_construction))(node);
+ },
+ "military_construction", ZERO_OR_ONE, [this](ast::NodeCPtr node) -> bool {
+ return expect_fvec2(assign_variable_callback(positions.military_construction))(node);
+ },
+ "building_position", ZERO_OR_ONE, expect_dictionary_keys(
+ "fort", ZERO_OR_ONE, [this](ast::NodeCPtr node) -> bool {
+ return expect_fvec2(assign_variable_callback(positions.fort))(node);
+ },
+ "railroad", ZERO_OR_ONE, [this](ast::NodeCPtr node) -> bool {
+ return expect_fvec2(assign_variable_callback(positions.railroad))(node);
+ },
+ "naval_base", ZERO_OR_ONE, [this](ast::NodeCPtr node) -> bool {
+ return expect_fvec2(assign_variable_callback(positions.navalbase))(node);
+ }
+ ),
+ "building_rotation", ZERO_OR_ONE, expect_dictionary_keys(
+ "fort", ZERO_OR_ONE, [this](ast::NodeCPtr node) -> bool {
+ return expect_fixed_point(assign_variable_callback(positions.fort_rotation))(node);
+ },
+ "railroad", ZERO_OR_ONE, [this](ast::NodeCPtr node) -> bool {
+ return expect_fixed_point(assign_variable_callback(positions.railroad_rotation))(node);
+ },
+ "naval_base", ZERO_OR_ONE, [this](ast::NodeCPtr node) -> bool {
+ return expect_fixed_point(assign_variable_callback(positions.navalbase_rotation))(node);
+ }
+ )
+ )(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..a621182 100644
--- a/src/openvic-simulation/map/Province.hpp
+++ b/src/openvic-simulation/map/Province.hpp
@@ -39,6 +39,25 @@ 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;
+ /* fvec2_t spawn_railway_track; treating as extraneous until proven need */
+ };
+
+
static constexpr index_t NULL_INDEX = 0, MAX_INDEX = std::numeric_limits<index_t>::max();
private:
@@ -55,6 +74,7 @@ namespace OpenVic {
distribution_t pop_types, cultures, religions;
std::vector<adjacency_t> adjacencies;
+ province_positions_t positions;
TerrainType const* terrain_type = nullptr;