Qt: Allow recording on game boot

This commit is contained in:
Light 2025-02-17 21:01:15 -05:00 committed by Ty
parent 8a594e673d
commit fa23628ae2
1 changed files with 68 additions and 11 deletions

View File

@ -99,6 +99,9 @@ static QString s_current_disc_serial;
static quint32 s_current_disc_crc; static quint32 s_current_disc_crc;
static quint32 s_current_running_crc; static quint32 s_current_running_crc;
static bool s_record_on_start = false;
static QString s_path_to_recording_for_record_on_start;
MainWindow::MainWindow() MainWindow::MainWindow()
{ {
pxAssert(!g_main_window); pxAssert(!g_main_window);
@ -738,7 +741,48 @@ void MainWindow::updateAdvancedSettingsVisibility()
void MainWindow::onVideoCaptureToggled(bool checked) void MainWindow::onVideoCaptureToggled(bool checked)
{ {
if (!s_vm_valid) if (!s_vm_valid)
{
if (!s_record_on_start)
{
QMessageBox msgbox(this);
msgbox.setIcon(QMessageBox::Question);
msgbox.setWindowIcon(QtHost::GetAppIcon());
msgbox.setWindowTitle(tr("Record On Boot"));
msgbox.setWindowModality(Qt::WindowModal);
msgbox.setText(tr("Did you want to start recording on boot?"));
msgbox.addButton(QMessageBox::Yes);
msgbox.addButton(QMessageBox::No);
msgbox.setDefaultButton(QMessageBox::Yes);
if (msgbox.exec() == QMessageBox::Yes)
{
const QString container(QString::fromStdString(
Host::GetStringSettingValue("EmuCore/GS", "CaptureContainer", Pcsx2Config::GSOptions::DEFAULT_CAPTURE_CONTAINER)));
const QString filter(tr("%1 Files (*.%2)").arg(container.toUpper()).arg(container));
QString temp(QStringLiteral("%1.%2").arg(QString::fromStdString(GSGetBaseVideoFilename())).arg(container));
temp = QDir::toNativeSeparators(QFileDialog::getSaveFileName(this, tr("Video Capture"), temp, filter));
s_path_to_recording_for_record_on_start = temp;
if (s_path_to_recording_for_record_on_start.isEmpty())
return;
s_record_on_start = true;
}
}
else
{
QMessageBox msgbox(this);
msgbox.setIcon(QMessageBox::Question);
msgbox.setWindowIcon(QtHost::GetAppIcon());
msgbox.setWindowTitle(tr("Record On Boot"));
msgbox.setWindowModality(Qt::WindowModal);
msgbox.setText(tr("Did you want to cancel recording on boot?"));
msgbox.addButton(QMessageBox::Yes);
msgbox.addButton(QMessageBox::No);
msgbox.setDefaultButton(QMessageBox::Yes);
if (msgbox.exec() == QMessageBox::Yes)
s_record_on_start = false;
}
return; return;
}
// Reset the checked state, we'll get updated by the GS thread. // Reset the checked state, we'll get updated by the GS thread.
QSignalBlocker sb(m_ui.actionVideoCapture); QSignalBlocker sb(m_ui.actionVideoCapture);
@ -750,16 +794,26 @@ void MainWindow::onVideoCaptureToggled(bool checked)
return; return;
} }
const QString container(QString::fromStdString( if (s_record_on_start && !s_path_to_recording_for_record_on_start.isEmpty())
Host::GetStringSettingValue("EmuCore/GS", "CaptureContainer", Pcsx2Config::GSOptions::DEFAULT_CAPTURE_CONTAINER))); {
const QString filter(tr("%1 Files (*.%2)").arg(container.toUpper()).arg(container)); // We can't start recording immediately, this is called before full GS init (specifically the fps amount)
// and GSCapture ends up unhappy.
// TODO: Pass some sort of flag or callback to the GS thread to start recording on frame 0.
Host::AddOSDMessage(tr("Recording will start in a moment").toStdString(), 3.0f);
QTimer::singleShot(2000, []() { g_emu_thread->beginCapture(s_path_to_recording_for_record_on_start); });
}
else
{
const QString container(QString::fromStdString(
Host::GetStringSettingValue("EmuCore/GS", "CaptureContainer", Pcsx2Config::GSOptions::DEFAULT_CAPTURE_CONTAINER)));
const QString filter(tr("%1 Files (*.%2)").arg(container.toUpper()).arg(container));
QString path(QStringLiteral("%1.%2").arg(QString::fromStdString(GSGetBaseVideoFilename())).arg(container)); QString path(QStringLiteral("%1.%2").arg(QString::fromStdString(GSGetBaseVideoFilename())).arg(container));
path = QDir::toNativeSeparators(QFileDialog::getSaveFileName(this, tr("Video Capture"), path, filter)); path = QDir::toNativeSeparators(QFileDialog::getSaveFileName(this, tr("Video Capture"), path, filter));
if (path.isEmpty()) if (path.isEmpty())
return; return;
g_emu_thread->beginCapture(path);
g_emu_thread->beginCapture(path); }
} }
void MainWindow::onCaptureStarted(const QString& filename) void MainWindow::onCaptureStarted(const QString& filename)
@ -904,8 +958,6 @@ void MainWindow::updateEmulationActions(bool starting, bool running, bool stoppi
m_ui.actionToolbarSaveState->setEnabled(running); m_ui.actionToolbarSaveState->setEnabled(running);
m_ui.actionViewGameProperties->setEnabled(running); m_ui.actionViewGameProperties->setEnabled(running);
m_ui.actionVideoCapture->setEnabled(running);
if (!running && m_ui.actionVideoCapture->isChecked()) if (!running && m_ui.actionVideoCapture->isChecked())
{ {
QSignalBlocker sb(m_ui.actionVideoCapture); QSignalBlocker sb(m_ui.actionVideoCapture);
@ -1991,6 +2043,11 @@ void MainWindow::onVMStarted()
updateWindowTitle(); updateWindowTitle();
updateStatusBarWidgetVisibility(); updateStatusBarWidgetVisibility();
updateInputRecordingActions(true); updateInputRecordingActions(true);
if (s_record_on_start)
{
m_ui.actionVideoCapture->setChecked(true);
s_record_on_start = false;
}
} }
void MainWindow::onVMPaused() void MainWindow::onVMPaused()