diff options
author | hop311 <hop3114@gmail.com> | 2024-03-20 01:11:22 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-03-20 23:47:37 +0100 |
commit | f8af17618e9f24dd6833ecaab64bf968cca2ec15 (patch) | |
tree | 3b5636e154a067c8383d2d9cac8c9f12839d64a1 /extension/src/openvic-extension/classes/GFXPieChartTexture.hpp | |
parent | 8088824d7b78311c0613b3876ba9555fbbe96c17 (diff) |
Label padding, progressbar range and piechart slice order tweaks
Diffstat (limited to 'extension/src/openvic-extension/classes/GFXPieChartTexture.hpp')
-rw-r--r-- | extension/src/openvic-extension/classes/GFXPieChartTexture.hpp | 10 |
1 files changed, 6 insertions, 4 deletions
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<godot::Dictionary>; + /* 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<godot::Dictionary> 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<std::derived_from<HasIdentifierAndColour> T> - static godot::TypedArray<godot::Dictionary> distribution_to_slices_array(fixed_point_map_t<T const*> const& dist) { + static godot_pie_chart_data_t distribution_to_slices_array(fixed_point_map_t<T const*> const& dist) { using namespace godot; using entry_t = std::pair<T const*, fixed_point_t>; std::vector<entry_t> 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<Dictionary> 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()); |