[gnome-games/wip/exalm/runner-refactor: 21/56] retro-runner: Move retro-specific snapshot creation to save_statestate_metadata()



commit 960b78fa324958b04c13288ee4d512e501f33649
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Fri Mar 6 16:53:42 2020 +0500

    retro-runner: Move retro-specific snapshot creation to save_statestate_metadata()

 src/retro/retro-runner.vala | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
---
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index bdb0dbbe..2b4a90c7 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -479,15 +479,6 @@ public class Games.RetroRunner : Object, Runner {
                if (is_automatic)
                        trim_autosaves ();
 
-               // Populate the savestate in tmp with data from the current state of the game
-               store_save_ram_in_tmp ();
-
-               if (media_set.get_size () > 1)
-                       tmp_live_savestate.set_media_data (media_set);
-
-               core.save_state (tmp_live_savestate.get_snapshot_path ());
-               save_screenshot_in_tmp ();
-
                // Populate the metadata file
                tmp_live_savestate.is_automatic = is_automatic;
 
@@ -497,10 +488,11 @@ public class Games.RetroRunner : Object, Runner {
                        tmp_live_savestate.name = create_new_savestate_name ();
 
                tmp_live_savestate.creation_date = new DateTime.now ();
-               tmp_live_savestate.screenshot_aspect_ratio = Retro.pixbuf_get_aspect_ratio 
(current_state_pixbuf);
 
                save_savestate_metadata (tmp_live_savestate);
 
+               tmp_live_savestate.write_metadata ();
+
                // Save the tmp_live_savestate into the game savestates directory
                var game_savestates_dir_path = get_game_savestates_dir_path ();
                var savestate = tmp_live_savestate.save_in (game_savestates_dir_path);
@@ -643,7 +635,17 @@ public class Games.RetroRunner : Object, Runner {
        }
 
        protected virtual void save_savestate_metadata (Savestate savestate) throws Error {
-               tmp_live_savestate.write_metadata ();
+               // Populate the savestate in tmp with data from the current state of the game
+               store_save_ram_in_tmp ();
+
+               if (media_set.get_size () > 1)
+                       savestate.set_media_data (media_set);
+
+               core.save_state (savestate.get_snapshot_path ());
+               save_screenshot_in_tmp ();
+               savestate.screenshot_aspect_ratio = Retro.pixbuf_get_aspect_ratio (current_state_pixbuf);
+
+               savestate.write_metadata ();
        }
 
        protected virtual void load_savestate_metadata (Savestate savestate) throws Error {


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