Search in sources :

Example 1 with ProviderPlugin

use of jack.rm.plugins.types.ProviderPlugin in project rom-manager by Jakz.

the class GameSetManager method buildRomsetList.

@SuppressWarnings("unchecked")
public void buildRomsetList() {
    Set<ActualPluginBuilder> parsers = manager.getBuildersByType(PluginRealType.DAT_PARSER);
    List<DatParserPlugin> datParsers = parsers.stream().map(b -> (DatParserPlugin) manager.build((Class<DatParserPlugin>) b.getID().getType())).collect(Collectors.toList());
    Set<ActualPluginBuilder> builders = manager.getBuildersByType(PluginRealType.PROVIDER);
    logger.d("Building available rom sets");
    logger.ld("Found %d dat parsers: %s", () -> datParsers.size(), () -> datParsers.stream().map(p -> Arrays.toString(p.getSupportedFormats())).collect(Collectors.joining(", ")));
    for (ActualPluginBuilder builder : builders) {
        ProviderPlugin plugin = (ProviderPlugin) manager.build((Class<ProviderPlugin>) builder.getID().getType());
        logger.d("Found ProviderPlugin: %s", plugin.getClass().getName());
        GameSet[] rsets = plugin.buildRomSets(datParsers);
        for (GameSet set : rsets) {
            helpers.put(set, new MyGameSetFeatures(set));
            List<GameSet> setsForPlatform = sets.computeIfAbsent(set.platform(), s -> new ArrayList<>());
            setsForPlatform.add(set);
        }
    }
    for (Platform platform : Platforms.values()) sets.computeIfAbsent(platform, s -> new ArrayList<>());
}
Also used : JsonParseException(com.google.gson.JsonParseException) NoSuchFileException(java.nio.file.NoSuchFileException) Arrays(java.util.Arrays) Asset(com.github.jakz.romlib.data.assets.Asset) HashMap(java.util.HashMap) ProviderPlugin(jack.rm.plugins.types.ProviderPlugin) Platforms(com.github.jakz.romlib.data.platforms.Platforms) ArrayList(java.util.ArrayList) GameSet(com.github.jakz.romlib.data.set.GameSet) Gson(com.google.gson.Gson) Map(java.util.Map) Log(com.pixbits.lib.log.Log) GameList(com.github.jakz.romlib.data.set.GameList) Json(jack.rm.json.Json) Path(java.nio.file.Path) DatParserPlugin(jack.rm.plugins.types.DatParserPlugin) Feature(com.github.jakz.romlib.data.set.Feature) ActualPluginBuilder(jack.rm.plugins.ActualPluginBuilder) Files(java.nio.file.Files) PluginManager(com.pixbits.lib.plugin.PluginManager) LogSource(jack.rm.log.LogSource) LogTarget(jack.rm.log.LogTarget) BufferedWriter(java.io.BufferedWriter) Collection(java.util.Collection) PluginRealType(jack.rm.plugins.PluginRealType) Set(java.util.Set) IOException(java.io.IOException) GameListAdapter(com.github.jakz.romlib.json.GameListAdapter) ActualPlugin(jack.rm.plugins.ActualPlugin) Collectors(java.util.stream.Collectors) FileNotFoundException(java.io.FileNotFoundException) List(java.util.List) Platform(com.github.jakz.romlib.data.platforms.Platform) Logger(com.pixbits.lib.log.Logger) Paths(java.nio.file.Paths) AssetManager(com.github.jakz.romlib.data.assets.AssetManager) GameSetFeatures(com.github.jakz.romlib.data.set.GameSetFeatures) Optional(java.util.Optional) BufferedReader(java.io.BufferedReader) GlobalSettings(jack.rm.GlobalSettings) Platform(com.github.jakz.romlib.data.platforms.Platform) ArrayList(java.util.ArrayList) ActualPluginBuilder(jack.rm.plugins.ActualPluginBuilder) ProviderPlugin(jack.rm.plugins.types.ProviderPlugin) DatParserPlugin(jack.rm.plugins.types.DatParserPlugin) GameSet(com.github.jakz.romlib.data.set.GameSet)

Aggregations

Asset (com.github.jakz.romlib.data.assets.Asset)1 AssetManager (com.github.jakz.romlib.data.assets.AssetManager)1 Platform (com.github.jakz.romlib.data.platforms.Platform)1 Platforms (com.github.jakz.romlib.data.platforms.Platforms)1 Feature (com.github.jakz.romlib.data.set.Feature)1 GameList (com.github.jakz.romlib.data.set.GameList)1 GameSet (com.github.jakz.romlib.data.set.GameSet)1 GameSetFeatures (com.github.jakz.romlib.data.set.GameSetFeatures)1 GameListAdapter (com.github.jakz.romlib.json.GameListAdapter)1 Gson (com.google.gson.Gson)1 JsonParseException (com.google.gson.JsonParseException)1 Log (com.pixbits.lib.log.Log)1 Logger (com.pixbits.lib.log.Logger)1 PluginManager (com.pixbits.lib.plugin.PluginManager)1 GlobalSettings (jack.rm.GlobalSettings)1 Json (jack.rm.json.Json)1 LogSource (jack.rm.log.LogSource)1 LogTarget (jack.rm.log.LogTarget)1 ActualPlugin (jack.rm.plugins.ActualPlugin)1 ActualPluginBuilder (jack.rm.plugins.ActualPluginBuilder)1