From e0d2567e6c337e93dfc26febb01d0b974d706957 Mon Sep 17 00:00:00 2001 From: zeromus Date: Thu, 6 Aug 2015 21:46:35 +0000 Subject: [PATCH] fix #1492 RAM Watch editing problem (dont reorder entries when editing them) --- desmume/src/windows/ramwatch.cpp | 15 ++++++++++++--- desmume/src/windows/ramwatch.h | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/desmume/src/windows/ramwatch.cpp b/desmume/src/windows/ramwatch.cpp index 427fa35c8..de4900979 100644 --- a/desmume/src/windows/ramwatch.cpp +++ b/desmume/src/windows/ramwatch.cpp @@ -101,7 +101,7 @@ bool VerifyWatchNotAlreadyAdded(const AddressWatcher& watch) } -bool InsertWatch(const AddressWatcher& Watch, char *Comment) +bool InsertWatch(const AddressWatcher& Watch, char *Comment, int atIndex) { if(!VerifyWatchNotAlreadyAdded(Watch)) return false; @@ -109,7 +109,16 @@ bool InsertWatch(const AddressWatcher& Watch, char *Comment) if(WatchCount >= MAX_WATCH_COUNT) return false; - int i = WatchCount++; + int i = WatchCount; + if(atIndex == -1) {} + else + { + //move watches down + i = atIndex; + for(int x=WatchCount;x>atIndex;x--) + rswatches[x] = rswatches[x-1]; + } + WatchCount++; AddressWatcher& NewWatch = rswatches[i]; NewWatch = Watch; //if (NewWatch.comment) free(NewWatch.comment); @@ -760,7 +769,7 @@ LRESULT CALLBACK EditWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara { GetDlgItemText(hDlg,IDC_PROMPT_EDIT,Str_Tmp,80); if (index < WatchCount) RemoveWatch(index); - InsertWatch(Temp,Str_Tmp); + InsertWatch(Temp,Str_Tmp,index); if(RamWatchHWnd) { ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); diff --git a/desmume/src/windows/ramwatch.h b/desmume/src/windows/ramwatch.h index 9d0801de0..ecccddef4 100644 --- a/desmume/src/windows/ramwatch.h +++ b/desmume/src/windows/ramwatch.h @@ -48,7 +48,7 @@ extern int WatchCount; // number of valid items in rswatches extern char Watch_Dir[1024]; -bool InsertWatch(const AddressWatcher& Watch, char *Comment); +bool InsertWatch(const AddressWatcher& Watch, char *Comment, int atIndex=-1); bool InsertWatch(const AddressWatcher& Watch, HWND parent=NULL); // asks user for comment void Update_RAM_Watch(); bool Load_Watches(bool clear, const char* filename);