mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Minor code cleanup on pause screen
This commit is contained in:
1 parent
510cfb421c
commit
2c73aead45
4 files changed
+32
-18
No files matched your search
@@ -532,3 +532,15 @@ void ScreenManager::SetBackgroundOverlayScreens(Screen *backgroundScreen, Screen
|
||||
overlayScreen_ = overlayScreen;
|
||||
overlayScreen_->setScreenManager(this);
|
||||
}
|
||||
|
||||
const char *DialogResultToString(DialogResult result) {
|
||||
switch (result) {
|
||||
case DR_NONE: return "DR_NONE";
|
||||
case DR_OK: return "DR_OK";
|
||||
case DR_CANCEL: return "DR_CANCEL";
|
||||
case DR_YES: return "DR_YES";
|
||||
case DR_NO: return "DR_NO";
|
||||
case DR_BACK: return "DR_BACK";
|
||||
default: return "(N/A)";
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,7 @@ enum DialogResult {
|
||||
DR_NO,
|
||||
DR_BACK,
|
||||
};
|
||||
const char *DialogResultToString(DialogResult result);
|
||||
|
||||
class ScreenManager;
|
||||
class UIContext;
|
||||
|
||||
+17
-18
@@ -389,9 +389,7 @@ GamePauseScreen::~GamePauseScreen() {
|
||||
void GamePauseScreen::OnVKey(VirtKey virtualKeyCode, bool down) {
|
||||
// Simple de-bounce using createdTime_, just to be safe.
|
||||
if (down && virtualKeyCode == VIRTKEY_PAUSE && time_now_d() > createdTime_ + 0.1) {
|
||||
std::lock_guard<std::mutex> lock(finishNextFrameMutex_);
|
||||
finishNextFrame_ = true;
|
||||
finishNextFrameResult_ = DR_BACK;
|
||||
FinishNextFrame(DR_BACK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,9 +408,7 @@ void GamePauseScreen::CreateSavestateControls(UI::LinearLayout *leftColumnItems,
|
||||
int slotNum = v->GetSlot();
|
||||
auto doLoad = [this, slotNum]() {
|
||||
SaveState::LoadSlot(saveStatePrefix_, slotNum, &ShowMessageAfterSaveStateAction);
|
||||
std::lock_guard<std::mutex> lock(finishNextFrameMutex_);
|
||||
finishNextFrame_ = true;
|
||||
finishNextFrameResult_ = DR_CANCEL;
|
||||
FinishNextFrame(DR_CANCEL);
|
||||
};
|
||||
if (g_Config.bConfirmLoadState) {
|
||||
screenManager()->push(new LoadStateConfirmScreen(saveStatePrefix_, slotNum, [doLoad](bool result) {
|
||||
@@ -783,16 +779,12 @@ void GamePauseScreen::ShowContextMenu(UI::View *menuButton, bool portrait) {
|
||||
screenManager()->push(new UI::MessagePopupScreen(di->T("Reset"), confirmMessage, di->T("Reset"), di->T("Cancel"), [this](bool result) {
|
||||
if (result) {
|
||||
System_PostUIMessage(UIMessage::REQUEST_GAME_RESET);
|
||||
std::lock_guard<std::mutex> lock(finishNextFrameMutex_);
|
||||
finishNextFrame_ = true;
|
||||
finishNextFrameResult_ = DR_BACK; // resume
|
||||
FinishNextFrame(DR_BACK); // resume
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
System_PostUIMessage(UIMessage::REQUEST_GAME_RESET);
|
||||
std::lock_guard<std::mutex> lock(finishNextFrameMutex_);
|
||||
finishNextFrameResult_ = DR_BACK; // resume
|
||||
finishNextFrame_ = true;
|
||||
FinishNextFrame(DR_BACK); // resume
|
||||
}
|
||||
});
|
||||
auto dev = GetI18NCategory(I18NCat::DEVELOPER);
|
||||
@@ -827,9 +819,7 @@ void GamePauseScreen::dialogFinished(const Screen *dialog, DialogResult dr) {
|
||||
std::string tag = dialog->tag();
|
||||
if (tag == "ScreenshotView") {
|
||||
if (dr == DR_OK) {
|
||||
std::lock_guard<std::mutex> lock(finishNextFrameMutex_);
|
||||
finishNextFrame_ = true;
|
||||
finishNextFrameResult_ = DR_BACK;
|
||||
FinishNextFrame(DR_BACK);
|
||||
} else if (dr != DR_CANCEL && dr != DR_BACK) {
|
||||
// Just go back to the pause menu, but refresh the savestate thumbnails in case something changed.
|
||||
SaveState::Rescan(saveStatePrefix_);
|
||||
@@ -904,9 +894,7 @@ void GamePauseScreen::OnExit(UI::EventParams &e) {
|
||||
if (g_Config.bPauseMenuExitsEmulator) {
|
||||
System_ExitApp();
|
||||
} else {
|
||||
std::lock_guard<std::mutex> lock(finishNextFrameMutex_);
|
||||
finishNextFrameResult_ = DR_OK; // exit game
|
||||
finishNextFrame_ = true;
|
||||
FinishNextFrame(DR_OK); // exit game
|
||||
}
|
||||
}
|
||||
}));
|
||||
@@ -962,3 +950,14 @@ void GamePauseScreen::OnDeleteConfig(UI::EventParams &e) {
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
// This is a bit of a hack that we should try to remove.
|
||||
void GamePauseScreen::FinishNextFrame(DialogResult finishNextFrameResult) {
|
||||
std::lock_guard<std::mutex> lock(finishNextFrameMutex_);
|
||||
if (!finishNextFrame_) {
|
||||
finishNextFrameResult_ = finishNextFrameResult;
|
||||
finishNextFrame_ = true;
|
||||
} else {
|
||||
WARN_LOG(Log::UI, "Duplicate call to FinishNextFrame - we were already finishing with result %d, now trying to finish with result %d", finishNextFrameResult_, finishNextFrameResult);
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,8 @@ private:
|
||||
|
||||
void AddExtraOptions(UI::ViewGroup *parent);
|
||||
|
||||
void FinishNextFrame(DialogResult finishNextFrameResult);
|
||||
|
||||
// hack
|
||||
std::mutex finishNextFrameMutex_;
|
||||
bool finishNextFrame_ = false;
|
||||
|
||||
Reference in new issue
Block a user