From 10e1a79f30dae8d2def820542b53596c2bfd222d Mon Sep 17 00:00:00 2001 From: hop311 Date: Wed, 18 Sep 2024 23:30:00 +0100 Subject: Allow GFXPieChartTexture to use any distribution with identifiers and colours rather than just those derived from HasIdentifierAndColour --- .../src/openvic-extension/classes/GFXPieChartTexture.hpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'extension/src/openvic-extension/classes') diff --git a/extension/src/openvic-extension/classes/GFXPieChartTexture.hpp b/extension/src/openvic-extension/classes/GFXPieChartTexture.hpp index 3610efb..69330a4 100644 --- a/extension/src/openvic-extension/classes/GFXPieChartTexture.hpp +++ b/extension/src/openvic-extension/classes/GFXPieChartTexture.hpp @@ -45,7 +45,7 @@ namespace OpenVic { * - weight: float */ 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. + /* Generate slice data from a distribution of objects satisfying HasGetIdentifierAndGetColour, sorted by their weight. * The resulting Array of Dictionaries can be used as an argument for set_slices_array. */ template static godot_pie_chart_data_t distribution_to_slices_array(Container const& dist) @@ -53,17 +53,18 @@ namespace OpenVic { ( /* fixed_point_map_t, T derived from HasIdentifierAndColour */ utility::is_specialization_of_v && - std::derived_from, HasIdentifierAndColour> && + HasGetIdentifierAndGetColour> && std::is_same_v ) || ( /* IndexedMap, T derived from HasIdentifierAndColour */ utility::is_specialization_of_v && - std::derived_from && + HasGetIdentifierAndGetColour && std::is_same_v ) ) { using namespace godot; - using entry_t = std::pair; + using key_type = std::remove_pointer_t; + using entry_t = std::pair; std::vector sorted_dist; if constexpr (utility::is_specialization_of_v) { @@ -78,7 +79,7 @@ namespace OpenVic { for (size_t index = 0; index < dist.size(); ++index) { fixed_point_t const& value = dist[index]; if (value != 0) { - HasIdentifierAndColour const* key = &dist(index); + key_type const* key = &dist(index); sorted_dist.emplace_back(key, value); } } -- cgit v1.2.3-56-ga3b1