citra_qt: Rebuilt movie frontend
This is completely rebuilt, in order to allow setting author, displaying movie metadata, and toggling read-only mode. The UX is changed to more closely match other emulators' behaviour. Now you can only record/play from start/reset (In the future, we might want to introduce 'record from savestate') Also fixed a critical bug where movie file can be corrupted when ending the recording while game is still running.master
parent
5a42a80f40
commit
113e0c7331
@ -0,0 +1,130 @@
|
||||
// Copyright 2020 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QPushButton>
|
||||
#include <QTime>
|
||||
#include "citra_qt/game_list.h"
|
||||
#include "citra_qt/game_list_p.h"
|
||||
#include "citra_qt/movie/movie_play_dialog.h"
|
||||
#include "citra_qt/uisettings.h"
|
||||
#include "core/core.h"
|
||||
#include "core/core_timing.h"
|
||||
#include "core/hle/service/hid/hid.h"
|
||||
#include "core/movie.h"
|
||||
#include "ui_movie_play_dialog.h"
|
||||
|
||||
MoviePlayDialog::MoviePlayDialog(QWidget* parent, GameList* game_list_)
|
||||
: QDialog(parent), ui(std::make_unique<Ui::MoviePlayDialog>()), game_list(game_list_) {
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
|
||||
connect(ui->filePathButton, &QToolButton::clicked, this, &MoviePlayDialog::OnToolButtonClicked);
|
||||
connect(ui->filePath, &QLineEdit::editingFinished, this, &MoviePlayDialog::UpdateUIDisplay);
|
||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &MoviePlayDialog::accept);
|
||||
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &MoviePlayDialog::reject);
|
||||
|
||||
if (Core::System::GetInstance().IsPoweredOn()) {
|
||||
QString note_text;
|
||||
note_text = tr("Current running game will be stopped.");
|
||||
if (Core::Movie::GetInstance().IsRecordingInput()) {
|
||||
note_text.append(tr("<br>Current recording will be discarded."));
|
||||
}
|
||||
ui->note2Label->setText(note_text);
|
||||
}
|
||||
}
|
||||
|
||||
MoviePlayDialog::~MoviePlayDialog() = default;
|
||||
|
||||
QString MoviePlayDialog::GetMoviePath() const {
|
||||
return ui->filePath->text();
|
||||
}
|
||||
|
||||
QString MoviePlayDialog::GetGamePath() const {
|
||||
const auto metadata = Core::Movie::GetInstance().GetMovieMetadata(GetMoviePath().toStdString());
|
||||
return game_list->FindGameByProgramID(metadata.program_id, GameListItemPath::FullPathRole);
|
||||
}
|
||||
|
||||
void MoviePlayDialog::OnToolButtonClicked() {
|
||||
const QString path =
|
||||
QFileDialog::getOpenFileName(this, tr("Play Movie"), UISettings::values.movie_playback_path,
|
||||
tr("Citra TAS Movie (*.ctm)"));
|
||||
if (path.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
ui->filePath->setText(path);
|
||||
UISettings::values.movie_playback_path = path;
|
||||
UpdateUIDisplay();
|
||||
}
|
||||
|
||||
void MoviePlayDialog::UpdateUIDisplay() {
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
ui->gameLineEdit->clear();
|
||||
ui->authorLineEdit->clear();
|
||||
ui->rerecordCountLineEdit->clear();
|
||||
ui->lengthLineEdit->clear();
|
||||
ui->note1Label->setVisible(true);
|
||||
|
||||
const auto path = GetMoviePath().toStdString();
|
||||
|
||||
const auto validation_result = Core::Movie::GetInstance().ValidateMovie(path);
|
||||
if (validation_result == Core::Movie::ValidationResult::Invalid) {
|
||||
ui->note1Label->setText(tr("Invalid movie file."));
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
ui->note2Label->setVisible(true);
|
||||
ui->infoGroupBox->setVisible(true);
|
||||
|
||||
switch (validation_result) {
|
||||
case Core::Movie::ValidationResult::OK:
|
||||
ui->note1Label->setText(QString{});
|
||||
break;
|
||||
case Core::Movie::ValidationResult::RevisionDismatch:
|
||||
ui->note1Label->setText(tr("Revision dismatch, playback may desync."));
|
||||
break;
|
||||
case Core::Movie::ValidationResult::InputCountDismatch:
|
||||
ui->note1Label->setText(tr("Indicated length is incorrect, file may be corrupted."));
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
const auto metadata = Core::Movie::GetInstance().GetMovieMetadata(path);
|
||||
|
||||
// Format game title
|
||||
const auto title =
|
||||
game_list->FindGameByProgramID(metadata.program_id, GameListItemPath::TitleRole);
|
||||
if (title.isEmpty()) {
|
||||
ui->gameLineEdit->setText(tr("(unknown)"));
|
||||
ui->note1Label->setText(tr("Game used in this movie is not in game list."));
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
} else {
|
||||
ui->gameLineEdit->setText(title);
|
||||
}
|
||||
|
||||
ui->authorLineEdit->setText(metadata.author.empty() ? tr("(unknown)")
|
||||
: QString::fromStdString(metadata.author));
|
||||
ui->rerecordCountLineEdit->setText(
|
||||
metadata.rerecord_count == 0 ? tr("(unknown)") : QString::number(metadata.rerecord_count));
|
||||
|
||||
// Format length
|
||||
if (metadata.input_count == 0) {
|
||||
ui->lengthLineEdit->setText(tr("(unknown)"));
|
||||
} else {
|
||||
if (metadata.input_count >
|
||||
BASE_CLOCK_RATE_ARM11 * 24 * 60 * 60 / Service::HID::Module::pad_update_ticks) {
|
||||
// More than a day
|
||||
ui->lengthLineEdit->setText(tr("(>1 day)"));
|
||||
} else {
|
||||
const u64 msecs = Service::HID::Module::pad_update_ticks * metadata.input_count * 1000 /
|
||||
BASE_CLOCK_RATE_ARM11;
|
||||
ui->lengthLineEdit->setText(
|
||||
QTime::fromMSecsSinceStartOfDay(msecs).toString(QStringLiteral("hh:mm:ss.zzz")));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
// Copyright 2020 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <memory>
|
||||
#include <QDialog>
|
||||
|
||||
class GameList;
|
||||
|
||||
namespace Ui {
|
||||
class MoviePlayDialog;
|
||||
}
|
||||
|
||||
class MoviePlayDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MoviePlayDialog(QWidget* parent, GameList* game_list);
|
||||
~MoviePlayDialog() override;
|
||||
|
||||
QString GetMoviePath() const;
|
||||
QString GetGamePath() const;
|
||||
|
||||
private:
|
||||
void OnToolButtonClicked();
|
||||
void UpdateUIDisplay();
|
||||
|
||||
std::unique_ptr<Ui::MoviePlayDialog> ui;
|
||||
GameList* game_list;
|
||||
};
|
@ -0,0 +1,136 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MoviePlayDialog</class>
|
||||
<widget class="QDialog" name="MoviePlayDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>100</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Play Movie</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>File:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="filePath"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="filePathButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="note1Label">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="infoGroupBox">
|
||||
<property name="title">
|
||||
<string>Info</string>
|
||||
</property>
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QFormLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Game:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="gameLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Author:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="authorLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="rerecordCountLabel">
|
||||
<property name="text">
|
||||
<string>Rerecord Count:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="rerecordCountLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lengthLabel">
|
||||
<property name="text">
|
||||
<string>Length:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="lengthLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="note2Label">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</ui>
|
@ -0,0 +1,61 @@
|
||||
// Copyright 2020 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QPushButton>
|
||||
#include "citra_qt/movie/movie_record_dialog.h"
|
||||
#include "citra_qt/uisettings.h"
|
||||
#include "core/core.h"
|
||||
#include "core/movie.h"
|
||||
#include "ui_movie_record_dialog.h"
|
||||
|
||||
MovieRecordDialog::MovieRecordDialog(QWidget* parent)
|
||||
: QDialog(parent), ui(std::make_unique<Ui::MovieRecordDialog>()) {
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
|
||||
connect(ui->filePathButton, &QToolButton::clicked, this,
|
||||
&MovieRecordDialog::OnToolButtonClicked);
|
||||
connect(ui->filePath, &QLineEdit::editingFinished, this, &MovieRecordDialog::UpdateUIDisplay);
|
||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &MovieRecordDialog::accept);
|
||||
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &MovieRecordDialog::reject);
|
||||
|
||||
QString note_text;
|
||||
if (Core::System::GetInstance().IsPoweredOn()) {
|
||||
note_text = tr("Current running game will be restarted.");
|
||||
if (Core::Movie::GetInstance().IsRecordingInput()) {
|
||||
note_text.append(tr("<br>Current recording will be discarded."));
|
||||
}
|
||||
} else {
|
||||
note_text = tr("Recording will start once you boot a game.");
|
||||
}
|
||||
ui->noteLabel->setText(note_text);
|
||||
}
|
||||
|
||||
MovieRecordDialog::~MovieRecordDialog() = default;
|
||||
|
||||
QString MovieRecordDialog::GetPath() const {
|
||||
return ui->filePath->text();
|
||||
}
|
||||
|
||||
QString MovieRecordDialog::GetAuthor() const {
|
||||
return ui->authorLineEdit->text();
|
||||
}
|
||||
|
||||
void MovieRecordDialog::OnToolButtonClicked() {
|
||||
const QString path =
|
||||
QFileDialog::getSaveFileName(this, tr("Record Movie"), UISettings::values.movie_record_path,
|
||||
tr("Citra TAS Movie (*.ctm)"));
|
||||
if (path.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
ui->filePath->setText(path);
|
||||
UISettings::values.movie_record_path = path;
|
||||
UpdateUIDisplay();
|
||||
}
|
||||
|
||||
void MovieRecordDialog::UpdateUIDisplay() {
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!ui->filePath->text().isEmpty());
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
// Copyright 2020 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <memory>
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class MovieRecordDialog;
|
||||
}
|
||||
|
||||
class MovieRecordDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MovieRecordDialog(QWidget* parent);
|
||||
~MovieRecordDialog() override;
|
||||
|
||||
QString GetPath() const;
|
||||
QString GetAuthor() const;
|
||||
|
||||
private:
|
||||
void OnToolButtonClicked();
|
||||
void UpdateUIDisplay();
|
||||
|
||||
std::unique_ptr<Ui::MovieRecordDialog> ui;
|
||||
};
|
@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MovieRecordDialog</class>
|
||||
<widget class="QDialog" name="MovieRecordDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>150</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Record Movie</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>File:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="filePath"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="filePathButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Author:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="authorLineEdit">
|
||||
<property name="maxLength">
|
||||
<number>32</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="noteLabel"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</ui>
|
Loading…
Reference in New Issue