From 822552b138a1514f98037776addb90558105581f Mon Sep 17 00:00:00 2001 From: mtabachenko Date: Sun, 26 Apr 2009 12:58:21 +0000 Subject: [PATCH] winport: - fixed toggle on/off for Action Replay (double click in list) --- desmume/src/cheatSystem.cpp | 21 ++++++++++++--------- desmume/src/windows/cheatsWin.cpp | 17 ++++++++++++++++- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/desmume/src/cheatSystem.cpp b/desmume/src/cheatSystem.cpp index 917525157..2b2606b6f 100644 --- a/desmume/src/cheatSystem.cpp +++ b/desmume/src/cheatSystem.cpp @@ -468,11 +468,13 @@ BOOL cheatsUpdate_AR(char *code, char *description, BOOL enabled, u32 pos) { if (pos > cheatsNum) return FALSE; - if (!cheatsXXcodePreparser(&cheats[pos], code)) return FALSE; + if (code != NULL) + { + if (!cheatsXXcodePreparser(&cheats[pos], code)) return FALSE; + strcpy(cheats[pos].description, description); + cheats[pos].type = 1; + } - cheats[pos].type = 1; - - strcpy(cheats[pos].description, description); cheats[pos].enabled = enabled; return TRUE; } @@ -495,11 +497,12 @@ BOOL cheatsUpdate_CB(char *code, char *description, BOOL enabled, u32 pos) { if (pos > cheatsNum) return FALSE; - if (!cheatsXXcodePreparser(&cheats[pos], code)) return FALSE; - - cheats[pos].type = 2; - - strcpy(cheats[pos].description, description); + if (code != NULL) + { + if (!cheatsXXcodePreparser(&cheats[pos], code)) return FALSE; + cheats[pos].type = 2; + strcpy(cheats[pos].description, description); + } cheats[pos].enabled = enabled; return TRUE; } diff --git a/desmume/src/windows/cheatsWin.cpp b/desmume/src/windows/cheatsWin.cpp index b745e74cd..1d9a0466a 100644 --- a/desmume/src/windows/cheatsWin.cpp +++ b/desmume/src/windows/cheatsWin.cpp @@ -695,7 +695,22 @@ BOOL CALLBACK CheatsListBox_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lpar cheatEditPos = ListView_GetNextItem(cheatListView, -1, LVNI_SELECTED|LVNI_FOCUSED); cheatsGet(&tempCheat, cheatEditPos); tempCheat.enabled = !tempCheat.enabled; - cheatsUpdate(tempCheat.size, tempCheat.hi[0], tempCheat.lo[0], tempCheat.description, tempCheat.enabled, cheatEditPos); + switch (tempCheat.type) + { + case 0: // internal + cheatsUpdate(tempCheat.size, tempCheat.hi[0], tempCheat.lo[0], tempCheat.description, tempCheat.enabled, cheatEditPos); + break; + + case 1: // Action Replay + cheatsUpdate_AR(NULL, NULL, tempCheat.enabled, cheatEditPos); + break; + + case 2: // Codebreaker + cheatsUpdate_CB(NULL, NULL, tempCheat.enabled, cheatEditPos); + break; + } + + if (tempCheat.enabled) ListView_SetItemText(cheatListView, cheatEditPos, 0, "X") else