diff options
author | Hop311 <Hop3114@gmail.com> | 2024-09-20 23:17:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-20 23:17:41 +0200 |
commit | 4d8148a3a06df6b93685222ff3d8f1f9b54c734e (patch) | |
tree | b00fced178ac9b0bf902187372c67efc2b2023a3 /extension/src/openvic-extension/classes | |
parent | 05c37434775fb879ac6f929ec90e1e9ae610d032 (diff) | |
parent | 10e1a79f30dae8d2def820542b53596c2bfd222d (diff) |
Merge pull request #275 from OpenVicProject/concept-pie-charts
Allow GFXPieChartTexture to use any distribution with identifiers and colours rather than just those derived from HasIdentifierAndColour
Diffstat (limited to 'extension/src/openvic-extension/classes')
-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); } } |