diff options
author | hop311 <hop3114@gmail.com> | 2024-09-19 00:30:00 +0200 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-09-20 14:22:59 +0200 |
commit | 10e1a79f30dae8d2def820542b53596c2bfd222d (patch) | |
tree | d140b82a99f3871b4a86526df3c3755fa6bdedfa /extension/src/openvic-extension/classes/GFXPieChartTexture.hpp | |
parent | b78093041d877ef30c2d17878cc03fd30c4b229c (diff) |
Allow GFXPieChartTexture to use any distribution with identifiers and colours rather than just those derived from HasIdentifierAndColourconcept-pie-charts
Diffstat (limited to 'extension/src/openvic-extension/classes/GFXPieChartTexture.hpp')
-rw-r--r-- | extension/src/openvic-extension/classes/GFXPieChartTexture.hpp | 11 |
1 files changed, 6 insertions, 5 deletions
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<typename Container> static godot_pie_chart_data_t distribution_to_slices_array(Container const& dist) @@ -53,17 +53,18 @@ namespace OpenVic { ( /* fixed_point_map_t<T const*>, T derived from HasIdentifierAndColour */ utility::is_specialization_of_v<Container, tsl::ordered_map> && - std::derived_from<std::remove_pointer_t<typename Container::key_type>, HasIdentifierAndColour> && + HasGetIdentifierAndGetColour<std::remove_pointer_t<typename Container::key_type>> && std::is_same_v<typename Container::mapped_type, fixed_point_t> ) || ( /* IndexedMap<T, fixed_point_t>, T derived from HasIdentifierAndColour */ utility::is_specialization_of_v<Container, IndexedMap> && - std::derived_from<typename Container::key_t, HasIdentifierAndColour> && + HasGetIdentifierAndGetColour<typename Container::key_type> && std::is_same_v<typename Container::value_t, fixed_point_t> ) ) { using namespace godot; - using entry_t = std::pair<HasIdentifierAndColour const*, fixed_point_t>; + using key_type = std::remove_pointer_t<typename Container::key_type>; + using entry_t = std::pair<key_type const*, fixed_point_t>; std::vector<entry_t> sorted_dist; if constexpr (utility::is_specialization_of_v<Container, tsl::ordered_map>) { @@ -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); } } |