[gnome-games/wip/aplazas/type-registration: 2/5] retro: Add RetroSimpleGameUriAdapter
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/aplazas/type-registration: 2/5] retro: Add RetroSimpleGameUriAdapter
- Date: Thu, 25 May 2017 12:47:54 +0000 (UTC)
commit 8e771a141fc375b4d90f4251bce2039691fd1b2a
Author: Adrien Plazas <kekun plazas laposte net>
Date: Thu May 25 14:02:12 2017 +0200
retro: Add RetroSimpleGameUriAdapter
This will be used to avoid code duplication in many plugins.
src/Makefile.am | 1 +
src/retro/retro-simple-game-uri-adapter.vala | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 28c1f81..184efe1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -100,6 +100,7 @@ gnome_games_SOURCES = \
retro/retro-input-manager.vala \
retro/retro-platform.vala \
retro/retro-runner.vala \
+ retro/retro-simple-game-uri-adapter.vala \
retro/retro-simple-type.vala \
\
tracker/mime-type-tracker-uri-query.vala \
diff --git a/src/retro/retro-simple-game-uri-adapter.vala b/src/retro/retro-simple-game-uri-adapter.vala
new file mode 100644
index 0000000..c5eb3ae
--- /dev/null
+++ b/src/retro/retro-simple-game-uri-adapter.vala
@@ -0,0 +1,26 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+private class Games.RetroSimpleGameUriAdapter : GameUriAdapter, Object {
+ private RetroSimpleType simple_type;
+
+ public RetroSimpleGameUriAdapter (RetroSimpleType simple_type) {
+ this.simple_type = simple_type;
+ }
+
+ public async Game game_for_uri (Uri uri) throws Error {
+ Idle.add (this.game_for_uri.callback);
+ yield;
+
+ var uid = new FingerprintUid (uri, simple_type.prefix);
+ var title = new FilenameTitle (uri);
+ var icon = new DummyIcon ();
+ var media = new GriloMedia (title, simple_type.mime_type);
+ var cover = new CompositeCover ({
+ new LocalCover (uri),
+ new GriloCover (media, uid)});
+ var core_source = new RetroCoreSource (simple_type.platform, { simple_type.mime_type });
+ var runner = new RetroRunner (core_source, uri, uid, title);
+
+ return new GenericGame (title, icon, cover, runner);
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]