Sync the code to master branch.

This commit is contained in:
owomomo 2019-06-11 17:39:30 +08:00
commit 02df3d6993
5 changed files with 104 additions and 41 deletions

View File

@ -104,4 +104,4 @@ bool FCEU_OpenGenie(void);
void FCEU_CloseGenie(void);
void FCEU_KillGenie(void);
#endif
#endif#endif

View File

@ -634,19 +634,32 @@ BOOL CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
case IDC_BTN_CHEAT_ADDFROMFILE:
{
OPENFILENAME ofn;
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
memset(&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwndDlg;
ofn.hInstance = fceu_hInstance;
ofn.lpstrTitle = "Open Cheats file";
ofn.lpstrTitle = "Open cheats file";
const char filter[] = "Cheat files (*.cht)\0*.cht\0All Files (*.*)\0*.*\0\0";
ofn.lpstrFilter = filter;
char nameo[2048] = { 0 };
/*
I gave up setting the default filename for import cheat dialog, since the filename display contains a bug.
if (GameInfo)
{
char* filename;
if ((filename = strrchr(GameInfo->filename, '\\')) || (filename = strrchr(GameInfo->filename, '/')))
strcpy(nameo, filename + 1);
else
strcpy(nameo, GameInfo->filename);
strcpy(strrchr(nameo, '.'), ".cht");
}
*/
ofn.lpstrFile = nameo;
ofn.nMaxFile = 2048;
ofn.lpstrDefExt = "cht";
ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_FILEMUSTEXIST;
std::string initdir = FCEU_GetPath(FCEUMKF_CHEAT);
std::string initdir = FCEU_GetPath(FCEUMKF_CHEAT) + PSS;
ofn.lpstrInitialDir = initdir.c_str();
if (GetOpenFileName(&ofn))
@ -662,6 +675,45 @@ BOOL CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
}
}
break;
case IDC_BTN_CHEAT_EXPORTTOFILE:
{
OPENFILENAME ofn;
memset(&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hInstance = fceu_hInstance;
ofn.lpstrTitle = "Save cheats file";
const char filter[] = "Cheat files (*.cht)\0*.cht\0All Files (*.*)\0*.*\0\0";
ofn.lpstrFilter = filter;
char nameo[2048] = { 0 };
if (GameInfo)
{
char* filename;
if ((filename = strrchr(GameInfo->filename, '\\')) || (filename = strrchr(GameInfo->filename, '/')))
strcpy(nameo, filename + 1);
else
strcpy(nameo, GameInfo->filename);
strcpy(strrchr(nameo, '.'), ".cht");
}
ofn.lpstrFile = nameo;
ofn.nMaxFile = 2048;
ofn.lpstrDefExt = "cht";
ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_FILEMUSTEXIST;
std::string initdir = FCEU_GetPath(FCEUMKF_CHEAT) + PSS;
ofn.lpstrInitialDir = initdir.c_str();
if (GetSaveFileName(&ofn))
{
FILE* file = FCEUD_UTF8fopen(nameo, "wb");
if (file)
{
savecheats = 1;
FCEU_FlushGameCheats(file, 0);
fclose(file);
}
}
}
break;
case IDC_BTN_CHEAT_RESET:
FCEUI_CheatSearchBegin();
ShowResults(hwndDlg);
@ -1001,6 +1053,10 @@ BOOL CALLBACK GGConvCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
GGConv_wndy = 0;
SetWindowPos(hwndDlg, 0, GGConv_wndx, GGConv_wndy, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
SendDlgItemMessage(hwndDlg, IDC_GAME_GENIE_CODE, EM_SETLIMITTEXT, 8, 0);
SendDlgItemMessage(hwndDlg, IDC_GAME_GENIE_ADDR, EM_SETLIMITTEXT, 4, 0);
SendDlgItemMessage(hwndDlg, IDC_GAME_GENIE_COMP, EM_SETLIMITTEXT, 2, 0);
SendDlgItemMessage(hwndDlg, IDC_GAME_GENIE_VAL, EM_SETLIMITTEXT, 2, 0);
break;
case WM_CLOSE:
case WM_QUIT:

View File

@ -1978,47 +1978,48 @@ BEGIN
LTEXT "New Selection Name:",-1,5,240,68,8
END
CHEATCONSOLE DIALOGEX 0, 0, 386, 217
CHEATCONSOLE DIALOGEX 0, 0, 387, 218
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Cheat Search"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
GROUPBOX "Active Cheats",IDC_GROUPBOX_CHEATLIST,5,2,169,209,WS_TABSTOP
GROUPBOX "Cheat Search",IDC_GROUPBOX_CHEATSEARCH,179,2,201,209,WS_TABSTOP
GROUPBOX "Cheat Search",IDC_GROUPBOX_CHEATSEARCH,180,2,201,198,WS_TABSTOP
CONTROL "",IDC_LIST_CHEATS,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,11,11,157,133
LTEXT "Name:",IDC_STATIC,12,149,22,10
LTEXT "Value:",IDC_CHEAT_VAL_LABEL,73,163,22,8
LTEXT "Compare:",IDC_CHEAT_COM_LABEL,117,163,34,8
EDITTEXT IDC_CHEAT_NAME,37,147,131,12,ES_AUTOHSCROLL | ES_WANTRETURN
EDITTEXT IDC_CHEAT_ADDR,44,161,25,12,ES_UPPERCASE | ES_WANTRETURN
EDITTEXT IDC_CHEAT_VAL,97,161,16,12,ES_UPPERCASE | ES_WANTRETURN
EDITTEXT IDC_CHEAT_COM,152,161,16,12,ES_UPPERCASE | ES_WANTRETURN
DEFPUSHBUTTON "Add",IDC_BTN_CHEAT_ADD,9,192,36,16
PUSHBUTTON "Delete",IDC_BTN_CHEAT_DEL,45,192,36,16
PUSHBUTTON "Update",IDC_BTN_CHEAT_UPD,81,192,36,16
PUSHBUTTON "Reset",IDC_BTN_CHEAT_RESET,191,12,55,15
PUSHBUTTON "Known Value:",IDC_BTN_CHEAT_KNOWN,191,32,55,15
LTEXT "0x",IDC_CHEAT_LABEL_KNOWN,216,51,9,8
EDITTEXT IDC_CHEAT_VAL_KNOWN,227,49,18,12,ES_UPPERCASE
GROUPBOX "Previous Compare",IDC_GROUP_PREV_COM,184,63,69,132
PUSHBUTTON "Equal",IDC_BTN_CHEAT_EQ,191,75,55,15,WS_GROUP
PUSHBUTTON "Not Equal",IDC_BTN_CHEAT_NE,191,96,55,15
CONTROL "By:",IDC_CHEAT_CHECK_NE_BY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,203,114,22,10
EDITTEXT IDC_CHEAT_VAL_NE_BY,227,113,18,12,ES_UPPERCASE | ES_WANTRETURN
PUSHBUTTON "Greater Than",IDC_BTN_CHEAT_GT,191,129,55,15
CONTROL "By:",IDC_CHEAT_CHECK_GT_BY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,203,147,22,10
EDITTEXT IDC_CHEAT_VAL_GT_BY,227,146,18,12,ES_UPPERCASE | ES_WANTRETURN
PUSHBUTTON "Less Than",IDC_BTN_CHEAT_LT,191,162,55,15
CONTROL "By:",IDC_CHEAT_CHECK_LT_BY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,203,180,22,10
EDITTEXT IDC_CHEAT_VAL_LT_BY,227,179,18,12,ES_UPPERCASE | ES_WANTRETURN
GROUPBOX "Possibilities",IDC_CHEAT_BOX_POSSIBILITIES,257,8,117,187,WS_TABSTOP
CONTROL "",IDC_CHEAT_LIST_POSSIBILITIES,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_OWNERDATA | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,263,18,106,172
LTEXT "Name:", IDC_STATIC, 12, 149, 22, 10
EDITTEXT IDC_CHEAT_NAME,37,147,131,12,ES_AUTOHSCROLL | ES_WANTRETURN
LTEXT "Address:", IDC_CHEAT_ADDRESS_LABEL, 12, 163, 30, 8
EDITTEXT IDC_CHEAT_ADDR,44,161,25,12,ES_UPPERCASE | ES_WANTRETURN
LTEXT "Value:", IDC_CHEAT_VAL_LABEL, 73, 163, 22, 8
EDITTEXT IDC_CHEAT_VAL,97,161,16,12,ES_UPPERCASE | ES_WANTRETURN
LTEXT "Compare:", IDC_CHEAT_COM_LABEL, 117, 163, 34, 8
EDITTEXT IDC_CHEAT_COM,152,161,16,12,ES_UPPERCASE | ES_WANTRETURN
LTEXT "Cheat code / Game Genie:", IDC_CHEAT_CODE_GG_LABEL, 11, 177, 87, 8
EDITTEXT IDC_CHEAT_TEXT, 105, 175, 63, 12, ES_UPPERCASE | ES_AUTOHSCROLL
DEFPUSHBUTTON "Add",IDC_BTN_CHEAT_ADD,7,192,30,16
PUSHBUTTON "Delete",IDC_BTN_CHEAT_DEL,37,192,30,16
PUSHBUTTON "Update",IDC_BTN_CHEAT_UPD,67,192,30,16
PUSHBUTTON "Import...", IDC_BTN_CHEAT_ADDFROMFILE, 100, 192, 36, 16
PUSHBUTTON "Export...", IDC_BTN_CHEAT_EXPORTTOFILE, 136, 192, 36, 16
PUSHBUTTON "Reset",IDC_BTN_CHEAT_RESET,192,12,55,15
PUSHBUTTON "Known Value:",IDC_BTN_CHEAT_KNOWN,192,32,55,15
LTEXT "0x",IDC_CHEAT_LABEL_KNOWN,217,51,9,8
EDITTEXT IDC_CHEAT_VAL_KNOWN,228,49,18,12,ES_UPPERCASE
GROUPBOX "Previous Compare",IDC_GROUP_PREV_COM,185,63,69,132
PUSHBUTTON "Equal",IDC_BTN_CHEAT_EQ,192,75,55,15,WS_GROUP
PUSHBUTTON "Not Equal",IDC_BTN_CHEAT_NE,192,96,55,15
CONTROL "By:",IDC_CHEAT_CHECK_NE_BY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,204,114,22,10
EDITTEXT IDC_CHEAT_VAL_NE_BY,228,113,18,12,ES_UPPERCASE | ES_WANTRETURN
PUSHBUTTON "Greater Than",IDC_BTN_CHEAT_GT,192,129,55,15
CONTROL "By:",IDC_CHEAT_CHECK_GT_BY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,204,147,22,10
EDITTEXT IDC_CHEAT_VAL_GT_BY,228,146,18,12,ES_UPPERCASE | ES_WANTRETURN
PUSHBUTTON "Less Than",IDC_BTN_CHEAT_LT,192,162,55,15
CONTROL "By:",IDC_CHEAT_CHECK_LT_BY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,204,180,22,10
EDITTEXT IDC_CHEAT_VAL_LT_BY,228,179,18,12,ES_UPPERCASE | ES_WANTRETURN
GROUPBOX "Possibilities",IDC_CHEAT_BOX_POSSIBILITIES,258,8,117,187,WS_TABSTOP
CONTROL "",IDC_CHEAT_LIST_POSSIBILITIES,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_OWNERDATA | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,264,18,106,172
CONTROL " Pause emulation when this window is active",IDC_CHEAT_PAUSEWHENACTIVE,
"Button",BS_AUTOCHECKBOX,185,198,157,10
PUSHBUTTON "Import...",IDC_BTN_CHEAT_ADDFROMFILE,126,192,43,16
EDITTEXT IDC_CHEAT_TEXT,105,175,63,12,ES_UPPERCASE | ES_AUTOHSCROLL
LTEXT "Address:",IDC_CHEAT_ADDRESS_LABEL,12,163,30,8
LTEXT "Cheat code / Game Genie:",IDC_CHEAT_CODE_GG_LABEL,12,177,87,8
"Button",BS_AUTOCHECKBOX,180,202,157,10
END
IDD_LUA DIALOGEX 0, 0, 270, 150
@ -2509,8 +2510,8 @@ BEGIN
"CHEATCONSOLE", DIALOG
BEGIN
RIGHTMARGIN, 385
BOTTOMMARGIN, 216
RIGHTMARGIN, 386
BOTTOMMARGIN, 217
END
"VIDEOCONFIG", DIALOG

View File

@ -469,6 +469,7 @@
#define IDC_NTVIEW_SHOW_ATTRIBUTES 1009
#define IDC_NTVIEW_HIDE_PALETTES 1010
#define MW_ADDR03 1010
#define IDC_BTN_CHEAT_EXPORTTOFILE 1011
#define IDSAVE 1012
#define MW_ADDR04 1013
#define IDC_CHECK1 1013

View File

@ -274,4 +274,9 @@ void Mapper252_Init(CartInfo *);
void Mapper253_Init(CartInfo *);
void Mapper254_Init(CartInfo *);
typedef struct {
char *name;
int32 number;
void (*init)(CartInfo *);
} BMAPPINGLocal;
#endif