From f8af17618e9f24dd6833ecaab64bf968cca2ec15 Mon Sep 17 00:00:00 2001 From: hop311 Date: Wed, 20 Mar 2024 00:11:22 +0000 Subject: Label padding, progressbar range and piechart slice order tweaks --- extension/src/openvic-extension/classes/GFXPieChartTexture.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'extension/src/openvic-extension/classes/GFXPieChartTexture.hpp') diff --git a/extension/src/openvic-extension/classes/GFXPieChartTexture.hpp b/extension/src/openvic-extension/classes/GFXPieChartTexture.hpp index f8279e4..abeca1e 100644 --- a/extension/src/openvic-extension/classes/GFXPieChartTexture.hpp +++ b/extension/src/openvic-extension/classes/GFXPieChartTexture.hpp @@ -29,15 +29,17 @@ namespace OpenVic { public: GFXPieChartTexture(); + using godot_pie_chart_data_t = godot::TypedArray; + /* Set slices given an Array of Dictionaries, each with the following key-value entries: * - colour: Color * - weight: float */ - godot::Error set_slices_array(godot::TypedArray const& new_slices); + godot::Error set_slices_array(godot_pie_chart_data_t const& new_slices); /* Generate slice data from a distribution of HasIdentifierAndColour derived objects, sorted by their weight. * The resulting Array of Dictionaries can be used as an argument for set_slices_array. */ template T> - static godot::TypedArray distribution_to_slices_array(fixed_point_map_t const& dist) { + static godot_pie_chart_data_t distribution_to_slices_array(fixed_point_map_t const& dist) { using namespace godot; using entry_t = std::pair; std::vector sorted_dist; @@ -49,9 +51,9 @@ namespace OpenVic { sorted_dist.push_back(entry); } std::sort(sorted_dist.begin(), sorted_dist.end(), [](entry_t const& lhs, entry_t const& rhs) -> bool { - return lhs.second < rhs.second; + return lhs.first < rhs.first; }); - TypedArray array; + godot_pie_chart_data_t array; for (auto const& [key, val] : sorted_dist) { Dictionary sub_dict; sub_dict[_slice_identifier_key()] = Utilities::std_view_to_godot_string(key->get_identifier()); -- cgit v1.2.3-56-ga3b1