diff options
author | Joel Machens <ajmach6@gmail.com> | 2023-10-03 00:09:45 +0200 |
---|---|---|
committer | BrickPi <49528459+BrickPi@users.noreply.github.com> | 2023-10-03 17:32:25 +0200 |
commit | 470d8c45522543aa161b3b98c5e6991024c8a5af (patch) | |
tree | a6733d661a1c622651908523631fd85a9227cd57 /src/openvic-simulation/map/Province.cpp | |
parent | eb49a207014da4f60617453c4d6a3ca355c661df (diff) |
Implement positions.txt Loading
Diffstat (limited to 'src/openvic-simulation/map/Province.cpp')
-rw-r--r-- | src/openvic-simulation/map/Province.cpp | 54 |
1 files changed, 51 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) { |