[gnome-games] display-view: Recreate the runner when restarting
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] display-view: Recreate the runner when restarting
- Date: Sat, 14 Mar 2020 16:32:10 +0000 (UTC)
commit af4bd40fb2e9212333cc0cab701824f0c642ba03
Author: Neville <nevilleantony98 gmail com>
Date: Thu Mar 12 16:31:42 2020 +0530
display-view: Recreate the runner when restarting
Currently restart just asks the core to restart and it's up to the cores
to support it. Some cores, such as BlastEm or MAME, don't handle it.
To circumvent it, destroy the current runner and create a new one, that
is guaranteed to work.
Additionally, adds and shows a dialog in case the current game cannot be saved,
same as when quitting the game.
src/ui/display-view.vala | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
---
diff --git a/src/ui/display-view.vala b/src/ui/display-view.vala
index 384ed520..20a4e274 100644
--- a/src/ui/display-view.vala
+++ b/src/ui/display-view.vala
@@ -55,6 +55,7 @@ private class Games.DisplayView : Object, UiView {
private ResumeDialog resume_dialog;
private ResumeFailedDialog resume_failed_dialog;
private QuitDialog quit_dialog;
+ private RestartDialog restart_dialog;
private long focus_out_timeout_id;
private Game game;
@@ -243,6 +244,9 @@ private class Games.DisplayView : Object, UiView {
if (quit_dialog != null)
return quit_dialog.is_active && quit_dialog.gamepad_button_press_event (event);
+ if (restart_dialog != null)
+ return restart_dialog.is_active && restart_dialog.gamepad_button_press_event (event);
+
if (!window.is_active || !window.get_mapped ())
return false;
@@ -580,6 +584,9 @@ private class Games.DisplayView : Object, UiView {
if (quit_game_cancellable != null)
return false;
+ if (restart_dialog != null)
+ return false;
+
return true;
}
@@ -606,8 +613,28 @@ private class Games.DisplayView : Object, UiView {
private void restart () {
if (runner != null && runner.is_integrated) {
+ runner.pause ();
+
+ if (runner.try_create_snapshot (true) == null) {
+ restart_dialog = new RestartDialog ();
+ restart_dialog.transient_for = window;
+
+ var response = restart_dialog.run ();
+ restart_dialog.destroy ();
+ restart_dialog = null;
+
+ if (response == Gtk.ResponseType.CANCEL || response ==
Gtk.ResponseType.DELETE_EVENT) {
+ runner.resume ();
+
+ return;
+ }
+ }
+
+ runner.stop ();
+ runner = try_get_runner (game);
+
try {
- runner.restart ();
+ runner.start ();
}
catch (Error e) {
critical ("Couldn't restart: %s", e.message);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]