win32: add search database button, increase dialog size

This commit is contained in:
OV2 2018-05-01 23:21:25 +02:00
parent 3f4fc0e25a
commit d4230b3225
3 changed files with 109 additions and 39 deletions

View File

@ -157,6 +157,8 @@
#define IDC_KEYBOARD 1127 #define IDC_KEYBOARD 1127
#define IDC_ALLOWLEFTRIGHT 1127 #define IDC_ALLOWLEFTRIGHT 1127
#define IDC_CHEAT_ADDRESS 1128 #define IDC_CHEAT_ADDRESS 1128
#define IDC_CLEAR_CHEATS2 1128
#define IDC_SEARCH_DB 1128
#define IDC_CHEAT_BYTE 1129 #define IDC_CHEAT_BYTE 1129
#define IDC_ADD_CHEAT 1130 #define IDC_ADD_CHEAT 1130
#define IDC_CHEAT_LIST 1131 #define IDC_CHEAT_LIST 1131
@ -386,28 +388,6 @@
#define ID_SOUND_22050HZ 40035 #define ID_SOUND_22050HZ 40035
#define ID_SOUND_44100HZ 40036 #define ID_SOUND_44100HZ 40036
#define ID_SOUND_30000HZ 40037 #define ID_SOUND_30000HZ 40037
#define ID_FILE_SAVE0 44000
#define ID_FILE_SAVE1 44001
#define ID_FILE_SAVE2 44002
#define ID_FILE_SAVE3 44003
#define ID_FILE_SAVE4 44004
#define ID_FILE_SAVE5 44005
#define ID_FILE_SAVE6 44006
#define ID_FILE_SAVE7 44007
#define ID_FILE_SAVE8 44008
#define ID_FILE_SAVE9 44009
#define ID_FILE_SAVE_FILE 44010
#define ID_FILE_LOAD0 44020
#define ID_FILE_LOAD1 44021
#define ID_FILE_LOAD2 44022
#define ID_FILE_LOAD3 44023
#define ID_FILE_LOAD4 44024
#define ID_FILE_LOAD5 44025
#define ID_FILE_LOAD6 44026
#define ID_FILE_LOAD7 44027
#define ID_FILE_LOAD8 44028
#define ID_FILE_LOAD9 44029
#define ID_FILE_LOAD_FILE 44030
#define ID_CHEAT_ENTER 40063 #define ID_CHEAT_ENTER 40063
#define ID_CHEAT_SEARCH 40064 #define ID_CHEAT_SEARCH 40064
#define ID_CHEAT_APPLY 40065 #define ID_CHEAT_APPLY 40065
@ -504,13 +484,35 @@
#define ID_DEBUG_APU_TRACE 40173 #define ID_DEBUG_APU_TRACE 40173
#define ID_EMULATION_BACKGROUNDINPUT 40174 #define ID_EMULATION_BACKGROUNDINPUT 40174
#define ID_SAVEMEMPACK 40175 #define ID_SAVEMEMPACK 40175
#define ID_FILE_SAVE0 44000
#define ID_FILE_SAVE1 44001
#define ID_FILE_SAVE2 44002
#define ID_FILE_SAVE3 44003
#define ID_FILE_SAVE4 44004
#define ID_FILE_SAVE5 44005
#define ID_FILE_SAVE6 44006
#define ID_FILE_SAVE7 44007
#define ID_FILE_SAVE8 44008
#define ID_FILE_SAVE9 44009
#define ID_FILE_SAVE_FILE 44010
#define ID_FILE_LOAD0 44020
#define ID_FILE_LOAD1 44021
#define ID_FILE_LOAD2 44022
#define ID_FILE_LOAD3 44023
#define ID_FILE_LOAD4 44024
#define ID_FILE_LOAD5 44025
#define ID_FILE_LOAD6 44026
#define ID_FILE_LOAD7 44027
#define ID_FILE_LOAD8 44028
#define ID_FILE_LOAD9 44029
#define ID_FILE_LOAD_FILE 44030
#define IDC_STATIC -1 #define IDC_STATIC -1
// Next default values for new objects // Next default values for new objects
// //
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 153 #define _APS_NEXT_RESOURCE_VALUE 154
#define _APS_NEXT_COMMAND_VALUE 40176 #define _APS_NEXT_COMMAND_VALUE 40176
#define _APS_NEXT_CONTROL_VALUE 3022 #define _APS_NEXT_CONTROL_VALUE 3022
#define _APS_NEXT_SYMED_VALUE 101 #define _APS_NEXT_SYMED_VALUE 101

View File

@ -246,22 +246,23 @@ BEGIN
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,187,168,131,10 "Button",BS_AUTOCHECKBOX | WS_TABSTOP,187,168,131,10
END END
IDD_CHEATER DIALOGEX 0, 0, 262, 194 IDD_CHEATER DIALOGEX 0, 0, 375, 194
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU
CAPTION "Cheat Entry and Editor" CAPTION "Cheat Entry and Editor"
FONT 8, "MS Sans Serif", 0, 0, 0x1 FONT 8, "MS Sans Serif", 0, 0, 0x1
BEGIN BEGIN
CONTROL "List1",IDC_CHEAT_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,5,200,125,WS_EX_CLIENTEDGE CONTROL "List1",IDC_CHEAT_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,5,291,125,WS_EX_CLIENTEDGE
PUSHBUTTON "&Add",IDC_ADD_CHEAT,215,5,40,15,WS_DISABLED PUSHBUTTON "&Add",IDC_ADD_CHEAT,306,7,62,15,WS_DISABLED
PUSHBUTTON "&Delete",IDC_DELETE_CHEAT,215,25,40,15,WS_DISABLED PUSHBUTTON "&Delete",IDC_DELETE_CHEAT,306,27,62,15,WS_DISABLED
PUSHBUTTON "&Update",IDC_UPDATE_CHEAT,215,45,40,15,WS_DISABLED PUSHBUTTON "&Update",IDC_UPDATE_CHEAT,306,47,62,15,WS_DISABLED
PUSHBUTTON "C&lear",IDC_CLEAR_CHEATS,215,65,40,15 PUSHBUTTON "C&lear",IDC_CLEAR_CHEATS,306,67,62,15
EDITTEXT IDC_CHEAT_CODE,86,134,118,15,ES_UPPERCASE | ES_AUTOHSCROLL EDITTEXT IDC_CHEAT_CODE,86,134,206,15,ES_UPPERCASE | ES_AUTOHSCROLL
EDITTEXT IDC_CHEAT_DESCRIPTION,85,154,119,15,ES_AUTOHSCROLL EDITTEXT IDC_CHEAT_DESCRIPTION,86,154,206,15,ES_AUTOHSCROLL
PUSHBUTTON "&OK",IDOK,99,174,50,15 PUSHBUTTON "&OK",IDOK,99,174,50,15
PUSHBUTTON "&Cancel",IDCANCEL,154,174,50,15 PUSHBUTTON "&Cancel",IDCANCEL,154,174,50,15
RTEXT "Enter Cheat Code:",IDC_LABEL_CHEAT_CODE,23,134,59,15,SS_CENTERIMAGE RTEXT "Enter Cheat Code:",IDC_LABEL_CHEAT_CODE,19,134,61,15,SS_CENTERIMAGE
RTEXT "Cheat Description",IDC_LABEL_CHEAT_DESCRIPTION,19,154,61,15,SS_CENTERIMAGE RTEXT "Cheat Description:",IDC_LABEL_CHEAT_DESCRIPTION,19,154,61,15,SS_CENTERIMAGE
PUSHBUTTON "&Search Database",IDC_SEARCH_DB,306,115,62,15
END END
IDD_NETPLAYPROGRESS DIALOG 0, 0, 186, 61 IDD_NETPLAYPROGRESS DIALOG 0, 0, 186, 61
@ -618,9 +619,8 @@ BEGIN
IDD_CHEATER, DIALOG IDD_CHEATER, DIALOG
BEGIN BEGIN
LEFTMARGIN, 7 LEFTMARGIN, 7
RIGHTMARGIN, 255 RIGHTMARGIN, 368
TOPMARGIN, 7 TOPMARGIN, 7
BOTTOMMARGIN, 211
END END
IDD_NETPLAYPROGRESS, DIALOG IDD_NETPLAYPROGRESS, DIALOG
@ -1001,6 +1001,11 @@ BEGIN
0 0
END END
IDD_CHEATER AFX_DIALOG_LAYOUT
BEGIN
0
END
#endif // English (United States) resources #endif // English (United States) resources
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////

View File

@ -287,6 +287,7 @@ INT_PTR CALLBACK DlgCheatSearchAdd(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP
INT_PTR CALLBACK DlgCreateMovie(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); INT_PTR CALLBACK DlgCreateMovie(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK DlgOpenMovie(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); INT_PTR CALLBACK DlgOpenMovie(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
HRESULT CALLBACK EnumModesCallback( LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpContext); HRESULT CALLBACK EnumModesCallback( LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpContext);
int WinSearchCheatDatabase();
VOID CALLBACK HotkeyTimer( UINT idEvent, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2); VOID CALLBACK HotkeyTimer( UINT idEvent, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2);
@ -300,6 +301,7 @@ void S9xDetectJoypads();
#define WM_CUSTKEYUP (WM_USER+51) #define WM_CUSTKEYUP (WM_USER+51)
#define TIMER_SCANJOYPADS (99999) #define TIMER_SCANJOYPADS (99999)
#define NC_SEARCHDB 0x8000
#ifdef UNICODE #ifdef UNICODE
#define S9XW_SHARD_PATH SHARD_PATHW #define S9XW_SHARD_PATH SHARD_PATHW
@ -2306,7 +2308,10 @@ LRESULT CALLBACK WinProc(
break; break;
case ID_CHEAT_ENTER: case ID_CHEAT_ENTER:
RestoreGUIDisplay (); RestoreGUIDisplay ();
DialogBox(g_hInst, MAKEINTRESOURCE(IDD_CHEATER), hWnd, DlgCheater); while (DialogBox(g_hInst, MAKEINTRESOURCE(IDD_CHEATER), hWnd, DlgCheater) == NC_SEARCHDB)
{
WinSearchCheatDatabase();
}
S9xSaveCheatFile (S9xGetFilename (".bml", CHEAT_DIR)); S9xSaveCheatFile (S9xGetFilename (".bml", CHEAT_DIR));
RestoreSNESDisplay (); RestoreSNESDisplay ();
break; break;
@ -8482,6 +8487,54 @@ int* index;
DWORD* state; DWORD* state;
}CheatTracker; }CheatTracker;
int WinSearchCheatDatabase()
{
std::string filename;
int result;
int reason = 0;
filename = S9xGetDirectory(CHEAT_DIR);
filename += "\\cheats.bml";
if (!(result = S9xImportCheatsFromDatabase(filename.c_str())))
{
return result;
}
if (result < reason)
reason = result;
filename = S9xGetDirectory(HOME_DIR);
filename += "\\cheats.bml";
if (!(result = S9xImportCheatsFromDatabase(filename.c_str())))
{
return result;
}
if (result < reason)
reason = result;
filename = S9xGetDirectory(ROM_DIR);
filename += "\\cheats.bml";
if (!(result = S9xImportCheatsFromDatabase(filename.c_str())))
{
return result;
}
if (result < reason)
reason = result;
MessageBox(GUI.hWnd,
reason == -1 ?
TEXT("The database file cheats.bml was not found. It is normally installed with "
"Snes9x, but you may also place a custom copy in your configuration or cheats directory.") :
TEXT("No matching game was found in the databases. If you are using a non-official "
"translation or modified copy, you may be able to find and manually enter the codes."),
reason == -1 ? TEXT("Couldn't Find Cheats Database") : TEXT("No Matching Game Found"),
MB_OK | MB_ICONEXCLAMATION);
return reason;
}
#define ITEM_QUERY(a, b, c, d, e) memset(&a, 0, sizeof(LV_ITEM)); \ #define ITEM_QUERY(a, b, c, d, e) memset(&a, 0, sizeof(LV_ITEM)); \
a.iItem= ListView_GetSelectionMark(GetDlgItem(hDlg, b)); \ a.iItem= ListView_GetSelectionMark(GetDlgItem(hDlg, b)); \
a.iSubItem=c; \ a.iSubItem=c; \
@ -8515,7 +8568,7 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
col.mask=LVCF_FMT|LVCF_ORDER|LVCF_TEXT|LVCF_WIDTH; col.mask=LVCF_FMT|LVCF_ORDER|LVCF_TEXT|LVCF_WIDTH;
col.fmt=LVCFMT_LEFT; col.fmt=LVCFMT_LEFT;
col.iOrder=0; col.iOrder=0;
col.cx=70; col.cx=100;
col.pszText=temp; col.pszText=temp;
ListView_InsertColumn(GetDlgItem(hDlg,IDC_CHEAT_LIST), 0, &col); ListView_InsertColumn(GetDlgItem(hDlg,IDC_CHEAT_LIST), 0, &col);
@ -8525,7 +8578,7 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
col.mask=LVCF_FMT|LVCF_ORDER|LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM; col.mask=LVCF_FMT|LVCF_ORDER|LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM;
col.fmt=LVCFMT_LEFT; col.fmt=LVCFMT_LEFT;
col.iOrder=2; col.iOrder=2;
col.cx=165; col.cx=300;
col.pszText=temp; col.pszText=temp;
col.iSubItem=2; col.iSubItem=2;
@ -8761,11 +8814,21 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
internal_change = true; internal_change = true;
SetDlgItemText(hDlg,IDC_CHEAT_CODE,TEXT("")); SetDlgItemText(hDlg,IDC_CHEAT_CODE,TEXT(""));
SetDlgItemText(hDlg,IDC_CHEAT_DESCRIPTION,TEXT("")); SetDlgItemText(hDlg,IDC_CHEAT_DESCRIPTION,TEXT(""));
internal_change = false;
ListView_SetItemState(GetDlgItem(hDlg, IDC_CHEAT_LIST),sel_idx, 0, LVIS_SELECTED|LVIS_FOCUSED); ListView_SetItemState(GetDlgItem(hDlg, IDC_CHEAT_LIST),sel_idx, 0, LVIS_SELECTED|LVIS_FOCUSED);
ListView_SetSelectionMark(GetDlgItem(hDlg, IDC_CHEAT_LIST), -1); ListView_SetSelectionMark(GetDlgItem(hDlg, IDC_CHEAT_LIST), -1);
sel_idx=-1; sel_idx=-1;
has_sel=false; has_sel=false;
break; break;
case IDC_SEARCH_DB:
if (MessageBox(hDlg,
TEXT("This will apply current changes from the cheat dialog, try to import cheats from the cheat database, then reopen the dialog."),
TEXT("Search Database"),
MB_OKCANCEL | MB_ICONINFORMATION) == IDOK)
{
PostMessage(hDlg, WM_COMMAND, MAKEWPARAM(IDOK, NC_SEARCHDB), (LPARAM)GetDlgItem(hDlg, IDOK));
}
break;
case IDC_CHEAT_CODE: case IDC_CHEAT_CODE:
{ {
uint32 j, k; uint32 j, k;
@ -8897,7 +8960,7 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
case IDCANCEL: case IDCANCEL:
delete [] ct.index; delete [] ct.index;
delete [] ct.state; delete [] ct.state;
EndDialog(hDlg, 0); EndDialog(hDlg, HIWORD(wParam) == NC_SEARCHDB ? NC_SEARCHDB : 0);
return true; return true;
default: default:
return false; return false;