From 0a5f3b25214c11556f62ce04601c06812a3464d8 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Mon, 19 May 2025 13:42:39 +0200 Subject: lib: add support for different sort modes --- lib/src/turnsmm/enums.cpp | 5 +++++ lib/src/turnsmm/enums.hpp | 7 +++++++ lib/src/turnsmm/turn-order.cpp | 21 +++++++++++++++++++++ lib/src/turnsmm/turn-order.hpp | 6 ++++++ 4 files changed, 39 insertions(+) (limited to 'lib/src/turnsmm') diff --git a/lib/src/turnsmm/enums.cpp b/lib/src/turnsmm/enums.cpp index 91d6eb3..475d6f8 100644 --- a/lib/src/turnsmm/enums.cpp +++ b/lib/src/turnsmm/enums.cpp @@ -4,6 +4,7 @@ #include "turns-enums.h" // IWYU pragma: keep #include +#include #include @@ -22,6 +23,9 @@ namespace Turns static_assert(matches); static_assert(matches); + static_assert(matches); + static_assert(matches); + } // namespace Turns namespace Glib @@ -33,6 +37,7 @@ namespace Glib } VALUE_SPECIALIZATION(Disposition, disposition) + VALUE_SPECIALIZATION(SortMode, turn_order_sort_mode) #undef VALUE_SPECIALIZATION } // namespace Glib \ No newline at end of file diff --git a/lib/src/turnsmm/enums.hpp b/lib/src/turnsmm/enums.hpp index f99a6f1..b866b33 100644 --- a/lib/src/turnsmm/enums.hpp +++ b/lib/src/turnsmm/enums.hpp @@ -15,6 +15,12 @@ namespace Turns Secret, }; + enum struct SortMode + { + Descending, + Ascending, + }; + } // namespace Turns namespace Glib @@ -29,6 +35,7 @@ namespace Glib } VALUE_SPECIALIZATION(Disposition); + VALUE_SPECIALIZATION(SortMode); #undef VALUE_SPECIALIZATION diff --git a/lib/src/turnsmm/turn-order.cpp b/lib/src/turnsmm/turn-order.cpp index c89bd92..1f795d2 100644 --- a/lib/src/turnsmm/turn-order.cpp +++ b/lib/src/turnsmm/turn-order.cpp @@ -1,6 +1,7 @@ #include "turnsmm/turn-order.hpp" #include "turns-turn-order.h" +#include "turnsmm/enums.hpp" #include "turnsmm/participant.hpp" #include "turnsmm/private/turn-order_p.hpp" @@ -100,6 +101,26 @@ namespace Turns return {this, "running"}; } + auto TurnOrder::get_sort_mode() const noexcept -> SortMode + { + return static_cast(turns_turn_order_get_sort_mode(unwrap(this))); + } + + auto TurnOrder::set_sort_mode(SortMode value) noexcept -> void + { + turns_turn_order_set_sort_mode(unwrap(this), static_cast(value)); + } + + auto TurnOrder::property_sort_mode() noexcept -> Glib::PropertyProxy + { + return {this, "sort_mode"}; + } + + auto TurnOrder::property_sort_mode() const noexcept -> Glib::PropertyProxy_ReadOnly + { + return {this, "sort_mode"}; + } + TurnOrder::TurnOrder(BaseObjectType * gobj) : Glib::Object(G_OBJECT(gobj)) { diff --git a/lib/src/turnsmm/turn-order.hpp b/lib/src/turnsmm/turn-order.hpp index 9485275..c135ab2 100644 --- a/lib/src/turnsmm/turn-order.hpp +++ b/lib/src/turnsmm/turn-order.hpp @@ -2,6 +2,7 @@ #define TURNSMM_TURN_ORDER_HPP #include "turns-turn-order.h" +#include "turnsmm/enums.hpp" #include "turnsmm/participant.hpp" #include @@ -40,8 +41,13 @@ namespace Turns [[nodiscard]] auto get_participant_count() const noexcept -> std::size_t; [[nodiscard]] auto get_running() const noexcept -> bool; + [[nodiscard]] auto get_sort_mode() const noexcept -> SortMode; + + auto set_sort_mode(SortMode value) noexcept -> void; [[nodiscard]] auto property_running() const noexcept -> Glib::PropertyProxy_ReadOnly; + [[nodiscard]] auto property_sort_mode() noexcept -> Glib::PropertyProxy; + [[nodiscard]] auto property_sort_mode() const noexcept -> Glib::PropertyProxy_ReadOnly; protected: friend TurnOrder_Class; -- cgit v1.2.3