From 049003977912233e462d92aadae2a223c8f80f0e Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 20 Dec 2009 17:19:32 +0000 Subject: [PATCH] win32: fix newlines in action replay cheats edit, and fix sticky pause condition when resetting or loading games --- desmume/src/utils/xstring.cpp | 5 ++++- desmume/src/windows/cheatsWin.cpp | 4 +++- desmume/src/windows/main.cpp | 7 +++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/desmume/src/utils/xstring.cpp b/desmume/src/utils/xstring.cpp index 9f7de6898..cdde5ee1f 100644 --- a/desmume/src/utils/xstring.cpp +++ b/desmume/src/utils/xstring.cpp @@ -589,7 +589,10 @@ std::string mass_replace(const std::string &source, const std::string &victim, c std::string answer = source; std::string::size_type j = 0; while ((j = answer.find(victim, j)) != std::string::npos ) - answer.replace(j, victim.length(), replacement); + { + answer.replace(j, victim.length(), replacement); + j+= replacement.length(); + } return answer; } diff --git a/desmume/src/windows/cheatsWin.cpp b/desmume/src/windows/cheatsWin.cpp index 70982d4b8..3b7af2bd5 100644 --- a/desmume/src/windows/cheatsWin.cpp +++ b/desmume/src/windows/cheatsWin.cpp @@ -22,6 +22,7 @@ #include "../cheatSystem.h" #include "resource.h" #include "../debug.h" +#include "../utils/xstring.h" static u8 searchType = 0; static u8 searchSize = 0; @@ -566,7 +567,8 @@ INT_PTR CALLBACK CheatsAdd_XX_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lp memset(buf, 0, sizeof(buf)); cheats->getXXcodeString(tempCheat, buf); - SetWindowText(GetDlgItem(dialog, IDC_EDIT2), buf); + std::string bufstr = mass_replace(buf,"\n","\r\n"); + SetWindowText(GetDlgItem(dialog, IDC_EDIT2), bufstr.c_str()); SetWindowText(GetDlgItem(dialog, IDC_EDIT3), tempCheat.description); EnableWindow(GetDlgItem(dialog, IDOK), (strlen(buf) > 16)?TRUE:FALSE); diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 43135d773..e8ebb4c4a 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -3031,7 +3031,7 @@ static BOOL OpenCore(const char* filename) if(LoadROM(filename, LogicalName)) { romloaded = TRUE; - NDS_UnPause(); + Unpause(); return TRUE; } else return FALSE; @@ -5597,7 +5597,10 @@ static LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam void ResetGame() { if(movieMode != MOVIEMODE_PLAY) - NDS_Reset(); + { + NDS_Reset(); + Unpause(); + } } //adelikat: This function changes a menu item's text