[gnome-games/wip/exalm/savestates: 1/20] retro-runner: Split resetting out of load_extra_savestate_metadata()



commit e57d0b4f93b429f560e02c28115c76c33677f49e
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Sat Jan 25 23:03:46 2020 +0500

    retro-runner: Split resetting out of load_extra_savestate_metadata()
    
    Also rename the functions to remove the "extra" part.

 plugins/nintendo-ds/src/nintendo-ds-runner.vala | 15 +++++++--------
 src/retro/retro-runner.vala                     | 13 ++++++++-----
 2 files changed, 15 insertions(+), 13 deletions(-)
---
diff --git a/plugins/nintendo-ds/src/nintendo-ds-runner.vala b/plugins/nintendo-ds/src/nintendo-ds-runner.vala
index bfebab0f..2d7901ec 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-runner.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-runner.vala
@@ -113,7 +113,7 @@ private class Games.NintendoDsRunner : RetroRunner {
                return true;
        }
 
-       protected override void save_extra_savestate_metadata (Savestate savestate) {
+       protected override void save_savestate_metadata (Savestate savestate) {
                assert (savestate is NintendoDsSavestate);
 
                var ds_savestate = savestate as NintendoDsSavestate;
@@ -121,13 +121,7 @@ private class Games.NintendoDsRunner : RetroRunner {
                ds_savestate.view_bottom_screen = view_bottom_screen;
        }
 
-       protected override void load_extra_savestate_metadata (Savestate savestate, bool reset) {
-               if (reset) {
-                       screen_layout = NintendoDsLayout.TOP_BOTTOM;
-                       view_bottom_screen = false;
-                       return;
-               }
-
+       protected override void load_savestate_metadata (Savestate savestate) {
                assert (savestate is NintendoDsSavestate);
 
                var ds_savestate = savestate as NintendoDsSavestate;
@@ -136,4 +130,9 @@ private class Games.NintendoDsRunner : RetroRunner {
                screen_layout = ds_savestate.screen_layout;
                view_bottom_screen = ds_savestate.view_bottom_screen;
        }
+
+       protected override void reset_metadata (Savestate last_savestate) {
+               screen_layout = NintendoDsLayout.TOP_BOTTOM;
+               view_bottom_screen = false;
+       }
 }
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index ee0eea56..bd16b903 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -208,7 +208,7 @@ public class Games.RetroRunner : Object, Runner {
                if (previewed_savestate.has_media_data ())
                        media_set.selected_media_number = previewed_savestate.get_media_data ();
 
-               load_extra_savestate_metadata (previewed_savestate, false);
+               load_savestate_metadata (previewed_savestate);
 
                is_ready = true;
        }
@@ -244,7 +244,7 @@ public class Games.RetroRunner : Object, Runner {
                loop.start ();
 
                if (latest_savestate != null)
-                       load_extra_savestate_metadata (latest_savestate, true);
+                       reset_metadata (latest_savestate);
 
                running = true;
        }
@@ -488,7 +488,7 @@ public class Games.RetroRunner : Object, Runner {
 
                // FIXME: Because of how saving metadata is done currently, saving
                // any additional data has to be done before the keyfile is written
-               save_extra_savestate_metadata (tmp_live_savestate);
+               save_savestate_metadata (tmp_live_savestate);
 
                if (is_automatic)
                        tmp_live_savestate.set_metadata_automatic (now_time, platform_prefix,
@@ -660,10 +660,13 @@ public class Games.RetroRunner : Object, Runner {
                }
        }
 
-       protected virtual void save_extra_savestate_metadata (Savestate savestate) {
+       protected virtual void save_savestate_metadata (Savestate savestate) {
        }
 
-       protected virtual void load_extra_savestate_metadata (Savestate savestate, bool reset) {
+       protected virtual void load_savestate_metadata (Savestate savestate) {
+       }
+
+       protected virtual void reset_metadata (Savestate last_savestate) {
        }
 }
 


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