From ce5459bc696313e9f36447cd113de10846eb6089 Mon Sep 17 00:00:00 2001 From: OV2 Date: Sat, 5 May 2018 15:51:45 +0200 Subject: [PATCH] win32: add hotkeys for saving/loading from file --- win32/InputCustom.cpp | 6 ++- win32/rsrc/snes9x.rc | 99 +++++++++++++++++++++++-------------------- win32/wconfig.cpp | 1 + win32/wlanguage.h | 2 + win32/wsnes9x.cpp | 28 +++++++++--- win32/wsnes9x.h | 2 + 6 files changed, 84 insertions(+), 54 deletions(-) diff --git a/win32/InputCustom.cpp b/win32/InputCustom.cpp index 437b441f..4d1e824f 100644 --- a/win32/InputCustom.cpp +++ b/win32/InputCustom.cpp @@ -702,8 +702,10 @@ int GetNumHotKeysAssignedTo (WORD Key, int modifiers) if(MATCHES_KEY(TurboDown)) count++; if(MATCHES_KEY(ResetGame)) count++; if(MATCHES_KEY(ToggleCheats)) count++; - if(MATCHES_KEY(QuitS9X)) count++; - if(MATCHES_KEY(Rewind)) count++; + if(MATCHES_KEY(QuitS9X)) count++; + if(MATCHES_KEY(Rewind)) count++; + if(MATCHES_KEY(SaveFileSelect)) count++; + if(MATCHES_KEY(LoadFileSelect)) count++; #undef MATCHES_KEY } diff --git a/win32/rsrc/snes9x.rc b/win32/rsrc/snes9x.rc index a28a41a6..90ccdaec 100644 --- a/win32/rsrc/snes9x.rc +++ b/win32/rsrc/snes9x.rc @@ -442,60 +442,60 @@ BEGIN END IDD_KEYCUSTOM DIALOGEX 0, 0, 349, 203 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_CLIPCHILDREN | WS_CAPTION +STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CLIPCHILDREN | WS_CAPTION CAPTION "Customize Special Keys" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN PUSHBUTTON "Cancel",IDCANCEL,66,182,50,14 PUSHBUTTON "OK",IDOK,16,182,50,14 - RTEXT "speed +",IDC_LABEL_HK1,4,8,58,8 - RTEXT "frame advance",IDC_LABEL_HK4,2,47,59,8 + RTEXT "speed +",IDC_LABEL_HK1,3,8,59,8 + RTEXT "frame advance",IDC_LABEL_HK4,3,47,59,8 RTEXT "speed -",IDC_LABEL_HK2,3,21,59,8 - RTEXT "pause",IDC_LABEL_HK3,2,34,60,8 - RTEXT "skip +",IDC_LABEL_HK6,2,74,60,8 - RTEXT "movie frame count",IDC_LABEL_HK11,0,138,62,8 - RTEXT "superscope turbo",IDC_LABEL_HK8,0,98,62,8 + RTEXT "pause",IDC_LABEL_HK3,3,34,59,8 + RTEXT "skip +",IDC_LABEL_HK6,3,74,59,8 + RTEXT "movie frame count",IDC_LABEL_HK11,3,138,59,8 + RTEXT "superscope turbo",IDC_LABEL_HK8,3,98,59,8 RTEXT "movie read-only",IDC_LABEL_HK12,3,150,59,8 - RTEXT "superscope pause",IDC_LABEL_HK9,2,111,60,8 + RTEXT "superscope pause",IDC_LABEL_HK9,3,111,59,8 RTEXT "skip -",IDC_LABEL_HK7,3,85,59,8 - CONTROL "",IDC_HOTKEY1,"InputCustomHot",WS_TABSTOP,66,5,98,12,WS_EX_CLIENTEDGE - CONTROL "",IDC_HOTKEY2,"InputCustomHot",WS_TABSTOP,66,18,98,12,WS_EX_CLIENTEDGE - CONTROL "",IDC_HOTKEY3,"InputCustomHot",WS_TABSTOP,66,31,98,12,WS_EX_CLIENTEDGE + CONTROL "",IDC_HOTKEY1,"InputCustomHot",WS_TABSTOP,66,6,98,12,WS_EX_CLIENTEDGE + CONTROL "",IDC_HOTKEY2,"InputCustomHot",WS_TABSTOP,66,19,98,12,WS_EX_CLIENTEDGE + CONTROL "",IDC_HOTKEY3,"InputCustomHot",WS_TABSTOP,66,32,98,12,WS_EX_CLIENTEDGE CONTROL "",IDC_HOTKEY4,"InputCustomHot",WS_TABSTOP,66,45,98,12,WS_EX_CLIENTEDGE CONTROL "",IDC_HOTKEY5,"InputCustomHot",WS_TABSTOP,66,58,98,12,WS_EX_CLIENTEDGE - CONTROL "",IDC_HOTKEY6,"InputCustomHot",WS_TABSTOP,66,70,98,12,WS_EX_CLIENTEDGE - CONTROL "",IDC_HOTKEY7,"InputCustomHot",WS_TABSTOP,66,83,98,12,WS_EX_CLIENTEDGE - CONTROL "",IDC_HOTKEY8,"InputCustomHot",WS_TABSTOP,66,96,98,12,WS_EX_CLIENTEDGE - CONTROL "",IDC_HOTKEY9,"InputCustomHot",WS_TABSTOP,66,109,98,12,WS_EX_CLIENTEDGE - CONTROL "",IDC_HOTKEY10,"InputCustomHot",WS_TABSTOP,66,122,98,12,WS_EX_CLIENTEDGE - CONTROL "",IDC_HOTKEY11,"InputCustomHot",WS_TABSTOP,66,135,98,12,WS_EX_CLIENTEDGE + CONTROL "",IDC_HOTKEY6,"InputCustomHot",WS_TABSTOP,66,71,98,12,WS_EX_CLIENTEDGE + CONTROL "",IDC_HOTKEY7,"InputCustomHot",WS_TABSTOP,66,84,98,12,WS_EX_CLIENTEDGE + CONTROL "",IDC_HOTKEY8,"InputCustomHot",WS_TABSTOP,66,97,98,12,WS_EX_CLIENTEDGE + CONTROL "",IDC_HOTKEY9,"InputCustomHot",WS_TABSTOP,66,110,98,12,WS_EX_CLIENTEDGE + CONTROL "",IDC_HOTKEY10,"InputCustomHot",WS_TABSTOP,66,123,98,12,WS_EX_CLIENTEDGE + CONTROL "",IDC_HOTKEY11,"InputCustomHot",WS_TABSTOP,66,136,98,12,WS_EX_CLIENTEDGE CONTROL "",IDC_HOTKEY12,"InputCustomHot",WS_TABSTOP,66,149,98,12,WS_EX_CLIENTEDGE CONTROL "",IDC_HOTKEY13,"InputCustomHot",WS_TABSTOP,66,162,98,12,WS_EX_CLIENTEDGE - CONTROL "",IDC_SAVE1,"InputCustomHot",WS_TABSTOP,192,5,60,12,WS_EX_CLIENTEDGE - RTEXT "save1",IDC_LABEL_UP2,170,21,20,8 - CONTROL "",IDC_SAVE2,"InputCustomHot",WS_TABSTOP,192,18,60,12,WS_EX_CLIENTEDGE - RTEXT "save2",IDC_LABEL_UP3,170,34,20,8 - CONTROL "",IDC_SAVE3,"InputCustomHot",WS_TABSTOP,192,31,60,12,WS_EX_CLIENTEDGE - RTEXT "save3",IDC_LABEL_UP4,170,47,20,8 + CONTROL "",IDC_SAVE1,"InputCustomHot",WS_TABSTOP,192,6,60,12,WS_EX_CLIENTEDGE + RTEXT "save1",IDC_LABEL_UP2,166,21,23,8 + CONTROL "",IDC_SAVE2,"InputCustomHot",WS_TABSTOP,192,19,60,12,WS_EX_CLIENTEDGE + RTEXT "save2",IDC_LABEL_UP3,166,34,23,8 + CONTROL "",IDC_SAVE3,"InputCustomHot",WS_TABSTOP,192,32,60,12,WS_EX_CLIENTEDGE + RTEXT "save3",IDC_LABEL_UP4,166,47,23,8 CONTROL "",IDC_SAVE4,"InputCustomHot",WS_TABSTOP,192,45,60,12,WS_EX_CLIENTEDGE - RTEXT "save4",IDC_LABEL_UP5,170,58,20,8 + RTEXT "save4",IDC_LABEL_UP5,166,58,23,8 CONTROL "",IDC_SAVE5,"InputCustomHot",WS_TABSTOP,192,58,60,12,WS_EX_CLIENTEDGE - RTEXT "save5",IDC_LABEL_UP6,170,72,20,8 + RTEXT "save5",IDC_LABEL_UP6,166,72,23,8 CONTROL "",IDC_SAVE6,"InputCustomHot",WS_TABSTOP,192,71,60,12,WS_EX_CLIENTEDGE - RTEXT "save6",IDC_LABEL_UP7,170,85,20,8 - CONTROL "",IDC_SAVE7,"InputCustomHot",WS_TABSTOP,192,82,60,12,WS_EX_CLIENTEDGE - RTEXT "save7",IDC_LABEL_UP8,170,98,20,8 - CONTROL "",IDC_SAVE8,"InputCustomHot",WS_TABSTOP,192,96,60,12,WS_EX_CLIENTEDGE - RTEXT "save8",IDC_LABEL_UP9,170,112,20,8 - CONTROL "",IDC_SAVE9,"InputCustomHot",WS_TABSTOP,192,109,60,12,WS_EX_CLIENTEDGE - RTEXT "save9",IDC_LABEL_UP10,170,125,20,8 - CONTROL "",IDC_SAVE10,"InputCustomHot",WS_TABSTOP,192,122,60,12,WS_EX_CLIENTEDGE - RTEXT "save0",IDC_LABEL_UP11,170,8,20,8 - CONTROL "",IDC_SAVE11,"InputCustomHot",WS_TABSTOP,279,5,60,12,WS_EX_CLIENTEDGE + RTEXT "save6",IDC_LABEL_UP7,166,85,23,8 + CONTROL "",IDC_SAVE7,"InputCustomHot",WS_TABSTOP,192,84,60,12,WS_EX_CLIENTEDGE + RTEXT "save7",IDC_LABEL_UP8,166,98,23,8 + CONTROL "",IDC_SAVE8,"InputCustomHot",WS_TABSTOP,192,97,60,12,WS_EX_CLIENTEDGE + RTEXT "save8",IDC_LABEL_UP9,166,112,23,8 + CONTROL "",IDC_SAVE9,"InputCustomHot",WS_TABSTOP,192,110,60,12,WS_EX_CLIENTEDGE + RTEXT "save9",IDC_LABEL_UP10,166,125,23,8 + CONTROL "",IDC_SAVE10,"InputCustomHot",WS_TABSTOP,192,123,60,12,WS_EX_CLIENTEDGE + RTEXT "save0",IDC_LABEL_UP11,166,8,23,8 + CONTROL "",IDC_SAVE11,"InputCustomHot",WS_TABSTOP,279,6,60,12,WS_EX_CLIENTEDGE RTEXT "load1",IDC_LABEL_UP12,257,21,20,8 - CONTROL "",IDC_SAVE12,"InputCustomHot",WS_TABSTOP,279,18,60,12,WS_EX_CLIENTEDGE + CONTROL "",IDC_SAVE12,"InputCustomHot",WS_TABSTOP,279,19,60,12,WS_EX_CLIENTEDGE RTEXT "load2",IDC_LABEL_UP13,257,34,20,8 - CONTROL "",IDC_SAVE13,"InputCustomHot",WS_TABSTOP,279,31,60,12,WS_EX_CLIENTEDGE + CONTROL "",IDC_SAVE13,"InputCustomHot",WS_TABSTOP,279,32,60,12,WS_EX_CLIENTEDGE RTEXT "load3",IDC_LABEL_UP14,257,48,20,8 CONTROL "",IDC_SAVE14,"InputCustomHot",WS_TABSTOP,279,45,60,12,WS_EX_CLIENTEDGE RTEXT "load4",IDC_LABEL_UP15,257,61,20,8 @@ -503,24 +503,24 @@ BEGIN RTEXT "load5",IDC_LABEL_UP16,257,72,20,8 CONTROL "",IDC_SAVE16,"InputCustomHot",WS_TABSTOP,279,71,60,12,WS_EX_CLIENTEDGE RTEXT "load6",IDC_LABEL_UP17,257,85,20,8 - CONTROL "",IDC_SAVE17,"InputCustomHot",WS_TABSTOP,279,82,60,12,WS_EX_CLIENTEDGE + CONTROL "",IDC_SAVE17,"InputCustomHot",WS_TABSTOP,279,84,60,12,WS_EX_CLIENTEDGE RTEXT "load7",IDC_LABEL_UP18,257,98,20,8 - CONTROL "",IDC_SAVE18,"InputCustomHot",WS_TABSTOP,279,96,60,12,WS_EX_CLIENTEDGE + CONTROL "",IDC_SAVE18,"InputCustomHot",WS_TABSTOP,279,97,60,12,WS_EX_CLIENTEDGE RTEXT "load8",IDC_LABEL_UP19,257,111,20,8 - CONTROL "",IDC_SAVE19,"InputCustomHot",WS_TABSTOP,279,109,60,12,WS_EX_CLIENTEDGE + CONTROL "",IDC_SAVE19,"InputCustomHot",WS_TABSTOP,279,110,60,12,WS_EX_CLIENTEDGE RTEXT "load9",IDC_LABEL_UP20,257,125,20,8 - CONTROL "",IDC_SAVE20,"InputCustomHot",WS_TABSTOP,279,122,60,12,WS_EX_CLIENTEDGE + CONTROL "",IDC_SAVE20,"InputCustomHot",WS_TABSTOP,279,123,60,12,WS_EX_CLIENTEDGE RTEXT "load0",IDC_LABEL_UP21,257,8,20,8 - RTEXT "fast forward",IDC_LABEL_HK5,3,61,58,8 - RTEXT "show pressed keys",IDC_LABEL_HK10,1,125,61,8 + RTEXT "fast forward",IDC_LABEL_HK5,3,61,59,8 + RTEXT "show pressed keys",IDC_LABEL_HK10,3,125,59,8 RTEXT "save screenshot",IDC_LABEL_HK13,3,163,59,8 - RTEXT "slot-",IDC_LABEL_UP22,170,138,20,8 - CONTROL "",IDC_SLOTMINUS,"InputCustomHot",WS_TABSTOP,192,135,60,12,WS_EX_CLIENTEDGE + RTEXT "slot-",IDC_LABEL_UP22,166,138,23,8 + CONTROL "",IDC_SLOTMINUS,"InputCustomHot",WS_TABSTOP,192,136,60,12,WS_EX_CLIENTEDGE RTEXT "slot+",IDC_LABEL_UP23,257,138,20,8 - CONTROL "",IDC_SLOTPLUS,"InputCustomHot",WS_TABSTOP,279,135,60,12,WS_EX_CLIENTEDGE + CONTROL "",IDC_SLOTPLUS,"InputCustomHot",WS_TABSTOP,279,136,60,12,WS_EX_CLIENTEDGE RTEXT "save#",IDC_LABEL_UP24,166,151,23,8 CONTROL "",IDC_SLOTSAVE,"InputCustomHot",WS_TABSTOP,192,149,60,12,WS_EX_CLIENTEDGE - RTEXT "load#",IDC_LABEL_UP25,253,151,23,8 + RTEXT "load#",IDC_LABEL_UP25,257,151,20,8 CONTROL "",IDC_SLOTLOAD,"InputCustomHot",WS_TABSTOP,279,149,60,12,WS_EX_CLIENTEDGE LTEXT "Blue means the hotkey is already mapped.\nPink means it conflicts with a game button.\nRed means it's reserved by Windows.\nA hotkey can be disabled using Escape.",IDC_LABEL_BLUE,208,164,136,32 COMBOBOX IDC_HKCOMBO,134,183,60,60,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP @@ -1007,6 +1007,11 @@ BEGIN 0 END +IDD_KEYCUSTOM AFX_DIALOG_LAYOUT +BEGIN + 0 +END + #endif // English (United States) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/win32/wconfig.cpp b/win32/wconfig.cpp index 2a817bcb..922cf0da 100644 --- a/win32/wconfig.cpp +++ b/win32/wconfig.cpp @@ -1059,6 +1059,7 @@ void WinRegisterConfigItems() /*ADD(InterpMode7);*/ ADD(JoypadSwap); ADD(SwitchControllers); ADD(ResetGame); ADD(ToggleCheats); ADD(TurboA); ADD(TurboB); ADD(TurboY); ADD(TurboX); ADD(TurboL); ADD(TurboR); ADD(TurboStart); ADD(TurboSelect); ADD(TurboUp); ADD(TurboDown); ADD(TurboLeft); ADD(TurboRight); ADD(QuitS9X);ADD(Rewind); + ADD(SaveFileSelect); ADD(LoadFileSelect); #undef ADD #undef ADDN #undef CATEGORY diff --git a/win32/wlanguage.h b/win32/wlanguage.h index 5201e616..a1dce2da 100644 --- a/win32/wlanguage.h +++ b/win32/wlanguage.h @@ -305,6 +305,8 @@ Nintendo is a trade mark.") #define HOTKEYS_LABEL_3_11 TEXT("Turbo Right mode") #define HOTKEYS_LABEL_3_12 TEXT("Turbo Down mode") //#define HOTKEYS_LABEL_4_12 "Interpolate Mode 7" +#define HOTKEYS_LABEL_4_11 TEXT("Save To File") +#define HOTKEYS_LABEL_4_12 TEXT("Load From File") #define HOTKEYS_LABEL_4_13 TEXT("Quit Snes9x") // gaming buttons and axes diff --git a/win32/wsnes9x.cpp b/win32/wsnes9x.cpp index 13d118ad..0157b5d5 100644 --- a/win32/wsnes9x.cpp +++ b/win32/wsnes9x.cpp @@ -1297,7 +1297,21 @@ int HandleKeyMessage(WPARAM wParam, LPARAM lParam) if(!GUI.rewinding) S9xMessage (S9X_INFO, 0, GUI.rewindBufferSize?WINPROC_REWINDING_TEXT:WINPROC_REWINDING_DISABLED); GUI.rewinding = true; + hitHotKey = true; } + + if (wParam == CustomKeys.SaveFileSelect.key + && modifiers == CustomKeys.SaveFileSelect.modifiers) + { + FreezeUnfreezeDialog(TRUE); + hitHotKey = true; + } + if (wParam == CustomKeys.LoadFileSelect.key + && modifiers == CustomKeys.LoadFileSelect.modifiers) + { + FreezeUnfreezeDialog(FALSE); + hitHotKey = true; + } //if(wParam == CustomKeys.BGLHack.key //&& modifiers == CustomKeys.BGLHack.modifiers) //{ @@ -3692,6 +3706,9 @@ loop_exit: void FreezeUnfreezeDialog(bool8 freeze) { + if (Settings.StopEmulation) + return; + TCHAR filename[MAX_PATH]; OPENFILENAME ofn; @@ -8152,8 +8169,8 @@ static void set_hotkeyinfo(HWND hDlg) case 3: for(int i = 0 ; i < 10 ; i++) SendDlgItemMessage(hDlg,IDC_HOTKEY1+i,WM_USER+44,CustomKeys.SelectSave[i].key,CustomKeys.SelectSave[i].modifiers); - SendDlgItemMessage(hDlg,IDC_HOTKEY11,WM_USER+44,0,0); - SendDlgItemMessage(hDlg,IDC_HOTKEY12,WM_USER+44,0,0); + SendDlgItemMessage(hDlg,IDC_HOTKEY11,WM_USER+44, CustomKeys.SaveFileSelect.key, CustomKeys.SaveFileSelect.modifiers); + SendDlgItemMessage(hDlg,IDC_HOTKEY12,WM_USER+44, CustomKeys.LoadFileSelect.key, CustomKeys.LoadFileSelect.modifiers); SendDlgItemMessage(hDlg,IDC_HOTKEY13,WM_USER+44,CustomKeys.QuitS9X.key,CustomKeys.QuitS9X.modifiers); break; } @@ -8222,8 +8239,8 @@ static void set_hotkeyinfo(HWND hDlg) _stprintf(temp, TEXT("Select Slot %d"), i); SetDlgItemText(hDlg,IDC_LABEL_HK1+i,temp); } - for(int i = 10 ; i < 12 ; i++) - SetDlgItemText(hDlg,IDC_LABEL_HK1+i,INPUTCONFIG_LABEL_UNUSED); + SetDlgItemText(hDlg, IDC_LABEL_HK11, HOTKEYS_LABEL_4_11); + SetDlgItemText(hDlg, IDC_LABEL_HK12, HOTKEYS_LABEL_4_12); SetDlgItemText(hDlg,IDC_LABEL_HK13,HOTKEYS_LABEL_4_13); break; @@ -8372,12 +8389,13 @@ switch(msg) if(index == 0) CustomKeys.FrameCount.key = wParam, CustomKeys.FrameCount.modifiers = modifiers; if(index == 1) CustomKeys.JoypadSwap.key = wParam, CustomKeys.JoypadSwap.modifiers = modifiers; if(index == 2) CustomKeys.TurboRight.key = wParam, CustomKeys.TurboRight.modifiers = modifiers; + if(index == 3) CustomKeys.SaveFileSelect.key = wParam, CustomKeys.SaveFileSelect.modifiers = modifiers; break; case IDC_HOTKEY12: if(index == 0) CustomKeys.ReadOnly.key = wParam, CustomKeys.ReadOnly.modifiers = modifiers; if(index == 1) CustomKeys.ResetGame.key = wParam, CustomKeys.ResetGame.modifiers = modifiers; if(index == 2) CustomKeys.TurboDown.key = wParam, CustomKeys.TurboDown.modifiers = modifiers; -// if(index == 3) CustomKeys.InterpMode7.key = wParam, CustomKeys.InterpMode7.modifiers = modifiers; + if(index == 3) CustomKeys.LoadFileSelect.key = wParam, CustomKeys.LoadFileSelect.modifiers = modifiers; break; case IDC_HOTKEY13: if(index == 0) CustomKeys.SaveScreenShot.key = wParam, CustomKeys.SaveScreenShot.modifiers = modifiers; diff --git a/win32/wsnes9x.h b/win32/wsnes9x.h index 3413c0b9..10256b15 100644 --- a/win32/wsnes9x.h +++ b/win32/wsnes9x.h @@ -496,6 +496,8 @@ struct SCustomKeys { SCustomKey ToggleCheats; SCustomKey QuitS9X; SCustomKey Rewind; + SCustomKey SaveFileSelect; + SCustomKey LoadFileSelect; }; struct SJoypad {