[gnome-games] Add the wonderswan plugin



commit 025faef6fcebe107e5f59031f5bf0044b858100c
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Thu May 25 08:04:14 2017 +0200

    Add the wonderswan plugin
    
    This allows to list WonderSwan and WonderSwan Color games.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=783068

 configure.ac                                  |    1 +
 plugins/Makefile.am                           |    4 ++
 plugins/wonderswan/Makefile.am                |    3 +
 plugins/wonderswan/configure.ac               |   14 +++++
 plugins/wonderswan/data/Makefile.am           |    6 ++
 plugins/wonderswan/data/wonderswan.plugin     |    6 ++
 plugins/wonderswan/src/Makefile.am            |   49 +++++++++++++++++
 plugins/wonderswan/src/wonderswan-plugin.vala |   69 +++++++++++++++++++++++++
 8 files changed, 152 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 1d6b4e0..ed8b187 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,6 +49,7 @@ m4_include([plugins/snes/configure.ac])
 m4_include([plugins/steam/configure.ac])
 m4_include([plugins/wii/configure.ac])
 m4_include([plugins/wii-ware/configure.ac])
+m4_include([plugins/wonderswan/configure.ac])
 
 PKG_CHECK_MODULES(GNOME_GAMES, [
        gio-2.0
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 6df3e70..69fda75 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -108,4 +108,8 @@ if ENABLE_WII_WARE_PLUGIN
 SUBDIRS += wii-ware
 endif
 
+if ENABLE_WONDERSWAN_PLUGIN
+SUBDIRS += wonderswan
+endif
+
 -include $(top_srcdir)/git.mk
diff --git a/plugins/wonderswan/Makefile.am b/plugins/wonderswan/Makefile.am
new file mode 100644
index 0000000..5d55ad0
--- /dev/null
+++ b/plugins/wonderswan/Makefile.am
@@ -0,0 +1,3 @@
+SUBDIRS = data src
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/wonderswan/configure.ac b/plugins/wonderswan/configure.ac
new file mode 100644
index 0000000..dab9a14
--- /dev/null
+++ b/plugins/wonderswan/configure.ac
@@ -0,0 +1,14 @@
+PKG_CHECK_MODULES(WONDERSWAN_PLUGIN, [
+       gio-2.0
+       glib-2.0 >= $GLIB_MIN_VERSION
+       gtk+-3.0
+       retro-gtk-0.10
+], [enable_wonderswan_plugin=yes], [enable_wonderswan_plugin=no])
+
+AM_CONDITIONAL(ENABLE_WONDERSWAN_PLUGIN, test x$enable_wonderswan_plugin != xno)
+
+AC_CONFIG_FILES([
+       plugins/wonderswan/Makefile
+       plugins/wonderswan/data/Makefile
+       plugins/wonderswan/src/Makefile
+])
diff --git a/plugins/wonderswan/data/Makefile.am b/plugins/wonderswan/data/Makefile.am
new file mode 100644
index 0000000..9251f3c
--- /dev/null
+++ b/plugins/wonderswan/data/Makefile.am
@@ -0,0 +1,6 @@
+EXTRA_DIST = $(plugin_DATA)
+
+plugindir = $(libdir)/gnome-games/plugins
+dist_plugin_DATA = wonderswan.plugin
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/wonderswan/data/wonderswan.plugin b/plugins/wonderswan/data/wonderswan.plugin
new file mode 100644
index 0000000..d055dfc
--- /dev/null
+++ b/plugins/wonderswan/data/wonderswan.plugin
@@ -0,0 +1,6 @@
+[Plugin]
+Module=libgames-wonderswan-plugin
+Name=WonderSwan Plugin
+Description=Provides support for WonderSwan/WonderSwan Color games.
+Authors=Adrien Plazas <kekun plazas laposte net>
+Copyright=Copyright © 2017 Adrien Plazas
diff --git a/plugins/wonderswan/src/Makefile.am b/plugins/wonderswan/src/Makefile.am
new file mode 100644
index 0000000..5488877
--- /dev/null
+++ b/plugins/wonderswan/src/Makefile.am
@@ -0,0 +1,49 @@
+plugindir = $(libdir)/gnome-games/plugins
+plugin_LTLIBRARIES = libgames-wonderswan-plugin.la
+
+libgames_wonderswan_plugin_la_DEPENDENCIES = \
+       $(top_builddir)/src/gnome-games.vapi \
+       $(NULL)
+
+libgames_wonderswan_plugin_la_SOURCES = \
+       wonderswan-plugin.vala \
+       $(NULL)
+
+libgames_wonderswan_plugin_la_VALAFLAGS = \
+       --target-glib=@GLIB_MIN_VERSION@ \
+       --pkg gnome-games \
+       --vapidir $(top_builddir)/src \
+       $(NULL)
+
+libgames_wonderswan_plugin_la_CFLAGS = \
+       $(WONDERSWAN_PLUGIN_CFLAGS) \
+       $(GNOME_GAMES_CFLAGS) \
+       -DG_LOG_DOMAIN=\"GamesWonderSwan\" \
+       -DLOCALEDIR=\"$(localedir)\" \
+       $(NULL)
+
+libgames_wonderswan_plugin_la_CPPFLAGS = \
+       -I$(top_srcdir) \
+       -I$(top_srcdir)/src \
+       $(NULL)
+
+libgames_wonderswan_plugin_la_LIBADD = \
+       $(WONDERSWAN_PLUGIN_LIBS) \
+       $(GNOME_GAMES_LIBS) \
+       $(NULL)
+
+libgames_wonderswan_plugin_la_LDFLAGS = \
+       -no-undefined \
+       -module \
+       -avoid-version \
+       $(NULL)
+
+EXTRA_DIST = \
+       $(plugin_DATA) \
+       $(NULL)
+
+MAINTAINERCLEANFILES = \
+       $(BUILT_SOURCES) \
+       $(NULL)
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/wonderswan/src/wonderswan-plugin.vala b/plugins/wonderswan/src/wonderswan-plugin.vala
new file mode 100644
index 0000000..d8a7e1a
--- /dev/null
+++ b/plugins/wonderswan/src/wonderswan-plugin.vala
@@ -0,0 +1,69 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+private class Games.WonderSwanPlugin : Object, Plugin {
+       private const string WONDERSWAN_PREFIX = "wonderswan";
+       private const string WONDERSWAN_MIME_TYPE = "application/x-wonderswan-rom";
+       private const string WONDERSWAN_PLATFORM = "WonderSwan";
+
+       private const string WONDERSWAN_COLOR_PREFIX = "wonderswan-color";
+       private const string WONDERSWAN_COLOR_MIME_TYPE = "application/x-wonderswan-color-rom";
+       private const string WONDERSWAN_COLOR_PLATFORM = "WonderSwanColor";
+
+       public string[] get_mime_types () {
+               return {
+                       WONDERSWAN_MIME_TYPE,
+                       WONDERSWAN_COLOR_MIME_TYPE,
+               };
+       }
+
+       public UriGameFactory[] get_uri_game_factories () {
+               var game_uri_adapter = new GenericGameUriAdapter (game_for_uri);
+               var factory = new GenericUriGameFactory (game_uri_adapter);
+               factory.add_mime_type (WONDERSWAN_MIME_TYPE);
+               factory.add_mime_type (WONDERSWAN_COLOR_MIME_TYPE);
+
+               return { factory };
+       }
+
+       private static Game game_for_uri (Uri uri) throws Error {
+               var file = uri.to_file ();
+               var file_info = file.query_info (FileAttribute.STANDARD_CONTENT_TYPE, 
FileQueryInfoFlags.NONE);
+               var mime_type = file_info.get_content_type ();
+
+               string prefix;
+               string platform;
+               switch (mime_type) {
+               case WONDERSWAN_MIME_TYPE:
+                       prefix = WONDERSWAN_PREFIX;
+                       platform = WONDERSWAN_PLATFORM;
+
+                       break;
+               case WONDERSWAN_COLOR_MIME_TYPE:
+                       prefix = WONDERSWAN_COLOR_PREFIX;
+                       platform = WONDERSWAN_COLOR_PLATFORM;
+
+                       break;
+               default:
+                       assert_not_reached ();
+
+                       break;
+               }
+
+               var uid = new FingerprintUid (uri, prefix);
+               var title = new FilenameTitle (uri);
+               var icon = new DummyIcon ();
+               var media = new GriloMedia (title, mime_type);
+               var cover = new CompositeCover ({
+                       new LocalCover (uri),
+                       new GriloCover (media, uid)});
+               var core_source = new RetroCoreSource (platform, { mime_type });
+               var runner = new RetroRunner (core_source, uri, uid, title);
+
+               return new GenericGame (title, icon, cover, runner);
+       }
+}
+
+[ModuleInit]
+public Type register_games_plugin (TypeModule module) {
+       return typeof(Games.WonderSwanPlugin);
+}


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