1. Added context menu to Cheat Dialog Cheat Listbox

2. Populated list with Toggle Cheat, Poke Cheat Value, and Goto In Hex Editor
3. Fixed Hex Editor Color Display code. I was overflowing it before.
4. Made enabling/disabling cheats no longer deselect the selected cheat.
This commit is contained in:
ugetab 2010-05-08 00:04:26 +00:00
parent e3a0c66034
commit 61fd43ab95
6 changed files with 87 additions and 16 deletions

View File

@ -28,6 +28,8 @@
static HWND pwindow = 0; //Handle to Cheats dialog
HWND hCheat; //mbg merge 7/19/06 had to add
static HMENU hCheatcontext; //Handle to context menu
static HMENU hCheatcontextsub; //Handle to context sub menu
void InitializeCheatsAdded(HWND hwndDlg);
@ -204,6 +206,10 @@ BOOL CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
searchdone=0;
SetDlgItemText(hwndDlg,IDC_CHEAT_VAL_KNOWN,(LPTSTR)U8ToStr(knownvalue));
InitializeCheatsAdded(hwndDlg);
// Enable Context Sub-Menus
hCheatcontext = LoadMenu(fceu_hInstance,"CHEATCONTEXTMENUS");
break;
case WM_KILLFOCUS:
@ -345,10 +351,49 @@ BOOL CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
}
break;
case WM_CONTEXTMENU:
{
// Handle certain subborn context menus for nearly incapable controls.
// Only need 9, but I'd rather double it to be safe
//char TestHwnd[17];
//char TestwParam[17];
// Convert wParam to a string
sprintf(str,"%08x",wParam);
// Convert HWND of IDC_LIST_CHEATS to a string
sprintf(str2,"%08x",GetDlgItem(hwndDlg,IDC_LIST_CHEATS));
// Compare the now-compatible data with strcmp.
if (!strcmp(str, str2)) {
// Only open the menu if a cheat is selected
if (selcheat >= 0) {
// Open IDC_LIST_CHEATS Context Menu
hCheatcontextsub = GetSubMenu(hCheatcontext,0);
TrackPopupMenu(hCheatcontextsub,0,LOWORD(lParam),HIWORD(lParam),TPM_RIGHTBUTTON,hwndDlg,0); //Create menu
}
}
}
break;
case WM_COMMAND:
switch (HIWORD(wParam)) {
case BN_CLICKED:
switch (LOWORD(wParam)) {
case CHEAT_CONTEXT_TOGGLECHEAT:
CheatConsoleCallB(hwndDlg, WM_COMMAND, (LBN_DBLCLK * 0x10000) | (IDC_LIST_CHEATS), lParam);
break;
case CHEAT_CONTEXT_POKECHEATVALUE:
FCEUI_GetCheat(selcheat,&name,&a,&v,NULL,&s,NULL);
BWrite[a](a,v);
break;
case CHEAT_CONTEXT_GOTOINHEXEDITOR:
DoMemView();
FCEUI_GetCheat(selcheat,&name,&a,&v,NULL,&s,NULL);
SetHexEditorAddress(a);
break;
case IDC_CHEAT_PAUSEWHENACTIVE:
pauseWhileActive ^= 1;
break;
@ -489,9 +534,9 @@ BOOL CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
//strcat(str,name);
SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_DELETESTRING,selcheat,0);
SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_INSERTSTRING,selcheat,(LPARAM)(LPSTR)str);
SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_SETCURSEL,selcheat,0);
UpdateCheatsAdded();
UpdateColorTable();
SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_SETCURSEL,selcheat,0);
break;
}
break;
@ -836,3 +881,8 @@ void DoGGConv(){
return;
}
/*
void ListBox::OnRButtonDown(UINT nFlags, CPoint point)
{
CPoint test = point;
} */

View File

@ -238,15 +238,21 @@ void GotoAddress(HWND hwnd) {
{
if(EOF != sscanf(gotoaddressstring, "%x", &gotoaddress))
{
SetHexEditorAddress(gotoaddress);
}
}
}
void SetHexEditorAddress(int gotoaddress) {
if (gotoaddress < 0)
gotoaddress = 0;
if (gotoaddress > (MaxSize-1))
gotoaddress = (MaxSize-1);
CursorStartAddy = gotoaddress;
CursorEndAddy = -1;
ChangeMemViewFocus(EditingMode,CursorStartAddy,-1);
}
}
}
static void FlushUndoBuffer(){
@ -454,7 +460,7 @@ void UpdateMemoryView(int draw_all)
SetTextColor(HDataDC,RGB(255,255,255)); //single address highlight
SetBkColor(HDataDC,RGB(0,0,0));
TextOut(HDataDC,0,0,str,1);
SetTextColor(HDataDC,TextColorList[CursorStartAddy]); //single address highlight 2nd address
SetTextColor(HDataDC,TextColorList[i+j-CurOffset]); //single address highlight 2nd address
SetBkColor(HDataDC,RGB(HexBackColorR,HexBackColorG,HexBackColorB));
TextOut(HDataDC,0,0,&str[1],1);
}

View File

@ -7,5 +7,7 @@ void ChangeMemViewFocus(int newEditingMode, int StartOffset,int EndOffset);
void ApplyPatch(int addr,int size, uint8* data);
void UndoLastPatch();
void SetHexEditorAddress(int gotoaddress);
extern HWND hMemView;
extern int EditingMode;

View File

@ -420,6 +420,16 @@ BEGIN
END
END
CHEATCONTEXTMENUS MENU
BEGIN
POPUP "CheatListPopup"
BEGIN
MENUITEM "Toggle Cheat", CHEAT_CONTEXT_TOGGLECHEAT
MENUITEM "Poke Cheat Value", CHEAT_CONTEXT_POKECHEATVALUE
MENUITEM "Goto In Hex Editor", CHEAT_CONTEXT_GOTOINHEXEDITOR
END
END
LUAWINDOW_MENU MENU
BEGIN
POPUP "Console"

View File

@ -132,6 +132,9 @@
#define IDC_DEBUGGER_RUN_FRAME2 115
#define LBL_CLEAR_AH 116
#define IDC_CHECK_LOG_UPDATE_WINDOW 116
#define CHEAT_CONTEXT_TOGGLECHEAT 117
#define CHEAT_CONTEXT_POKECHEATVALUE 118
#define CHEAT_CONTEXT_GOTOINHEXEDITOR 119
#define CHECK_SOUND_8BIT 122
#define IDD_DIALOG3 123
#define CHECK_SOUND_GLOBAL_FOCUS 124

View File

@ -1164,14 +1164,14 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
if (GameInfo && FCEUMOV_Mode(MOVIEMODE_PLAY|MOVIEMODE_RECORD) && movie_readonly)
{
hfceuxcontextsub = GetSubMenu(hfceuxcontext,0);
whichContext = 0;
whichContext = 0; // Game+Movie+readonly
}
//If there is a movie loaded in read+write
else if (GameInfo && FCEUMOV_Mode(MOVIEMODE_PLAY|MOVIEMODE_RECORD) && !movie_readonly)
{
hfceuxcontextsub = GetSubMenu(hfceuxcontext,3);
whichContext = 3;
whichContext = 3; // Game+Movie+readwrite
}
@ -1179,14 +1179,14 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
else if (GameInfo)
{
hfceuxcontextsub = GetSubMenu(hfceuxcontext,1);
whichContext = 1;
whichContext = 1; // Game+NoMovie
}
//Else no ROM
else
{
hfceuxcontextsub = GetSubMenu(hfceuxcontext,2);
whichContext = 2;
whichContext = 2; // NoGame
}
UpdateContextMenuItems(hfceuxcontextsub, whichContext);
pt.x = LOWORD(lParam); //Get mouse x in terms of client area