diff options
Diffstat (limited to 'lib/include/turnsmm')
| -rw-r--r-- | lib/include/turnsmm/enum_helpers.hpp | 39 | ||||
| -rw-r--r-- | lib/include/turnsmm/init.hpp | 14 | ||||
| -rw-r--r-- | lib/include/turnsmm/participant.hpp | 91 | ||||
| -rw-r--r-- | lib/include/turnsmm/private/participant_p.hpp | 36 | ||||
| -rw-r--r-- | lib/include/turnsmm/private/turn-order_p.hpp | 36 | ||||
| -rw-r--r-- | lib/include/turnsmm/turn-order.hpp | 89 |
6 files changed, 305 insertions, 0 deletions
diff --git a/lib/include/turnsmm/enum_helpers.hpp b/lib/include/turnsmm/enum_helpers.hpp new file mode 100644 index 0000000..60b8cd7 --- /dev/null +++ b/lib/include/turnsmm/enum_helpers.hpp @@ -0,0 +1,39 @@ +/* + * SPDX-FileCopyrightText: 2025 Felix Morgner <felix.morgner@gmail.com> + * SPDX-License-Identifier: LGPL-2.1-only + */ + +#ifndef TURNSMM_ENUM_HELPERS_HPP +#define TURNSMM_ENUM_HELPERS_HPP + +#include <glibmm/value.h> + +#include <glib-object.h> +#include <glib.h> + +#include <type_traits> + +#define TURNS_DECLARE_ENUM_VALUE_SPECIALIZATION(Enum) \ + template<> \ + class Value<::Turns::Enum> : public Glib::Value_Enum<::Turns::Enum> \ + { \ + public: \ + auto static value_type() -> GType; \ + } + +#define TURNS_DEFINE_VALUE_SPECIALIZATION(Enum, TurnsEnumName) \ + auto Value<::Turns::Enum>::value_type() -> GType \ + { \ + return ::turns_##TurnsEnumName##_get_type(); \ + } + +namespace Turns +{ + + template<auto Wrapped, auto Unwrapped> + auto constexpr enum_matches = + static_cast<std::underlying_type_t<decltype(Wrapped)>>(Wrapped) == static_cast<std::underlying_type_t<decltype(Unwrapped)>>(Unwrapped); + +} // namespace Turns + +#endif
\ No newline at end of file diff --git a/lib/include/turnsmm/init.hpp b/lib/include/turnsmm/init.hpp new file mode 100644 index 0000000..c22b4c9 --- /dev/null +++ b/lib/include/turnsmm/init.hpp @@ -0,0 +1,14 @@ +/* + * SPDX-FileCopyrightText: 2025 Felix Morgner <felix.morgner@gmail.com> + * SPDX-License-Identifier: LGPL-2.1-only + */ + +#ifndef TURNSMM_INIT_HPP +#define TURNSMM_INIT_HPP + +namespace Turns +{ + void init(void); +} + +#endif diff --git a/lib/include/turnsmm/participant.hpp b/lib/include/turnsmm/participant.hpp new file mode 100644 index 0000000..6dece0e --- /dev/null +++ b/lib/include/turnsmm/participant.hpp @@ -0,0 +1,91 @@ +/* + * SPDX-FileCopyrightText: 2025 Felix Morgner <felix.morgner@gmail.com> + * SPDX-License-Identifier: LGPL-2.1-only + */ + +#ifndef TURNSMM_PARTICIPANT_HPP +#define TURNSMM_PARTICIPANT_HPP + +#include "turns-participant.h" +#include "turnsmm/enum_helpers.hpp" + +#include <glibmm/object.h> +#include <glibmm/propertyproxy.h> +#include <glibmm/refptr.h> +#include <glibmm/ustring.h> + +#include <glib-object.h> +#include <glib.h> + +namespace Turns +{ + + class Participant final : public Glib::Object + { + public: + using BaseClassType = TurnsParticipantClass; + using BaseObjectType = TurnsParticipant; + using CppClassType = class Participant_Class; + using CppObjectType = Participant; + + enum struct Disposition : guint + { + Neutral, + Friendly, + Hostile, + Secret, + }; + + auto static get_base_type() -> GType; + auto static get_type() -> GType; + + auto static create() -> Glib::RefPtr<Participant>; + auto static create(Glib::ustring const & name, float priority, Disposition disposition) -> Glib::RefPtr<Participant>; + + Participant(); + Participant(Glib::ustring const & name, float priority, Disposition disposition); + + [[nodiscard]] auto gobj() noexcept -> BaseObjectType *; + [[nodiscard]] auto gobj() const -> BaseObjectType const *; + [[nodiscard]] auto gobj_copy() noexcept -> BaseObjectType *; + + [[nodiscard]] auto get_active() const noexcept -> bool; + [[nodiscard]] auto get_defeated() const noexcept -> bool; + [[nodiscard]] auto get_disposition() const noexcept -> Disposition; + [[nodiscard]] auto get_id() const noexcept -> Glib::ustring; + [[nodiscard]] auto get_name() const -> Glib::ustring; + [[nodiscard]] auto get_priority() const noexcept -> float; + + auto set_active(bool value) noexcept -> void; + auto set_defeated(bool value) noexcept -> void; + auto set_disposition(Disposition value) noexcept -> void; + auto set_name(Glib::ustring const & value) noexcept -> void; + auto set_priority(float value) noexcept -> void; + + [[nodiscard]] auto property_active() const noexcept -> Glib::PropertyProxy_ReadOnly<bool>; + [[nodiscard]] auto property_active() noexcept -> Glib::PropertyProxy<bool>; + [[nodiscard]] auto property_defeated() const noexcept -> Glib::PropertyProxy_ReadOnly<bool>; + [[nodiscard]] auto property_defeated() noexcept -> Glib::PropertyProxy<bool>; + [[nodiscard]] auto property_disposition() const noexcept -> Glib::PropertyProxy_ReadOnly<Disposition>; + [[nodiscard]] auto property_disposition() noexcept -> Glib::PropertyProxy<Disposition>; + [[nodiscard]] auto property_name() const noexcept -> Glib::PropertyProxy_ReadOnly<Glib::ustring const &>; + [[nodiscard]] auto property_name() noexcept -> Glib::PropertyProxy<Glib::ustring const &>; + [[nodiscard]] auto property_priority() const noexcept -> Glib::PropertyProxy_ReadOnly<float>; + [[nodiscard]] auto property_priority() noexcept -> Glib::PropertyProxy<float>; + + protected: + friend Participant_Class; + + explicit Participant(BaseObjectType * gobj); + }; + +} // namespace Turns + +namespace Glib +{ + TURNS_DECLARE_ENUM_VALUE_SPECIALIZATION(Participant::Disposition); + + auto wrap(TurnsParticipant * object, bool copy = false) -> Glib::RefPtr<Turns::Participant>; +} // namespace Glib + +#endif
\ No newline at end of file diff --git a/lib/include/turnsmm/private/participant_p.hpp b/lib/include/turnsmm/private/participant_p.hpp new file mode 100644 index 0000000..d0f4f0d --- /dev/null +++ b/lib/include/turnsmm/private/participant_p.hpp @@ -0,0 +1,36 @@ +/* + * SPDX-FileCopyrightText: 2025 Felix Morgner <felix.morgner@gmail.com> + * SPDX-License-Identifier: LGPL-2.1-only + */ + +#ifndef TURNSMM_PARTICIPANT_P_HPP +#define TURNSMM_PARTICIPANT_P_HPP + +#include "turns-participant.h" + +#include <glibmm/class.h> +#include <glibmm/object.h> +#include <glibmm/objectbase.h> + +#include <glib-object.h> + +namespace Turns +{ + + class Participant_Class : Glib::Class + { + public: + using BaseClassParent = GObjectClass; + using BaseClassType = TurnsParticipantClass; + using BaseObjectType = TurnsParticipant; + using CppClassParent = Glib::Object_Class; + using CppObjectType = class Participant; + + auto init() -> Glib::Class const &; + auto static class_init_function(void * gclass, void * data) -> void; + auto static wrap_new(GObject * object) -> Glib::ObjectBase *; + }; + +} // namespace Turns + +#endif
\ No newline at end of file diff --git a/lib/include/turnsmm/private/turn-order_p.hpp b/lib/include/turnsmm/private/turn-order_p.hpp new file mode 100644 index 0000000..d694b3e --- /dev/null +++ b/lib/include/turnsmm/private/turn-order_p.hpp @@ -0,0 +1,36 @@ +/* + * SPDX-FileCopyrightText: 2025 Felix Morgner <felix.morgner@gmail.com> + * SPDX-License-Identifier: LGPL-2.1-only + */ + +#ifndef TURNSMM_TURN_ORDER_P_HPP +#define TURNSMM_TURN_ORDER_P_HPP + +#include "turns-turn-order.h" + +#include <glibmm/class.h> +#include <glibmm/object.h> +#include <glibmm/objectbase.h> + +#include <glib-object.h> + +namespace Turns +{ + + class TurnOrder_Class : Glib::Class + { + public: + using BaseClassParent = GObjectClass; + using BaseClassType = TurnsTurnOrderClass; + using BaseObjectType = TurnsTurnOrder; + using CppClassParent = Glib::Object_Class; + using CppObjectType = class TURN_ORDER; + + auto init() -> Glib::Class const &; + auto static class_init_function(void * gclass, void * data) -> void; + auto static wrap_new(GObject * object) -> Glib::ObjectBase *; + }; + +} // namespace Turns + +#endif
\ No newline at end of file diff --git a/lib/include/turnsmm/turn-order.hpp b/lib/include/turnsmm/turn-order.hpp new file mode 100644 index 0000000..5b8deb9 --- /dev/null +++ b/lib/include/turnsmm/turn-order.hpp @@ -0,0 +1,89 @@ +/* + * SPDX-FileCopyrightText: 2025 Felix Morgner <felix.morgner@gmail.com> + * SPDX-License-Identifier: LGPL-2.1-only + */ + +#ifndef TURNSMM_TURN_ORDER_HPP +#define TURNSMM_TURN_ORDER_HPP + +#include "turns-turn-order.h" +#include "turnsmm/participant.hpp" + +#include <glibmm/object.h> +#include <glibmm/propertyproxy.h> +#include <glibmm/refptr.h> +#include <glibmm/ustring.h> +#include <glibmm/value.h> + +#include <giomm/listmodel.h> + +#include <glib-object.h> +#include <glib.h> + +#include <cstddef> + +namespace Turns +{ + + class TurnOrder final : public Glib::Object, + public Gio::ListModel + { + public: + using BaseClassType = TurnsTurnOrderClass; + using BaseObjectType = TurnsTurnOrder; + using CppClassType = class TurnOrder_Class; + using CppObjectType = TurnOrder; + + enum struct SortMode : guint + { + Descending, + Ascending, + }; + + auto static get_base_type() -> GType; + auto static get_type() -> GType; + + TurnOrder(); + + [[nodiscard]] auto gobj() noexcept -> BaseObjectType *; + [[nodiscard]] auto gobj() const -> BaseObjectType const *; + [[nodiscard]] auto gobj_copy() noexcept -> BaseObjectType *; + + auto add(Glib::RefPtr<Participant> const & participant) noexcept -> void; + auto clear() noexcept -> void; + auto remove_at(guint position) noexcept -> void; + + [[nodiscard]] auto get_empty() const noexcept -> bool; + [[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_empty() const noexcept -> Glib::PropertyProxy_ReadOnly<bool>; + [[nodiscard]] auto property_participant_count() const noexcept -> Glib::PropertyProxy_ReadOnly<std::size_t>; + [[nodiscard]] auto property_running() const noexcept -> Glib::PropertyProxy_ReadOnly<bool>; + [[nodiscard]] auto property_sort_mode() noexcept -> Glib::PropertyProxy<SortMode>; + [[nodiscard]] auto property_sort_mode() const noexcept -> Glib::PropertyProxy_ReadOnly<SortMode>; + + protected: + friend TurnOrder_Class; + + explicit TurnOrder(BaseObjectType * gobj); + }; + +} // namespace Turns + +namespace Glib +{ + template<> + class Value<Turns::TurnOrder::SortMode> : public Glib ::Value_Enum<Turns::TurnOrder::SortMode> + { + public: + auto static value_type() -> GType; + }; + + auto wrap(TurnsTurnOrder * object, bool copy = false) -> Glib::RefPtr<Turns::TurnOrder>; +} // namespace Glib + +#endif
\ No newline at end of file |
