diff --git a/extern/aurora b/extern/aurora index 0acac1320c..22351fb0b7 160000 --- a/extern/aurora +++ b/extern/aurora @@ -1 +1 @@ -Subproject commit 0acac1320c58d9083f9bbd8bd8b40647c0d52ecf +Subproject commit 22351fb0b76a4f4f2c4a4dff95aa300101e861aa diff --git a/src/dusk/ui/document.cpp b/src/dusk/ui/document.cpp index fc8be92a83..1ad03bc1ec 100644 --- a/src/dusk/ui/document.cpp +++ b/src/dusk/ui/document.cpp @@ -3,9 +3,7 @@ #include "aurora/rmlui.hpp" #include "ui.hpp" -#include "Z2AudioLib/Z2SeMgr.h" #include "m_Do/m_Do_audio.h" -#include namespace dusk::ui { namespace { @@ -30,19 +28,19 @@ Document::Document(const Rml::String& source, bool passive) return; } const auto cmd = map_nav_event(event); - if (cmd != NavCommand::Menu && !visible()) { + if (cmd != NavCommand::Menu && (!visible() || !active())) { event.StopImmediatePropagation(); } }, true); - const auto blockUnlessVisible = [this](Rml::Event& event) { - if (!visible()) { + const auto blockUnlessActive = [this](Rml::Event& event) { + if (!visible() || !active()) { event.StopImmediatePropagation(); } }; - listen(Rml::EventId::Mouseover, blockUnlessVisible, true); - listen(Rml::EventId::Click, blockUnlessVisible, true); - listen(Rml::EventId::Scroll, blockUnlessVisible, true); + listen(Rml::EventId::Mouseover, blockUnlessActive, true); + listen(Rml::EventId::Click, blockUnlessActive, true); + listen(Rml::EventId::Scroll, blockUnlessActive, true); listen(Rml::EventId::Keydown, [this](Rml::Event& event) { if (mPassive) { @@ -124,9 +122,16 @@ bool Document::visible() const { return *mDocument->GetProperty(Rml::PropertyId::Visibility) == Rml::Style::Visibility::Visible; } +bool Document::active() const { + return !mClosed && !mPendingClose; +} + bool Document::handle_nav_event(Rml::Event& event) { + if (!active()) { + return false; + } const auto cmd = map_nav_event(event); - if (cmd == NavCommand::None) { + if (cmd == NavCommand::None || (cmd != NavCommand::Menu && !visible())) { return false; } return handle_nav_command(event, cmd); diff --git a/src/dusk/ui/document.hpp b/src/dusk/ui/document.hpp index cf61267ee9..c3428d9fea 100644 --- a/src/dusk/ui/document.hpp +++ b/src/dusk/ui/document.hpp @@ -18,6 +18,7 @@ public: virtual void update(); virtual bool focus(); virtual bool visible() const; + virtual bool active() const; void listen(Rml::Element* element, Rml::EventId event, ScopedEventListener::Callback callback, bool capture = false); @@ -41,12 +42,11 @@ public: push_document(std::move(document)); hide(false); } - void pop() { + void pop(bool show = true) { hide(true); - show_top_document(); + focus_top_document(show); } - bool pending_close() const { return mPendingClose; } bool closed() const { return mClosed; } bool handle_nav_event(Rml::Event& event); diff --git a/src/dusk/ui/prelaunch.cpp b/src/dusk/ui/prelaunch.cpp index 44b73b75ef..998cdb87ea 100644 --- a/src/dusk/ui/prelaunch.cpp +++ b/src/dusk/ui/prelaunch.cpp @@ -715,7 +715,7 @@ Prelaunch::Prelaunch() : Document(kDocumentSource), mRoot(mDocument->GetElementB } IsGameLaunched = true; - hide(true); + pop(false); }); apply_intro_animation(mMenuButtons.back()->root(), "delay-1"); diff --git a/src/dusk/ui/ui.cpp b/src/dusk/ui/ui.cpp index 0d9d0b7e1e..ecff09f6aa 100644 --- a/src/dusk/ui/ui.cpp +++ b/src/dusk/ui/ui.cpp @@ -195,9 +195,13 @@ Document& push_document(std::unique_ptr doc, bool show, bool passive) return ret; } -void show_top_document() noexcept { +void focus_top_document(bool show) noexcept { if (auto* doc = top_document()) { - doc->show(); + if (show) { + doc->show(); + } else { + doc->focus(); + } } input::sync_input_block(); } @@ -210,13 +214,13 @@ bool any_document_visible() noexcept { bool is_prelaunch_open() noexcept { return std::any_of(sDocumentStack.begin(), sDocumentStack.end(), [](const auto& doc) { const auto* prelaunch = dynamic_cast(doc.get()); - return prelaunch != nullptr && !prelaunch->pending_close() && !prelaunch->closed(); + return prelaunch != nullptr && prelaunch->active(); }); } Document* top_document() noexcept { for (auto& doc : std::views::reverse(sDocumentStack)) { - if (!doc->closed() && !doc->pending_close()) { + if (doc->active()) { return doc.get(); } } @@ -259,7 +263,7 @@ void update() noexcept { context->GetFocusElement() == context->GetRootElement())) { for (auto& doc : std::views::reverse(sDocumentStack)) { - if (!doc->closed() && !doc->pending_close() && doc->focus()) { + if (doc->active() && doc->focus()) { break; } } diff --git a/src/dusk/ui/ui.hpp b/src/dusk/ui/ui.hpp index cbfe3dcc9d..a32bfbbcbc 100644 --- a/src/dusk/ui/ui.hpp +++ b/src/dusk/ui/ui.hpp @@ -74,7 +74,7 @@ void update() noexcept; Document& push_document( std::unique_ptr doc, bool show = true, bool passive = false) noexcept; -void show_top_document() noexcept; +void focus_top_document(bool show) noexcept; bool any_document_visible() noexcept; bool is_prelaunch_open() noexcept; Document* top_document() noexcept;