diff options
Diffstat (limited to 'extension/src/openvic-extension/classes/GFXPieChartTexture.hpp')
-rw-r--r-- | extension/src/openvic-extension/classes/GFXPieChartTexture.hpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/extension/src/openvic-extension/classes/GFXPieChartTexture.hpp b/extension/src/openvic-extension/classes/GFXPieChartTexture.hpp index abeca1e..8683b10 100644 --- a/extension/src/openvic-extension/classes/GFXPieChartTexture.hpp +++ b/extension/src/openvic-extension/classes/GFXPieChartTexture.hpp @@ -2,7 +2,7 @@ #include <godot_cpp/classes/image_texture.hpp> -#include <openvic-simulation/interface/GFX.hpp> +#include <openvic-simulation/interface/GFXSprite.hpp> #include "openvic-extension/utility/Utilities.hpp" @@ -54,12 +54,14 @@ namespace OpenVic { return lhs.first < rhs.first; }); godot_pie_chart_data_t array; - for (auto const& [key, val] : sorted_dist) { + ERR_FAIL_COND_V(array.resize(sorted_dist.size()) != OK, {}); + for (size_t idx = 0; idx < array.size(); ++idx) { + auto const& [key, val] = sorted_dist[idx]; Dictionary sub_dict; sub_dict[_slice_identifier_key()] = Utilities::std_view_to_godot_string(key->get_identifier()); sub_dict[_slice_colour_key()] = Utilities::to_godot_color(key->get_colour()); sub_dict[_slice_weight_key()] = val.to_float(); - array.push_back(sub_dict); + array[idx] = std::move(sub_dict); } return array; } |