commit
68d365c2f8
|
@ -73,6 +73,22 @@ BOOL CHEATS::update(u8 size, u32 address, u32 val, char *description, BOOL enabl
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CHEATS::move(u32 srcPos, u32 dstPos)
|
||||
{
|
||||
if (srcPos >= list.size() || dstPos > list.size()) return false;
|
||||
if (srcPos < 0 || dstPos < 0) return false;
|
||||
|
||||
// get the item to move
|
||||
CHEATS_LIST srcCheat = list[srcPos];
|
||||
// insert item in the new position
|
||||
list.insert(list.begin() + dstPos, srcCheat);
|
||||
// remove the original item
|
||||
if (dstPos < srcPos) srcPos++;
|
||||
list.erase(list.begin() + srcPos);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#define CHEATLOG(...)
|
||||
//#define CHEATLOG(...) printf(__VA_ARGS__)
|
||||
|
||||
|
@ -1021,7 +1037,10 @@ void CHEATS::process(int targetType)
|
|||
if(cheatsResetJit)
|
||||
{
|
||||
if(CommonSettings.use_jit)
|
||||
arm_jit_reset(true,true);
|
||||
{
|
||||
printf("Cheat code operation potentially not compatible with JIT operations. Resetting JIT...\n");
|
||||
arm_jit_reset(true, true);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@ public:
|
|||
void init(char *path);
|
||||
BOOL add(u8 size, u32 address, u32 val, char *description, BOOL enabled);
|
||||
BOOL update(u8 size, u32 address, u32 val, char *description, BOOL enabled, u32 pos);
|
||||
BOOL move(u32 srcPos, u32 dstPos);
|
||||
BOOL add_AR(char *code, char *description, BOOL enabled);
|
||||
BOOL update_AR(char *code, char *description, BOOL enabled, u32 pos);
|
||||
BOOL add_AR_Direct(CHEATS_LIST cheat);
|
||||
|
|
|
@ -56,6 +56,9 @@ static u32 cheatEditPos = 0;
|
|||
static u8 cheatAddPasteCheck = 0;
|
||||
static u8 cheatXXtype = 0;
|
||||
static u8 cheatXXaction = 0;
|
||||
static s32 draggedItem = -1;
|
||||
static s32 highlightedItem = -1;
|
||||
static bool multiCheck = false;
|
||||
|
||||
static HWND searchWnd = NULL;
|
||||
static HWND searchListView = NULL;
|
||||
|
@ -670,6 +673,46 @@ INT_PTR CALLBACK CheatsAdd_XX_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lp
|
|||
return FALSE;
|
||||
}
|
||||
//==============================================================================
|
||||
void AttemptSaveAndClose(HWND dialog)
|
||||
{
|
||||
if (cheats->save())
|
||||
EndDialog(dialog, TRUE);
|
||||
else
|
||||
MessageBox(dialog, "Can't save cheats to file.\nCheck your path (Menu->Config->Path Settings->\"Cheats\")", "Error", MB_OK);
|
||||
}
|
||||
void MoveRow(HWND list, int src, int dst)
|
||||
{
|
||||
// move the cheat
|
||||
if (!cheats->move(src, dst))
|
||||
return;
|
||||
|
||||
// insert new row
|
||||
LVITEM item;
|
||||
memset(&item, 0, sizeof(LVITEM));
|
||||
item.mask = LVIF_TEXT | LVIF_STATE;
|
||||
item.iItem = dst;
|
||||
ListView_InsertItem(cheatListView, &item);
|
||||
if (dst < src) src++;
|
||||
|
||||
// get and set each subitem
|
||||
item.iItem = src;
|
||||
char* buf = new char[256];
|
||||
item.pszText = buf;
|
||||
item.cchTextMax = 256;
|
||||
item.mask = LVIF_TEXT;
|
||||
for (int i = 1; i < 4; i++)
|
||||
{
|
||||
item.iSubItem = i;
|
||||
ListView_GetItem(cheatListView, &item);
|
||||
ListView_SetItemText(cheatListView, dst, i, item.pszText);
|
||||
}
|
||||
|
||||
// set check state
|
||||
ListView_SetCheckState(cheatListView, dst, ListView_GetCheckState(cheatListView, src));
|
||||
|
||||
// delete the original item
|
||||
ListView_DeleteItem(cheatListView, src);
|
||||
}
|
||||
INT_PTR CALLBACK CheatsListBox_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam)
|
||||
{
|
||||
switch(msg)
|
||||
|
@ -700,7 +743,7 @@ INT_PTR CALLBACK CheatsListBox_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM l
|
|||
lvColumn.cx=100;
|
||||
lvColumn.pszText="Value";
|
||||
ListView_InsertColumn(cheatListView, 2, &lvColumn);
|
||||
lvColumn.cx=245;
|
||||
lvColumn.cx=467;
|
||||
lvColumn.pszText="Description";
|
||||
ListView_InsertColumn(cheatListView, 3, &lvColumn);
|
||||
lvColumn.fmt=LVCFMT_CENTER;
|
||||
|
@ -763,8 +806,8 @@ INT_PTR CALLBACK CheatsListBox_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM l
|
|||
case WM_NOTIFY:
|
||||
if (wparam == IDC_LIST1)
|
||||
{
|
||||
LPNMHDR tmp_msg = (LPNMHDR)lparam;
|
||||
switch (tmp_msg->code)
|
||||
tagLVKEYDOWN* tmp_msg = (tagLVKEYDOWN*)lparam;
|
||||
switch (tmp_msg->hdr.code)
|
||||
{
|
||||
case LVN_ITEMACTIVATE:
|
||||
SendMessage(dialog, WM_COMMAND, IDC_BEDIT, 0);
|
||||
|
@ -810,6 +853,38 @@ INT_PTR CALLBACK CheatsListBox_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM l
|
|||
EnableWindow(GetDlgItem(dialog, IDOK), TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
// check all other selected items too
|
||||
if (!multiCheck && ListView_GetItemState(cheatListView, cheatEditPos, LVNI_SELECTED))
|
||||
{
|
||||
multiCheck = true;
|
||||
bool check = ListView_GetCheckState(cheatListView, cheatEditPos);
|
||||
int index = ListView_GetNextItem(cheatListView, -1, LVNI_SELECTED);
|
||||
while (index != -1)
|
||||
{
|
||||
if (index != cheatEditPos)
|
||||
ListView_SetCheckState(cheatListView, index, check);
|
||||
index = ListView_GetNextItem(cheatListView, index, LVNI_SELECTED);
|
||||
}
|
||||
multiCheck = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LVN_BEGINDRAG:
|
||||
{
|
||||
draggedItem = ListView_GetSelectionMark(cheatListView);
|
||||
SetCapture(dialog); // This sends all mouse messages to the dialog.
|
||||
}
|
||||
break;
|
||||
|
||||
case LVN_KEYDOWN:
|
||||
{
|
||||
if (tmp_msg->wVKey == 0x41) // A key
|
||||
{
|
||||
if (GetKeyState(VK_CONTROL) & 0x7000)
|
||||
ListView_SetItemState(cheatListView, -1, LVNI_SELECTED, LVNI_SELECTED);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -818,17 +893,77 @@ INT_PTR CALLBACK CheatsListBox_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM l
|
|||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
if (draggedItem != -1)
|
||||
{
|
||||
// un-highlight any previously highlighted item
|
||||
if (highlightedItem != -1)
|
||||
ListView_SetItemState(cheatListView, highlightedItem, 0, LVIS_DROPHILITED);
|
||||
|
||||
// get location of the cursor, relative to the list view
|
||||
RECT r;
|
||||
GetWindowRect(GetDlgItem(dialog, IDC_LIST1), &r);
|
||||
POINT p = { r.left, r.top };
|
||||
ScreenToClient(dialog, &p);
|
||||
|
||||
LVHITTESTINFO hitTestInfo;
|
||||
hitTestInfo.pt.x = LOWORD(lparam) - p.x;
|
||||
hitTestInfo.pt.y = HIWORD(lparam) - p.y;
|
||||
|
||||
// find the item under the cursor and highlight it
|
||||
ListView_HitTest(cheatListView, &hitTestInfo);
|
||||
if (hitTestInfo.iItem != -1)
|
||||
ListView_SetItemState(cheatListView, hitTestInfo.iItem, LVIS_DROPHILITED, LVIS_DROPHILITED);
|
||||
highlightedItem = hitTestInfo.iItem;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_LBUTTONUP:
|
||||
{
|
||||
if (highlightedItem != -1)
|
||||
ListView_SetItemState(cheatListView, highlightedItem, 0, LVIS_DROPHILITED);
|
||||
|
||||
if (draggedItem != -1)
|
||||
{
|
||||
if (highlightedItem != -1 && highlightedItem != draggedItem)
|
||||
{
|
||||
if (highlightedItem > draggedItem)
|
||||
highlightedItem++; // if dragging an item down, item should be placed below highlighted item (required to move an item to the bottom)
|
||||
MoveRow(cheatListView, draggedItem, highlightedItem);
|
||||
EnableWindow(GetDlgItem(dialog, IDOK), TRUE);
|
||||
}
|
||||
}
|
||||
draggedItem = -1;
|
||||
ReleaseCapture();
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
{
|
||||
switch (LOWORD(wparam))
|
||||
{
|
||||
case IDOK:
|
||||
if (cheats->save())
|
||||
EndDialog(dialog, TRUE);
|
||||
else
|
||||
MessageBox(dialog, "Can't save cheats to file.\nCheck your path (Menu->Config->Path Settings->\"Cheats\")","Error",MB_OK);
|
||||
AttemptSaveAndClose(dialog);
|
||||
return TRUE;
|
||||
|
||||
case IDCANCEL:
|
||||
{
|
||||
if (IsWindowEnabled(GetDlgItem(dialog, IDOK)))
|
||||
{
|
||||
int result = MessageBox(dialog, "Do you wish to save your changes?", "Save?", MB_YESNOCANCEL);
|
||||
if (result == IDYES)
|
||||
AttemptSaveAndClose(dialog);
|
||||
else if (result == IDNO)
|
||||
EndDialog(dialog, FALSE);
|
||||
}
|
||||
else
|
||||
EndDialog(dialog, FALSE);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case IDCLOSE:
|
||||
EndDialog(dialog, FALSE);
|
||||
return TRUE;
|
||||
|
||||
|
|
|
@ -202,19 +202,19 @@ BEGIN
|
|||
LTEXT "Description:",-1,9,116,39,8
|
||||
END
|
||||
|
||||
IDD_CHEAT_LIST DIALOGEX 0, 0, 499, 285
|
||||
IDD_CHEAT_LIST DIALOGEX 0, 0, 461, 285
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Cheats list"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
CONTROL "",IDC_LIST1,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,7,488,218
|
||||
CONTROL "",IDC_LIST1,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,7,450,218
|
||||
PUSHBUTTON "internal",IDC_BADD,10,240,50,14
|
||||
PUSHBUTTON "Action Replay",IDC_BADD_AR,66,240,67,14
|
||||
PUSHBUTTON "Codebreaker",IDC_BADD_CB,139,240,67,14,WS_DISABLED
|
||||
PUSHBUTTON "Edit",IDC_BEDIT,245,228,64,14,WS_DISABLED
|
||||
PUSHBUTTON "Remove",IDC_BREMOVE,246,244,63,14,WS_DISABLED
|
||||
DEFPUSHBUTTON "Save",IDOK,109,263,50,14,WS_DISABLED
|
||||
PUSHBUTTON "Cancel",IDCANCEL,163,263,50,14
|
||||
PUSHBUTTON "Cancel",IDCLOSE,163,263,50,14
|
||||
GROUPBOX " Add cheats code as... ",IDC_STATIC,7,230,205,31
|
||||
PUSHBUTTON "Cheats Database",IDC_EXPORT,246,263,63,14
|
||||
END
|
||||
|
@ -1873,7 +1873,6 @@ BEGIN
|
|||
|
||||
IDD_CHEAT_LIST, DIALOG
|
||||
BEGIN
|
||||
RIGHTMARGIN, 495
|
||||
BOTTOMMARGIN, 277
|
||||
END
|
||||
|
||||
|
|
Loading…
Reference in New Issue