[gnome-games] retro: Adapt to changes in retro-gtk



commit 561b0241d767b3349af324034eca856a8fee35ed
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Fri Jul 7 11:11:47 2017 +0200

    retro: Adapt to changes in retro-gtk
    
    Adapt to the new game loading system in retro-gtk which does most of the
    job for the frontends. Also remove RetroRunner.try_load_game() as it is
    not needed anymore.

 src/retro/retro-runner.vala |   54 ++++++++----------------------------------
 1 files changed, 11 insertions(+), 43 deletions(-)
---
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index 8d7d5f8..bc5d67d 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -200,19 +200,6 @@ public class Games.RetroRunner : Object, Runner {
                input_manager = new RetroInputManager (widget, present_analog_sticks);
 
                prepare_core ();
-               if (media_set.get_size () == 0)
-                       core.prepare ();
-               else {
-                       var media_number = media_set.selected_media_number;
-                       var media = media_set.get_selected_media (media_number);
-                       var uris = media.get_uris ();
-                       if (uris.length == 0)
-                               throw new RetroError.INVALID_GAME_FILE (_("No game file found for media 
ā€œ%sā€."), media.title.get_title ());
-
-                       var uri = uris[0];
-                       if (!try_load_game (core, uri))
-                               throw new RetroError.INVALID_GAME_FILE (_("Invalid game file: ā€œ%sā€."), 
uri.to_string ());
-               }
 
                core.shutdown.connect (on_shutdown);
 
@@ -283,38 +270,17 @@ public class Games.RetroRunner : Object, Runner {
                core.input_interface = input_manager;
                core.rumble_interface = input_manager;
 
-               core.init ();
-       }
-
-       private bool try_load_game (Retro.Core core, Uri uri) {
-               var file = uri.to_file ();
-               var path = file.get_path ();
-
-               try {
-                       var fullpath = core.system_info.need_fullpath;
-                       if (core.load_game (fullpath ? Retro.GameInfo (path) : Retro.GameInfo.with_data 
(path))) {
-                               if (core.disk_control_interface != null) {
-                                       var disk = core.disk_control_interface;
-
-                                       disk.set_eject_state (true);
-
-                                       while (disk.get_num_images () < 1)
-                                               disk.add_image_index ();
-
-                                       var index = disk.get_num_images () - 1;
+               string[] medias_uris = {};
+               media_set.foreach_media ((media) => {
+                       var uris = media.get_uris ();
+                       medias_uris += (uris.length == 0) ? "" : uris[0].to_string ();
+               });
 
-                                       disk.replace_image_index (index, fullpath ? Retro.GameInfo (path) : 
Retro.GameInfo.with_data (path));
+               core.set_medias (medias_uris);
 
-                                       disk.set_eject_state (false);
-                               }
-                               return true;
-                       }
-               }
-               catch (Error e) {
-                       debug (e.message);
-               }
+               core.init ();
 
-               return false;
+               core.set_current_media (media_set.selected_media_number);
        }
 
        public void pause () {
@@ -347,6 +313,8 @@ public class Games.RetroRunner : Object, Runner {
                if (!is_initialized)
                        return;
 
+               core.set_current_media (media_set.selected_media_number);
+
                var media_number = media_set.selected_media_number;
 
                Media media = null;
@@ -365,7 +333,7 @@ public class Games.RetroRunner : Object, Runner {
 
                var uri = uris[0];
 
-               try_load_game (core, uri);
+               core.set_current_media (media_set.selected_media_number);
 
                try {
                        save_media_data ();


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