From e323439e4f4dccb119917646f178b5e8ca928140 Mon Sep 17 00:00:00 2001 From: Dario Date: Thu, 16 Jan 2025 22:34:47 -0300 Subject: [PATCH] Mod menu progress. --- src/ui/elements/ui_button.cpp | 4 +-- src/ui/elements/ui_element.cpp | 12 +++++-- src/ui/elements/ui_element.h | 18 +++++----- src/ui/elements/ui_style.cpp | 8 ++--- src/ui/elements/ui_style.h | 4 +-- src/ui/elements/ui_toggle.cpp | 58 +++++++++++++++++++++++---------- src/ui/elements/ui_toggle.h | 10 ++++-- src/ui/elements/ui_types.h | 7 ++++ src/ui/ui_mod_details_panel.cpp | 6 ++-- src/ui/ui_mod_details_panel.h | 3 +- src/ui/ui_mod_menu.cpp | 6 ++-- 11 files changed, 91 insertions(+), 45 deletions(-) diff --git a/src/ui/elements/ui_button.cpp b/src/ui/elements/ui_button.cpp index 6da95d6..e467354 100644 --- a/src/ui/elements/ui_button.cpp +++ b/src/ui/elements/ui_button.cpp @@ -4,8 +4,8 @@ namespace recompui { - static const std::string hover_state = "hover"; - static const std::string disabled_state = "disabled"; + static const std::string_view hover_state = "hover"; + static const std::string_view disabled_state = "disabled"; Button::Button(const std::string &text, ButtonStyle style, Element *parent) : Element(parent, Events(EventType::Click, EventType::Hover, EventType::Enable), "button") { this->style = style; diff --git a/src/ui/elements/ui_element.cpp b/src/ui/elements/ui_element.cpp index 477ddba..173bad2 100644 --- a/src/ui/elements/ui_element.cpp +++ b/src/ui/elements/ui_element.cpp @@ -52,11 +52,13 @@ void Element::add_child(Element *child) { void Element::set_property(Rml::PropertyId property_id, const Rml::Property &property, Animation animation) { assert(base != nullptr); - if (animation.type == AnimationType::None) { + if (animation.type == AnimationType::None || animation.type == AnimationType::Set) { base->SetProperty(property_id, property); - // Only non-animated properties should be stored as part of the style. - Style::set_property(property_id, property, animation); + if (animation.type == AnimationType::None) { + // Only non-animated properties should be stored as part of the style. + Style::set_property(property_id, property, animation); + } } else { const Rml::String property_name = Rml::StyleSheetSpecification::GetPropertyName(property_id); @@ -184,6 +186,10 @@ void Element::set_enabled(bool enabled) { propagate_disabled(disabled_from_parent); } +bool Element::is_enabled() const { + return enabled && !disabled_from_parent; +} + void Element::set_text(const std::string &text) { base->SetInnerRML(text); } diff --git a/src/ui/elements/ui_element.h b/src/ui/elements/ui_element.h index 7d774ac..0b975cc 100644 --- a/src/ui/elements/ui_element.h +++ b/src/ui/elements/ui_element.h @@ -9,10 +9,18 @@ namespace recompui { class Element : public Style, public Rml::EventListener { friend class Element; private: + Rml::Element *base = nullptr; + uint32_t events_enabled = 0; std::vector