diff --git a/pcsx2/Recording/InputRecordingControls.cpp b/pcsx2/Recording/InputRecordingControls.cpp index 5b2c3d585e..1ffd33bd97 100644 --- a/pcsx2/Recording/InputRecordingControls.cpp +++ b/pcsx2/Recording/InputRecordingControls.cpp @@ -31,7 +31,8 @@ InputRecordingControls g_InputRecordingControls; void InputRecordingControls::CheckPauseStatus() { - if (frameAdvancing) + frame_advance_frame_counter++; + if (frameAdvancing && frame_advance_frame_counter >= frames_per_frame_advance) { frameAdvancing = false; pauseEmulation = true; @@ -99,9 +100,15 @@ void InputRecordingControls::FrameAdvance() return; } frameAdvancing = true; + frame_advance_frame_counter = 0; Resume(); } +void InputRecordingControls::setFrameAdvanceAmount(int amount) +{ + frames_per_frame_advance = amount; +} + bool InputRecordingControls::IsFrameAdvancing() { return frameAdvancing; diff --git a/pcsx2/Recording/InputRecordingControls.h b/pcsx2/Recording/InputRecordingControls.h index f12655e1f6..afc05f5fad 100644 --- a/pcsx2/Recording/InputRecordingControls.h +++ b/pcsx2/Recording/InputRecordingControls.h @@ -46,6 +46,7 @@ public: // Resume emulation (incase the emulation is currently paused) and pause after a single frame has passed void FrameAdvance(); + void setFrameAdvanceAmount(int amount); // Returns true if emulation is currently set up to frame advance. bool IsFrameAdvancing(); // Returns true if the input recording has been paused, which can occur: @@ -77,6 +78,8 @@ private: // Indicates on the next VSync if we are frame advancing, this value // and should be cleared once a single frame has passed bool frameAdvancing = false; + u32 frame_advance_frame_counter = 0; + u32 frames_per_frame_advance = 1; // Indicates if we intend to call CoreThread.PauseSelf() on the current or next available vsync bool pauseEmulation = false; // Indicates if we intend to call CoreThread.Resume() when the next pcsx2 App event is handled diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index 724c83e84f..15f3014a65 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -204,6 +204,8 @@ enum MenuIdentifiers MenuId_Recording_New, MenuId_Recording_Play, MenuId_Recording_Stop, + MenuId_Recording_Settings, + MenuId_Recording_Config_FrameAdvance, MenuId_Recording_TogglePause, MenuId_Recording_FrameAdvance, MenuId_Recording_ToggleRecordingMode, diff --git a/pcsx2/gui/AppConfig.cpp b/pcsx2/gui/AppConfig.cpp index 7cdcdc2310..985a79d64a 100644 --- a/pcsx2/gui/AppConfig.cpp +++ b/pcsx2/gui/AppConfig.cpp @@ -913,6 +913,7 @@ void AppConfig::GSWindowOptions::LoadSave( IniInterface& ini ) #ifndef DISABLE_RECORDING AppConfig::InputRecordingOptions::InputRecordingOptions() : VirtualPadPosition(wxDefaultPosition) + , m_frame_advance_amount(1) { } @@ -921,6 +922,7 @@ void AppConfig::InputRecordingOptions::loadSave(IniInterface& ini) ScopedIniGroup path(ini, L"InputRecording"); IniEntry(VirtualPadPosition); + IniEntry(m_frame_advance_amount); } #endif diff --git a/pcsx2/gui/AppConfig.h b/pcsx2/gui/AppConfig.h index be0719adec..7fac2c2f63 100644 --- a/pcsx2/gui/AppConfig.h +++ b/pcsx2/gui/AppConfig.h @@ -259,10 +259,11 @@ public: #ifndef DISABLE_RECORDING struct InputRecordingOptions { - wxPoint VirtualPadPosition; + wxPoint VirtualPadPosition; + int m_frame_advance_amount; InputRecordingOptions(); - void loadSave( IniInterface& conf ); + void loadSave(IniInterface& conf); }; #endif diff --git a/pcsx2/gui/MainFrame.cpp b/pcsx2/gui/MainFrame.cpp index 916de3c056..821e9f636c 100644 --- a/pcsx2/gui/MainFrame.cpp +++ b/pcsx2/gui/MainFrame.cpp @@ -22,6 +22,7 @@ #include "Dialogs/ModalPopups.h" #include "IsoDropTarget.h" +#include "fmt/core.h" #include #include @@ -29,12 +30,12 @@ #include "svnrev.h" #include "Saveslots.h" + #ifndef DISABLE_RECORDING #include "Recording/InputRecording.h" +#include "Recording/InputRecordingControls.h" #endif - -#include "fmt/core.h" // ------------------------------------------------------------------------ wxMenu* MainEmuFrame::MakeStatesSubMenu(int baseid, int loadBackupId) const { @@ -317,6 +318,7 @@ void MainEmuFrame::ConnectMenus() Bind(wxEVT_MENU, &MainEmuFrame::Menu_Recording_New_Click, this, MenuId_Recording_New); Bind(wxEVT_MENU, &MainEmuFrame::Menu_Recording_Play_Click, this, MenuId_Recording_Play); Bind(wxEVT_MENU, &MainEmuFrame::Menu_Recording_Stop_Click, this, MenuId_Recording_Stop); + Bind(wxEVT_MENU, &MainEmuFrame::Menu_Recording_Config_FrameAdvance, this, MenuId_Recording_Config_FrameAdvance); Bind(wxEVT_MENU, &MainEmuFrame::Menu_Recording_TogglePause_Click, this, MenuId_Recording_TogglePause); Bind(wxEVT_MENU, &MainEmuFrame::Menu_Recording_FrameAdvance_Click, this, MenuId_Recording_FrameAdvance); Bind(wxEVT_MENU, &MainEmuFrame::Menu_Recording_ToggleRecordingMode_Click, this, MenuId_Recording_ToggleRecordingMode); @@ -533,17 +535,25 @@ void MainEmuFrame::CreateCaptureMenu() m_submenuScreenshot.Append(MenuId_Capture_Screenshot_Screenshot_As, _("Screenshot As...")); } -void MainEmuFrame::CreateRecordMenu() +void MainEmuFrame::CreateInputRecordingMenu() { #ifndef DISABLE_RECORDING m_menuRecording.Append(MenuId_Recording_New, _("New"), _("Create a new input recording."))->Enable(false); 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."))->Enable(false); m_menuRecording.AppendSeparator(); + + m_menuRecording.Append(MenuId_Recording_Settings, _("Settings"), &m_submenu_recording_settings); + wxString frame_advance_label = wxString(_("Configure Frame Advance")); + frame_advance_label.Append(fmt::format(" ({})", g_Conf->inputRecording.m_frame_advance_amount)); + m_submenu_recording_settings.Append(MenuId_Recording_Config_FrameAdvance, frame_advance_label, _("Change the amount of frames advanced each time")); + m_menuRecording.AppendSeparator(); + 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)")); #endif @@ -583,6 +593,7 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title) , m_submenuScreenshot(*new wxMenu()) #ifndef DISABLE_RECORDING , m_menuRecording(*new wxMenu()) + , m_submenu_recording_settings(*new wxMenu()) #endif , m_menuHelp(*new wxMenu()) , m_LoadStatesSubmenu(*MakeStatesSubMenu(MenuId_State_Load01, MenuId_State_LoadBackup)) @@ -686,7 +697,7 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title) CreateWindowsMenu(); CreateCaptureMenu(); #ifndef DISABLE_RECORDING - CreateRecordMenu(); + CreateInputRecordingMenu(); #endif CreateHelpMenu(); @@ -842,6 +853,10 @@ void MainEmuFrame::ApplyConfigToGui(AppConfig& configToApply, int flags) menubar.Check(MenuId_Capture_Video_IncludeAudio, configToApply.AudioCapture.EnableAudio); #ifndef DISABLE_RECORDING menubar.Check(MenuId_EnableInputRecording, configToApply.EmuOptions.EnableRecordingTools); + wxString frame_advance_label = wxString(_("Configure Frame Advance")); + frame_advance_label.Append(fmt::format(" ({})", configToApply.inputRecording.m_frame_advance_amount)); + m_submenu_recording_settings.SetLabel(MenuId_Recording_Config_FrameAdvance, frame_advance_label); + g_InputRecordingControls.setFrameAdvanceAmount(configToApply.inputRecording.m_frame_advance_amount); #endif menubar.Check(MenuId_EnableHostFs, configToApply.EmuOptions.HostFs); menubar.Check(MenuId_Debug_CreateBlockdump, configToApply.EmuOptions.CdvdDumpBlocks); diff --git a/pcsx2/gui/MainFrame.h b/pcsx2/gui/MainFrame.h index 2e0b49508e..c7a3186f05 100644 --- a/pcsx2/gui/MainFrame.h +++ b/pcsx2/gui/MainFrame.h @@ -122,6 +122,7 @@ protected: #ifndef DISABLE_RECORDING wxMenu& m_menuRecording; + wxMenu& m_submenu_recording_settings; #endif wxMenu& m_menuHelp; @@ -164,7 +165,7 @@ public: void CreateWindowsMenu(); void CreateCaptureMenu(); #ifndef DISABLE_RECORDING - void CreateRecordMenu(); + void CreateInputRecordingMenu(); #endif void CreateHelpMenu(); @@ -267,6 +268,7 @@ protected: void Menu_Recording_New_Click(wxCommandEvent& event); void Menu_Recording_Play_Click(wxCommandEvent& event); void Menu_Recording_Stop_Click(wxCommandEvent& event); + void Menu_Recording_Config_FrameAdvance(wxCommandEvent& event); void ApplyFirstFrameStatus(); void Menu_Recording_TogglePause_Click(wxCommandEvent& event); void Menu_Recording_FrameAdvance_Click(wxCommandEvent& event); diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp index 79d62b9bfb..63f46d4ade 100644 --- a/pcsx2/gui/MainMenuClicks.cpp +++ b/pcsx2/gui/MainMenuClicks.cpp @@ -39,6 +39,9 @@ #include "Utilities/IniInterface.h" +#include "fmt/core.h" +#include "wx/numdlg.h" + #ifndef DISABLE_RECORDING #include "Recording/InputRecording.h" #include "Recording/InputRecordingControls.h" @@ -1120,6 +1123,19 @@ void MainEmuFrame::Menu_Recording_Stop_Click(wxCommandEvent& event) StopInputRecording(); } +void MainEmuFrame::Menu_Recording_Config_FrameAdvance(wxCommandEvent& event) +{ + long result = wxGetNumberFromUser(_("Enter the number of frames to advance per advance"), _("Number of Frames"), _("Configure Frame Advance"), g_Conf->inputRecording.m_frame_advance_amount, 1, INT_MAX); + if (result != -1) + { + g_Conf->inputRecording.m_frame_advance_amount = result; + g_InputRecordingControls.setFrameAdvanceAmount(result); + wxString frame_advance_label = wxString(_("Configure Frame Advance")); + frame_advance_label.Append(fmt::format(" ({})", result)); + m_submenu_recording_settings.SetLabel(MenuId_Recording_Config_FrameAdvance, frame_advance_label); + } +} + void MainEmuFrame::StartInputRecording() { m_menuRecording.FindChildItem(MenuId_Recording_New)->Enable(false);