aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-07-04 19:20:38 +0200
committer hop311 <hop3114@gmail.com>2024-07-26 21:53:17 +0200
commit7c5de8f8d8fc7a9b861f23a4c1a249fb00e88b99 (patch)
treebbf41f999d630df44ac2327c302290fb10d819f4
parent7dfb935447708cfdff664603eadafcbb4aa24042 (diff)
Update openvic-simulation to OpenVicProject/OpenVicSimulation@861acffcountry-instance
m---------extension/deps/openvic-simulation0
-rw-r--r--extension/src/openvic-extension/singletons/MenuSingleton.cpp6
-rw-r--r--extension/src/openvic-extension/singletons/MenuSingleton.hpp4
-rw-r--r--extension/src/openvic-extension/singletons/PopulationMenu.cpp21
4 files changed, 12 insertions, 19 deletions
diff --git a/extension/deps/openvic-simulation b/extension/deps/openvic-simulation
-Subproject d1f3a96b72dd06b5f97dd4643e5f016a02b42ea
+Subproject 861acff78bd238232ed9e369ea046c2ed4a3119
diff --git a/extension/src/openvic-extension/singletons/MenuSingleton.cpp b/extension/src/openvic-extension/singletons/MenuSingleton.cpp
index 36e5f58..8d3de60 100644
--- a/extension/src/openvic-extension/singletons/MenuSingleton.cpp
+++ b/extension/src/openvic-extension/singletons/MenuSingleton.cpp
@@ -207,7 +207,7 @@ Dictionary MenuSingleton::get_province_info_from_index(int32_t index) const {
ret[province_info_life_rating_key] = province->get_life_rating();
- CountryDefinition const* controller = province->get_controller();
+ CountryInstance const* controller = province->get_controller();
if (controller != nullptr) {
ret[province_info_controller_key] = std_view_to_godot_string(controller->get_identifier());
}
@@ -244,12 +244,12 @@ Dictionary MenuSingleton::get_province_info_from_index(int32_t index) const {
ret[province_info_pop_cultures_key] = std::move(cultures);
}
- std::vector<CountryDefinition const*> const& cores = province->get_cores();
+ ordered_set<CountryInstance*> const& cores = province->get_cores();
if (!cores.empty()) {
PackedStringArray cores_array;
if (cores_array.resize(cores.size()) == OK) {
for (size_t idx = 0; idx < cores.size(); ++idx) {
- cores_array[idx] = std_view_to_godot_string(cores[idx]->get_identifier());
+ cores_array[idx] = std_view_to_godot_string(cores.data()[idx]->get_identifier());
}
ret[province_info_cores_key] = std::move(cores_array);
} else {
diff --git a/extension/src/openvic-extension/singletons/MenuSingleton.hpp b/extension/src/openvic-extension/singletons/MenuSingleton.hpp
index b89f948..018a074 100644
--- a/extension/src/openvic-extension/singletons/MenuSingleton.hpp
+++ b/extension/src/openvic-extension/singletons/MenuSingleton.hpp
@@ -6,7 +6,9 @@
#include <openvic-simulation/types/OrderedContainers.hpp>
namespace OpenVic {
+ struct CountryInstance;
struct State;
+ struct ProvinceInstance;
class MenuSingleton : public godot::Object {
GDCLASS(MenuSingleton, godot::Object)
@@ -20,7 +22,7 @@ namespace OpenVic {
};
struct country_entry_t {
- CountryDefinition const& country;
+ CountryInstance const& country;
bool selected = true;
};
diff --git a/extension/src/openvic-extension/singletons/PopulationMenu.cpp b/extension/src/openvic-extension/singletons/PopulationMenu.cpp
index db2ac53..c1a1253 100644
--- a/extension/src/openvic-extension/singletons/PopulationMenu.cpp
+++ b/extension/src/openvic-extension/singletons/PopulationMenu.cpp
@@ -29,9 +29,9 @@ bool MenuSingleton::_population_menu_update_provinces() {
MapInstance const& map_instance = instance_manager->get_map_instance();
ERR_FAIL_COND_V(!map_instance.province_instances_are_locked(), false);
- for (CountryDefinition const* country : {
+ for (CountryInstance const* country : {
// Example country
- game_singleton->get_definition_manager().get_country_definition_manager().get_country_definition_by_identifier("ENG")
+ instance_manager->get_country_instance_manager().get_country_instance_by_identifier("ENG")
}) {
ERR_CONTINUE(country == nullptr);
@@ -67,12 +67,6 @@ int32_t MenuSingleton::get_population_menu_province_list_row_count() const {
}
TypedArray<Dictionary> 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
- GameSingleton const* game_singleton = GameSingleton::get_singleton();
- ERR_FAIL_NULL_V(game_singleton, {});
- InstanceManager const* instance_manager = game_singleton->get_instance_manager();
- ERR_FAIL_NULL_V(instance_manager, {});
-
if (population_menu.province_list_entries.empty()) {
return {};
}
@@ -101,9 +95,6 @@ TypedArray<Dictionary> 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;
@@ -121,7 +112,7 @@ TypedArray<Dictionary> 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] = total_map_population;
+ country_dict[size_key] = country_entry.country.get_total_population();
country_dict[change_key] = 0;
country_dict[selected_key] = country_entry.selected;
@@ -174,7 +165,7 @@ TypedArray<Dictionary> MenuSingleton::get_population_menu_province_list_rows(int
return true;
}
- } entry_visitor { *this, start, count, instance_manager->get_map_instance().get_total_map_population() };
+ } entry_visitor { *this, start, count };
while (entry_visitor.index < population_menu.province_list_entries.size()
&& std::visit(entry_visitor, population_menu.province_list_entries[entry_visitor.index])) {
@@ -422,13 +413,13 @@ void MenuSingleton::_population_menu_update_filtered_pops() {
_population_menu_sort_pops();
}
-template<std::derived_from<HasIdentifier> T>
+template<HasGetIdentifier T>
static bool compare_translated_identifiers(Object const& object, T const& lhs, T const& rhs) {
return object.tr(std_view_to_godot_string(lhs.get_identifier()))
< object.tr(std_view_to_godot_string(rhs.get_identifier()));
}
-template<std::derived_from<HasIdentifier> T>
+template<HasGetIdentifier T>
static bool compare_translated_identifiers(Object const& object, T const* lhs, T const* rhs) {
return (lhs != nullptr ? object.tr(std_view_to_godot_string(lhs->get_identifier())) : godot::String {})
< (rhs != nullptr ? object.tr(std_view_to_godot_string(rhs->get_identifier())) : godot::String {});