adapted ram search/watch fixes/improvements from desmume
This commit is contained in:
parent
795de75419
commit
422dd2783d
|
@ -1086,8 +1086,8 @@ void RefreshRamListSelectedCountControlStatus(HWND hDlg)
|
||||||
{
|
{
|
||||||
if(selCount < 2 || prevSelCount < 2)
|
if(selCount < 2 || prevSelCount < 2)
|
||||||
{
|
{
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_C_WATCH), (selCount == 1 && WatchCount < MAX_WATCH_COUNT) ? TRUE : FALSE);
|
EnableWindow(GetDlgItem(hDlg, IDC_C_WATCH), (selCount >= 1 && WatchCount < MAX_WATCH_COUNT) ? TRUE : FALSE);
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_C_ADDCHEAT), (selCount == 1) ? TRUE : FALSE);
|
EnableWindow(GetDlgItem(hDlg, IDC_C_ADDCHEAT), (selCount >= 1) ? TRUE : FALSE);
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_C_ELIMINATE), (selCount >= 1) ? TRUE : FALSE);
|
EnableWindow(GetDlgItem(hDlg, IDC_C_ELIMINATE), (selCount >= 1) ? TRUE : FALSE);
|
||||||
}
|
}
|
||||||
prevSelCount = selCount;
|
prevSelCount = selCount;
|
||||||
|
@ -1134,7 +1134,7 @@ void signal_new_size ()
|
||||||
int addr = CALL_WITH_T_SIZE_TYPES_1(GetHardwareAddressFromItemIndex, rs_last_type_size,rs_t=='s',rs_last_no_misalign, watchIndex);
|
int addr = CALL_WITH_T_SIZE_TYPES_1(GetHardwareAddressFromItemIndex, rs_last_type_size,rs_t=='s',rs_last_no_misalign, watchIndex);
|
||||||
if(!selHardwareAddrs.empty() && addr == selHardwareAddrs.back().End())
|
if(!selHardwareAddrs.empty() && addr == selHardwareAddrs.back().End())
|
||||||
selHardwareAddrs.back().size += size;
|
selHardwareAddrs.back().size += size;
|
||||||
else
|
else if (!(noMisalign && oldSize < newSize && addr % newSize != 0))
|
||||||
selHardwareAddrs.push_back(AddrRange(addr,size));
|
selHardwareAddrs.push_back(AddrRange(addr,size));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1164,15 +1164,11 @@ void signal_new_size ()
|
||||||
if(selRangeTop == -1)
|
if(selRangeTop == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// select the entire range at once without deselecting the other ranges
|
// select the entire range
|
||||||
// looks hacky but it works, and the only documentation I found on how to do this was blatantly false and equally hacky anyway
|
for (int j = selRangeTop; j <= selRangeBottom; j++)
|
||||||
POINT pos;
|
{
|
||||||
ListView_EnsureVisible(lv, selRangeTop, 0);
|
ListView_SetItemState(lv, j, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
|
||||||
ListView_GetItemPosition(lv, selRangeTop, &pos);
|
}
|
||||||
SendMessage(lv, WM_LBUTTONDOWN, MK_LBUTTON|MK_CONTROL, MAKELONG(pos.x,pos.y));
|
|
||||||
ListView_EnsureVisible(lv, selRangeBottom, 0);
|
|
||||||
ListView_GetItemPosition(lv, selRangeBottom, &pos);
|
|
||||||
SendMessage(lv, WM_LBUTTONDOWN, MK_LBUTTON|MK_CONTROL|MK_SHIFT, MAKELONG(pos.x,pos.y));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore previous scroll position
|
// restore previous scroll position
|
||||||
|
@ -1192,6 +1188,7 @@ void signal_new_size ()
|
||||||
ListView_Update(lv, -1);
|
ListView_Update(lv, -1);
|
||||||
}
|
}
|
||||||
InvalidateRect(lv, NULL, TRUE);
|
InvalidateRect(lv, NULL, TRUE);
|
||||||
|
//SetFocus(lv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1498,7 +1495,8 @@ LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
||||||
case LVN_ITEMCHANGED: // selection changed event
|
case LVN_ITEMCHANGED: // selection changed event
|
||||||
{
|
{
|
||||||
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)lP;
|
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
|
// disable buttons that we don't have the right number of selected items for
|
||||||
RefreshRamListSelectedCountControlStatus(hDlg);
|
RefreshRamListSelectedCountControlStatus(hDlg);
|
||||||
|
@ -1701,8 +1699,9 @@ LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
||||||
} {rv = true; break;}
|
} {rv = true; break;}
|
||||||
case IDC_C_ADDCHEAT:
|
case IDC_C_ADDCHEAT:
|
||||||
{
|
{
|
||||||
int watchItemIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_RAMLIST));
|
HWND ramListControl = GetDlgItem(hDlg,IDC_RAMLIST);
|
||||||
if(watchItemIndex >= 0)
|
int watchItemIndex = ListView_GetNextItem(ramListControl, -1, LVNI_SELECTED);
|
||||||
|
while (watchItemIndex >= 0)
|
||||||
{
|
{
|
||||||
unsigned long address = CALL_WITH_T_SIZE_TYPES_1(GetHardwareAddressFromItemIndex, rs_type_size,rs_t=='s',noMisalign, watchItemIndex);
|
unsigned long address = CALL_WITH_T_SIZE_TYPES_1(GetHardwareAddressFromItemIndex, rs_type_size,rs_t=='s',noMisalign, watchItemIndex);
|
||||||
unsigned long curvalue = CALL_WITH_T_SIZE_TYPES_1(GetCurValueFromItemIndex, rs_type_size,rs_t=='s',noMisalign, watchItemIndex);
|
unsigned long curvalue = CALL_WITH_T_SIZE_TYPES_1(GetCurValueFromItemIndex, rs_type_size,rs_t=='s',noMisalign, watchItemIndex);
|
||||||
|
@ -1743,6 +1742,8 @@ LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
||||||
|
|
||||||
UpdateCheatsAdded();
|
UpdateCheatsAdded();
|
||||||
|
|
||||||
|
watchItemIndex = ListView_GetNextItem(ramListControl, watchItemIndex, LVNI_SELECTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
} {rv = true; break;}
|
} {rv = true; break;}
|
||||||
case IDC_C_RESET:
|
case IDC_C_RESET:
|
||||||
|
@ -1831,8 +1832,12 @@ invalid_field:
|
||||||
}
|
}
|
||||||
case IDC_C_WATCH:
|
case IDC_C_WATCH:
|
||||||
{
|
{
|
||||||
int watchItemIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_RAMLIST));
|
HWND ramListControl = GetDlgItem(hDlg,IDC_RAMLIST);
|
||||||
if(watchItemIndex >= 0)
|
int selCount = ListView_GetSelectedCount(ramListControl);
|
||||||
|
|
||||||
|
bool inserted = false;
|
||||||
|
int watchItemIndex = ListView_GetNextItem(ramListControl, -1, LVNI_SELECTED);
|
||||||
|
while (watchItemIndex >= 0)
|
||||||
{
|
{
|
||||||
AddressWatcher tempWatch;
|
AddressWatcher tempWatch;
|
||||||
tempWatch.Address = CALL_WITH_T_SIZE_TYPES_1(GetHardwareAddressFromItemIndex, rs_type_size,rs_t=='s',noMisalign, watchItemIndex);
|
tempWatch.Address = CALL_WITH_T_SIZE_TYPES_1(GetHardwareAddressFromItemIndex, rs_type_size,rs_t=='s',noMisalign, watchItemIndex);
|
||||||
|
@ -1841,14 +1846,17 @@ invalid_field:
|
||||||
tempWatch.WrongEndian = 0; //Replace when I get little endian working
|
tempWatch.WrongEndian = 0; //Replace when I get little endian working
|
||||||
tempWatch.comment = NULL;
|
tempWatch.comment = NULL;
|
||||||
|
|
||||||
bool inserted = InsertWatch(tempWatch, hDlg);
|
if (selCount == 1)
|
||||||
//ListView_Update(GetDlgItem(hDlg,IDC_RAMLIST), -1);
|
inserted |= InsertWatch(tempWatch, hDlg);
|
||||||
|
else
|
||||||
|
inserted |= InsertWatch(tempWatch, "");
|
||||||
|
|
||||||
|
watchItemIndex = ListView_GetNextItem(ramListControl, watchItemIndex, LVNI_SELECTED);
|
||||||
|
}
|
||||||
// bring up the ram watch window if it's not already showing so the user knows where the watch went
|
// bring up the ram watch window if it's not already showing so the user knows where the watch went
|
||||||
if(inserted && !RamWatchHWnd)
|
if(inserted && !RamWatchHWnd)
|
||||||
SendMessage(hWnd, WM_COMMAND, ID_RAM_WATCH, 0);
|
SendMessage(hWnd, WM_COMMAND, ID_RAM_WATCH, 0);
|
||||||
SetForegroundWindow(RamSearchHWnd);
|
SetForegroundWindow(RamSearchHWnd);
|
||||||
}
|
|
||||||
{rv = true; break;}
|
{rv = true; break;}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,8 @@ void init_list_box(HWND Box, const char* Strs[], int numColumns, int *columnWidt
|
||||||
bool QuickSaveWatches();
|
bool QuickSaveWatches();
|
||||||
bool ResetWatches();
|
bool ResetWatches();
|
||||||
|
|
||||||
|
void RefreshWatchListSelectedCountControlStatus(HWND hDlg);
|
||||||
|
|
||||||
unsigned int GetCurrentValue(AddressWatcher& watch)
|
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!
|
//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);
|
fclose(WatchFile);
|
||||||
if (RamWatchHWnd)
|
if (RamWatchHWnd) {
|
||||||
ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount);
|
ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount);
|
||||||
|
RefreshWatchListSelectedCountControlStatus(RamWatchHWnd);
|
||||||
|
}
|
||||||
RWfileChanged=false;
|
RWfileChanged=false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -646,8 +650,10 @@ bool ResetWatches()
|
||||||
rswatches[WatchCount].comment = NULL;
|
rswatches[WatchCount].comment = NULL;
|
||||||
}
|
}
|
||||||
WatchCount++;
|
WatchCount++;
|
||||||
if (RamWatchHWnd)
|
if (RamWatchHWnd) {
|
||||||
ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount);
|
ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount);
|
||||||
|
RefreshWatchListSelectedCountControlStatus(RamWatchHWnd);
|
||||||
|
}
|
||||||
RWfileChanged = false;
|
RWfileChanged = false;
|
||||||
currentWatch[0] = NULL;
|
currentWatch[0] = NULL;
|
||||||
return true;
|
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)
|
LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
RECT r;
|
RECT r;
|
||||||
|
@ -914,6 +952,7 @@ LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
|
||||||
|
|
||||||
DragAcceptFiles(hDlg, TRUE);
|
DragAcceptFiles(hDlg, TRUE);
|
||||||
|
|
||||||
|
RefreshWatchListSelectedCountControlStatus(hDlg);
|
||||||
return false;
|
return false;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -950,10 +989,11 @@ LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
|
||||||
case LVN_ITEMCHANGED: // selection changed event
|
case LVN_ITEMCHANGED: // selection changed event
|
||||||
{
|
{
|
||||||
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)lP;
|
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
|
// disable buttons that we don't have the right number of selected items for
|
||||||
RefreshWatchListSelectedItemControlStatus(hDlg);
|
RefreshWatchListSelectedCountControlStatus(hDlg);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -1028,15 +1068,19 @@ LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
|
||||||
ResetWatches();
|
ResetWatches();
|
||||||
return true;
|
return true;
|
||||||
case IDC_C_WATCH_REMOVE:
|
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);
|
RemoveWatch(watchIndex);
|
||||||
ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount);
|
ListView_DeleteItem(watchListControl, watchIndex);
|
||||||
|
watchIndex = ListView_GetNextItem(watchListControl, -1, LVNI_ALL | LVNI_SELECTED);
|
||||||
|
}
|
||||||
RWfileChanged=true;
|
RWfileChanged=true;
|
||||||
SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST));
|
SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST));
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
case IDC_C_WATCH_EDIT:
|
case IDC_C_WATCH_EDIT:
|
||||||
watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST));
|
watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST));
|
||||||
if(watchIndex != -1)
|
if(watchIndex != -1)
|
||||||
|
|
|
@ -1638,7 +1638,7 @@ CAPTION " RAM Watch"
|
||||||
MENU RAMWATCH_MENU
|
MENU RAMWATCH_MENU
|
||||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||||
BEGIN
|
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 "Edit",IDC_C_WATCH_EDIT,226,66,34,14
|
||||||
PUSHBUTTON "Remove",IDC_C_WATCH_REMOVE,226,83,34,14
|
PUSHBUTTON "Remove",IDC_C_WATCH_REMOVE,226,83,34,14
|
||||||
PUSHBUTTON "New",IDC_C_WATCH,226,100,34,14
|
PUSHBUTTON "New",IDC_C_WATCH,226,100,34,14
|
||||||
|
|
Loading…
Reference in New Issue