mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-30 17:53:42 +01:00
Implement exit confirmation when closing the window on Windows.
This commit is contained in:
1 parent
408d1b0916
commit
9bee4192ba
50 files changed
+224
-8
No files matched your search
+26
-3
@@ -37,6 +37,7 @@
|
||||
#include "Common/TimeUtil.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Common/Data/Text/I18n.h"
|
||||
#include "Common/Data/Text/Parsers.h"
|
||||
#include "Common/Input/InputState.h"
|
||||
#include "Common/Input/KeyCodes.h"
|
||||
#include "Common/Thread/ThreadUtil.h"
|
||||
@@ -85,6 +86,8 @@
|
||||
#include "GPU/GPUCommon.h"
|
||||
#include "UI/OnScreenDisplay.h"
|
||||
#include "UI/GameSettingsScreen.h"
|
||||
#include "Core/SaveState.h"
|
||||
#include "Core/Dialog/PSPSaveDialog.h"
|
||||
|
||||
#define MOUSEEVENTF_FROMTOUCH_NOPEN 0xFF515780 //http://msdn.microsoft.com/en-us/library/windows/desktop/ms703320(v=vs.85).aspx
|
||||
#define MOUSEEVENTF_MASK_PLUS_PENTOUCH 0xFFFFFF80
|
||||
@@ -1090,12 +1093,32 @@ namespace MainWindow
|
||||
break;
|
||||
|
||||
case WM_CLOSE:
|
||||
if (GetUIState() != UISTATE_MENU && g_Config.iAskForExitConfirmationAfterSeconds > 0) {
|
||||
const double timeSinceSaveState = SaveState::SecondsSinceLastSavestate();
|
||||
const double timeSinceGameSave = SecondsSinceLastGameSave();
|
||||
|
||||
const double minTime = std::min(timeSinceSaveState, timeSinceGameSave);
|
||||
if (minTime > g_Config.iAskForExitConfirmationAfterSeconds) {
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
auto mm = GetI18NCategory(I18NCat::MAINMENU);
|
||||
std::string dlgMsg = ApplySafeSubstitutions(di->T("You haven't saved your progress for %1."), NiceTimeFormat((int)minTime));
|
||||
dlgMsg += '\n';
|
||||
dlgMsg += '\n';
|
||||
dlgMsg += di->T("Are you sure you want to exit? All unsaved progress will be lost.");
|
||||
|
||||
if (IDNO == MessageBox(hWnd, ConvertUTF8ToWString(dlgMsg).c_str(), ConvertUTF8ToWString(mm->T("Exit")).c_str(), MB_YESNO | MB_ICONQUESTION)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DestroyWindow(hWnd);
|
||||
return 0;
|
||||
|
||||
case WM_DESTROY:
|
||||
InputDevice::StopPolling();
|
||||
MainThread_Stop();
|
||||
WindowsRawInput::Shutdown();
|
||||
return DefWindowProc(hWnd,message,wParam,lParam);
|
||||
|
||||
case WM_DESTROY:
|
||||
KillTimer(hWnd, TIMER_CURSORUPDATE);
|
||||
KillTimer(hWnd, TIMER_CURSORMOVEUPDATE);
|
||||
// Main window is gone, this tells the message loop to exit.
|
||||
|
||||
Reference in new issue
Block a user