From 3ed0604e12adcb89737320367e91bb93c3d02643 Mon Sep 17 00:00:00 2001 From: mtabachenko Date: Sun, 14 Jun 2009 16:44:00 +0000 Subject: [PATCH] winport: - fixed search after load savestate and reset game; - fixed grayed 'OK' button in GBAslot dialog; --- desmume/src/NDSSystem.cpp | 6 +- desmume/src/NDSSystem.h | 2 +- desmume/src/cheatSystem.cpp | 4 -- desmume/src/windows/gbaslot_config.cpp | 83 +++++++++++++++----------- desmume/src/windows/main.cpp | 2 +- 5 files changed, 53 insertions(+), 44 deletions(-) diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index b69c2c95e..18ddd130d 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -543,6 +543,7 @@ void NDS_DeInit(void) { #ifdef EXPERIMENTAL_WIFI WIFI_SoftAP_Shutdown(&wifiMac); #endif + cheatsSearchClose(); } BOOL NDS_SetROM(u8 * rom, u32 mask) @@ -828,6 +829,7 @@ int NDS_LoadROM( const char *filename, #endif + cheatsSearchClose(); MMU_unsetRom(); NDS_SetROM(data, mask); NDS_Reset(); @@ -868,7 +870,7 @@ void NDS_FreeROM(void) } bool _HACK_DONT_STOPMOVIE = false; -void NDS_Reset(BOOL resetBySavestate) +void NDS_Reset() { unsigned int i; u32 src; @@ -1054,8 +1056,6 @@ void NDS_Reset(BOOL resetBySavestate) gfx3d_reset(); gpu3D->NDS_3D_Reset(); SPU_Reset(); - if (!resetBySavestate) - cheatsSearchClose(); #ifdef EXPERIMENTAL_WIFI WIFI_Init(&wifiMac); diff --git a/desmume/src/NDSSystem.h b/desmume/src/NDSSystem.h index e9e86759b..210dda743 100644 --- a/desmume/src/NDSSystem.h +++ b/desmume/src/NDSSystem.h @@ -290,7 +290,7 @@ int NDS_LoadROM(const char *filename, const char *cflash_disk_image_file); #endif void NDS_FreeROM(void); -void NDS_Reset(BOOL resetBySaveState = FALSE); +void NDS_Reset(); int NDS_ImportSave(const char *filename); bool NDS_ExportSave(const char *filename); diff --git a/desmume/src/cheatSystem.cpp b/desmume/src/cheatSystem.cpp index 2cb7478cf..b6982a961 100644 --- a/desmume/src/cheatSystem.cpp +++ b/desmume/src/cheatSystem.cpp @@ -792,10 +792,6 @@ void cheatsSearchInit(u8 type, u8 size, u8 sign) void cheatsSearchClose() { -#ifdef _MSC_VER - void CheatsSearchReset(); - CheatsSearchReset(); -#endif if (searchStatMem) delete [] searchStatMem; searchStatMem = NULL; diff --git a/desmume/src/windows/gbaslot_config.cpp b/desmume/src/windows/gbaslot_config.cpp index 0e421ff7b..e170cb276 100644 --- a/desmume/src/windows/gbaslot_config.cpp +++ b/desmume/src/windows/gbaslot_config.cpp @@ -39,6 +39,7 @@ char tmp_gbagame_filename[MAX_PATH]; u8 tmp_CFlashUsePath; u8 tmp_CFlashUseRomPath; HWND OKbutton = NULL; +bool _OKbutton = false; BOOL CALLBACK GbaSlotNone(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) { @@ -46,7 +47,7 @@ BOOL CALLBACK GbaSlotNone(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) { case WM_INITDIALOG: { - EnableWindow(OKbutton, TRUE); + _OKbutton = TRUE; return TRUE; } } @@ -68,14 +69,13 @@ BOOL CALLBACK GbaSlotCFlash(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) CheckDlgButton(dialog, IDC_PATHDESMUME, BST_CHECKED); EnableWindow(GetDlgItem(dialog, IDC_PATH), FALSE); EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), FALSE); - EnableWindow(OKbutton, TRUE); + _OKbutton = TRUE; } else { EnableWindow(GetDlgItem(dialog, IDC_PATH), TRUE); EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), TRUE); - if (strlen(tmp_cflash_path)) - EnableWindow(OKbutton, TRUE); + if (strlen(tmp_cflash_path)) _OKbutton = TRUE; } EnableWindow(GetDlgItem(dialog, IDC_PATHIMG), FALSE); EnableWindow(GetDlgItem(dialog, IDC_BBROWSE), FALSE); @@ -86,8 +86,7 @@ BOOL CALLBACK GbaSlotCFlash(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), FALSE); EnableWindow(GetDlgItem(dialog, IDC_PATHDESMUME), FALSE); EnableWindow(GetDlgItem(dialog, IDC_PATH), FALSE); - if (strlen(tmp_cflash_filename)) - EnableWindow(OKbutton, TRUE); + if (strlen(tmp_cflash_filename)) _OKbutton = TRUE; CheckDlgButton(dialog, IDC_RFILE, BST_CHECKED); } return TRUE; @@ -161,40 +160,46 @@ BOOL CALLBACK GbaSlotCFlash(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) case IDC_RFILE: { - tmp_CFlashUsePath = FALSE; - EnableWindow(GetDlgItem(dialog, IDC_PATHIMG), TRUE); - EnableWindow(GetDlgItem(dialog, IDC_BBROWSE), TRUE); + if (HIWORD(wparam) == BN_CLICKED) + { + tmp_CFlashUsePath = FALSE; + EnableWindow(GetDlgItem(dialog, IDC_PATHIMG), TRUE); + EnableWindow(GetDlgItem(dialog, IDC_BBROWSE), TRUE); - EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), FALSE); - EnableWindow(GetDlgItem(dialog, IDC_PATHDESMUME), FALSE); - EnableWindow(GetDlgItem(dialog, IDC_PATH), FALSE); + EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), FALSE); + EnableWindow(GetDlgItem(dialog, IDC_PATHDESMUME), FALSE); + EnableWindow(GetDlgItem(dialog, IDC_PATH), FALSE); - if (!strlen(tmp_cflash_filename)) - EnableWindow(OKbutton, FALSE); + if (!strlen(tmp_cflash_filename)) + EnableWindow(OKbutton, FALSE); + } break; } case IDC_RFOLDER: { - tmp_CFlashUsePath = TRUE; - EnableWindow(GetDlgItem(dialog, IDC_PATHIMG), FALSE); - EnableWindow(GetDlgItem(dialog, IDC_BBROWSE), FALSE); - - if (IsDlgButtonChecked(dialog, IDC_PATHDESMUME)) + if (HIWORD(wparam) == BN_CLICKED) { - tmp_CFlashUseRomPath = TRUE; - EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), FALSE); - EnableWindow(GetDlgItem(dialog, IDC_PATH), FALSE); - EnableWindow(OKbutton, TRUE); - } - else - { - tmp_CFlashUseRomPath = FALSE; - EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), TRUE); - EnableWindow(GetDlgItem(dialog, IDC_PATH), TRUE); - } + tmp_CFlashUsePath = TRUE; + EnableWindow(GetDlgItem(dialog, IDC_PATHIMG), FALSE); + EnableWindow(GetDlgItem(dialog, IDC_BBROWSE), FALSE); - EnableWindow(GetDlgItem(dialog, IDC_PATHDESMUME), TRUE); + if (IsDlgButtonChecked(dialog, IDC_PATHDESMUME)) + { + tmp_CFlashUseRomPath = TRUE; + EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), FALSE); + EnableWindow(GetDlgItem(dialog, IDC_PATH), FALSE); + EnableWindow(OKbutton, TRUE); + } + else + { + tmp_CFlashUseRomPath = FALSE; + EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), TRUE); + EnableWindow(GetDlgItem(dialog, IDC_PATH), TRUE); + } + + EnableWindow(GetDlgItem(dialog, IDC_PATHDESMUME), TRUE); + } break; } @@ -232,7 +237,7 @@ BOOL CALLBACK GbaSlotRumblePak(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam { case WM_INITDIALOG: { - EnableWindow(OKbutton, TRUE); + _OKbutton = TRUE; return TRUE; } } @@ -246,8 +251,7 @@ BOOL CALLBACK GbaSlotGBAgame(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) case WM_INITDIALOG: { SetWindowText(GetDlgItem(dialog, IDC_PATHGAME), tmp_gbagame_filename); - if (!strlen(tmp_gbagame_filename)) - EnableWindow(OKbutton, FALSE); + if (strlen(tmp_gbagame_filename) > 0) _OKbutton = true; return TRUE; } case WM_COMMAND: @@ -326,10 +330,13 @@ BOOL CALLBACK GbaSlotBox_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) addonList[temp_type].info((char *)tmp_info); SetWindowText(GetDlgItem(dialog, IDC_ADDONS_INFO), (char *)tmp_info); + _OKbutton = false; wndConfig=CreateDialog(hAppInst, MAKEINTRESOURCE(GBAslot_IDDs[temp_type]), dialog, (DLGPROC)GBAslot_Procs[temp_type]); - if (temp_type == 0) + if ( (temp_type == 0) || (_OKbutton) ) EnableWindow(OKbutton, TRUE); + else + EnableWindow(OKbutton, FALSE); return TRUE; } @@ -365,9 +372,14 @@ BOOL CALLBACK GbaSlotBox_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) if (temp_type != last_type) { if (wndConfig) DestroyWindow(wndConfig); + _OKbutton = false; wndConfig=CreateDialog(hAppInst, MAKEINTRESOURCE(GBAslot_IDDs[temp_type]), dialog, (DLGPROC)GBAslot_Procs[temp_type]); + if ( (temp_type == 0) || (_OKbutton) ) + EnableWindow(OKbutton, TRUE); + else + EnableWindow(OKbutton, FALSE); u8 tmp_info[512]; addonList[temp_type].info((char *)tmp_info); SetWindowText(GetDlgItem(dialog, IDC_ADDONS_INFO), (char *)tmp_info); @@ -391,6 +403,7 @@ void GBAslotDialog(HWND hwnd) strcpy(tmp_gbagame_filename, GBAgameName); tmp_CFlashUseRomPath = CFlashUseRomPath; tmp_CFlashUsePath = CFlashUsePath; + _OKbutton = false; u32 res=DialogBox(hAppInst, MAKEINTRESOURCE(IDD_GBASLOT), hwnd, (DLGPROC) GbaSlotBox_Proc); if (res) { diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 3655e630b..58193e6c3 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -2419,8 +2419,8 @@ LRESULT OpenFile() { if (romloaded) { + CheatsSearchReset(); NDS_UnPause(); //Restart emulation if no new rom chosen - } return 0; }