[gnome-games/wip/exalm/rebrand: 91/124] retro-simple-type: Move to PlatformRegister
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/rebrand: 91/124] retro-simple-type: Move to PlatformRegister
- Date: Sat, 19 Jun 2021 14:37:46 +0000 (UTC)
commit 520a48aa74118b84b8299ddbe98a6db094ea6fe0
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Mar 30 17:17:42 2021 +0500
retro-simple-type: Move to PlatformRegister
Now the plugin types can be easily added there as well.
src/meson.build | 2 -
src/platforms/platform-register.vala | 197 +++++++++++++++++++++++++++++++++++
src/retro/retro-simple-type.vala | 69 ------------
src/retro/retro-simple-types.vala | 29 ------
src/ui/application.vala | 51 +++------
5 files changed, 214 insertions(+), 134 deletions(-)
---
diff --git a/src/meson.build b/src/meson.build
index d2ddbbb7..4964aa65 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -100,8 +100,6 @@ vala_sources = [
'retro/retro-gamepad.vala',
'retro/retro-input-manager.vala',
'retro/retro-options.vala',
- 'retro/retro-simple-type.vala',
- 'retro/retro-simple-types.vala',
'screen-layout/screen-layout.vala',
'screen-layout/screen-layout-item.vala',
diff --git a/src/platforms/platform-register.vala b/src/platforms/platform-register.vala
index c3021109..f4e505f8 100644
--- a/src/platforms/platform-register.vala
+++ b/src/platforms/platform-register.vala
@@ -6,6 +6,8 @@ private class Games.PlatformRegister : Object {
private PlatformRegister () {
platforms = new HashTable<string, Platform> (str_hash, str_equal);
+
+ init_platforms ();
}
public static PlatformRegister get_register () {
@@ -38,4 +40,199 @@ private class Games.PlatformRegister : Object {
public Platform? get_platform (string id) {
return platforms[id];
}
+
+ private void init_platforms () {
+ var platform = new Platform (
+ "Amiga",
+ _("Amiga"),
+ "application/x-amiga-disk-format",
+ "amiga"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "Atari2600",
+ _("Atari 2600"),
+ "application/x-atari-2600-rom",
+ "atari-2600"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "Atari7800",
+ _("Atari 7800"),
+ "application/x-atari-7800-rom",
+ "atari-7800"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "AtariLynx",
+ _("Atari Lynx"),
+ "application/x-atari-lynx-rom",
+ "atari-lynx"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "DOOM",
+ _("DOOM"),
+ "application/x-doom-wad",
+ "doom"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "FamicomDiskSystem",
+ /* translators: only released in eastern Asia */
+ _("Famicom Disk System"),
+ "application/x-fds-disk",
+ "fds"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "GameBoy",
+ _("Game Boy"),
+ "application/x-gameboy-rom",
+ "game-boy"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "GameBoyColor",
+ _("Game Boy Color"),
+ "application/x-gameboy-color-rom",
+ /* The prefix is the same as the Game Boy type for backward compatibility */
+ "game-boy"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "GameBoyAdvance",
+ _("Game Boy Advance"),
+ "application/x-gba-rom",
+ "game-boy-advance"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "GameGear",
+ _("Game Gear"),
+ "application/x-gamegear-rom",
+ "game-gear"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "MasterSystem",
+ /* translators: also known as "Sega Mark III" in eastern Asia */
+ _("Master System"),
+ "application/x-sms-rom",
+ "master-system"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "NeoGeoPocket",
+ _("Neo Geo Pocket"),
+ "application/x-neo-geo-pocket-rom",
+ "neo-geo-pocket"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "NeoGeoPocketColor",
+ _("Neo Geo Pocket Color"),
+ "application/x-neo-geo-pocket-color-rom",
+ /* The prefix is the same as the Neo Geo Pocket type for backward compatibility */
+ "neo-geo-pocket"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "NintendoEntertainmentSystem",
+ /* translators: known as "Famicom" in eastern Asia */
+ _("Nintendo Entertainment System"),
+ "application/x-nes-rom",
+ "nes"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "Sega32X",
+ /* translators: known as "Mega Drive 32X", "Mega 32X" or "Super 32X" in other places
*/
+ _("Genesis 32X"),
+ "application/x-genesis-32x-rom",
+ "mega-drive-32x"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "SegaGenesis",
+ /* translators: known as "Mega Drive" in most of the world */
+ _("Sega Genesis"),
+ "application/x-genesis-rom",
+ "mega-drive"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "SegaPico",
+ _("Sega Pico"),
+ "application/x-sega-pico-rom",
+ "sega-pico"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "SG1000",
+ _("SG-1000"),
+ "application/x-sg1000-rom",
+ "sg-1000"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "SuperNintendoEntertainmentSystem",
+ /* translators: known as "Super Famicom" in eastern Asia */
+ _("Super Nintendo Entertainment System"),
+ "application/vnd.nintendo.snes.rom",
+ "snes"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "TurboGrafx16",
+ /* translators: known as "PC Engine" in eastern Asia and France */
+ _("TurboGrafx-16"),
+ "application/x-pc-engine-rom",
+ "pc-engine"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "WiiWare",
+ _("WiiWare"),
+ "application/x-wii-wad",
+ "wii-ware"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "WonderSwan",
+ _("WonderSwan"),
+ "application/x-wonderswan-wad",
+ "wonderswan"
+ );
+ add_platform (platform);
+
+ platform = new Platform (
+ "WonderSwanColor",
+ _("WonderSwan Color"),
+ "application/x-wonderswan-color-wad",
+ "wonderswan-color"
+ );
+ add_platform (platform);
+ }
}
diff --git a/src/ui/application.vala b/src/ui/application.vala
index 7f963841..22991b8b 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -446,54 +446,37 @@ public class Games.Application : Gtk.Application {
if (tracker_uri_source != null)
game_collection.add_source (tracker_uri_source);
- var mime_types = new GenericSet<string> (str_hash, str_equal);
var platform_register = PlatformRegister.get_register ();
- /* Register simple Libretro-based game types */
- foreach (var simple_type in RETRO_SIMPLE_TYPES) {
- assert (!mime_types.contains (simple_type.mime_type));
-
- if (simple_type.search_mime_type && tracker_uri_source != null) {
- mime_types.add (simple_type.mime_type);
- var query = new MimeTypeTrackerUriQuery (simple_type.mime_type);
- tracker_uri_source.add_query (query);
- }
-
- var platform_name = simple_type.get_platform_name ();
- var platform = new Platform (simple_type.platform, platform_name,
simple_type.mime_type, simple_type.prefix);
- platform_register.add_platform (platform);
-
- var factory = new UriGameFactory (platform);
- game_collection.add_factory (factory);
- }
-
/* Register game types from the plugins */
var register = PluginRegister.get_register ();
foreach (var plugin_registrar in register) {
try {
var plugin = plugin_registrar.get_plugin ();
- foreach (var platform in plugin.get_platforms ()) {
+ foreach (var platform in plugin.get_platforms ())
platform_register.add_platform (platform);
+ }
+ catch (Error e) {
+ debug ("Error: %s", e.message);
+ }
+ }
- var factory = new UriGameFactory (platform);
- game_collection.add_factory (factory);
+ var mime_types = new GenericSet<string> (str_hash, str_equal);
+ foreach (var platform in PlatformRegister.get_register ().get_all_platforms ()) {
+ var factory = new UriGameFactory (platform);
+ game_collection.add_factory (factory);
- if (platform.autodiscovery && tracker_uri_source != null) {
- foreach (var mime_type in platform.get_mime_types ()) {
- if (mime_types.contains (mime_type))
- continue;
+ if (platform.autodiscovery && tracker_uri_source != null) {
+ foreach (var mime_type in platform.get_mime_types ()) {
+ if (mime_types.contains (mime_type))
+ continue;
- mime_types.add (mime_type);
- var query = new MimeTypeTrackerUriQuery (mime_type);
- tracker_uri_source.add_query (query);
- }
- }
+ mime_types.add (mime_type);
+ var query = new MimeTypeTrackerUriQuery (mime_type);
+ tracker_uri_source.add_query (query);
}
}
- catch (Error e) {
- debug ("Error: %s", e.message);
- }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]