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
This commit is contained in:
Tyler Wilding 2020-09-14 20:26:26 -04:00 committed by refractionpcsx2
parent 1954c2ce09
commit 0df056ac61
5 changed files with 44 additions and 11 deletions

View File

@ -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 )

View File

@ -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");
}

View File

@ -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

View File

@ -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:

View File

@ -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)