Minor improvements to the UX

1. Game will now be paused on movie finish
2. Added 'Save without Closing'
This commit is contained in:
zhupengfei 2020-10-14 22:35:20 +08:00
parent f8eb9a541d
commit b2531310b4
No known key found for this signature in database
GPG key ID: DD129E108BD09378
5 changed files with 47 additions and 4 deletions

View file

@ -176,8 +176,9 @@ GMainWindow::GMainWindow()
Network::Init(); Network::Init();
Core::Movie::GetInstance().SetPlaybackCompletionCallback( Core::Movie::GetInstance().SetPlaybackCompletionCallback([this] {
[this] { QMetaObject::invokeMethod(this, "OnMoviePlaybackCompleted"); }); QMetaObject::invokeMethod(this, "OnMoviePlaybackCompleted", Qt::BlockingQueuedConnection);
});
InitializeWidgets(); InitializeWidgets();
InitializeDebugWidgets(); InitializeDebugWidgets();
@ -748,6 +749,7 @@ void GMainWindow::ConnectMenuEvents() {
connect(ui->action_Record_Movie, &QAction::triggered, this, &GMainWindow::OnRecordMovie); connect(ui->action_Record_Movie, &QAction::triggered, this, &GMainWindow::OnRecordMovie);
connect(ui->action_Play_Movie, &QAction::triggered, this, &GMainWindow::OnPlayMovie); connect(ui->action_Play_Movie, &QAction::triggered, this, &GMainWindow::OnPlayMovie);
connect(ui->action_Close_Movie, &QAction::triggered, this, &GMainWindow::OnCloseMovie); connect(ui->action_Close_Movie, &QAction::triggered, this, &GMainWindow::OnCloseMovie);
connect(ui->action_Save_Movie, &QAction::triggered, this, &GMainWindow::OnSaveMovie);
connect(ui->action_Movie_Read_Only_Mode, &QAction::toggled, this, connect(ui->action_Movie_Read_Only_Mode, &QAction::toggled, this,
[this](bool checked) { Core::Movie::GetInstance().SetReadOnly(checked); }); [this](bool checked) { Core::Movie::GetInstance().SetReadOnly(checked); });
connect(ui->action_Enable_Frame_Advancing, &QAction::triggered, this, [this] { connect(ui->action_Enable_Frame_Advancing, &QAction::triggered, this, [this] {
@ -1878,6 +1880,7 @@ void GMainWindow::OnRecordMovie() {
BootGame(QString(game_path)); BootGame(QString(game_path));
} }
ui->action_Close_Movie->setEnabled(true); ui->action_Close_Movie->setEnabled(true);
ui->action_Save_Movie->setEnabled(true);
} }
void GMainWindow::OnPlayMovie() { void GMainWindow::OnPlayMovie() {
@ -1891,6 +1894,7 @@ void GMainWindow::OnPlayMovie() {
BootGame(dialog.GetGamePath()); BootGame(dialog.GetGamePath());
ui->action_Close_Movie->setEnabled(true); ui->action_Close_Movie->setEnabled(true);
ui->action_Save_Movie->setEnabled(false);
} }
void GMainWindow::OnCloseMovie() { void GMainWindow::OnCloseMovie() {
@ -1919,6 +1923,25 @@ void GMainWindow::OnCloseMovie() {
} }
ui->action_Close_Movie->setEnabled(false); ui->action_Close_Movie->setEnabled(false);
ui->action_Save_Movie->setEnabled(false);
}
void GMainWindow::OnSaveMovie() {
const bool was_running = emu_thread && emu_thread->IsRunning();
if (was_running) {
OnPauseGame();
}
if (Core::Movie::GetInstance().GetPlayMode() == Core::Movie::PlayMode::Recording) {
Core::Movie::GetInstance().SaveMovie();
QMessageBox::information(this, tr("Movie Saved"), tr("The movie is successfully saved."));
} else {
LOG_ERROR(Frontend, "Tried to save movie while movie is not being recorded");
}
if (was_running) {
OnStartGame();
}
} }
void GMainWindow::OnCaptureScreenshot() { void GMainWindow::OnCaptureScreenshot() {
@ -2005,18 +2028,22 @@ void GMainWindow::UpdateStatusBar() {
message_label->setText(tr("Recording %1").arg(current)); message_label->setText(tr("Recording %1").arg(current));
message_label->setVisible(true); message_label->setVisible(true);
message_label_used_for_movie = true; message_label_used_for_movie = true;
ui->action_Save_Movie->setEnabled(true);
} else if (play_mode == Core::Movie::PlayMode::Playing) { } else if (play_mode == Core::Movie::PlayMode::Playing) {
message_label->setText(tr("Playing %1 / %2").arg(current).arg(total)); message_label->setText(tr("Playing %1 / %2").arg(current).arg(total));
message_label->setVisible(true); message_label->setVisible(true);
message_label_used_for_movie = true; message_label_used_for_movie = true;
ui->action_Save_Movie->setEnabled(false);
} else if (play_mode == Core::Movie::PlayMode::MovieFinished) { } else if (play_mode == Core::Movie::PlayMode::MovieFinished) {
message_label->setText(tr("Movie Finished")); message_label->setText(tr("Movie Finished"));
message_label->setVisible(true); message_label->setVisible(true);
message_label_used_for_movie = true; message_label_used_for_movie = true;
ui->action_Save_Movie->setEnabled(false);
} else if (message_label_used_for_movie) { // Clear the label if movie was just closed } else if (message_label_used_for_movie) { // Clear the label if movie was just closed
message_label->setText(QString{}); message_label->setText(QString{});
message_label->setVisible(false); message_label->setVisible(false);
message_label_used_for_movie = false; message_label_used_for_movie = false;
ui->action_Save_Movie->setEnabled(false);
} }
auto results = Core::System::GetInstance().GetAndResetPerfStats(); auto results = Core::System::GetInstance().GetAndResetPerfStats();
@ -2309,6 +2336,7 @@ void GMainWindow::OnLanguageChanged(const QString& locale) {
} }
void GMainWindow::OnMoviePlaybackCompleted() { void GMainWindow::OnMoviePlaybackCompleted() {
OnPauseGame();
QMessageBox::information(this, tr("Playback Completed"), tr("Movie playback completed.")); QMessageBox::information(this, tr("Playback Completed"), tr("Movie playback completed."));
} }

View file

@ -209,6 +209,7 @@ private slots:
void OnRecordMovie(); void OnRecordMovie();
void OnPlayMovie(); void OnPlayMovie();
void OnCloseMovie(); void OnCloseMovie();
void OnSaveMovie();
void OnCaptureScreenshot(); void OnCaptureScreenshot();
#ifdef ENABLE_FFMPEG_VIDEO_DUMPER #ifdef ENABLE_FFMPEG_VIDEO_DUMPER
void OnStartVideoDumping(); void OnStartVideoDumping();

View file

@ -166,6 +166,7 @@
<addaction name="action_Close_Movie"/> <addaction name="action_Close_Movie"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="action_Movie_Read_Only_Mode"/> <addaction name="action_Movie_Read_Only_Mode"/>
<addaction name="action_Save_Movie"/>
</widget> </widget>
<widget class="QMenu" name="menu_Frame_Advance"> <widget class="QMenu" name="menu_Frame_Advance">
<property name="title"> <property name="title">
@ -334,6 +335,14 @@
<string>Close</string> <string>Close</string>
</property> </property>
</action> </action>
<action name="action_Save_Movie">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Save without Closing</string>
</property>
</action>
<action name="action_Movie_Read_Only_Mode"> <action name="action_Movie_Read_Only_Mode">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>

View file

@ -543,6 +543,7 @@ void Movie::StartPlayback(const std::string& movie_file) {
current_byte = 0; current_byte = 0;
current_input = 0; current_input = 0;
id = header.id; id = header.id;
program_id = header.program_id;
LOG_INFO(Movie, "Loaded Movie, ID: {:016X}", id); LOG_INFO(Movie, "Loaded Movie, ID: {:016X}", id);
} }

View file

@ -125,6 +125,12 @@ public:
u64 GetCurrentInputIndex() const; u64 GetCurrentInputIndex() const;
u64 GetTotalInputCount() const; u64 GetTotalInputCount() const;
/**
* Saves the movie immediately, in its current state.
* This is called in Shutdown.
*/
void SaveMovie();
private: private:
static Movie s_instance; static Movie s_instance;
@ -152,8 +158,6 @@ private:
ValidationResult ValidateHeader(const CTMHeader& header) const; ValidationResult ValidateHeader(const CTMHeader& header) const;
ValidationResult ValidateInput(const std::vector<u8>& input, u64 expected_count) const; ValidationResult ValidateInput(const std::vector<u8>& input, u64 expected_count) const;
void SaveMovie();
PlayMode play_mode; PlayMode play_mode;
std::string record_movie_file; std::string record_movie_file;