From dfc951fbbbc6021838f38da3d94396212a1bd60e Mon Sep 17 00:00:00 2001 From: degasus Date: Tue, 2 Jun 2015 23:40:02 +0200 Subject: [PATCH] Hotkey: move some code into ParseHotkey --- Source/Core/Core/CoreParameter.h | 2 + Source/Core/DolphinWX/Frame.cpp | 76 ++++++++++++-------------------- 2 files changed, 30 insertions(+), 48 deletions(-) diff --git a/Source/Core/Core/CoreParameter.h b/Source/Core/Core/CoreParameter.h index 7be02ce6f6..43d758bbad 100644 --- a/Source/Core/Core/CoreParameter.h +++ b/Source/Core/Core/CoreParameter.h @@ -111,6 +111,8 @@ enum Hotkey HK_LOAD_LAST_STATE_6, HK_LOAD_LAST_STATE_7, HK_LOAD_LAST_STATE_8, + HK_LOAD_LAST_STATE_9, + HK_LOAD_LAST_STATE_10, HK_SAVE_FIRST_STATE, HK_UNDO_LOAD_STATE, diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 27aec09d9d..e541ace507 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -1262,8 +1262,7 @@ void CFrame::PollHotkeys(wxTimerEvent& event) void CFrame::ParseHotkeys() { - unsigned int i = 0; - for (i = 0; i < NUM_HOTKEYS; i++) + for (int i = 0; i < NUM_HOTKEYS; i++) { switch (i) { @@ -1277,43 +1276,8 @@ void CFrame::ParseHotkeys() case HK_EXPORT_RECORDING: case HK_READ_ONLY_MODE: - case HK_LOAD_STATE_SLOT_1: - case HK_LOAD_STATE_SLOT_2: - case HK_LOAD_STATE_SLOT_3: - case HK_LOAD_STATE_SLOT_4: - case HK_LOAD_STATE_SLOT_5: - case HK_LOAD_STATE_SLOT_6: - case HK_LOAD_STATE_SLOT_7: - case HK_LOAD_STATE_SLOT_8: - case HK_LOAD_STATE_SLOT_9: - case HK_LOAD_STATE_SLOT_10: - - case HK_SAVE_STATE_SLOT_1: - case HK_SAVE_STATE_SLOT_2: - case HK_SAVE_STATE_SLOT_3: - case HK_SAVE_STATE_SLOT_4: - case HK_SAVE_STATE_SLOT_5: - case HK_SAVE_STATE_SLOT_6: - case HK_SAVE_STATE_SLOT_7: - case HK_SAVE_STATE_SLOT_8: - case HK_SAVE_STATE_SLOT_9: - case HK_SAVE_STATE_SLOT_10: - - case HK_LOAD_LAST_STATE_1: - case HK_LOAD_LAST_STATE_2: - case HK_LOAD_LAST_STATE_3: - case HK_LOAD_LAST_STATE_4: - case HK_LOAD_LAST_STATE_5: - case HK_LOAD_LAST_STATE_6: - case HK_LOAD_LAST_STATE_7: - case HK_LOAD_LAST_STATE_8: - - case HK_SAVE_FIRST_STATE: - case HK_UNDO_LOAD_STATE: - case HK_UNDO_SAVE_STATE: case HK_LOAD_STATE_FILE: case HK_SAVE_STATE_FILE: - case HK_LOAD_STATE_SLOT_SELECTED: if (IsHotkey(i)) @@ -1337,7 +1301,7 @@ void CFrame::ParseHotkeys() } } - if (Core::GetState() == Core::CORE_UNINITIALIZED) + if (!Core::IsRunningAndStarted()) { return; } @@ -1461,16 +1425,6 @@ void CFrame::ParseHotkeys() g_Config.iStereoConvergence = 500; } - for (i = HK_SELECT_STATE_SLOT_1; i < HK_SELECT_STATE_SLOT_10; ++i) - { - if (IsHotkey(i)) - { - wxCommandEvent slot_event; - slot_event.SetId(i + IDM_SELECT_SLOT_1 - HK_SELECT_STATE_SLOT_1); - CFrame::OnSelectSlot(slot_event); - } - } - static float debugSpeed = 1.0f; if (IsHotkey(HK_FREELOOK_DECREASE_SPEED, true)) debugSpeed /= 1.1f; @@ -1492,4 +1446,30 @@ void CFrame::ParseHotkeys() VertexShaderManager::TranslateView(0.0f, -debugSpeed); if (IsHotkey(HK_FREELOOK_RESET, true)) VertexShaderManager::ResetView(); + + // Savestates + for (int i = 0; i < 10; i++) + { + if (IsHotkey(HK_LOAD_STATE_SLOT_1 + i)) + State::Load(1 + i); + + if (IsHotkey(HK_SAVE_STATE_SLOT_1 + i)) + State::Save(1 + i); + + if (IsHotkey(HK_LOAD_LAST_STATE_1 + i)) + State::LoadLastSaved(1 + i); + + if (IsHotkey(HK_SELECT_STATE_SLOT_1 + i)) + { + wxCommandEvent slot_event; + slot_event.SetId(i + IDM_SELECT_SLOT_1 - HK_SELECT_STATE_SLOT_1); + CFrame::OnSelectSlot(slot_event); + } + } + if (IsHotkey(HK_SAVE_FIRST_STATE)) + State::SaveFirstSaved(); + if (IsHotkey(HK_UNDO_LOAD_STATE)) + State::UndoLoadState(); + if (IsHotkey(HK_UNDO_SAVE_STATE)) + State::UndoSaveState(); }