input-rec: Allow configuring the frame advance amount

This commit is contained in:
Tyler Wilding 2021-04-23 23:47:11 -04:00 committed by lightningterror
parent 3a877a51b5
commit 7a7f98955b
8 changed files with 56 additions and 8 deletions

View File

@ -31,7 +31,8 @@ InputRecordingControls g_InputRecordingControls;
void InputRecordingControls::CheckPauseStatus() void InputRecordingControls::CheckPauseStatus()
{ {
if (frameAdvancing) frame_advance_frame_counter++;
if (frameAdvancing && frame_advance_frame_counter >= frames_per_frame_advance)
{ {
frameAdvancing = false; frameAdvancing = false;
pauseEmulation = true; pauseEmulation = true;
@ -99,9 +100,15 @@ void InputRecordingControls::FrameAdvance()
return; return;
} }
frameAdvancing = true; frameAdvancing = true;
frame_advance_frame_counter = 0;
Resume(); Resume();
} }
void InputRecordingControls::setFrameAdvanceAmount(int amount)
{
frames_per_frame_advance = amount;
}
bool InputRecordingControls::IsFrameAdvancing() bool InputRecordingControls::IsFrameAdvancing()
{ {
return frameAdvancing; return frameAdvancing;

View File

@ -46,6 +46,7 @@ public:
// Resume emulation (incase the emulation is currently paused) and pause after a single frame has passed // Resume emulation (incase the emulation is currently paused) and pause after a single frame has passed
void FrameAdvance(); void FrameAdvance();
void setFrameAdvanceAmount(int amount);
// Returns true if emulation is currently set up to frame advance. // Returns true if emulation is currently set up to frame advance.
bool IsFrameAdvancing(); bool IsFrameAdvancing();
// Returns true if the input recording has been paused, which can occur: // 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 // Indicates on the next VSync if we are frame advancing, this value
// and should be cleared once a single frame has passed // and should be cleared once a single frame has passed
bool frameAdvancing = false; 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 // Indicates if we intend to call CoreThread.PauseSelf() on the current or next available vsync
bool pauseEmulation = false; bool pauseEmulation = false;
// Indicates if we intend to call CoreThread.Resume() when the next pcsx2 App event is handled // Indicates if we intend to call CoreThread.Resume() when the next pcsx2 App event is handled

View File

@ -204,6 +204,8 @@ enum MenuIdentifiers
MenuId_Recording_New, MenuId_Recording_New,
MenuId_Recording_Play, MenuId_Recording_Play,
MenuId_Recording_Stop, MenuId_Recording_Stop,
MenuId_Recording_Settings,
MenuId_Recording_Config_FrameAdvance,
MenuId_Recording_TogglePause, MenuId_Recording_TogglePause,
MenuId_Recording_FrameAdvance, MenuId_Recording_FrameAdvance,
MenuId_Recording_ToggleRecordingMode, MenuId_Recording_ToggleRecordingMode,

View File

@ -913,6 +913,7 @@ void AppConfig::GSWindowOptions::LoadSave( IniInterface& ini )
#ifndef DISABLE_RECORDING #ifndef DISABLE_RECORDING
AppConfig::InputRecordingOptions::InputRecordingOptions() AppConfig::InputRecordingOptions::InputRecordingOptions()
: VirtualPadPosition(wxDefaultPosition) : VirtualPadPosition(wxDefaultPosition)
, m_frame_advance_amount(1)
{ {
} }
@ -921,6 +922,7 @@ void AppConfig::InputRecordingOptions::loadSave(IniInterface& ini)
ScopedIniGroup path(ini, L"InputRecording"); ScopedIniGroup path(ini, L"InputRecording");
IniEntry(VirtualPadPosition); IniEntry(VirtualPadPosition);
IniEntry(m_frame_advance_amount);
} }
#endif #endif

View File

@ -259,10 +259,11 @@ public:
#ifndef DISABLE_RECORDING #ifndef DISABLE_RECORDING
struct InputRecordingOptions struct InputRecordingOptions
{ {
wxPoint VirtualPadPosition; wxPoint VirtualPadPosition;
int m_frame_advance_amount;
InputRecordingOptions(); InputRecordingOptions();
void loadSave( IniInterface& conf ); void loadSave(IniInterface& conf);
}; };
#endif #endif

View File

@ -22,6 +22,7 @@
#include "Dialogs/ModalPopups.h" #include "Dialogs/ModalPopups.h"
#include "IsoDropTarget.h" #include "IsoDropTarget.h"
#include "fmt/core.h"
#include <wx/iconbndl.h> #include <wx/iconbndl.h>
#include <unordered_map> #include <unordered_map>
@ -29,12 +30,12 @@
#include "svnrev.h" #include "svnrev.h"
#include "Saveslots.h" #include "Saveslots.h"
#ifndef DISABLE_RECORDING #ifndef DISABLE_RECORDING
#include "Recording/InputRecording.h" #include "Recording/InputRecording.h"
#include "Recording/InputRecordingControls.h"
#endif #endif
#include "fmt/core.h"
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
wxMenu* MainEmuFrame::MakeStatesSubMenu(int baseid, int loadBackupId) const 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_New_Click, this, MenuId_Recording_New);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_Recording_Play_Click, this, MenuId_Recording_Play); 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_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_TogglePause_Click, this, MenuId_Recording_TogglePause);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_Recording_FrameAdvance_Click, this, MenuId_Recording_FrameAdvance); Bind(wxEVT_MENU, &MainEmuFrame::Menu_Recording_FrameAdvance_Click, this, MenuId_Recording_FrameAdvance);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_Recording_ToggleRecordingMode_Click, this, MenuId_Recording_ToggleRecordingMode); 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...")); m_submenuScreenshot.Append(MenuId_Capture_Screenshot_Screenshot_As, _("Screenshot As..."));
} }
void MainEmuFrame::CreateRecordMenu() void MainEmuFrame::CreateInputRecordingMenu()
{ {
#ifndef DISABLE_RECORDING #ifndef DISABLE_RECORDING
m_menuRecording.Append(MenuId_Recording_New, _("New"), _("Create a new input recording."))->Enable(false); 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_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.Append(MenuId_Recording_Play, _("Play"), _("Playback an existing input recording."))->Enable(false);
m_menuRecording.AppendSeparator(); 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_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_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.Append(MenuId_Recording_ToggleRecordingMode, _("Toggle Recording Mode"), _("Save/playback inputs to/from the recording file."))->Enable(false);
m_menuRecording.AppendSeparator(); m_menuRecording.AppendSeparator();
m_menuRecording.Append(MenuId_Recording_VirtualPad_Port0, _("Virtual Pad (Port 1)")); m_menuRecording.Append(MenuId_Recording_VirtualPad_Port0, _("Virtual Pad (Port 1)"));
m_menuRecording.Append(MenuId_Recording_VirtualPad_Port1, _("Virtual Pad (Port 2)")); m_menuRecording.Append(MenuId_Recording_VirtualPad_Port1, _("Virtual Pad (Port 2)"));
#endif #endif
@ -583,6 +593,7 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title)
, m_submenuScreenshot(*new wxMenu()) , m_submenuScreenshot(*new wxMenu())
#ifndef DISABLE_RECORDING #ifndef DISABLE_RECORDING
, m_menuRecording(*new wxMenu()) , m_menuRecording(*new wxMenu())
, m_submenu_recording_settings(*new wxMenu())
#endif #endif
, m_menuHelp(*new wxMenu()) , m_menuHelp(*new wxMenu())
, m_LoadStatesSubmenu(*MakeStatesSubMenu(MenuId_State_Load01, MenuId_State_LoadBackup)) , m_LoadStatesSubmenu(*MakeStatesSubMenu(MenuId_State_Load01, MenuId_State_LoadBackup))
@ -686,7 +697,7 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title)
CreateWindowsMenu(); CreateWindowsMenu();
CreateCaptureMenu(); CreateCaptureMenu();
#ifndef DISABLE_RECORDING #ifndef DISABLE_RECORDING
CreateRecordMenu(); CreateInputRecordingMenu();
#endif #endif
CreateHelpMenu(); CreateHelpMenu();
@ -842,6 +853,10 @@ void MainEmuFrame::ApplyConfigToGui(AppConfig& configToApply, int flags)
menubar.Check(MenuId_Capture_Video_IncludeAudio, configToApply.AudioCapture.EnableAudio); menubar.Check(MenuId_Capture_Video_IncludeAudio, configToApply.AudioCapture.EnableAudio);
#ifndef DISABLE_RECORDING #ifndef DISABLE_RECORDING
menubar.Check(MenuId_EnableInputRecording, configToApply.EmuOptions.EnableRecordingTools); 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 #endif
menubar.Check(MenuId_EnableHostFs, configToApply.EmuOptions.HostFs); menubar.Check(MenuId_EnableHostFs, configToApply.EmuOptions.HostFs);
menubar.Check(MenuId_Debug_CreateBlockdump, configToApply.EmuOptions.CdvdDumpBlocks); menubar.Check(MenuId_Debug_CreateBlockdump, configToApply.EmuOptions.CdvdDumpBlocks);

View File

@ -122,6 +122,7 @@ protected:
#ifndef DISABLE_RECORDING #ifndef DISABLE_RECORDING
wxMenu& m_menuRecording; wxMenu& m_menuRecording;
wxMenu& m_submenu_recording_settings;
#endif #endif
wxMenu& m_menuHelp; wxMenu& m_menuHelp;
@ -164,7 +165,7 @@ public:
void CreateWindowsMenu(); void CreateWindowsMenu();
void CreateCaptureMenu(); void CreateCaptureMenu();
#ifndef DISABLE_RECORDING #ifndef DISABLE_RECORDING
void CreateRecordMenu(); void CreateInputRecordingMenu();
#endif #endif
void CreateHelpMenu(); void CreateHelpMenu();
@ -267,6 +268,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 Menu_Recording_Config_FrameAdvance(wxCommandEvent& event);
void ApplyFirstFrameStatus(); 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);

View File

@ -39,6 +39,9 @@
#include "Utilities/IniInterface.h" #include "Utilities/IniInterface.h"
#include "fmt/core.h"
#include "wx/numdlg.h"
#ifndef DISABLE_RECORDING #ifndef DISABLE_RECORDING
#include "Recording/InputRecording.h" #include "Recording/InputRecording.h"
#include "Recording/InputRecordingControls.h" #include "Recording/InputRecordingControls.h"
@ -1120,6 +1123,19 @@ void MainEmuFrame::Menu_Recording_Stop_Click(wxCommandEvent& event)
StopInputRecording(); 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() void MainEmuFrame::StartInputRecording()
{ {
m_menuRecording.FindChildItem(MenuId_Recording_New)->Enable(false); m_menuRecording.FindChildItem(MenuId_Recording_New)->Enable(false);