mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Core/Movie: Refactor to class, move to System.
A bit of global state remains (the `header` in `BeginRecordingInput()`) due to unclear lifetime requirements.
This commit is contained in:
@ -15,6 +15,7 @@
|
||||
#include "Core/Config/MainSettings.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/Movie.h"
|
||||
#include "Core/System.h"
|
||||
|
||||
#include "DolphinQt/Config/ControllerInterface/ControllerInterfaceWindow.h"
|
||||
#include "DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h"
|
||||
@ -197,9 +198,9 @@ void AchievementSettingsWidget::LoadSettings()
|
||||
SignalBlocking(m_common_hardcore_enabled_input)
|
||||
->setChecked(Config::Get(Config::RA_HARDCORE_ENABLED));
|
||||
SignalBlocking(m_common_hardcore_enabled_input)
|
||||
->setEnabled(enabled &&
|
||||
(hardcore_enabled ||
|
||||
(Core::GetState() == Core::State::Uninitialized && !Movie::IsPlayingInput())));
|
||||
->setEnabled(enabled && (hardcore_enabled ||
|
||||
(Core::GetState() == Core::State::Uninitialized &&
|
||||
!Core::System::GetInstance().GetMovie().IsPlayingInput())));
|
||||
|
||||
SignalBlocking(m_common_progress_enabled_input)
|
||||
->setChecked(Config::Get(Config::RA_PROGRESS_ENABLED));
|
||||
|
@ -365,7 +365,7 @@ void GBAWidget::SaveSettings()
|
||||
|
||||
bool GBAWidget::CanControlCore()
|
||||
{
|
||||
return !Movie::IsMovieActive() && !NetPlay::IsNetPlayRunning();
|
||||
return !Core::System::GetInstance().GetMovie().IsMovieActive() && !NetPlay::IsNetPlayRunning();
|
||||
}
|
||||
|
||||
bool GBAWidget::CanResetCore()
|
||||
|
@ -277,7 +277,7 @@ MainWindow::MainWindow(std::unique_ptr<BootParameters> boot_parameters,
|
||||
if (!movie_path.empty())
|
||||
{
|
||||
std::optional<std::string> savestate_path;
|
||||
if (Movie::PlayInput(movie_path, &savestate_path))
|
||||
if (Core::System::GetInstance().GetMovie().PlayInput(movie_path, &savestate_path))
|
||||
{
|
||||
m_pending_boot->boot_session_data.SetSavestateData(std::move(savestate_path),
|
||||
DeleteSavestateAfterBoot::No);
|
||||
@ -646,8 +646,9 @@ void MainWindow::ConnectHotkeys()
|
||||
connect(m_hotkey_scheduler, &HotkeyScheduler::ConnectWiiRemote, this,
|
||||
&MainWindow::OnConnectWiiRemote);
|
||||
connect(m_hotkey_scheduler, &HotkeyScheduler::ToggleReadOnlyMode, [this] {
|
||||
bool read_only = !Movie::IsReadOnly();
|
||||
Movie::SetReadOnly(read_only);
|
||||
auto& movie = Core::System::GetInstance().GetMovie();
|
||||
bool read_only = !movie.IsReadOnly();
|
||||
movie.SetReadOnly(read_only);
|
||||
emit ReadOnlyModeChanged(read_only);
|
||||
});
|
||||
|
||||
@ -1011,9 +1012,10 @@ void MainWindow::ForceStop()
|
||||
|
||||
void MainWindow::Reset()
|
||||
{
|
||||
if (Movie::IsRecordingInput())
|
||||
Movie::SetReset(true);
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& movie = system.GetMovie();
|
||||
if (movie.IsRecordingInput())
|
||||
movie.SetReset(true);
|
||||
system.GetProcessorInterface().ResetButton_Tap();
|
||||
}
|
||||
|
||||
@ -1853,15 +1855,16 @@ void MainWindow::OnPlayRecording()
|
||||
if (dtm_file.isEmpty())
|
||||
return;
|
||||
|
||||
if (!Movie::IsReadOnly())
|
||||
auto& movie = Core::System::GetInstance().GetMovie();
|
||||
if (!movie.IsReadOnly())
|
||||
{
|
||||
// let's make the read-only flag consistent at the start of a movie.
|
||||
Movie::SetReadOnly(true);
|
||||
movie.SetReadOnly(true);
|
||||
emit ReadOnlyModeChanged(true);
|
||||
}
|
||||
|
||||
std::optional<std::string> savestate_path;
|
||||
if (Movie::PlayInput(dtm_file.toStdString(), &savestate_path))
|
||||
if (movie.PlayInput(dtm_file.toStdString(), &savestate_path))
|
||||
{
|
||||
emit RecordingStatusChanged(true);
|
||||
|
||||
@ -1871,14 +1874,17 @@ void MainWindow::OnPlayRecording()
|
||||
|
||||
void MainWindow::OnStartRecording()
|
||||
{
|
||||
if ((!Core::IsRunningAndStarted() && Core::IsRunning()) || Movie::IsRecordingInput() ||
|
||||
Movie::IsPlayingInput())
|
||||
auto& movie = Core::System::GetInstance().GetMovie();
|
||||
if ((!Core::IsRunningAndStarted() && Core::IsRunning()) || movie.IsRecordingInput() ||
|
||||
movie.IsPlayingInput())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Movie::IsReadOnly())
|
||||
if (movie.IsReadOnly())
|
||||
{
|
||||
// The user just chose to record a movie, so that should take precedence
|
||||
Movie::SetReadOnly(false);
|
||||
movie.SetReadOnly(false);
|
||||
emit ReadOnlyModeChanged(true);
|
||||
}
|
||||
|
||||
@ -1897,7 +1903,7 @@ void MainWindow::OnStartRecording()
|
||||
wiimotes[i] = Config::Get(Config::GetInfoForWiimoteSource(i)) != WiimoteSource::None;
|
||||
}
|
||||
|
||||
if (Movie::BeginRecordingInput(controllers, wiimotes))
|
||||
if (movie.BeginRecordingInput(controllers, wiimotes))
|
||||
{
|
||||
emit RecordingStatusChanged(true);
|
||||
|
||||
@ -1908,10 +1914,11 @@ void MainWindow::OnStartRecording()
|
||||
|
||||
void MainWindow::OnStopRecording()
|
||||
{
|
||||
if (Movie::IsRecordingInput())
|
||||
auto& movie = Core::System::GetInstance().GetMovie();
|
||||
if (movie.IsRecordingInput())
|
||||
OnExportRecording();
|
||||
if (Movie::IsMovieActive())
|
||||
Movie::EndPlayInput(false);
|
||||
if (movie.IsMovieActive())
|
||||
movie.EndPlayInput(false);
|
||||
emit RecordingStatusChanged(false);
|
||||
}
|
||||
|
||||
@ -1921,7 +1928,7 @@ void MainWindow::OnExportRecording()
|
||||
QString dtm_file = DolphinFileDialog::getSaveFileName(
|
||||
this, tr("Save Recording File As"), QString(), tr("Dolphin TAS Movies (*.dtm)"));
|
||||
if (!dtm_file.isEmpty())
|
||||
Movie::SaveRecording(dtm_file.toStdString());
|
||||
Core::System::GetInstance().GetMovie().SaveRecording(dtm_file.toStdString());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,8 @@ void MenuBar::OnEmulationStateChanged(Core::State state)
|
||||
#else // USE_RETRO_ACHIEVEMENTS
|
||||
m_recording_play->setEnabled(m_game_selected && !running);
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
m_recording_start->setEnabled((m_game_selected || running) && !Movie::IsPlayingInput());
|
||||
m_recording_start->setEnabled((m_game_selected || running) &&
|
||||
!Core::System::GetInstance().GetMovie().IsPlayingInput());
|
||||
|
||||
// JIT
|
||||
m_jit_interpreter_core->setEnabled(running);
|
||||
@ -775,8 +776,9 @@ void MenuBar::AddMovieMenu()
|
||||
|
||||
m_recording_read_only = movie_menu->addAction(tr("&Read-Only Mode"));
|
||||
m_recording_read_only->setCheckable(true);
|
||||
m_recording_read_only->setChecked(Movie::IsReadOnly());
|
||||
connect(m_recording_read_only, &QAction::toggled, [](bool value) { Movie::SetReadOnly(value); });
|
||||
m_recording_read_only->setChecked(Core::System::GetInstance().GetMovie().IsReadOnly());
|
||||
connect(m_recording_read_only, &QAction::toggled,
|
||||
[](bool value) { Core::System::GetInstance().GetMovie().SetReadOnly(value); });
|
||||
|
||||
movie_menu->addAction(tr("TAS Input"), this, [this] { emit ShowTASInput(); });
|
||||
|
||||
@ -1231,7 +1233,8 @@ void MenuBar::OnSelectionChanged(std::shared_ptr<const UICommon::GameFile> game_
|
||||
m_game_selected = !!game_file;
|
||||
|
||||
m_recording_play->setEnabled(m_game_selected && !Core::IsRunning());
|
||||
m_recording_start->setEnabled((m_game_selected || Core::IsRunning()) && !Movie::IsPlayingInput());
|
||||
m_recording_start->setEnabled((m_game_selected || Core::IsRunning()) &&
|
||||
!Core::System::GetInstance().GetMovie().IsPlayingInput());
|
||||
}
|
||||
|
||||
void MenuBar::OnRecordingStatusChanged(bool recording)
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include "Core/Movie.h"
|
||||
#include "Core/System.h"
|
||||
#include "DolphinQt/QtUtils/QueueOnObject.h"
|
||||
#include "DolphinQt/TAS/TASInputWindow.h"
|
||||
|
||||
@ -23,7 +24,8 @@ bool TASCheckBox::GetValue() const
|
||||
|
||||
if (check_state == Qt::PartiallyChecked)
|
||||
{
|
||||
const u64 frames_elapsed = Movie::GetCurrentFrame() - m_frame_turbo_started;
|
||||
const u64 frames_elapsed =
|
||||
Core::System::GetInstance().GetMovie().GetCurrentFrame() - m_frame_turbo_started;
|
||||
return static_cast<int>(frames_elapsed % m_turbo_total_frames) < m_turbo_press_frames;
|
||||
}
|
||||
|
||||
@ -50,7 +52,7 @@ void TASCheckBox::mousePressEvent(QMouseEvent* event)
|
||||
return;
|
||||
}
|
||||
|
||||
m_frame_turbo_started = Movie::GetCurrentFrame();
|
||||
m_frame_turbo_started = Core::System::GetInstance().GetMovie().GetCurrentFrame();
|
||||
m_turbo_press_frames = m_parent->GetTurboPressFrames();
|
||||
m_turbo_total_frames = m_turbo_press_frames + m_parent->GetTurboReleaseFrames();
|
||||
setCheckState(Qt::PartiallyChecked);
|
||||
|
Reference in New Issue
Block a user