]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Are you sure quit option.
authorToni Wilen <twilen@winuae.net>
Sat, 14 Apr 2018 07:30:13 +0000 (10:30 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 14 Apr 2018 07:30:13 +0000 (10:30 +0300)
include/options.h
od-win32/dinput.cpp
od-win32/resources/resource.h
od-win32/resources/winuae.rc
od-win32/win32.cpp
od-win32/win32.h
od-win32/win32gfx.cpp
od-win32/win32gui.cpp

index bc839fbf1c1ee7619adbcd7c4a6fd6801bf0d82f..4534a3bfc0ef70a0f82749e29a1aaf4216fa1d80 100644 (file)
@@ -800,6 +800,7 @@ struct uae_prefs {
        TCHAR win32_guiactivepage[32];
        bool win32_filesystem_mangle_reserved_names;
        bool win32_shutdown_notification;
+       bool win32_warn_exit;
        bool right_control_is_right_win_key;
 #ifdef WITH_SLIRP
        struct slirp_redir slirp_redirs[MAX_SLIRP_REDIRS];
index 8d5aa63f35be5b6bbca67403be6c25bf3d54bee6..7307396d6f1b3e10d7fdb5f7cdf315a4ff3b8576 100644 (file)
@@ -566,6 +566,8 @@ static int keyhack (int scancode, int pressed, int num)
                        if (rp_close ())
                                return -1;
 #endif
+                       if (!quit_ok())
+                               return -1;
                        uae_quit ();
                        return -1;
                }
index 3a81d821e6cfe2bbebe165d723da31d217427ca9..88d63cf72f19d6fafa1443e4555a2f4dd3b37a97 100644 (file)
 #define IDC_HARDDRIVE_ID                415
 #define IDS_MISCLISTITEMS4              416
 #define IDS_SHUTDOWN_NOTIFICATION       417
+#define IDS_QUIT_WARNING                418
 #define IDS_QS_MODELS                   1000
 #define IDS_QS_MODEL_A500               1001
 #define IDS_QS_MODEL_A500P              1002
index 2876e4ceb586d5a17e6a1e3fb0f1a15cdc40fd17..067ae351ba4b2881a7ec53b1ac9cedab7d4e878e 100644 (file)
@@ -2141,8 +2141,9 @@ END
 
 STRINGTABLE
 BEGIN
-    IDS_MISCLISTITEMS4      "Windows shutdown/logoff notification\n"
+    IDS_MISCLISTITEMS4      "Windows shutdown/logoff notification\nWarn when attempting to close window\n"
     IDS_SHUTDOWN_NOTIFICATION "Emulation session active"
+    IDS_QUIT_WARNING        "Are you sure you want to quit WinUAE?"
 END
 
 STRINGTABLE
index 0df2cb1a1c5a98acf67d65164c0158f601f4a763..d37c0861ba5dcc1e43c71d5b6c6de4ac537c5f06 100644 (file)
@@ -441,6 +441,20 @@ int sleep_millis_amiga(int ms)
        return ret;
 }
 
+bool quit_ok()
+{
+       if (isfullscreen() > 0)
+               return true;
+       if (!currprefs.win32_warn_exit)
+               return true;
+       if (quit_program == -UAE_QUIT)
+               return true;
+       TCHAR temp[MAX_DPATH];
+       WIN32GUI_LoadUIString(IDS_QUIT_WARNING, temp, MAX_DPATH);
+       int ret = gui_message_multibutton(1, temp);
+       return ret == 1;
+}
+
 static void setcursor(struct AmigaMonitor *mon, int oldx, int oldy)
 {
        int dx = (mon->amigawinclip_rect.left - mon->amigawin_rect.left) + (mon->amigawinclip_rect.right - mon->amigawinclip_rect.left) / 2;
@@ -1944,7 +1958,8 @@ static LRESULT CALLBACK AmigaWindowProc(HWND hWnd, UINT message, WPARAM wParam,
                return 0;
 
        case WM_CLOSE:
-               uae_quit();
+               if (quit_ok())
+                       uae_quit();
                return 0;
 
        case WM_WINDOWPOSCHANGED:
@@ -2172,12 +2187,16 @@ static LRESULT CALLBACK AmigaWindowProc(HWND hWnd, UINT message, WPARAM wParam,
                {
                        LRESULT lr;
 
-#ifdef RETROPLATFORM
                        if ((wParam & 0xfff0) == SC_CLOSE) {
+#ifdef RETROPLATFORM
                                if (rp_close())
                                        return 0;
-                       }
 #endif
+
+                               if (!quit_ok())
+                                       return 0;
+                               uae_quit();
+                       }
                        lr = DefWindowProc(hWnd, message, wParam, lParam);
                        switch (wParam & 0xfff0)
                        {
@@ -2187,7 +2206,6 @@ static LRESULT CALLBACK AmigaWindowProc(HWND hWnd, UINT message, WPARAM wParam,
                        case SC_RESTORE:
                                break;
                        case SC_CLOSE:
-                               uae_quit();
                                break;
                        }
                        return lr;
@@ -4074,6 +4092,7 @@ void target_save_options (struct zfile *f, struct uae_prefs *p)
        cfgfile_target_dwrite_bool(f, _T("filesystem_mangle_reserved_names"), p->win32_filesystem_mangle_reserved_names);
        cfgfile_target_dwrite_bool(f, _T("right_control_is_right_win"), p->right_control_is_right_win_key);
        cfgfile_target_dwrite_bool(f, _T("windows_shutdown_notification"), p->win32_shutdown_notification);
+       cfgfile_target_dwrite_bool(f, _T("warn_exit"), p->win32_warn_exit);
 
        cfgfile_target_dwrite(f, _T("extraframewait"), _T("%d"), extraframewait);
        cfgfile_target_dwrite(f, _T("extraframewait_us"), _T("%d"), extraframewait2);
@@ -4196,6 +4215,7 @@ int target_parse_option (struct uae_prefs *p, const TCHAR *option, const TCHAR *
                || cfgfile_yesno(option, value, _T("filesystem_mangle_reserved_names"), &p->win32_filesystem_mangle_reserved_names)
                || cfgfile_yesno(option, value, _T("right_control_is_right_win"), &p->right_control_is_right_win_key)
                || cfgfile_yesno(option, value, _T("windows_shutdown_notification"), &p->win32_shutdown_notification)
+               || cfgfile_yesno(option, value, _T("warn_exit"), &p->win32_warn_exit)
                || cfgfile_intval(option, value, _T("extraframewait"), &extraframewait, 1)
                || cfgfile_intval(option, value, _T("extraframewait_us"), &extraframewait2, 1)
                || cfgfile_intval(option, value, _T("framelatency"), &forcedframelatency, 1)
index e305bf389a30521bcdde9861c376f00196c1cd31..2294828429084279f482036a7d5f406a9bff78e9 100644 (file)
@@ -66,6 +66,7 @@ extern void remove_brkhandler (void);
 extern void disablecapture (void);
 extern int isfocus(void);
 extern void gui_restart (void);
+extern bool quit_ok(void);
 int timebegin (void);
 int timeend (void);
 
index d07c73160045d197eee19cba4e82c4978a2d609d..a0c6922e8e8849e69a2fe2a067bed8687c0349ff 100644 (file)
@@ -2524,6 +2524,7 @@ int check_prefs_changed_gfx (void)
                currprefs.win32_iconified_pause != changed_prefs.win32_iconified_pause ||
                currprefs.win32_iconified_input != changed_prefs.win32_iconified_input ||
                currprefs.win32_ctrl_F11_is_quit != changed_prefs.win32_ctrl_F11_is_quit ||
+               currprefs.win32_warn_exit != changed_prefs.win32_warn_exit ||
                currprefs.right_control_is_right_win_key != changed_prefs.right_control_is_right_win_key)
        {
                currprefs.win32_minimize_inactive = changed_prefs.win32_minimize_inactive;
@@ -2544,6 +2545,7 @@ int check_prefs_changed_gfx (void)
                currprefs.win32_iconified_pause = changed_prefs.win32_iconified_pause;
                currprefs.win32_iconified_input = changed_prefs.win32_iconified_input;
                currprefs.win32_ctrl_F11_is_quit = changed_prefs.win32_ctrl_F11_is_quit;
+               currprefs.win32_warn_exit = changed_prefs.win32_warn_exit;
                currprefs.right_control_is_right_win_key = changed_prefs.right_control_is_right_win_key;
                inputdevice_unacquire ();
                currprefs.keyboard_leds_in_use = changed_prefs.keyboard_leds_in_use = (currprefs.keyboard_leds[0] | currprefs.keyboard_leds[1] | currprefs.keyboard_leds[2]) != 0;
index 4de8c1817b79b1db0001abeed5c76db195f6a790..76a2cdffa4f62d4a1556ee0565f545c49501e691 100644 (file)
@@ -4396,6 +4396,7 @@ static const struct miscentry misclist[] = {
        { 0, 0, _T("Hide all UAE autoconfig boards"), &workprefs.uae_hide_autoconfig },
        { 0, 1, _T("Right Control = Right Windows key"), &workprefs.right_control_is_right_win_key },
        { 0, 0, _T("Windows shutdown/logoff notification"), &workprefs.win32_shutdown_notification },
+       { 0, 1, _T("Warn when attempting to close window"), &workprefs.win32_warn_exit },
        { 0, NULL }
 };