aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic-extension
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-05-14 01:18:16 +0200
committer hop311 <hop3114@gmail.com>2024-05-14 01:18:16 +0200
commit14a2b79f261091dede324f972f9c7841974c9a2a (patch)
tree1ee38ce3be0325752f89e72062aea51d54747a70 /extension/src/openvic-extension
parentbfccdb87d66304604ad018037db1581746646bfa (diff)
Misc UI code changesmisc
Diffstat (limited to 'extension/src/openvic-extension')
-rw-r--r--extension/src/openvic-extension/classes/GFXPieChartTexture.cpp11
-rw-r--r--extension/src/openvic-extension/singletons/GameSingleton.cpp5
-rw-r--r--extension/src/openvic-extension/singletons/GameSingleton.hpp1
3 files changed, 11 insertions, 6 deletions
diff --git a/extension/src/openvic-extension/classes/GFXPieChartTexture.cpp b/extension/src/openvic-extension/classes/GFXPieChartTexture.cpp
index 10a2cb5..ead72cf 100644
--- a/extension/src/openvic-extension/classes/GFXPieChartTexture.cpp
+++ b/extension/src/openvic-extension/classes/GFXPieChartTexture.cpp
@@ -111,12 +111,11 @@ Error GFXPieChartTexture::set_slices_array(godot_pie_chart_data_t const& new_sli
ERR_CONTINUE_MSG(
!slice_dict.has(_slice_colour_key()) || !slice_dict.has(_slice_weight_key()), vformat("Invalid slice keys at index %d", i)
);
- slice_t slice = std::make_pair(slice_dict[_slice_colour_key()], slice_dict[_slice_weight_key()]);
- ERR_CONTINUE_MSG(
- slice.second <= 0.0f, vformat("Invalid slice values at index %d \"%s\"", i, slice_dict[_slice_identifier_key()])
- );
- total_weight += slice.second;
- slices.emplace_back(std::move(slice));
+ const slice_t slice = std::make_pair(slice_dict[_slice_colour_key()], slice_dict[_slice_weight_key()]);
+ if (slice.second > 0.0f) {
+ total_weight += slice.second;
+ slices.push_back(slice);
+ }
}
return _generate_pie_chart_image();
}
diff --git a/extension/src/openvic-extension/singletons/GameSingleton.cpp b/extension/src/openvic-extension/singletons/GameSingleton.cpp
index ef19a6c..9f080b5 100644
--- a/extension/src/openvic-extension/singletons/GameSingleton.cpp
+++ b/extension/src/openvic-extension/singletons/GameSingleton.cpp
@@ -69,6 +69,7 @@ void GameSingleton::_bind_methods() {
OV_BIND_METHOD(GameSingleton::is_parchment_mapmode_allowed);
OV_BIND_METHOD(GameSingleton::get_selected_province_index);
OV_BIND_METHOD(GameSingleton::set_selected_province, { "index" });
+ OV_BIND_METHOD(GameSingleton::unset_selected_province);
OV_BIND_METHOD(GameSingleton::try_tick);
@@ -321,6 +322,10 @@ void GameSingleton::set_selected_province(int32_t index) {
emit_signal(_signal_province_selected(), index);
}
+void GameSingleton::unset_selected_province() {
+ set_selected_province(Province::NULL_INDEX);
+}
+
void GameSingleton::try_tick() {
game_manager.get_simulation_clock().conditionally_advance_game();
}
diff --git a/extension/src/openvic-extension/singletons/GameSingleton.hpp b/extension/src/openvic-extension/singletons/GameSingleton.hpp
index 7f86eb2..eab8f63 100644
--- a/extension/src/openvic-extension/singletons/GameSingleton.hpp
+++ b/extension/src/openvic-extension/singletons/GameSingleton.hpp
@@ -105,6 +105,7 @@ namespace OpenVic {
bool is_parchment_mapmode_allowed() const;
int32_t get_selected_province_index() const;
void set_selected_province(int32_t index);
+ void unset_selected_province();
void try_tick();
};