UI: Add load state confirmation option

This commit is contained in:
Eloren1
2026-05-31 19:15:31 +03:00
parent 93340779e1
commit 23aef44ae1
5 changed files with 37 additions and 4 deletions
+32 -4
View File
@@ -161,8 +161,19 @@ void ScreenshotViewScreen::OnSaveState(UI::EventParams &e) {
void ScreenshotViewScreen::OnLoadState(UI::EventParams &e) {
if (!NetworkWarnUserIfOnlineAndCantSavestate()) {
g_Config.iCurrentStateSlot = slot_;
SaveState::LoadSlot(saveStatePrefix_, slot_, &ShowMessageAfterSaveStateAction);
TriggerFinish(DR_OK);
if (g_Config.bConfirmLoadState) {
auto pa = GetI18NCategory(I18NCat::PAUSE);
auto di = GetI18NCategory(I18NCat::DIALOG);
screenManager()->push(new UI::MessagePopupScreen(pa->T("Load State"), di->T("ConfirmLoadState"), pa->T("Load State"), di->T("Cancel"), [this](bool result) {
if (result) {
SaveState::LoadSlot(saveStatePrefix_, slot_, &ShowMessageAfterSaveStateAction);
TriggerFinish(DR_OK);
}
}));
} else {
SaveState::LoadSlot(saveStatePrefix_, slot_, &ShowMessageAfterSaveStateAction);
TriggerFinish(DR_OK);
}
}
}
@@ -218,6 +229,7 @@ public:
UI::Event OnStateSaved;
UI::Event OnScreenshotClicked;
UI::Event OnSelected;
UI::Event OnLoadRequested;
private:
void OnSaveState(UI::EventParams &e);
@@ -303,10 +315,9 @@ void SaveSlotView::Draw(UIContext &dc) {
void SaveSlotView::OnLoadState(UI::EventParams &e) {
if (!NetworkWarnUserIfOnlineAndCantSavestate()) {
g_Config.iCurrentStateSlot = slot_;
SaveState::LoadSlot(saveStatePrefix_, slot_, &ShowMessageAfterSaveStateAction);
UI::EventParams e2{};
e2.v = this;
OnStateLoaded.Trigger(e2);
OnLoadRequested.Trigger(e2);
}
}
@@ -394,6 +405,23 @@ void GamePauseScreen::CreateSavestateControls(UI::LinearLayout *leftColumnItems,
SaveSlotView *slot = leftColumnItems->Add(new SaveSlotView(saveStatePrefix_, i, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, Gravity::G_HCENTER, Margins(0,0,0,0))));
slot->OnStateLoaded.Handle(this, &GamePauseScreen::OnState);
slot->OnStateSaved.Handle(this, &GamePauseScreen::OnState);
slot->OnLoadRequested.Add([this](UI::EventParams &e) {
SaveSlotView *v = static_cast<SaveSlotView *>(e.v);
int slotNum = v->GetSlot();
auto doLoad = [this, slotNum]() {
SaveState::LoadSlot(saveStatePrefix_, slotNum, &ShowMessageAfterSaveStateAction);
TriggerFinish(DR_CANCEL);
};
if (g_Config.bConfirmLoadState) {
auto pa = GetI18NCategory(I18NCat::PAUSE);
auto di = GetI18NCategory(I18NCat::DIALOG);
screenManager()->push(new UI::MessagePopupScreen(pa->T("Load State"), di->T("ConfirmLoadState"), pa->T("Load State"), di->T("Cancel"), [doLoad](bool result) {
if (result) doLoad();
}));
} else {
doLoad();
}
});
slot->OnScreenshotClicked.Add([this](UI::EventParams &e) {
SaveSlotView *v = static_cast<SaveSlotView *>(e.v);
int slot = v->GetSlot();