fix #1492 RAM Watch editing problem (dont reorder entries when editing them)

This commit is contained in:
zeromus 2015-08-06 21:46:35 +00:00
parent f06c81d671
commit e0d2567e6c
2 changed files with 13 additions and 4 deletions

View File

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

View File

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