diff options
author | Hop311 <Hop3114@gmail.com> | 2024-04-24 20:20:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-24 20:20:43 +0200 |
commit | e286cfef29d7c431ba33cd77283e838e6fba05d2 (patch) | |
tree | a23a97bd30aa6cb6b2731cd96c1d6c7e3d4bf4b9 /src/openvic-simulation/map | |
parent | d0f8ec5484a0ea49d778c0ebb6c2ba2e6df9b7d1 (diff) | |
parent | ef770b37ee841cca6899d1c91c3997365a8e8bb6 (diff) |
Merge pull request #160 from OpenVicProject/province-text
Province text info functions
Diffstat (limited to 'src/openvic-simulation/map')
-rw-r--r-- | src/openvic-simulation/map/Province.cpp | 18 | ||||
-rw-r--r-- | src/openvic-simulation/map/Province.hpp | 10 |
2 files changed, 22 insertions, 6 deletions
diff --git a/src/openvic-simulation/map/Province.cpp b/src/openvic-simulation/map/Province.cpp index 89ddd39..d4569ad 100644 --- a/src/openvic-simulation/map/Province.cpp +++ b/src/openvic-simulation/map/Province.cpp @@ -32,9 +32,9 @@ bool Province::load_positions(Map const& map, BuildingTypeManager const& buildin const fixed_point_t map_height = map.get_height(); const bool ret = expect_dictionary_keys( - "text_position", ZERO_OR_ONE, expect_fvec2(flip_y_callback(assign_variable_callback(positions.text), map_height)), - "text_rotation", ZERO_OR_ONE, - expect_fixed_point(negate_callback<fixed_point_t>(assign_variable_callback(positions.text_rotation))), + "text_position", ZERO_OR_ONE, + expect_fvec2(flip_y_callback(assign_variable_callback(positions.text_position), map_height)), + "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(flip_y_callback(assign_variable_callback(positions.unit), map_height)), @@ -94,6 +94,18 @@ bool Province::load_positions(Map const& map, BuildingTypeManager const& buildin return ret; } +fvec2_t Province::get_text_position() const { + return positions.text_position.value_or(centre); +} + +fixed_point_t Province::get_text_rotation() const { + return positions.text_rotation.value_or(0); +} + +fixed_point_t Province::get_text_scale() const { + return positions.text_scale.value_or(1); +} + bool Province::expand_building(size_t building_index) { BuildingInstance* building = buildings.get_item_by_index(building_index); if (building == nullptr) { diff --git a/src/openvic-simulation/map/Province.hpp b/src/openvic-simulation/map/Province.hpp index cfe5ed6..bfbeab2 100644 --- a/src/openvic-simulation/map/Province.hpp +++ b/src/openvic-simulation/map/Province.hpp @@ -69,9 +69,9 @@ namespace OpenVic { struct province_positions_t { /* Province name placement */ - std::optional<fvec2_t> text; - std::optional<fvec2_t> text_rotation; - std::optional<fvec2_t> text_scale; + std::optional<fvec2_t> text_position; + std::optional<fixed_point_t> text_rotation; + std::optional<fixed_point_t> text_scale; /* Model positions */ std::optional<fvec2_t> unit; @@ -141,6 +141,10 @@ namespace OpenVic { /* The positions' y coordinates need to be inverted. */ bool load_positions(Map const& map, BuildingTypeManager const& building_type_manager, ast::NodeCPtr root); + fvec2_t get_text_position() const; + fixed_point_t get_text_rotation() const; + fixed_point_t get_text_scale() const; + bool expand_building(size_t building_index); /* This returns a pointer to the position of the specified building type, or nullptr if none exists. */ fvec2_t const* get_building_position(BuildingType const* building_type) const; |