[gnome-games/wip/aplazas/generic-game: 4/4] generic-game: Pass only necessary data to the constructor
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/aplazas/generic-game: 4/4] generic-game: Pass only necessary data to the constructor
- Date: Thu, 19 Jul 2018 19:20:05 +0000 (UTC)
commit fb3c25dabda399a490e4aa6387685b1a750692e1
Author: Adrien Plazas <kekun plazas laposte net>
Date: Thu Jul 19 20:53:42 2018 +0200
generic-game: Pass only necessary data to the constructor
Also makes usage of the previously introduced metadata setters and drop
explicit creation of dummy implementations.
plugins/desktop/src/desktop-plugin.vala | 10 ++++------
plugins/dreamcast/src/dreamcast-plugin.vala | 10 ++++++++--
plugins/game-cube/src/game-cube-plugin.vala | 10 ++++++++--
plugins/libretro/src/libretro-plugin.vala | 10 ++++------
plugins/love/src/love-plugin.vala | 10 +++++-----
plugins/mame/src/mame-game-uri-adapter.vala | 10 ++++------
plugins/nintendo-ds/src/nintendo-ds-plugin.vala | 10 +++++++++-
plugins/playstation/src/playstation-game-factory.vala | 10 ++++++++--
plugins/sega-cd/src/sega-cd-plugin.vala | 10 ++++++++--
plugins/sega-saturn/src/sega-saturn-plugin.vala | 10 ++++++++--
plugins/steam/src/steam-plugin.vala | 9 ++++-----
plugins/turbografx-cd/src/turbografx-cd-plugin.vala | 10 ++++++++--
plugins/virtual-boy/src/virtual-boy-plugin.vala | 10 ++++++++--
plugins/wii/src/wii-plugin.vala | 10 ++++++++--
src/generic/generic-game.vala | 8 +-------
src/retro/retro-simple-game-uri-adapter.vala | 10 ++++++++--
16 files changed, 103 insertions(+), 54 deletions(-)
---
diff --git a/plugins/desktop/src/desktop-plugin.vala b/plugins/desktop/src/desktop-plugin.vala
index 7a04425..b630f5f 100644
--- a/plugins/desktop/src/desktop-plugin.vala
+++ b/plugins/desktop/src/desktop-plugin.vala
@@ -41,11 +41,6 @@ private class Games.DesktopPlugin : Object, Plugin {
var uid = new DesktopUid (app_info);
var title = new DesktopTitle (app_info);
var icon = new DesktopIcon (app_info);
- var cover = new DummyCover ();
- var release_date = new DummyReleaseDate ();
- var cooperative = new DummyCooperative ();
- var genre = new DummyGenre ();
- var players = new DummyPlayers ();
string[] args;
var command = app_info.get_commandline ();
@@ -53,7 +48,10 @@ private class Games.DesktopPlugin : Object, Plugin {
throw new CommandError.INVALID_COMMAND (_("Invalid command ā%sā."), command);
var runner = new CommandRunner (args, true);
- return new GenericGame (uid, title, icon, cover, release_date, cooperative, genre, players,
runner);
+ var game = new GenericGame (uid, title, runner);
+ game.set_icon (icon);
+
+ return game;
}
private static void check_uri (Uri uri) throws Error {
diff --git a/plugins/dreamcast/src/dreamcast-plugin.vala b/plugins/dreamcast/src/dreamcast-plugin.vala
index f67bcc8..ec10bbc 100644
--- a/plugins/dreamcast/src/dreamcast-plugin.vala
+++ b/plugins/dreamcast/src/dreamcast-plugin.vala
@@ -23,7 +23,6 @@ private class Games.DreamcastPlugin : Object, Plugin {
var uid = new DreamcastUid (header);
var title = new FilenameTitle (uri);
- var icon = new DummyIcon ();
var media = new GriloMedia (title, MIME_TYPE);
var cover = new CompositeCover ({
new LocalCover (uri),
@@ -35,7 +34,14 @@ private class Games.DreamcastPlugin : Object, Plugin {
var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
var runner = new RetroRunner (core_source, uri, uid, title);
- return new GenericGame (uid, title, icon, cover, release_date, cooperative, genre, players,
runner);
+ var game = new GenericGame (uid, title, runner);
+ game.set_cover (cover);
+ game.set_release_date (release_date);
+ game.set_cooperative (cooperative);
+ game.set_genre (genre);
+ game.set_players (players);
+
+ return game;
}
}
diff --git a/plugins/game-cube/src/game-cube-plugin.vala b/plugins/game-cube/src/game-cube-plugin.vala
index 90bc744..877cbc0 100644
--- a/plugins/game-cube/src/game-cube-plugin.vala
+++ b/plugins/game-cube/src/game-cube-plugin.vala
@@ -23,7 +23,6 @@ private class Games.GameCubePlugin : Object, Plugin {
var uid = new GameCubeUid (header);
var title = new FilenameTitle (uri);
- var icon = new DummyIcon ();
var media = new GriloMedia (title, MIME_TYPE);
var cover = new CompositeCover ({
new LocalCover (uri),
@@ -35,7 +34,14 @@ private class Games.GameCubePlugin : Object, Plugin {
var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
var runner = new RetroRunner (core_source, uri, uid, title);
- return new GenericGame (uid, title, icon, cover, release_date, cooperative, genre, players,
runner);
+ var game = new GenericGame (uid, title, runner);
+ game.set_cover (cover);
+ game.set_release_date (release_date);
+ game.set_cooperative (cooperative);
+ game.set_genre (genre);
+ game.set_players (players);
+
+ return game;
}
}
diff --git a/plugins/libretro/src/libretro-plugin.vala b/plugins/libretro/src/libretro-plugin.vala
index e04555c..0aa4d03 100644
--- a/plugins/libretro/src/libretro-plugin.vala
+++ b/plugins/libretro/src/libretro-plugin.vala
@@ -31,14 +31,12 @@ private class Games.LibretroPlugin : Object, Plugin {
var uid = new LibretroUid (core_descriptor);
var title = new LibretroTitle (core_descriptor);
var icon = new LibretroIcon (core_descriptor);
- var cover = new DummyCover ();
- var release_date = new DummyReleaseDate ();
- var cooperative = new DummyCooperative ();
- var genre = new DummyGenre ();
- var players = new DummyPlayers ();
var runner = new RetroRunner.for_core_descriptor (core_descriptor, uid, title);
- return new GenericGame (uid, title, icon, cover, release_date, cooperative, genre, players,
runner);
+ var game = new GenericGame (uid, title, runner);
+ game.set_icon (icon);
+
+ return game;
}
}
diff --git a/plugins/love/src/love-plugin.vala b/plugins/love/src/love-plugin.vala
index 1fa9a0a..e83356d 100644
--- a/plugins/love/src/love-plugin.vala
+++ b/plugins/love/src/love-plugin.vala
@@ -22,14 +22,14 @@ private class Games.LovePlugin : Object, Plugin {
var title = new LoveTitle (package);
var icon = new LoveIcon (package);
var cover = new LocalCover (uri);
- var release_date = new DummyReleaseDate ();
- var cooperative = new DummyCooperative ();
- var genre = new DummyGenre ();
- var players = new DummyPlayers ();
string[] args = { "love", uri.to_string () };
var runner = new CommandRunner (args, true);
- return new GenericGame (uid, title, icon, cover, release_date, cooperative, genre, players,
runner);
+ var game = new GenericGame (uid, title, runner);
+ game.set_icon (icon);
+ game.set_cover (cover);
+
+ return game;
}
}
diff --git a/plugins/mame/src/mame-game-uri-adapter.vala b/plugins/mame/src/mame-game-uri-adapter.vala
index 08faac7..b036d19 100644
--- a/plugins/mame/src/mame-game-uri-adapter.vala
+++ b/plugins/mame/src/mame-game-uri-adapter.vala
@@ -24,18 +24,16 @@ private class Games.MameGameUriAdapter : GameUriAdapter, Object {
title_string = title_string.strip ();
var title = new GenericTitle (title_string);
- var icon = new DummyIcon ();
var cover = new LocalCover (uri);
- var release_date = new DummyReleaseDate ();
- var cooperative = new DummyCooperative ();
- var genre = new DummyGenre ();
- var players = new DummyPlayers ();
var core_source = new RetroCoreSource (PLATFORM, { SEARCHED_MIME_TYPE, SPECIFIC_MIME_TYPE });
var runner = new RetroRunner (core_source, uri, uid, title);
Idle.add (this.game_for_uri.callback);
yield;
- return new GenericGame (uid, title, icon, cover, release_date, cooperative, genre, players,
runner);
+ var game = new GenericGame (uid, title, runner);
+ game.set_cover (cover);
+
+ return game;
}
}
diff --git a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
index 0d759cb..9e8acfa 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
@@ -32,7 +32,15 @@ private class Games.NintendoDsPlugin : Object, Plugin {
var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
var runner = new RetroRunner (core_source, uri, uid, title);
- return new GenericGame (uid, title, icon, cover, release_date, cooperative, genre, players,
runner);
+ var game = new GenericGame (uid, title, runner);
+ game.set_icon (icon);
+ game.set_cover (cover);
+ game.set_release_date (release_date);
+ game.set_cooperative (cooperative);
+ game.set_genre (genre);
+ game.set_players (players);
+
+ return game;
}
}
diff --git a/plugins/playstation/src/playstation-game-factory.vala
b/plugins/playstation/src/playstation-game-factory.vala
index b5fa16d..679c429 100644
--- a/plugins/playstation/src/playstation-game-factory.vala
+++ b/plugins/playstation/src/playstation-game-factory.vala
@@ -138,7 +138,6 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
new GameinfoDiscIdGameTitle (gameinfo, disc_set_id),
new FilenameTitle (uri)
});
- var icon = new DummyIcon ();
var media = new GriloMedia (title, PHONY_MIME_TYPE);
var cover = new CompositeCover ({
new LocalCover (uri),
@@ -151,7 +150,14 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
var core_source = new RetroCoreSource (PLATFORM, { CUE_MIME_TYPE, PHONY_MIME_TYPE });
var runner = new RetroRunner.for_media_set_and_input_capabilities (core_source, media_set,
uid, input_capabilities, title);
- return new GenericGame (uid, title, icon, cover, release_date, cooperative, genre, players,
runner);
+ var game = new GenericGame (uid, title, runner);
+ game.set_cover (cover);
+ game.set_release_date (release_date);
+ game.set_cooperative (cooperative);
+ game.set_genre (genre);
+ game.set_players (players);
+
+ return game;
}
private static GameinfoDoc get_gameinfo () throws Error {
diff --git a/plugins/sega-cd/src/sega-cd-plugin.vala b/plugins/sega-cd/src/sega-cd-plugin.vala
index 7067e8b..133665a 100644
--- a/plugins/sega-cd/src/sega-cd-plugin.vala
+++ b/plugins/sega-cd/src/sega-cd-plugin.vala
@@ -62,7 +62,6 @@ private class Games.SegaCDPlugin : Object, Plugin {
var header_offset = header.get_offset ();
var uid = new FingerprintUid.for_chunk (bin_uri, SEGA_CD_PREFIX, header_offset,
SegaCDHeader.HEADER_LENGTH);
var title = new FilenameTitle (uri);
- var icon = new DummyIcon ();
var media = new GriloMedia (title, SEGA_CD_MIME_TYPE);
var cover = new CompositeCover ({
new LocalCover (uri),
@@ -74,7 +73,14 @@ private class Games.SegaCDPlugin : Object, Plugin {
var core_source = new RetroCoreSource (platform, mime_types);
var runner = new RetroRunner (core_source, uri, uid, title);
- return new GenericGame (uid, title, icon, cover, release_date, cooperative, genre, players,
runner);
+ var game = new GenericGame (uid, title, runner);
+ game.set_cover (cover);
+ game.set_release_date (release_date);
+ game.set_cooperative (cooperative);
+ game.set_genre (genre);
+ game.set_players (players);
+
+ return game;
}
private static File get_binary_file (CueSheet cue) throws Error {
diff --git a/plugins/sega-saturn/src/sega-saturn-plugin.vala b/plugins/sega-saturn/src/sega-saturn-plugin.vala
index 7e166ef..4eee1bb 100644
--- a/plugins/sega-saturn/src/sega-saturn-plugin.vala
+++ b/plugins/sega-saturn/src/sega-saturn-plugin.vala
@@ -46,7 +46,6 @@ private class Games.SegaSaturnPlugin : Object, Plugin {
var uid = new SegaSaturnUid (header);
var title = new FilenameTitle (uri);
- var icon = new DummyIcon ();
var media = new GriloMedia (title, SEGA_SATURN_MIME_TYPE);
var cover = new CompositeCover ({
new LocalCover (uri),
@@ -58,7 +57,14 @@ private class Games.SegaSaturnPlugin : Object, Plugin {
var core_source = new RetroCoreSource (PLATFORM, { CUE_MIME_TYPE, SEGA_SATURN_MIME_TYPE });
var runner = new RetroRunner (core_source, uri, uid, title);
- return new GenericGame (uid, title, icon, cover, release_date, cooperative, genre, players,
runner);
+ var game = new GenericGame (uid, title, runner);
+ game.set_cover (cover);
+ game.set_release_date (release_date);
+ game.set_cooperative (cooperative);
+ game.set_genre (genre);
+ game.set_players (players);
+
+ return game;
}
private static File get_binary_file (CueSheet cue) throws Error {
diff --git a/plugins/steam/src/steam-plugin.vala b/plugins/steam/src/steam-plugin.vala
index d5078d1..5aa19ec 100644
--- a/plugins/steam/src/steam-plugin.vala
+++ b/plugins/steam/src/steam-plugin.vala
@@ -54,14 +54,13 @@ private class Games.SteamPlugin : Object, Plugin {
var title = new SteamTitle (registry);
var icon = new SteamIcon (game_id);
var cover = new SteamCover (game_id);
- var release_date = new DummyReleaseDate ();
- var cooperative = new DummyCooperative ();
- var genre = new DummyGenre ();
- var players = new DummyPlayers ();
string[] args = { "steam", @"steam://rungameid/" + game_id };
var runner = new CommandRunner (args, false);
- var game = new GenericGame (uid, title, icon, cover, release_date, cooperative, genre,
players, runner);
+ var game = new GenericGame (uid, title, runner);
+ game.set_icon (icon);
+ game.set_cover (cover);
+
game_for_id[game_id] = game;
return game;
diff --git a/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
b/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
index c8b4572..5aae205 100644
--- a/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
+++ b/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
@@ -25,7 +25,6 @@ private class Games.TurboGrafxCDPlugin : Object, Plugin {
var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
var title = new FilenameTitle (uri);
- var icon = new DummyIcon ();
var media = new GriloMedia (title, PHONY_MIME_TYPE);
var cover = new CompositeCover ({
new LocalCover (uri),
@@ -37,7 +36,14 @@ private class Games.TurboGrafxCDPlugin : Object, Plugin {
var core_source = new RetroCoreSource (CD_PLATFORM, { CUE_MIME_TYPE, PHONY_MIME_TYPE });
var runner = new RetroRunner (core_source, uri, uid, title);
- return new GenericGame (uid, title, icon, cover, release_date, cooperative, genre, players,
runner);
+ var game = new GenericGame (uid, title, runner);
+ game.set_cover (cover);
+ game.set_release_date (release_date);
+ game.set_cooperative (cooperative);
+ game.set_genre (genre);
+ game.set_players (players);
+
+ return game;
}
private static bool is_valid_disc (Uri uri) throws Error {
diff --git a/plugins/virtual-boy/src/virtual-boy-plugin.vala b/plugins/virtual-boy/src/virtual-boy-plugin.vala
index 7131ed6..6d53307 100644
--- a/plugins/virtual-boy/src/virtual-boy-plugin.vala
+++ b/plugins/virtual-boy/src/virtual-boy-plugin.vala
@@ -25,7 +25,6 @@ private class Games.VirtualBoyPlugin : Object, Plugin {
var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
var title = new FilenameTitle (uri);
- var icon = new DummyIcon ();
var media = new GriloMedia (title, MIME_TYPE);
var cover = new CompositeCover ({
new LocalCover (uri),
@@ -37,7 +36,14 @@ private class Games.VirtualBoyPlugin : Object, Plugin {
var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
var runner = new RetroRunner (core_source, uri, uid, title);
- return new GenericGame (uid, title, icon, cover, release_date, cooperative, genre, players,
runner);
+ var game = new GenericGame (uid, title, runner);
+ game.set_cover (cover);
+ game.set_release_date (release_date);
+ game.set_cooperative (cooperative);
+ game.set_genre (genre);
+ game.set_players (players);
+
+ return game;
}
}
diff --git a/plugins/wii/src/wii-plugin.vala b/plugins/wii/src/wii-plugin.vala
index 4df1bac..a515cb7 100644
--- a/plugins/wii/src/wii-plugin.vala
+++ b/plugins/wii/src/wii-plugin.vala
@@ -23,7 +23,6 @@ private class Games.WiiPlugin : Object, Plugin {
var uid = new WiiUid (header);
var title = new FilenameTitle (uri);
- var icon = new DummyIcon ();
var media = new GriloMedia (title, MIME_TYPE);
var cover = new CompositeCover ({
new LocalCover (uri),
@@ -35,7 +34,14 @@ private class Games.WiiPlugin : Object, Plugin {
var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
var runner = new RetroRunner (core_source, uri, uid, title);
- return new GenericGame (uid, title, icon, cover, release_date, cooperative, genre, players,
runner);
+ var game = new GenericGame (uid, title, runner);
+ game.set_cover (cover);
+ game.set_release_date (release_date);
+ game.set_cooperative (cooperative);
+ game.set_genre (genre);
+ game.set_players (players);
+
+ return game;
}
}
diff --git a/src/generic/generic-game.vala b/src/generic/generic-game.vala
index 91193f3..1da59be 100644
--- a/src/generic/generic-game.vala
+++ b/src/generic/generic-game.vala
@@ -28,15 +28,9 @@ public class Games.GenericGame : Object, Game {
private Players game_players;
private Runner game_runner;
- public GenericGame (Uid uid, Title title, Icon icon, Cover cover, ReleaseDate release_date,
Cooperative cooperative, Genre genre, Players players, Runner runner) {
+ public GenericGame (Uid uid, Title title, Runner runner) {
game_uid = uid;
game_title = title;
- game_icon = icon;
- game_cover = cover;
- game_release_date = release_date;
- game_cooperative = cooperative;
- game_genre = genre;
- game_players = players;
game_runner = runner;
}
diff --git a/src/retro/retro-simple-game-uri-adapter.vala b/src/retro/retro-simple-game-uri-adapter.vala
index ec59517..c391dd7 100644
--- a/src/retro/retro-simple-game-uri-adapter.vala
+++ b/src/retro/retro-simple-game-uri-adapter.vala
@@ -13,7 +13,6 @@ private class Games.RetroSimpleGameUriAdapter : GameUriAdapter, Object {
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),
@@ -25,6 +24,13 @@ private class Games.RetroSimpleGameUriAdapter : GameUriAdapter, Object {
var core_source = new RetroCoreSource (simple_type.platform, { simple_type.mime_type });
var runner = new RetroRunner (core_source, uri, uid, title);
- return new GenericGame (uid, title, icon, cover, release_date, cooperative, genre, players,
runner);
+ var game = new GenericGame (uid, title, runner);
+ game.set_cover (cover);
+ game.set_release_date (release_date);
+ game.set_cooperative (cooperative);
+ game.set_genre (genre);
+ game.set_players (players);
+
+ return game;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]