Merge pull request #907 from Voxel9/Settings-Initialize

Implement 'Reset to Defaults' menu feature.
This commit is contained in:
PatrickvL 2018-02-07 08:10:27 +01:00 committed by GitHub
commit 735a4bcfc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 51 additions and 5 deletions

Binary file not shown.

Binary file not shown.

View File

@ -95,7 +95,7 @@ void XBAudio::Save(const char *szRegistryKey)
// ******************************************************************
// * Save Configuration to Registry
// ******************************************************************
{
if (g_SaveOnExit) {
DWORD dwDisposition, dwType, dwSize;
HKEY hKey;

View File

@ -160,7 +160,7 @@ void XBController::Save(const char *szRegistryKey)
// ******************************************************************
// * Save Configuration to Registry
// ******************************************************************
{
if (g_SaveOnExit) {
DWORD dwDisposition, dwType, dwSize;
HKEY hKey;

View File

@ -97,7 +97,7 @@ void XBVideo::Save(const char *szRegistryKey)
// ******************************************************************
// * Save Configuration to Registry
// ******************************************************************
{
if (g_SaveOnExit) {
DWORD dwDisposition, dwType, dwSize;
HKEY hKey;

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -131,6 +131,11 @@ class WndMain : public Wnd
// ******************************************************************
void CrashMonitor();
// ******************************************************************
// * clear registry values and keys
// ******************************************************************
void InitializeSettings();
// ******************************************************************
// * draw Xbox LED bitmap
// ******************************************************************