adapted ram search/watch fixes/improvements from desmume
This commit is contained in:
parent
795de75419
commit
422dd2783d
File diff suppressed because it is too large
Load Diff
|
@ -57,6 +57,8 @@ void init_list_box(HWND Box, const char* Strs[], int numColumns, int *columnWidt
|
|||
bool QuickSaveWatches();
|
||||
bool ResetWatches();
|
||||
|
||||
void RefreshWatchListSelectedCountControlStatus(HWND hDlg);
|
||||
|
||||
unsigned int GetCurrentValue(AddressWatcher& watch)
|
||||
{
|
||||
//TODO: A similar if for 4-byte just to be through, but there shouldn't be any reason to have 4-byte on the NES!
|
||||
|
@ -449,8 +451,10 @@ void OpenRWRecentFile(int memwRFileNumber)
|
|||
}
|
||||
|
||||
fclose(WatchFile);
|
||||
if (RamWatchHWnd)
|
||||
if (RamWatchHWnd) {
|
||||
ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount);
|
||||
RefreshWatchListSelectedCountControlStatus(RamWatchHWnd);
|
||||
}
|
||||
RWfileChanged=false;
|
||||
return;
|
||||
}
|
||||
|
@ -646,8 +650,10 @@ bool ResetWatches()
|
|||
rswatches[WatchCount].comment = NULL;
|
||||
}
|
||||
WatchCount++;
|
||||
if (RamWatchHWnd)
|
||||
if (RamWatchHWnd) {
|
||||
ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount);
|
||||
RefreshWatchListSelectedCountControlStatus(RamWatchHWnd);
|
||||
}
|
||||
RWfileChanged = false;
|
||||
currentWatch[0] = NULL;
|
||||
return true;
|
||||
|
@ -827,6 +833,38 @@ LRESULT CALLBACK EditWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
|||
|
||||
|
||||
|
||||
void RamWatchEnableCommand(HWND hDlg, HMENU hMenu, UINT uIDEnableItem, bool enable)
|
||||
{
|
||||
EnableWindow(GetDlgItem(hDlg, uIDEnableItem), (enable?TRUE:FALSE));
|
||||
if (hMenu != NULL) {
|
||||
if (uIDEnableItem == ID_WATCHES_UPDOWN) {
|
||||
EnableMenuItem(hMenu, IDC_C_WATCH_UP, MF_BYCOMMAND | (enable?MF_ENABLED:MF_GRAYED));
|
||||
EnableMenuItem(hMenu, IDC_C_WATCH_DOWN, MF_BYCOMMAND | (enable?MF_ENABLED:MF_GRAYED));
|
||||
}
|
||||
else
|
||||
EnableMenuItem(hMenu, uIDEnableItem, MF_BYCOMMAND | (enable?MF_ENABLED:MF_GRAYED));
|
||||
}
|
||||
}
|
||||
|
||||
void RefreshWatchListSelectedCountControlStatus(HWND hDlg)
|
||||
{
|
||||
static int prevSelCount=-1;
|
||||
int selCount = ListView_GetSelectedCount(GetDlgItem(hDlg,IDC_WATCHLIST));
|
||||
if(selCount != prevSelCount)
|
||||
{
|
||||
if(selCount < 2 || prevSelCount < 2)
|
||||
{
|
||||
RamWatchEnableCommand(hDlg, ramwatchmenu, IDC_C_WATCH_EDIT, selCount == 1);
|
||||
RamWatchEnableCommand(hDlg, ramwatchmenu, IDC_C_WATCH_REMOVE, selCount >= 1);
|
||||
RamWatchEnableCommand(hDlg, ramwatchmenu, IDC_C_WATCH, selCount == 1);
|
||||
RamWatchEnableCommand(hDlg, ramwatchmenu, IDC_C_WATCH_DUPLICATE, selCount == 1);
|
||||
RamWatchEnableCommand(hDlg, ramwatchmenu, IDC_C_ADDCHEAT, selCount == 1);
|
||||
RamWatchEnableCommand(hDlg, ramwatchmenu, ID_WATCHES_UPDOWN, selCount == 1);
|
||||
}
|
||||
prevSelCount = selCount;
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
RECT r;
|
||||
|
@ -914,6 +952,7 @@ LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
|
|||
|
||||
DragAcceptFiles(hDlg, TRUE);
|
||||
|
||||
RefreshWatchListSelectedCountControlStatus(hDlg);
|
||||
return false;
|
||||
} break;
|
||||
|
||||
|
@ -950,10 +989,11 @@ LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
|
|||
case LVN_ITEMCHANGED: // selection changed event
|
||||
{
|
||||
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)lP;
|
||||
if(pNMListView->uNewState & LVIS_FOCUSED)
|
||||
if(pNMListView->uNewState & LVIS_FOCUSED ||
|
||||
(pNMListView->uNewState ^ pNMListView->uOldState) & LVIS_SELECTED)
|
||||
{
|
||||
// disable buttons that we don't have the right number of selected items for
|
||||
RefreshWatchListSelectedItemControlStatus(hDlg);
|
||||
RefreshWatchListSelectedCountControlStatus(hDlg);
|
||||
}
|
||||
} break;
|
||||
|
||||
|
@ -1028,15 +1068,19 @@ LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
|
|||
ResetWatches();
|
||||
return true;
|
||||
case IDC_C_WATCH_REMOVE:
|
||||
watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST));
|
||||
if(watchIndex != -1)
|
||||
{
|
||||
HWND watchListControl = GetDlgItem(hDlg, IDC_WATCHLIST);
|
||||
watchIndex = ListView_GetNextItem(watchListControl, -1, LVNI_ALL | LVNI_SELECTED);
|
||||
while (watchIndex >= 0)
|
||||
{
|
||||
RemoveWatch(watchIndex);
|
||||
ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount);
|
||||
RWfileChanged=true;
|
||||
SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST));
|
||||
ListView_DeleteItem(watchListControl, watchIndex);
|
||||
watchIndex = ListView_GetNextItem(watchListControl, -1, LVNI_ALL | LVNI_SELECTED);
|
||||
}
|
||||
RWfileChanged=true;
|
||||
SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST));
|
||||
return true;
|
||||
}
|
||||
case IDC_C_WATCH_EDIT:
|
||||
watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST));
|
||||
if(watchIndex != -1)
|
||||
|
|
|
@ -1638,7 +1638,7 @@ CAPTION " RAM Watch"
|
|||
MENU RAMWATCH_MENU
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
CONTROL "",IDC_WATCHLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP,9,9,210,279,WS_EX_CLIENTEDGE
|
||||
CONTROL "",IDC_WATCHLIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP,9,9,210,279,WS_EX_CLIENTEDGE
|
||||
PUSHBUTTON "Edit",IDC_C_WATCH_EDIT,226,66,34,14
|
||||
PUSHBUTTON "Remove",IDC_C_WATCH_REMOVE,226,83,34,14
|
||||
PUSHBUTTON "New",IDC_C_WATCH,226,100,34,14
|
||||
|
|
Loading…
Reference in New Issue