GUI: Visually alter status bar and Boot menu option while an input recording is active

+ Defines GSPanel method for generating the string keycode for a command
This commit is contained in:
sonicfind 2021-02-23 00:06:21 -06:00 committed by refractionpcsx2
parent c664a48f26
commit ceb7eaaf47
4 changed files with 67 additions and 11 deletions

View File

@ -141,18 +141,23 @@ void GSPanel::InitRecordingAccelerators()
GetMainFramePtr()->initializeRecordingMenuItem( GetMainFramePtr()->initializeRecordingMenuItem(
MenuId_Recording_FrameAdvance, MenuId_Recording_FrameAdvance,
m_Accels->findKeycodeWithCommandId("FrameAdvance").toTitleizedString()); GetAssociatedKeyCode("FrameAdvance"));
GetMainFramePtr()->initializeRecordingMenuItem( GetMainFramePtr()->initializeRecordingMenuItem(
MenuId_Recording_TogglePause, MenuId_Recording_TogglePause,
m_Accels->findKeycodeWithCommandId("TogglePause").toTitleizedString()); GetAssociatedKeyCode("TogglePause"));
GetMainFramePtr()->initializeRecordingMenuItem( GetMainFramePtr()->initializeRecordingMenuItem(
MenuId_Recording_ToggleRecordingMode, MenuId_Recording_ToggleRecordingMode,
m_Accels->findKeycodeWithCommandId("InputRecordingModeToggle").toTitleizedString(), GetAssociatedKeyCode("InputRecordingModeToggle"),
g_InputRecording.IsActive()); g_InputRecording.IsActive());
inputRec::consoleLog("Initialized Input Recording Key Bindings"); inputRec::consoleLog("Initialized Input Recording Key Bindings");
} }
wxString GSPanel::GetAssociatedKeyCode(const char* id)
{
return m_Accels->findKeycodeWithCommandId(id).toTitleizedString();
}
void GSPanel::RemoveRecordingAccelerators() void GSPanel::RemoveRecordingAccelerators()
{ {
m_Accels.reset(new AcceleratorDictionary); m_Accels.reset(new AcceleratorDictionary);

View File

@ -29,6 +29,10 @@
#include "svnrev.h" #include "svnrev.h"
#include "Saveslots.h" #include "Saveslots.h"
#ifndef DISABLE_RECORDING
# include "Recording/InputRecording.h"
#endif
#include "fmt/core.h" #include "fmt/core.h"
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -65,11 +69,18 @@ void MainEmuFrame::UpdateStatusBar()
{ {
wxString temp(wxEmptyString); wxString temp(wxEmptyString);
if (g_Conf->EnableFastBoot) #ifndef DISABLE_RECORDING
temp += "Fast Boot - "; if (g_InputRecording.IsActive() && g_InputRecording.GetInputRecordingData().FromSaveState())
temp += "Base Savestate - " + g_InputRecording.GetInputRecordingData().GetFilename() + "_SaveState.p2s";
else
#endif
{
if (g_Conf->EnableFastBoot)
temp += "Fast Boot - ";
if (g_Conf->CdvdSource == CDVD_SourceType::Iso) if (g_Conf->CdvdSource == CDVD_SourceType::Iso)
temp += "Load: '" + wxFileName(g_Conf->CurrentIso).GetFullName() + "' "; temp += "Load: '" + wxFileName(g_Conf->CurrentIso).GetFullName() + "' ";
}
m_statusbar.SetStatusText(temp, 0); m_statusbar.SetStatusText(temp, 0);
m_statusbar.SetStatusText(CDVD_SourceLabels[enum_cast(g_Conf->CdvdSource)], 1); m_statusbar.SetStatusText(CDVD_SourceLabels[enum_cast(g_Conf->CdvdSource)], 1);
@ -100,6 +111,10 @@ void MainEmuFrame::UpdateCdvdSrcSelection()
jNO_DEFAULT jNO_DEFAULT
} }
sMenuBar.Check(cdsrc, true); sMenuBar.Check(cdsrc, true);
#ifndef DISABLE_RECORDING
if (!g_InputRecording.IsActive())
#endif
ApplyCDVDStatus();
UpdateStatusBar(); UpdateStatusBar();
} }
@ -348,7 +363,7 @@ void MainEmuFrame::DispatchEvent(const CoreThreadStatus& status)
{ {
if (!pxAssertMsg(GetMenuBar() != NULL, "Mainframe menu bar is NULL!")) if (!pxAssertMsg(GetMenuBar() != NULL, "Mainframe menu bar is NULL!"))
return; return;
ApplyCoreStatus(); ApplySuspendStatus();
} }
void MainEmuFrame::AppStatusEvent_OnSettingsApplied() void MainEmuFrame::AppStatusEvent_OnSettingsApplied()
@ -735,12 +750,16 @@ void MainEmuFrame::OnActivate(wxActivateEvent& evt)
void MainEmuFrame::ApplyCoreStatus() void MainEmuFrame::ApplyCoreStatus()
{ {
wxMenuBar& menubar(*GetMenuBar()); ApplySuspendStatus();
ApplyCDVDStatus();
}
void MainEmuFrame::ApplySuspendStatus()
{
// [TODO] : Ideally each of these items would bind a listener instance to the AppCoreThread // [TODO] : Ideally each of these items would bind a listener instance to the AppCoreThread
// dispatcher, and modify their states accordingly. This is just a hack (for now) -- air // dispatcher, and modify their states accordingly. This is just a hack (for now) -- air
if (wxMenuItem* susres = menubar.FindItem(MenuId_Sys_SuspendResume)) if (wxMenuItem* susres = GetMenuBar()->FindItem(MenuId_Sys_SuspendResume))
{ {
if (!CoreThread.IsClosing()) if (!CoreThread.IsClosing())
{ {
@ -766,10 +785,13 @@ void MainEmuFrame::ApplyCoreStatus()
// Re-init keybinding after changing the label. // Re-init keybinding after changing the label.
AppendShortcutToMenuOption(*susres, wxGetApp().GlobalAccels->findKeycodeWithCommandId("Sys_SuspendResume").toTitleizedString()); AppendShortcutToMenuOption(*susres, wxGetApp().GlobalAccels->findKeycodeWithCommandId("Sys_SuspendResume").toTitleizedString());
} }
}
void MainEmuFrame::ApplyCDVDStatus()
{
const CDVD_SourceType Source = g_Conf->CdvdSource; const CDVD_SourceType Source = g_Conf->CdvdSource;
wxMenuItem* cdvd_menu = menubar.FindItem(MenuId_Boot_CDVD); wxMenuItem* cdvd_menu = GetMenuBar()->FindItem(MenuId_Boot_CDVD);
wxString label; wxString label;
wxString help_text = _("Use fast boot to skip PS2 startup and splash screens."); wxString help_text = _("Use fast boot to skip PS2 startup and splash screens.");

View File

@ -163,7 +163,9 @@ public:
void CreateConfigMenu(); void CreateConfigMenu();
void CreateWindowsMenu(); void CreateWindowsMenu();
void CreateCaptureMenu(); void CreateCaptureMenu();
#ifndef DISABLE_RECORDING
void CreateRecordMenu(); void CreateRecordMenu();
#endif
void CreateHelpMenu(); void CreateHelpMenu();
bool Destroy(); bool Destroy();
@ -186,6 +188,8 @@ protected:
//Apply here is from config to GUI. //Apply here is from config to GUI.
void ApplySettings(); void ApplySettings();
void ApplyCoreStatus(); void ApplyCoreStatus();
void ApplySuspendStatus();
void ApplyCDVDStatus();
void InitLogBoxPosition(AppConfig::ConsoleLogOptions& conf); void InitLogBoxPosition(AppConfig::ConsoleLogOptions& conf);
@ -262,6 +266,7 @@ protected:
void Menu_Recording_New_Click(wxCommandEvent& event); void Menu_Recording_New_Click(wxCommandEvent& event);
void Menu_Recording_Play_Click(wxCommandEvent& event); void Menu_Recording_Play_Click(wxCommandEvent& event);
void Menu_Recording_Stop_Click(wxCommandEvent& event); void Menu_Recording_Stop_Click(wxCommandEvent& event);
void ApplyFirstFrameStatus();
void Menu_Recording_TogglePause_Click(wxCommandEvent& event); void Menu_Recording_TogglePause_Click(wxCommandEvent& event);
void Menu_Recording_FrameAdvance_Click(wxCommandEvent& event); void Menu_Recording_FrameAdvance_Click(wxCommandEvent& event);
void Menu_Recording_ToggleRecordingMode_Click(wxCommandEvent& event); void Menu_Recording_ToggleRecordingMode_Click(wxCommandEvent& event);

View File

@ -461,6 +461,10 @@ void MainEmuFrame::Menu_CdvdSource_Click(wxCommandEvent& event)
} }
SwapOrReset_CdvdSrc(this, newsrc); SwapOrReset_CdvdSrc(this, newsrc);
#ifndef DISABLE_RECORDING
if (!g_InputRecording.IsActive())
#endif
ApplyCDVDStatus();
} }
void MainEmuFrame::Menu_BootCdvd_Click(wxCommandEvent& event) void MainEmuFrame::Menu_BootCdvd_Click(wxCommandEvent& event)
@ -1020,6 +1024,24 @@ void MainEmuFrame::Menu_Recording_Play_Click(wxCommandEvent& event)
StartInputRecording(); StartInputRecording();
} }
void MainEmuFrame::ApplyFirstFrameStatus()
{
wxMenuItem* cdvd_menu = m_menuSys.FindChildItem(MenuId_Boot_CDVD);
wxString keyCodeStr;
if (GSFrame* gsFrame = wxGetApp().GetGsFramePtr())
if (GSPanel* viewport = gsFrame->GetViewport())
keyCodeStr = '\t' + viewport->GetAssociatedKeyCode(("GoToFirstFrame"));
cdvd_menu->SetItemLabel(L"Restart Recording" + keyCodeStr);
if (g_InputRecording.GetInputRecordingData().FromSaveState())
cdvd_menu->SetHelp(L"Loads the savestate that accompanies the active input recording");
else
cdvd_menu->SetHelp(L"Reboots Emulation");
UpdateStatusBar();
}
void MainEmuFrame::Menu_Recording_Stop_Click(wxCommandEvent& event) void MainEmuFrame::Menu_Recording_Stop_Click(wxCommandEvent& event)
{ {
StopInputRecording(); StopInputRecording();
@ -1030,6 +1052,7 @@ void MainEmuFrame::StartInputRecording()
m_menuRecording.FindChildItem(MenuId_Recording_New)->Enable(false); m_menuRecording.FindChildItem(MenuId_Recording_New)->Enable(false);
m_menuRecording.FindChildItem(MenuId_Recording_Stop)->Enable(true); m_menuRecording.FindChildItem(MenuId_Recording_Stop)->Enable(true);
m_menuRecording.FindChildItem(MenuId_Recording_ToggleRecordingMode)->Enable(true); m_menuRecording.FindChildItem(MenuId_Recording_ToggleRecordingMode)->Enable(true);
ApplyFirstFrameStatus();
} }
void MainEmuFrame::StopInputRecording() void MainEmuFrame::StopInputRecording()
@ -1040,6 +1063,7 @@ void MainEmuFrame::StopInputRecording()
m_menuRecording.FindChildItem(MenuId_Recording_New)->Enable(true); m_menuRecording.FindChildItem(MenuId_Recording_New)->Enable(true);
m_menuRecording.FindChildItem(MenuId_Recording_Stop)->Enable(false); m_menuRecording.FindChildItem(MenuId_Recording_Stop)->Enable(false);
m_menuRecording.FindChildItem(MenuId_Recording_ToggleRecordingMode)->Enable(false); m_menuRecording.FindChildItem(MenuId_Recording_ToggleRecordingMode)->Enable(false);
ApplyCDVDStatus();
} }
} }