mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-11 21:21:57 -04:00
Add confirmations modals to Reset and Quit
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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<AchievementsWindow>()); });
|
||||
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>(Modal::Props{
|
||||
.title = "Reset Game",
|
||||
.bodyRml = "Unsaved progress will be lost.<br/>"
|
||||
"<span class=\"tip\">Tip: You can also reset by holding Start+X+B</span>",
|
||||
.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>(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) {
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -19,8 +19,7 @@ public:
|
||||
std::vector<ModalAction> actions;
|
||||
std::function<void(Modal&)> onDismiss;
|
||||
Rml::String variant;
|
||||
bool isWarning = false;
|
||||
bool isError = false;
|
||||
Rml::String icon = "";
|
||||
};
|
||||
|
||||
explicit Modal(Props props);
|
||||
|
||||
@@ -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",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user