From 1ab95a6827c1525d0b48d6d28205f0b1e512bd9d Mon Sep 17 00:00:00 2001 From: hop311 Date: Sat, 20 Apr 2024 22:28:18 +0100 Subject: Update openvic-simulation to OpenVicProject/OpenVic-Simulation@109d31f --- extension/deps/openvic-simulation | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'extension/deps/openvic-simulation') diff --git a/extension/deps/openvic-simulation b/extension/deps/openvic-simulation index 020ada6..109d31f 160000 --- a/extension/deps/openvic-simulation +++ b/extension/deps/openvic-simulation @@ -1 +1 @@ -Subproject commit 020ada6c8f0f1bf4486fd9e76ec29673044794d6 +Subproject commit 109d31f147512c8d51f35f9773cd3c6bb1b8b994 -- cgit v1.2.3-56-ga3b1 From acad20f397b818a124890ae18ee59c4be5bd718d Mon Sep 17 00:00:00 2001 From: hop311 Date: Sat, 20 Apr 2024 22:28:36 +0100 Subject: Update openvic-simulation to OpenVicProject/OpenVic-Simulation@8f97145 --- extension/deps/openvic-simulation | 2 +- extension/src/openvic-extension/singletons/GameSingleton.cpp | 10 +++++++--- extension/src/openvic-extension/singletons/GameSingleton.hpp | 1 + extension/src/openvic-extension/utility/Utilities.hpp | 8 ++++++-- 4 files changed, 15 insertions(+), 6 deletions(-) (limited to 'extension/deps/openvic-simulation') diff --git a/extension/deps/openvic-simulation b/extension/deps/openvic-simulation index 109d31f..8f97145 160000 --- a/extension/deps/openvic-simulation +++ b/extension/deps/openvic-simulation @@ -1 +1 @@ -Subproject commit 109d31f147512c8d51f35f9773cd3c6bb1b8b994 +Subproject commit 8f97145e9570a9b728010a818137cb31a51fd5f6 diff --git a/extension/src/openvic-extension/singletons/GameSingleton.cpp b/extension/src/openvic-extension/singletons/GameSingleton.cpp index 563f1cb..8b19dc3 100644 --- a/extension/src/openvic-extension/singletons/GameSingleton.cpp +++ b/extension/src/openvic-extension/singletons/GameSingleton.cpp @@ -51,6 +51,7 @@ void GameSingleton::_bind_methods() { OV_BIND_METHOD(GameSingleton::get_map_width); OV_BIND_METHOD(GameSingleton::get_map_height); + OV_BIND_METHOD(GameSingleton::get_map_dims); OV_BIND_METHOD(GameSingleton::get_map_aspect_ratio); OV_BIND_METHOD(GameSingleton::get_terrain_texture); OV_BIND_METHOD(GameSingleton::get_province_shape_image_subdivisions); @@ -133,9 +134,8 @@ Error GameSingleton::setup_game(int32_t bookmark_index) { } int32_t GameSingleton::get_province_index_from_uv_coords(Vector2 const& coords) const { - const size_t x_mod_w = UtilityFunctions::fposmod(coords.x, 1.0f) * get_map_width(); - const size_t y_mod_h = UtilityFunctions::fposmod(coords.y, 1.0f) * get_map_height(); - return game_manager.get_map().get_province_index_at(x_mod_w, y_mod_h); + const Vector2 pos = coords.posmod(1.0f) * get_map_dims(); + return game_manager.get_map().get_province_index_at(Utilities::from_godot_ivec2(pos)); } int32_t GameSingleton::get_map_width() const { @@ -146,6 +146,10 @@ int32_t GameSingleton::get_map_height() const { return game_manager.get_map().get_height(); } +Vector2i GameSingleton::get_map_dims() const { + return Utilities::to_godot_ivec2(game_manager.get_map().get_dims()); +} + float GameSingleton::get_map_aspect_ratio() const { return static_cast(get_map_width()) / static_cast(get_map_height()); } diff --git a/extension/src/openvic-extension/singletons/GameSingleton.hpp b/extension/src/openvic-extension/singletons/GameSingleton.hpp index e84e366..a741331 100644 --- a/extension/src/openvic-extension/singletons/GameSingleton.hpp +++ b/extension/src/openvic-extension/singletons/GameSingleton.hpp @@ -61,6 +61,7 @@ namespace OpenVic { int32_t get_map_width() const; int32_t get_map_height() const; + godot::Vector2i get_map_dims() const; float get_map_aspect_ratio() const; /* The cosmetic terrain textures stored in a Texture2DArray. */ diff --git a/extension/src/openvic-extension/utility/Utilities.hpp b/extension/src/openvic-extension/utility/Utilities.hpp index f39be3e..f7a0d67 100644 --- a/extension/src/openvic-extension/utility/Utilities.hpp +++ b/extension/src/openvic-extension/utility/Utilities.hpp @@ -41,11 +41,15 @@ namespace OpenVic::Utilities { return { colour.redf(), colour.greenf(), colour.bluef(), colour.alphaf() }; } - _FORCE_INLINE_ godot::Vector2i to_godot_ivec2(ivec2_t vec) { + _FORCE_INLINE_ godot::Vector2i to_godot_ivec2(ivec2_t const& vec) { return { vec.x, vec.y }; } - _FORCE_INLINE_ godot::Vector2 to_godot_fvec2(fvec2_t vec) { + _FORCE_INLINE_ godot::Vector2 to_godot_fvec2(fvec2_t const& vec) { + return { vec.x, vec.y }; + } + + _FORCE_INLINE_ ivec2_t from_godot_ivec2(godot::Vector2i const& vec) { return { vec.x, vec.y }; } -- cgit v1.2.3-56-ga3b1 From 2d5454c668fc866023c41f07ceed263b2c1ff237 Mon Sep 17 00:00:00 2001 From: hop311 Date: Sat, 20 Apr 2024 22:31:48 +0100 Subject: Update openvic-simulation to OpenVicProject/OpenVic-Simulation@d0f8ec5 --- extension/deps/openvic-simulation | 2 +- .../src/openvic-extension/singletons/PopulationMenu.cpp | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'extension/deps/openvic-simulation') diff --git a/extension/deps/openvic-simulation b/extension/deps/openvic-simulation index 8f97145..d0f8ec5 160000 --- a/extension/deps/openvic-simulation +++ b/extension/deps/openvic-simulation @@ -1 +1 @@ -Subproject commit 8f97145e9570a9b728010a818137cb31a51fd5f6 +Subproject commit d0f8ec5484a0ea49d778c0ebb6c2ba2e6df9b7d1 diff --git a/extension/src/openvic-extension/singletons/PopulationMenu.cpp b/extension/src/openvic-extension/singletons/PopulationMenu.cpp index b256e1f..f97cae6 100644 --- a/extension/src/openvic-extension/singletons/PopulationMenu.cpp +++ b/extension/src/openvic-extension/singletons/PopulationMenu.cpp @@ -55,6 +55,9 @@ int32_t MenuSingleton::get_population_menu_province_list_row_count() const { } TypedArray MenuSingleton::get_population_menu_province_list_rows(int32_t start, int32_t count) const { + // TODO - remove when country population is used instead of total map population + ERR_FAIL_NULL_V(game_manager, {}); + if (population_menu.province_list_entries.empty()) { return {}; } @@ -81,6 +84,9 @@ TypedArray MenuSingleton::get_population_menu_province_list_rows(int int32_t& start_counter; int32_t& count_counter; + // TODO - remove when country population is used instead of total map population + const Pop::pop_size_t total_map_population; + /* This is the index among all entries, not just visible ones unlike start and count. */ int32_t index = 0; @@ -98,7 +104,7 @@ TypedArray MenuSingleton::get_population_menu_province_list_rows(int country_dict[type_key] = population_menu_t::LIST_ENTRY_COUNTRY; country_dict[index_key] = index; country_dict[name_key] = std_view_to_godot_string(country_entry.country.get_identifier()); - country_dict[size_key] = 0; + country_dict[size_key] = total_map_population; country_dict[change_key] = 0; country_dict[selected_key] = country_entry.selected; @@ -119,7 +125,7 @@ TypedArray MenuSingleton::get_population_menu_province_list_rows(int state_dict[type_key] = population_menu_t::LIST_ENTRY_STATE; state_dict[index_key] = index; state_dict[name_key] = std_view_to_godot_string(state_entry.state.get_identifier()); - state_dict[size_key] = 0; + state_dict[size_key] = state_entry.state.calculate_total_population(); state_dict[change_key] = 0; state_dict[selected_key] = state_entry.selected; state_dict[expanded_key] = state_entry.expanded; @@ -151,7 +157,7 @@ TypedArray MenuSingleton::get_population_menu_province_list_rows(int return true; } - } entry_visitor { start, count }; + } entry_visitor { start, count, game_manager->get_map().get_total_map_population() }; while (entry_visitor.index < population_menu.province_list_entries.size() && std::visit(entry_visitor, population_menu.province_list_entries[entry_visitor.index])) { -- cgit v1.2.3-56-ga3b1