aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-06-15 12:45:48 +0200
committer hop311 <hop3114@gmail.com>2024-07-04 10:45:35 +0200
commit99a85d03de5297f2c7c29aedfc83e4e37cbc795b (patch)
tree2933b65a98ef0a4b32c4bd848ecdad574bc1cfde
parentdb246d901d1ccd39b0ed3fc024f28ad7b6b4848b (diff)
Use CountryDefinition and CountryInstancecountry-definition
m---------extension/deps/openvic-simulation0
-rw-r--r--extension/src/openvic-extension/classes/GFXMaskedFlagTexture.cpp20
-rw-r--r--extension/src/openvic-extension/classes/GFXMaskedFlagTexture.hpp11
-rw-r--r--extension/src/openvic-extension/singletons/GameSingleton.cpp15
-rw-r--r--extension/src/openvic-extension/singletons/MenuSingleton.cpp4
-rw-r--r--extension/src/openvic-extension/singletons/MenuSingleton.hpp2
-rw-r--r--extension/src/openvic-extension/singletons/ModelSingleton.cpp2
-rw-r--r--extension/src/openvic-extension/singletons/PopulationMenu.cpp4
8 files changed, 33 insertions, 25 deletions
diff --git a/extension/deps/openvic-simulation b/extension/deps/openvic-simulation
-Subproject bfd539513af435564daf70f94f6cce146dd5c94
+Subproject 8c8b9349e26b4f606e18810a201ff378eaac19b
diff --git a/extension/src/openvic-extension/classes/GFXMaskedFlagTexture.cpp b/extension/src/openvic-extension/classes/GFXMaskedFlagTexture.cpp
index fdc1a10..c17fa0e 100644
--- a/extension/src/openvic-extension/classes/GFXMaskedFlagTexture.cpp
+++ b/extension/src/openvic-extension/classes/GFXMaskedFlagTexture.cpp
@@ -162,7 +162,9 @@ String GFXMaskedFlagTexture::get_gfx_masked_flag_name() const {
return gfx_masked_flag != nullptr ? std_view_to_godot_string(gfx_masked_flag->get_name()) : String {};
}
-Error GFXMaskedFlagTexture::set_flag_country_and_type(Country const* new_flag_country, StringName const& new_flag_type) {
+Error GFXMaskedFlagTexture::set_flag_country_and_type(
+ CountryDefinition const* new_flag_country, StringName const& new_flag_type
+) {
if (flag_country == new_flag_country && flag_type == new_flag_type) {
return OK;
}
@@ -193,14 +195,15 @@ Error GFXMaskedFlagTexture::set_flag_country_name_and_type(
}
GameSingleton* game_singleton = GameSingleton::get_singleton();
ERR_FAIL_NULL_V(game_singleton, FAILED);
- Country const* new_flag_country = game_singleton->get_definition_manager().get_country_manager().get_country_by_identifier(
- godot_to_std_string(new_flag_country_name)
- );
+ CountryDefinition const* new_flag_country =
+ game_singleton->get_definition_manager().get_country_definition_manager().get_country_definition_by_identifier(
+ godot_to_std_string(new_flag_country_name)
+ );
ERR_FAIL_NULL_V_MSG(new_flag_country, FAILED, vformat("Country not found: %s", new_flag_country_name));
return set_flag_country_and_type(new_flag_country, new_flag_type);
}
-Error GFXMaskedFlagTexture::set_flag_country(Country const* new_flag_country) {
+Error GFXMaskedFlagTexture::set_flag_country(CountryDefinition const* new_flag_country) {
// TODO - get country's current flag type from the game state
return set_flag_country_and_type( new_flag_country, {});
}
@@ -211,9 +214,10 @@ Error GFXMaskedFlagTexture::set_flag_country_name(String const& new_flag_country
}
GameSingleton* game_singleton = GameSingleton::get_singleton();
ERR_FAIL_NULL_V(game_singleton, FAILED);
- Country const* new_flag_country = game_singleton->get_definition_manager().get_country_manager().get_country_by_identifier(
- godot_to_std_string(new_flag_country_name)
- );
+ CountryDefinition const* new_flag_country =
+ game_singleton->get_definition_manager().get_country_definition_manager().get_country_definition_by_identifier(
+ godot_to_std_string(new_flag_country_name)
+ );
ERR_FAIL_NULL_V_MSG(new_flag_country, FAILED, vformat("Country not found: %s", new_flag_country_name));
return set_flag_country(new_flag_country);
}
diff --git a/extension/src/openvic-extension/classes/GFXMaskedFlagTexture.hpp b/extension/src/openvic-extension/classes/GFXMaskedFlagTexture.hpp
index 9290d5c..3d361e4 100644
--- a/extension/src/openvic-extension/classes/GFXMaskedFlagTexture.hpp
+++ b/extension/src/openvic-extension/classes/GFXMaskedFlagTexture.hpp
@@ -1,16 +1,17 @@
#pragma once
-#include <openvic-simulation/country/Country.hpp>
#include <openvic-simulation/interface/GFXSprite.hpp>
#include "openvic-extension/classes/GFXButtonStateTexture.hpp"
namespace OpenVic {
+ struct CountryDefinition;
+
class GFXMaskedFlagTexture : public GFXButtonStateHavingTexture {
GDCLASS(GFXMaskedFlagTexture, GFXButtonStateHavingTexture)
GFX::MaskedFlag const* PROPERTY(gfx_masked_flag);
- Country const* PROPERTY(flag_country);
+ CountryDefinition const* PROPERTY(flag_country);
godot::StringName PROPERTY(flag_type);
godot::Ref<godot::Image> overlay_image, mask_image, flag_image;
@@ -42,7 +43,9 @@ namespace OpenVic {
godot::String get_gfx_masked_flag_name() const;
/* Set flag_country and flag_type and update the combined image to use that flag, or no flag if it doesn't exist. */
- godot::Error set_flag_country_and_type(Country const* new_flag_country, godot::StringName const& new_flag_type);
+ godot::Error set_flag_country_and_type(
+ CountryDefinition const* new_flag_country, godot::StringName const& new_flag_type
+ );
/* Look up the country with the specified identifier, then call set_flag_country_and_type with the country and
* specified flag_type as arguments. */
@@ -52,7 +55,7 @@ namespace OpenVic {
/* Look up the specified country's current flag type, then call set_flag_country_and_type
* with the country and its flag type as arguments. */
- godot::Error set_flag_country(Country const* new_flag_country);
+ godot::Error set_flag_country(CountryDefinition const* new_flag_country);
/* Look up the country with the specified identifier, then call set_flag_country with the country its argument. */
godot::Error set_flag_country_name(godot::String const& new_flag_country_name);
diff --git a/extension/src/openvic-extension/singletons/GameSingleton.cpp b/extension/src/openvic-extension/singletons/GameSingleton.cpp
index 7114189..074c8b5 100644
--- a/extension/src/openvic-extension/singletons/GameSingleton.cpp
+++ b/extension/src/openvic-extension/singletons/GameSingleton.cpp
@@ -188,8 +188,9 @@ Ref<ImageTexture> GameSingleton::get_flag_sheet_texture() const {
int32_t GameSingleton::get_flag_sheet_index(int32_t country_index, godot::StringName const& flag_type) const {
ERR_FAIL_COND_V_MSG(
- country_index < 0 || country_index >= get_definition_manager().get_country_manager().get_country_count(), -1,
- vformat("Invalid country index: %d", country_index)
+ country_index < 0 ||
+ country_index >= get_definition_manager().get_country_definition_manager().get_country_definition_count(),
+ -1, vformat("Invalid country index: %d", country_index)
);
const typename decltype(flag_type_index_map)::const_iterator it = flag_type_index_map.find(flag_type);
@@ -487,10 +488,10 @@ Error GameSingleton::_load_flag_sheet() {
government_type_manager.get_flag_types().empty() || !government_type_manager.government_types_are_locked(), FAILED,
"Cannot load flag images if flag types are empty or government types are not locked!"
);
- CountryManager const& country_manager = get_definition_manager().get_country_manager();
+ CountryDefinitionManager const& country_definition_manager = get_definition_manager().get_country_definition_manager();
ERR_FAIL_COND_V_MSG(
- country_manager.countries_empty() || !country_manager.countries_are_locked(), FAILED,
- "Cannot load flag images if countries are empty or not locked!"
+ country_definition_manager.country_definitions_empty() || !country_definition_manager.country_definitions_are_locked(),
+ FAILED, "Cannot load flag images if countries are empty or not locked!"
);
AssetManager* asset_manager = AssetManager::get_singleton();
@@ -502,7 +503,7 @@ Error GameSingleton::_load_flag_sheet() {
flag_type_index_map.emplace(std_to_godot_string_name(type), static_cast<int32_t>(flag_type_index_map.size()));
}
- flag_sheet_count = country_manager.get_countries().size() * flag_type_index_map.size();
+ flag_sheet_count = country_definition_manager.get_country_definition_count() * flag_type_index_map.size();
std::vector<Ref<Image>> flag_images;
flag_images.reserve(flag_sheet_count);
@@ -510,7 +511,7 @@ Error GameSingleton::_load_flag_sheet() {
static constexpr Image::Format flag_format = Image::FORMAT_RGB8;
Error ret = OK;
- for (Country const& country : country_manager.get_countries()) {
+ for (CountryDefinition const& country : country_definition_manager.get_country_definitions()) {
const String country_name = std_view_to_godot_string(country.get_identifier());
for (auto const& [flag_type, flag_type_index] : flag_type_index_map) {
diff --git a/extension/src/openvic-extension/singletons/MenuSingleton.cpp b/extension/src/openvic-extension/singletons/MenuSingleton.cpp
index 79998d7..b4baf40 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();
- Country const* controller = province->get_controller();
+ CountryDefinition const* controller = province->get_controller();
if (controller != nullptr) {
ret[province_info_controller_key] = std_view_to_godot_string(controller->get_identifier());
}
@@ -241,7 +241,7 @@ Dictionary MenuSingleton::get_province_info_from_index(int32_t index) const {
ret[province_info_pop_cultures_key] = GFXPieChartTexture::distribution_to_slices_array(cultures);
}
- std::vector<Country const*> const& cores = province->get_cores();
+ std::vector<CountryDefinition const*> const& cores = province->get_cores();
if (!cores.empty()) {
PackedStringArray cores_array;
if (cores_array.resize(cores.size()) == OK) {
diff --git a/extension/src/openvic-extension/singletons/MenuSingleton.hpp b/extension/src/openvic-extension/singletons/MenuSingleton.hpp
index a3bcb67..b89f948 100644
--- a/extension/src/openvic-extension/singletons/MenuSingleton.hpp
+++ b/extension/src/openvic-extension/singletons/MenuSingleton.hpp
@@ -20,7 +20,7 @@ namespace OpenVic {
};
struct country_entry_t {
- Country const& country;
+ CountryDefinition const& country;
bool selected = true;
};
diff --git a/extension/src/openvic-extension/singletons/ModelSingleton.cpp b/extension/src/openvic-extension/singletons/ModelSingleton.cpp
index 8735780..7dea1bd 100644
--- a/extension/src/openvic-extension/singletons/ModelSingleton.cpp
+++ b/extension/src/openvic-extension/singletons/ModelSingleton.cpp
@@ -207,7 +207,7 @@ bool ModelSingleton::add_unit_dict(ordered_set<T*> const& units, TypedArray<Dict
T const& unit = *units.back();
ERR_FAIL_COND_V_MSG(unit.empty(), false, vformat("Empty unit \"%s\"", std_view_to_godot_string(unit.get_name())));
- Country const* country = unit.get_country()->get_base_country();
+ CountryDefinition const* country = unit.get_country()->get_country_definition();
GraphicalCultureType const& graphical_culture_type = country->get_graphical_culture();
UnitType const* display_unit_type = unit.get_display_unit_type();
diff --git a/extension/src/openvic-extension/singletons/PopulationMenu.cpp b/extension/src/openvic-extension/singletons/PopulationMenu.cpp
index 1804539..1237e86 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 (Country const* country : {
+ for (CountryDefinition const* country : {
// Example country
- game_singleton->get_definition_manager().get_country_manager().get_country_by_identifier("ENG")
+ game_singleton->get_definition_manager().get_country_definition_manager().get_country_definition_by_identifier("ENG")
}) {
ERR_CONTINUE(country == nullptr);