[gnome-games] plugins: Add MS-DOS plugin



commit 02cdc7f49332c7fd5a1300c1a1be5d35ff26d6ce
Author: Yetizone <andreii lisita gmail com>
Date:   Thu Dec 6 15:12:57 2018 +0200

    plugins: Add MS-DOS plugin

 meson_options.txt                                 |  1 +
 plugins/meson.build                               |  1 +
 plugins/ms-dos/data/meson.build                   |  1 +
 plugins/ms-dos/data/ms-dos.plugin                 |  6 +++
 plugins/ms-dos/meson.build                        |  2 +
 plugins/ms-dos/src/meson.build                    | 17 +++++++
 plugins/ms-dos/src/ms-dos-input-capabilities.vala | 15 ++++++
 plugins/ms-dos/src/ms-dos-plugin.vala             | 61 +++++++++++++++++++++++
 po/POTFILES.in                                    |  1 +
 9 files changed, 105 insertions(+)
---
diff --git a/meson_options.txt b/meson_options.txt
index 3956cf6d..998ffb44 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -16,6 +16,7 @@ option ('game-cube-plugin',     description: 'Support for GameCube games',
 option ('libretro-plugin',      description: 'Support for Libretro games',      type: 'boolean')
 option ('love-plugin',          description: 'Support for LÖVE games',          type: 'boolean')
 option ('mame-plugin',          description: 'Support for MAME games',          type: 'boolean', value: 
false)
+option ('ms-dos-plugin',        description: 'Support for MS-DOS games',        type: 'boolean')
 option ('nintendo-ds-plugin',   description: 'Support for Nintendo DS games',   type: 'boolean')
 option ('playstation-plugin',   description: 'Support for PlayStation games',   type: 'boolean')
 option ('sega-cd-plugin',       description: 'Support for Sega CD games',       type: 'boolean')
diff --git a/plugins/meson.build b/plugins/meson.build
index 53265cfb..3fe8b172 100644
--- a/plugins/meson.build
+++ b/plugins/meson.build
@@ -5,6 +5,7 @@ plugins = [
   'libretro',
   'love',
   'mame',
+  'ms-dos',
   'nintendo-ds',
   'playstation',
   'sega-cd',
diff --git a/plugins/ms-dos/data/meson.build b/plugins/ms-dos/data/meson.build
new file mode 100644
index 00000000..0d4b6c49
--- /dev/null
+++ b/plugins/ms-dos/data/meson.build
@@ -0,0 +1 @@
+install_data (plugin_name + '.plugin', install_dir: plugins_dir)
diff --git a/plugins/ms-dos/data/ms-dos.plugin b/plugins/ms-dos/data/ms-dos.plugin
new file mode 100644
index 00000000..e8424f03
--- /dev/null
+++ b/plugins/ms-dos/data/ms-dos.plugin
@@ -0,0 +1,6 @@
+[Plugin]
+Module=libgames-ms-dos-plugin
+Name=MS-DOS Plugin
+Description=Provides support for MS-DOS games.
+Authors=Andrei Lisita <andreii lisita gmail com>
+Copyright=Copyright © 2018 Andrei Lisita
diff --git a/plugins/ms-dos/meson.build b/plugins/ms-dos/meson.build
new file mode 100644
index 00000000..d7e84900
--- /dev/null
+++ b/plugins/ms-dos/meson.build
@@ -0,0 +1,2 @@
+subdir ('data')
+subdir ('src')
diff --git a/plugins/ms-dos/src/meson.build b/plugins/ms-dos/src/meson.build
new file mode 100644
index 00000000..8b0253af
--- /dev/null
+++ b/plugins/ms-dos/src/meson.build
@@ -0,0 +1,17 @@
+vala_sources = [
+  'ms-dos-input-capabilities.vala',
+  'ms-dos-plugin.vala',
+]
+
+c_args = [
+  '-DG_LOG_DOMAIN="GamesMsDos"'
+]
+
+shared_module (
+  'games-' + plugin_name + '-plugin',
+  vala_sources,
+  dependencies: gnome_games_dep,
+  c_args: c_args,
+  install: true,
+  install_dir: plugins_dir
+)
diff --git a/plugins/ms-dos/src/ms-dos-input-capabilities.vala 
b/plugins/ms-dos/src/ms-dos-input-capabilities.vala
new file mode 100644
index 00000000..1a361e6f
--- /dev/null
+++ b/plugins/ms-dos/src/ms-dos-input-capabilities.vala
@@ -0,0 +1,15 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+public class Games.MsDosInputCapabilities : Object, InputCapabilities {
+       public bool get_allow_classic_gamepads () throws Error {
+               return true;
+       }
+
+       public bool get_allow_analog_gamepads () throws Error {
+               return true;
+       }
+
+       public bool get_allow_keyboard_mode () {
+               return true;
+       }
+}
diff --git a/plugins/ms-dos/src/ms-dos-plugin.vala b/plugins/ms-dos/src/ms-dos-plugin.vala
new file mode 100644
index 00000000..8d3c69fc
--- /dev/null
+++ b/plugins/ms-dos/src/ms-dos-plugin.vala
@@ -0,0 +1,61 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+private class Games.MsDosPlugin : Object, Plugin {
+       private const string FINGERPRINT_PREFIX = "ms-dos";
+       private const string MIME_TYPE = "application/x-ms-dos-executable";
+       private const string PLATFORM_ID = "MSDOS";
+       private const string PLATFORM_NAME = _("MS-DOS");
+
+       private static Platform platform;
+
+       static construct {
+               platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME);
+       }
+
+       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 (MIME_TYPE);
+
+               return { factory };
+       }
+
+       private static Game game_for_uri (Uri uri) throws Error {
+               var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
+               var title = new FilenameTitle (uri);
+               var media = new GriloMedia (title, MIME_TYPE);
+               var release_date = new GriloReleaseDate (media);
+               var cooperative = new GriloCooperative (media);
+               var genre = new GriloGenre (media);
+               var players = new GriloPlayers (media);
+               var developer = new GriloDeveloper (media);
+               var publisher = new GriloPublisher (media);
+               var description = new GriloDescription (media);
+               var rating = new GriloRating (media);
+               var cover = new CompositeCover ({
+                       new LocalCover (uri),
+                       new GriloCover (media, uid)});
+
+               var core_source = new RetroCoreSource (platform, { MIME_TYPE });
+               var input_capabilities = new MsDosInputCapabilities();
+               var runner = new RetroRunner (core_source, uri, uid, title, input_capabilities);
+
+               var game = new GenericGame (uid, title, platform, runner);
+               game.set_cover (cover);
+               game.set_release_date (release_date);
+               game.set_cooperative (cooperative);
+               game.set_genre (genre);
+               game.set_players (players);
+               game.set_developer (developer);
+               game.set_publisher (publisher);
+               game.set_description (description);
+               game.set_rating (rating);
+
+               return game;
+       }
+}
+
+[ModuleInit]
+public Type register_games_plugin (TypeModule module) {
+       return typeof (Games.MsDosPlugin);
+}
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ce98eebf..a30a8a13 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -34,6 +34,7 @@ plugins/love/src/love-package.vala
 plugins/love/src/love-plugin.vala
 plugins/mame/src/mame-game-uri-adapter.vala
 plugins/mame/src/mame-plugin.vala
+plugins/ms-dos/src/ms-dos-plugin.vala
 plugins/nintendo-ds/src/nintendo-ds-plugin.vala
 plugins/playstation/src/playstation-header.vala
 plugins/playstation/src/playstation-plugin.vala


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