Show default keyboard shortcuts in the menu next to Save State and Load State.

I can't figure out how to get the keycodes that have been modified by PCSX2_keys.ini, but this should give a decent base. I think you would just need to call AppendKeycodeNamesToMenuOptions again after GlobalAccels has been updated correctly, if I'm understanding this right, but I couldn't get it to work.
This commit is contained in:
Admiral H. Curtiss 2015-06-02 22:04:23 +02:00
parent 995ae51bf4
commit c9e9df95ac
2 changed files with 23 additions and 0 deletions

View File

@ -24,6 +24,9 @@
#include <wx/iconbndl.h>
#include <unordered_map>
#include "AppAccelerators.h"
#include "svnrev.h"
// ------------------------------------------------------------------------
@ -530,6 +533,7 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title)
ApplyCoreStatus();
ApplySettings();
AppendKeycodeNamesToMenuOptions();
}
MainEmuFrame::~MainEmuFrame() throw()
@ -696,6 +700,24 @@ void MainEmuFrame::CommitPreset_noTrigger()
g_Conf->EmuOptions.EnablePatches = menubar.IsChecked( MenuId_EnablePatches );
}
static void AppendShortcutToMenuOption( wxMenuItem& item, const char* id ) {
// this is NOT how a dictionary works but it has like 30 entries so this should still perform okay
auto* dict = &wxGetApp().GlobalAccels;
for ( auto it = ( *dict )->begin(); it != ( *dict )->end(); ++it ) {
if ( strcmp( it->second->Id, id ) == 0 ) {
wxString text = item.GetItemLabel();
size_t tabPos = text.rfind( L'\t' );
KeyAcceleratorCode keycode( (wxKeyCode)it->first );
item.SetItemLabel( text.Mid( 0, tabPos ) + L"\t" + keycode.ToString() );
}
}
}
void MainEmuFrame::AppendKeycodeNamesToMenuOptions() {
AppendShortcutToMenuOption( *m_menuSys.FindChildItem( MenuId_Sys_LoadStates ), "States_DefrostCurrentSlot" );
AppendShortcutToMenuOption( *m_menuSys.FindChildItem( MenuId_Sys_SaveStates ), "States_FreezeCurrentSlot" );
}
// ------------------------------------------------------------------------
// "Extensible" Plugin Menus

View File

@ -150,6 +150,7 @@ public:
void ApplyConfigToGui( AppConfig& configToApply, int flags=0 ); //flags are: AppConfig::APPLY_CONFIG_FROM_PRESET and (currently unused) AppConfig::APPLY_CONFIG_MANUALLY PROPAGATE
void CommitPreset_noTrigger();
void AppendKeycodeNamesToMenuOptions();
protected:
void DoGiveHelp(const wxString& text, bool show);