diff --git a/resource/Cxbx.aps b/resource/Cxbx.aps index b62101b45..f9f697a63 100644 Binary files a/resource/Cxbx.aps and b/resource/Cxbx.aps differ diff --git a/resource/Cxbx.rc b/resource/Cxbx.rc index cc0b630ce..ff71ea234 100644 Binary files a/resource/Cxbx.rc and b/resource/Cxbx.rc differ diff --git a/src/Common/Win32/XBAudio.cpp b/src/Common/Win32/XBAudio.cpp index 13cfd6b40..c76b56137 100644 --- a/src/Common/Win32/XBAudio.cpp +++ b/src/Common/Win32/XBAudio.cpp @@ -95,7 +95,7 @@ void XBAudio::Save(const char *szRegistryKey) // ****************************************************************** // * Save Configuration to Registry // ****************************************************************** - { + if (g_SaveOnExit) { DWORD dwDisposition, dwType, dwSize; HKEY hKey; diff --git a/src/Common/Win32/XBController.cpp b/src/Common/Win32/XBController.cpp index 66f30c447..d6423cc5f 100644 --- a/src/Common/Win32/XBController.cpp +++ b/src/Common/Win32/XBController.cpp @@ -160,7 +160,7 @@ void XBController::Save(const char *szRegistryKey) // ****************************************************************** // * Save Configuration to Registry // ****************************************************************** - { + if (g_SaveOnExit) { DWORD dwDisposition, dwType, dwSize; HKEY hKey; diff --git a/src/Common/Win32/XBVideo.cpp b/src/Common/Win32/XBVideo.cpp index 163cfdcfa..aa5dbcc85 100644 --- a/src/Common/Win32/XBVideo.cpp +++ b/src/Common/Win32/XBVideo.cpp @@ -97,7 +97,7 @@ void XBVideo::Save(const char *szRegistryKey) // ****************************************************************** // * Save Configuration to Registry // ****************************************************************** - { + if (g_SaveOnExit) { DWORD dwDisposition, dwType, dwSize; HKEY hKey; diff --git a/src/Cxbx.h b/src/Cxbx.h index 9e3cf1480..12b438fb3 100644 --- a/src/Cxbx.h +++ b/src/Cxbx.h @@ -122,6 +122,9 @@ extern bool g_bIsChihiro; /*! indicates emulation of a Debug xbe executable */ extern bool g_bIsDebug; +/*! indicates ability to save on exit (needed for settings reset) */ +extern bool g_SaveOnExit; + /*! maximum number of threads cxbx can handle */ #define MAXIMUM_XBOX_THREADS 256 diff --git a/src/Cxbx/ResCxbx.h b/src/Cxbx/ResCxbx.h index d18c0d8f9..f3dcc8cd1 100644 --- a/src/Cxbx/ResCxbx.h +++ b/src/Cxbx/ResCxbx.h @@ -1,5 +1,6 @@ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. +// Used by C:\msys64\home\thesy\Cxbx-Reloaded\resource\Cxbx.rc // #define IDI_CXBX 101 #define IDB_SPLASH 102 @@ -105,6 +106,7 @@ #define ID_SETTINGS_HACKS 40087 #define ID_HACKS_DISABLEPIXELSHADERS 40088 #define ID_LED 40089 +#define ID_SETTINGS_INITIALIZE 40090 #define IDC_STATIC -1 // Next default values for new objects @@ -112,7 +114,7 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 130 -#define _APS_NEXT_COMMAND_VALUE 40089 +#define _APS_NEXT_COMMAND_VALUE 40091 #define _APS_NEXT_CONTROL_VALUE 1058 #define _APS_NEXT_SYMED_VALUE 104 #endif diff --git a/src/Cxbx/WndMain.cpp b/src/Cxbx/WndMain.cpp index 5ff515ae7..fcae96033 100644 --- a/src/Cxbx/WndMain.cpp +++ b/src/Cxbx/WndMain.cpp @@ -60,6 +60,8 @@ static int gameLogoWidth, gameLogoHeight; +bool g_SaveOnExit = true; + void ClearHLECache() { std::string cacheDir = std::string(XTL::szFolder_CxbxReloadedData) + "\\HLECache\\"; @@ -88,6 +90,27 @@ void ClearHLECache() printf("Cleared HLE Cache\n"); } +void WndMain::InitializeSettings() { + HKEY hKey; + if (RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Cxbx-Reloaded", 0, KEY_SET_VALUE, &hKey) == ERROR_SUCCESS) { + for (int v = 0; v < m_dwRecentXbe; v++) { + char buffer[32]; + sprintf(buffer, "RecentXbe%d", v); + RegDeleteValue(hKey, buffer); + } + RegDeleteValue(hKey, "CxbxDebug"); RegDeleteValue(hKey, "CxbxDebugFilename"); + RegDeleteValue(hKey, "HackDisablePixelShaders"); RegDeleteValue(hKey, "KrnlDebug"); + RegDeleteValue(hKey, "KrnlDebugFilename"); RegDeleteValue(hKey, "LLEFLAGS"); + RegDeleteValue(hKey, "RecentXbe"); RegDeleteValue(hKey, "XInputEnabled"); + + RegDeleteTree(hKey, "XBVideo"); RegDeleteTree(hKey, "XBAudio"); RegDeleteTree(hKey, "XBController"); + + RegCloseKey(hKey); + + g_SaveOnExit = false; + } +} + #define TIMERID_FPS 0 #define TIMERID_LED 1 @@ -280,7 +303,7 @@ WndMain::WndMain(HINSTANCE x_hInstance) : WndMain::~WndMain() { // save configuration to registry - { + if (g_SaveOnExit) { DWORD dwDisposition, dwType, dwSize; HKEY hKey; @@ -1082,6 +1105,19 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP } break; + case ID_SETTINGS_INITIALIZE: + { + int ret = MessageBox(m_hwnd, "Warning: This will reset all Cxbx-Reloaded settings to their default values." + "\nAre you sure you want to proceed?", "Cxbx-Reloaded", MB_ICONEXCLAMATION | MB_YESNO); + + if (ret == IDYES) { + InitializeSettings(); + MessageBox(m_hwnd, "Cxbx-Reloaded has been initialized and will now close.", "Cxbx-Reloaded", MB_ICONINFORMATION | MB_OK); + SendMessage(hwnd, WM_CLOSE, 0, 0); + } + } + break; + case ID_EMULATION_DEBUGOUTPUTKERNEL_CONSOLE: { if (m_KrnlDebug == DM_NONE || m_KrnlDebug == DM_FILE) diff --git a/src/Cxbx/WndMain.h b/src/Cxbx/WndMain.h index 04ce46bef..fcaa0e41e 100644 --- a/src/Cxbx/WndMain.h +++ b/src/Cxbx/WndMain.h @@ -131,6 +131,11 @@ class WndMain : public Wnd // ****************************************************************** void CrashMonitor(); + // ****************************************************************** + // * clear registry values and keys + // ****************************************************************** + void InitializeSettings(); + // ****************************************************************** // * draw Xbox LED bitmap // ******************************************************************