From 0df056ac614fa42e1200d270b50e2cc24541f863 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Mon, 14 Sep 2020 20:26:26 -0400 Subject: [PATCH] pcsx2-gui: Enable and disable new recording menu items when appropriatewhen pcsx2-gui: Don't attempt to modify recording items if main frame is null pcsx2-gui: Add some help text for the recording options as well pcsx2-gui: Disable `Toggle Recording Mode` if no recording is active --- pcsx2/gui/AppMain.cpp | 16 ++++++++++++++++ pcsx2/gui/FrameForGS.cpp | 13 ++++++++++--- pcsx2/gui/MainFrame.cpp | 20 +++++++++++++------- pcsx2/gui/MainFrame.h | 3 ++- pcsx2/gui/MainMenuClicks.cpp | 3 +++ 5 files changed, 44 insertions(+), 11 deletions(-) diff --git a/pcsx2/gui/AppMain.cpp b/pcsx2/gui/AppMain.cpp index f2e3222edb..3efbc3aa60 100644 --- a/pcsx2/gui/AppMain.cpp +++ b/pcsx2/gui/AppMain.cpp @@ -1019,6 +1019,13 @@ void Pcsx2App::OpenGsPanel() #endif gsFrame->ShowFullScreen( g_Conf->GSWindow.IsFullscreen ); + +#ifndef DISABLE_RECORDING + // Disable recording controls that only make sense if the game is running + sMainFrame.enableRecordingMenuItem(MenuId_Recording_FrameAdvance, true); + sMainFrame.enableRecordingMenuItem(MenuId_Recording_TogglePause, true); + sMainFrame.enableRecordingMenuItem(MenuId_Recording_ToggleRecordingMode, g_InputRecording.IsActive()); +#endif } void Pcsx2App::CloseGsPanel() @@ -1045,6 +1052,15 @@ void Pcsx2App::OnGsFrameClosed( wxWindowID id ) // right now there's no way to resume from suspend without GUI. PrepForExit(); } +#ifndef DISABLE_RECORDING + else + { + // Disable recording controls that only make sense if the game is running + sMainFrame.enableRecordingMenuItem(MenuId_Recording_FrameAdvance, false); + sMainFrame.enableRecordingMenuItem(MenuId_Recording_TogglePause, false); + sMainFrame.enableRecordingMenuItem(MenuId_Recording_ToggleRecordingMode, false); + } +#endif } void Pcsx2App::OnProgramLogClosed( wxWindowID id ) diff --git a/pcsx2/gui/FrameForGS.cpp b/pcsx2/gui/FrameForGS.cpp index a14ee4d644..8fe893289a 100644 --- a/pcsx2/gui/FrameForGS.cpp +++ b/pcsx2/gui/FrameForGS.cpp @@ -131,9 +131,16 @@ void GSPanel::InitRecordingAccelerators() m_Accels->Map(AAC(WXK_NUMPAD8), "States_LoadSlot8"); m_Accels->Map(AAC(WXK_NUMPAD9), "States_LoadSlot9"); - GetMainFramePtr()->appendKeycodeNamesToRecordingMenuOptions(MenuId_Recording_FrameAdvance, m_Accels->findKeycodeWithCommandId("FrameAdvance").toTitleizedString()); - GetMainFramePtr()->appendKeycodeNamesToRecordingMenuOptions(MenuId_Recording_TogglePause, m_Accels->findKeycodeWithCommandId("TogglePause").toTitleizedString()); - GetMainFramePtr()->appendKeycodeNamesToRecordingMenuOptions(MenuId_Recording_ToggleRecordingMode, m_Accels->findKeycodeWithCommandId("InputRecordingModeToggle").toTitleizedString()); + GetMainFramePtr()->initializeRecordingMenuItem( + MenuId_Recording_FrameAdvance, + m_Accels->findKeycodeWithCommandId("FrameAdvance").toTitleizedString()); + GetMainFramePtr()->initializeRecordingMenuItem( + MenuId_Recording_TogglePause, + m_Accels->findKeycodeWithCommandId("TogglePause").toTitleizedString()); + GetMainFramePtr()->initializeRecordingMenuItem( + MenuId_Recording_ToggleRecordingMode, + m_Accels->findKeycodeWithCommandId("InputRecordingModeToggle").toTitleizedString(), + g_InputRecording.IsActive()); recordingConLog(L"Initialized Recording Key Bindings\n"); } diff --git a/pcsx2/gui/MainFrame.cpp b/pcsx2/gui/MainFrame.cpp index 628201b655..e9c9a488b1 100644 --- a/pcsx2/gui/MainFrame.cpp +++ b/pcsx2/gui/MainFrame.cpp @@ -470,13 +470,13 @@ void MainEmuFrame::CreateCaptureMenu() void MainEmuFrame::CreateRecordMenu() { #ifndef DISABLE_RECORDING - m_menuRecording.Append(MenuId_Recording_New, _("New")); - m_menuRecording.Append(MenuId_Recording_Stop, _("Stop"))->Enable(false); - m_menuRecording.Append(MenuId_Recording_Play, _("Play")); + m_menuRecording.Append(MenuId_Recording_New, _("New"), _("Create a new input recording.")); + m_menuRecording.Append(MenuId_Recording_Stop, _("Stop"), _("Stop the active input recording."))->Enable(false); + m_menuRecording.Append(MenuId_Recording_Play, _("Play"), _("Playback an existing input recording.")); m_menuRecording.AppendSeparator(); - m_menuRecording.Append(MenuId_Recording_TogglePause, _("Toggle Pause")); - m_menuRecording.Append(MenuId_Recording_FrameAdvance, _("Frame Advance")); - m_menuRecording.Append(MenuId_Recording_ToggleRecordingMode, _("Toggle Recording Mode")); + m_menuRecording.Append(MenuId_Recording_TogglePause, _("Toggle Pause"), _("Pause or resume emulation on the fly."))->Enable(false); + m_menuRecording.Append(MenuId_Recording_FrameAdvance, _("Frame Advance"), _("Advance emulation forward by a single frame at a time."))->Enable(false); + m_menuRecording.Append(MenuId_Recording_ToggleRecordingMode, _("Toggle Recording Mode"), _("Save/playback inputs to/from the recording file."))->Enable(false); m_menuRecording.AppendSeparator(); m_menuRecording.Append(MenuId_Recording_VirtualPad_Port0, _("Virtual Pad (Port 1)")); m_menuRecording.Append(MenuId_Recording_VirtualPad_Port1, _("Virtual Pad (Port 2)")); @@ -796,11 +796,17 @@ void MainEmuFrame::AppendKeycodeNamesToMenuOptions() { } #ifndef DISABLE_RECORDING -void MainEmuFrame::appendKeycodeNamesToRecordingMenuOptions(MenuIdentifiers menuId, wxString keyCodeStr) { +void MainEmuFrame::initializeRecordingMenuItem(MenuIdentifiers menuId, wxString keyCodeStr, bool enable) { wxMenuItem& item = *m_menuRecording.FindChildItem(menuId); wxString text = item.GetItemLabel(); const size_t tabPos = text.rfind(L'\t'); item.SetItemLabel(text.Mid(0, tabPos ) + L"\t" + keyCodeStr); + item.Enable(enable); +} +void MainEmuFrame::enableRecordingMenuItem(MenuIdentifiers menuId, bool enable) +{ + wxMenuItem& item = *m_menuRecording.FindChildItem(menuId); + item.Enable(enable); } #endif diff --git a/pcsx2/gui/MainFrame.h b/pcsx2/gui/MainFrame.h index 42930abe6a..712eff3ff3 100644 --- a/pcsx2/gui/MainFrame.h +++ b/pcsx2/gui/MainFrame.h @@ -167,7 +167,8 @@ public: void AppendKeycodeNamesToMenuOptions(); void UpdateStatusBar(); #ifndef DISABLE_RECORDING - void appendKeycodeNamesToRecordingMenuOptions(MenuIdentifiers menuId, wxString keyCodeStr); + void initializeRecordingMenuItem(MenuIdentifiers menuId, wxString keyCodeStr, bool enable = true); + void enableRecordingMenuItem(MenuIdentifiers menuId, bool enable); #endif protected: diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp index a5fe89b43d..a31acfaecd 100644 --- a/pcsx2/gui/MainMenuClicks.cpp +++ b/pcsx2/gui/MainMenuClicks.cpp @@ -932,6 +932,7 @@ void MainEmuFrame::Menu_Recording_New_Click(wxCommandEvent &event) } m_menuRecording.FindChildItem(MenuId_Recording_New)->Enable(false); m_menuRecording.FindChildItem(MenuId_Recording_Stop)->Enable(true); + sMainFrame.enableRecordingMenuItem(MenuId_Recording_ToggleRecordingMode, g_InputRecording.IsActive()); } void MainEmuFrame::Menu_Recording_Play_Click(wxCommandEvent &event) @@ -963,6 +964,7 @@ void MainEmuFrame::Menu_Recording_Play_Click(wxCommandEvent &event) m_menuRecording.FindChildItem(MenuId_Recording_New)->Enable(false); m_menuRecording.FindChildItem(MenuId_Recording_Stop)->Enable(true); } + sMainFrame.enableRecordingMenuItem(MenuId_Recording_ToggleRecordingMode, g_InputRecording.IsActive()); } void MainEmuFrame::Menu_Recording_Stop_Click(wxCommandEvent &event) @@ -970,6 +972,7 @@ void MainEmuFrame::Menu_Recording_Stop_Click(wxCommandEvent &event) g_InputRecording.Stop(); m_menuRecording.FindChildItem(MenuId_Recording_New)->Enable(true); m_menuRecording.FindChildItem(MenuId_Recording_Stop)->Enable(false); + sMainFrame.enableRecordingMenuItem(MenuId_Recording_ToggleRecordingMode, g_InputRecording.IsActive()); } void MainEmuFrame::Menu_Recording_TogglePause_Click(wxCommandEvent& event)