diff --git a/res/rml/window.rcss b/res/rml/window.rcss index bc8050a29f..97a4f589e1 100644 --- a/res/rml/window.rcss +++ b/res/rml/window.rcss @@ -287,6 +287,10 @@ icon.celebration { decorator: text("" center center); } +icon.question-mark { + decorator: text("" center center); +} + .achievement-row { display: flex; align-items: flex-start; @@ -447,6 +451,11 @@ window.modal.danger .modal-header icon { font-weight: normal; } +.modal-body span.tip { + font-size: 14dp; + color: #92875B; +} + .verification-progress { display: flex; flex-direction: column; diff --git a/src/dusk/ui/menu_bar.cpp b/src/dusk/ui/menu_bar.cpp index d6f6274798..1d68bd33df 100644 --- a/src/dusk/ui/menu_bar.cpp +++ b/src/dusk/ui/menu_bar.cpp @@ -13,6 +13,7 @@ #include "f_pc/f_pc_manager.h" #include "f_pc/f_pc_name.h" #include "imgui.h" +#include "modal.hpp" #include "settings.hpp" #include "ui.hpp" #include "window.hpp" @@ -54,13 +55,60 @@ MenuBar::MenuBar() : Document(kDocumentSource), mRoot(mDocument->GetElementById( mTabBar->add_tab("Achievements", [this] { push(std::make_unique()); }); mTabBar->add_tab("Reset", [this] { mTabBar->set_active_tab(-1); - if (fpcM_SearchByName(fpcNm_LOGO_SCENE_e)) { - return; - } - JUTGamePad::C3ButtonReset::sResetSwitchPushing = true; - hide(false); + const auto dismiss = [](Modal& modal) { modal.pop(); }; + push(std::make_unique(Modal::Props{ + .title = "Reset Game", + .bodyRml = "Unsaved progress will be lost.
" + "Tip: You can also reset by holding Start+X+B", + .actions = + { + ModalAction{ + .label = "Cancel", + .onPressed = dismiss, + }, + ModalAction{ + .label = "Reset", + .onPressed = + [this, dismiss](Modal& modal) { + if (fpcM_SearchByName(fpcNm_LOGO_SCENE_e)) { + dismiss(modal); + return; + } + JUTGamePad::C3ButtonReset::sResetSwitchPushing = true; + dismiss(modal); + hide(false); + }, + }, + }, + .onDismiss = dismiss, + .icon = "question-mark", + })); + }); + mTabBar->add_tab("Quit", [this] { + mTabBar->set_active_tab(-1); + const auto dismiss = [](Modal& modal) { modal.pop(); }; + push(std::make_unique(Modal::Props{ + .title = "Quit Dusk", + .bodyRml = "Unsaved progress will be lost.", + .actions = + { + ModalAction{ + .label = "Cancel", + .onPressed = dismiss, + }, + ModalAction{ + .label = "Quit", + .onPressed = + [dismiss](Modal& modal) { + dismiss(modal); + IsRunning = false; + }, + }, + }, + .onDismiss = dismiss, + .icon = "question-mark", + })); }); - mTabBar->add_tab("Quit", [] { IsRunning = false; }); // Hide document after transition completion listen(mRoot, Rml::EventId::Transitionend, [this](Rml::Event& event) { diff --git a/src/dusk/ui/modal.cpp b/src/dusk/ui/modal.cpp index 7120e56538..6aa1637de7 100644 --- a/src/dusk/ui/modal.cpp +++ b/src/dusk/ui/modal.cpp @@ -14,12 +14,9 @@ Modal::Modal(Props props) : WindowSmall("modal", "modal-dialog"), mProps(std::mo title->SetClass("modal-title", true); title->SetInnerRML(mProps.title); - if (mProps.isWarning) { + if (!mProps.icon.empty()) { auto* icon = append(header, "icon"); - icon->SetClass("warning", true); - } else if (mProps.isError) { - auto* icon = append(header, "icon"); - icon->SetClass("error", true); + icon->SetClass(mProps.icon, true); } auto* body = append(mDialog, "div"); diff --git a/src/dusk/ui/modal.hpp b/src/dusk/ui/modal.hpp index 5ffb8b65b4..8c0a5b9697 100644 --- a/src/dusk/ui/modal.hpp +++ b/src/dusk/ui/modal.hpp @@ -19,8 +19,7 @@ public: std::vector actions; std::function onDismiss; Rml::String variant; - bool isWarning = false; - bool isError = false; + Rml::String icon = ""; }; explicit Modal(Props props); diff --git a/src/dusk/ui/prelaunch.cpp b/src/dusk/ui/prelaunch.cpp index fda309237c..61e2d2a4de 100644 --- a/src/dusk/ui/prelaunch.cpp +++ b/src/dusk/ui/prelaunch.cpp @@ -507,7 +507,7 @@ void try_push_verification_modal(Document& host) { }, .onDismiss = dismiss, .variant = "danger", - .isWarning = true, + .icon = "warning", })); return; } @@ -523,7 +523,7 @@ void try_push_verification_modal(Document& host) { }, }, .onDismiss = dismiss, - .isError = true, + .icon = "error", })); }