[gnome-games] runner: Replace load_savestate() with load_previewed_savestate()



commit 29c839933f9bdc2642eab255320fba20a99cdfc6
Author: Yetizone <andreii lisita gmail com>
Date:   Thu Aug 8 15:16:39 2019 +0300

    runner: Replace load_savestate() with load_previewed_savestate()

 src/command/command-runner.vala | 14 +++++++-------
 src/core/runner.vala            |  2 +-
 src/dummy/dummy-runner.vala     | 14 +++++++-------
 src/retro/retro-runner.vala     | 24 +++++++++++-------------
 src/ui/display-view.vala        |  3 ++-
 5 files changed, 28 insertions(+), 29 deletions(-)
---
diff --git a/src/command/command-runner.vala b/src/command/command-runner.vala
index cf220943..6d5d1b94 100644
--- a/src/command/command-runner.vala
+++ b/src/command/command-runner.vala
@@ -62,6 +62,13 @@ public class Games.CommandRunner : Object, Runner {
        public void preview_savestate (Savestate savestate) {
        }
 
+       public void load_previewed_savestate () {
+       }
+
+       public Savestate[] get_savestates () {
+               return {};
+       }
+
        public void start () throws Error {
                string? working_directory = null;
                string[]? envp = null;
@@ -99,13 +106,6 @@ public class Games.CommandRunner : Object, Runner {
                return false;
        }
 
-       public void load_savestate (Savestate savestate) {
-       }
-
-       public Savestate[] get_savestates () {
-               return {};
-       }
-
        public InputMode[] get_available_input_modes () {
                return { };
        }
diff --git a/src/core/runner.vala b/src/core/runner.vala
index abdd6bab..3dd47682 100644
--- a/src/core/runner.vala
+++ b/src/core/runner.vala
@@ -24,7 +24,7 @@ public interface Games.Runner : Object {
        public abstract void preview_savestate (Savestate savestate);
 
        public abstract bool try_create_savestate (bool is_automatic);
-       public abstract void load_savestate (Savestate savestate) throws Error;
+       public abstract void load_previewed_savestate () throws Error;
        public abstract Savestate[] get_savestates ();
 
        public abstract InputMode[] get_available_input_modes ();
diff --git a/src/dummy/dummy-runner.vala b/src/dummy/dummy-runner.vala
index 634ace0e..a3db95c3 100644
--- a/src/dummy/dummy-runner.vala
+++ b/src/dummy/dummy-runner.vala
@@ -49,6 +49,13 @@ private class Games.DummyRunner : Object, Runner {
        public void preview_savestate (Savestate savestate) {
        }
 
+       public void load_previewed_savestate () {
+       }
+
+       public Savestate[] get_savestates () {
+               return {};
+       }
+
        public void start () throws Error {
        }
 
@@ -65,13 +72,6 @@ private class Games.DummyRunner : Object, Runner {
                return false;
        }
 
-       public void load_savestate (Savestate savestate) {
-       }
-
-       public Savestate[] get_savestates () {
-               return {};
-       }
-
        public InputMode[] get_available_input_modes () {
                return { };
        }
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index 8b8bfd80..457298ca 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -184,22 +184,16 @@ public class Games.RetroRunner : Object, Runner {
                view.set_pixbuf (pixbuf);
        }
 
-       public virtual Gtk.Widget? get_extra_widget () {
-               return null;
-       }
-
-       public void load_savestate (Savestate savestate) throws Error {
-               stop ();
-
-               tmp_live_savestate = savestate.clone_in_tmp ();
-               instantiate_core (tmp_live_savestate.get_save_directory_path ());
+       public void load_previewed_savestate () throws Error {
+               loop.stop ();
 
+               tmp_live_savestate = previewed_savestate.clone_in_tmp ();
                core.save_directory = tmp_live_savestate.get_save_directory_path ();
-               load_save_ram (savestate.get_save_ram_path ());
-               core.set_state (savestate.get_snapshot_data ());
+               load_save_ram (previewed_savestate.get_save_ram_path ());
+               core.set_state (previewed_savestate.get_snapshot_data ());
 
-               if (savestate.has_media_data ())
-                       media_set.selected_media_number = savestate.get_media_data ();
+               if (previewed_savestate.has_media_data ())
+                       media_set.selected_media_number = previewed_savestate.get_media_data ();
 
                loop.start ();
 
@@ -207,6 +201,10 @@ public class Games.RetroRunner : Object, Runner {
                running = true;
        }
 
+       public virtual Gtk.Widget? get_extra_widget () {
+               return null;
+       }
+
        public Savestate[] get_savestates () {
                if (game_savestates == null) {
                        critical ("RetroRunner hasn't loaded savestates. Call try_init_phase_one()");
diff --git a/src/ui/display-view.vala b/src/ui/display-view.vala
index 4f8ef415..7b0c3ab7 100644
--- a/src/ui/display-view.vala
+++ b/src/ui/display-view.vala
@@ -275,7 +275,8 @@ private class Games.DisplayView : Object, UiView {
                                var savestates = box.runner.get_savestates ();
                                var latest_savestate = savestates[0];
 
-                               box.runner.load_savestate (latest_savestate);
+                               box.runner.preview_savestate (latest_savestate);
+                               box.runner.load_previewed_savestate ();
                        }
                        else
                                runner.start ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]