aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic-extension/classes/GFXMaskedFlagTexture.cpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-07-04 10:39:28 +0200
committer GitHub <noreply@github.com>2024-07-04 10:39:28 +0200
commit6797e64ce8179635d56b73b5b4783eca560cbf11 (patch)
tree0c06560ddae94550077c997f8b7e14f69057f236 /extension/src/openvic-extension/classes/GFXMaskedFlagTexture.cpp
parent5a35e5f511c6af55c63cc0303e05da2812ab21a8 (diff)
parentdb246d901d1ccd39b0ed3fc024f28ad7b6b4848b (diff)
Merge pull request #235 from OpenVicProject/instance-definition-managers
Update to use SIM Instance and Definition Managers
Diffstat (limited to 'extension/src/openvic-extension/classes/GFXMaskedFlagTexture.cpp')
-rw-r--r--extension/src/openvic-extension/classes/GFXMaskedFlagTexture.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/extension/src/openvic-extension/classes/GFXMaskedFlagTexture.cpp b/extension/src/openvic-extension/classes/GFXMaskedFlagTexture.cpp
index 51a4235..fdc1a10 100644
--- a/extension/src/openvic-extension/classes/GFXMaskedFlagTexture.cpp
+++ b/extension/src/openvic-extension/classes/GFXMaskedFlagTexture.cpp
@@ -36,11 +36,20 @@ Error GFXMaskedFlagTexture::_generate_combined_image() {
if (mask_image.is_valid() && flag_image.is_valid() && flag_image_rect.has_area()) {
const Vector2i centre_translation = (mask_image->get_size() - button_image->get_size()) / 2;
- for (Vector2i combined_image_point { 0, 0 }; combined_image_point.y < button_image->get_height(); ++combined_image_point.y) {
+
+ for (
+ Vector2i combined_image_point { 0, 0 };
+ combined_image_point.y < button_image->get_height();
+ ++combined_image_point.y
+ ) {
+
for (combined_image_point.x = 0; combined_image_point.x < button_image->get_width(); ++combined_image_point.x) {
+
const Color overlay_image_colour = overlay_image->get_pixelv(combined_image_point);
+
// Translate to mask_image coordinates, keeping the centres of each image aligned.
const Vector2i mask_image_point = combined_image_point + centre_translation;
+
if (
0 <= mask_image_point.x && mask_image_point.x < mask_image->get_width() &&
0 <= mask_image_point.y && mask_image_point.y < mask_image->get_height()
@@ -176,13 +185,15 @@ Error GFXMaskedFlagTexture::set_flag_country_and_type(Country const* new_flag_co
return _generate_combined_image();
}
-Error GFXMaskedFlagTexture::set_flag_country_name_and_type(String const& new_flag_country_name, StringName const& new_flag_type) {
+Error GFXMaskedFlagTexture::set_flag_country_name_and_type(
+ String const& new_flag_country_name, StringName const& new_flag_type
+) {
if (new_flag_country_name.is_empty()) {
return set_flag_country_and_type(nullptr, {});
}
GameSingleton* game_singleton = GameSingleton::get_singleton();
ERR_FAIL_NULL_V(game_singleton, FAILED);
- Country const* new_flag_country = game_singleton->get_game_manager().get_country_manager().get_country_by_identifier(
+ 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)
);
ERR_FAIL_NULL_V_MSG(new_flag_country, FAILED, vformat("Country not found: %s", new_flag_country_name));
@@ -200,7 +211,7 @@ 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_game_manager().get_country_manager().get_country_by_identifier(
+ 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)
);
ERR_FAIL_NULL_V_MSG(new_flag_country, FAILED, vformat("Country not found: %s", new_flag_country_name));