Search in sources :

Example 1 with Platform

use of com.github.jakz.romlib.data.platforms.Platform in project rom-manager by Jakz.

the class MainFrame method rebuildEnabledDats.

public void rebuildEnabledDats() {
    GameSet current = cbRomSets.getSelectedIndex() != -1 ? cbRomSets.getItemAt(cbRomSets.getSelectedIndex()) : null;
    cbRomSets.setSelectedIndex(-1);
    cbRomSets.removeAllItems();
    List<Platform> platforms = Platforms.sortedValues();
    List<GameSet> sets = GlobalSettings.settings.getEnabledProviders().stream().map(setManager::byIdent).collect(Collectors.toList());
    platforms.forEach(s -> {
        sets.stream().filter(rs -> rs.platform().equals(s)).forEach(cbRomSets::addItem);
    });
    if (current != null && sets.contains(current))
        cbRomSets.setSelectedItem(current);
    else if (cbRomSets.getItemCount() == 0)
        gameListPanel.clearEverything();
}
Also used : Color(java.awt.Color) Arrays(java.util.Arrays) OperationalPlugin(jack.rm.plugins.OperationalPlugin) MyGameSetFeatures(jack.rm.data.romset.MyGameSetFeatures) ItemListener(java.awt.event.ItemListener) Platforms(com.github.jakz.romlib.data.platforms.Platforms) Organizer(jack.rm.files.Organizer) FileTransferHandler(com.pixbits.lib.ui.FileTransferHandler) GameSet(com.github.jakz.romlib.data.set.GameSet) GameListPanel(jack.rm.gui.gamelist.GameListPanel) WindowListener(java.awt.event.WindowListener) Map(java.util.Map) Text(jack.rm.i18n.Text) MouseAdapter(java.awt.event.MouseAdapter) BorderLayout(java.awt.BorderLayout) JComboBox(javax.swing.JComboBox) JFrame(javax.swing.JFrame) GameListData(jack.rm.gui.gamelist.GameListData) Feature(com.github.jakz.romlib.data.set.Feature) JMenuBar(javax.swing.JMenuBar) ItemEvent(java.awt.event.ItemEvent) Predicate(java.util.function.Predicate) InfoPanel(jack.rm.gui.gameinfo.InfoPanel) JMenu(javax.swing.JMenu) SearchPanel(com.github.jakz.romlib.ui.SearchPanel) Collectors(java.util.stream.Collectors) WindowEvent(java.awt.event.WindowEvent) Dimension(java.awt.Dimension) List(java.util.List) Drawable(com.github.jakz.romlib.data.game.Drawable) GameClone(com.github.jakz.romlib.data.game.GameClone) GlobalSettings(jack.rm.GlobalSettings) RomSize(com.github.jakz.romlib.data.game.RomSize) JPanel(javax.swing.JPanel) CardLayout(java.awt.CardLayout) JSplitPane(javax.swing.JSplitPane) GameAttribute(com.github.jakz.romlib.data.game.attributes.GameAttribute) Game(com.github.jakz.romlib.data.game.Game) GameListModel(jack.rm.gui.gamelist.GameListModel) Attribute(com.github.jakz.romlib.data.game.attributes.Attribute) ArrayList(java.util.ArrayList) GridLayout(java.awt.GridLayout) SwingUtilities(javax.swing.SwingUtilities) JMenuItem(javax.swing.JMenuItem) GameCellRenderer(jack.rm.gui.gamelist.GameCellRenderer) ButtonGroup(javax.swing.ButtonGroup) CountPanel(jack.rm.gui.gamelist.CountPanel) PluginRealType(jack.rm.plugins.PluginRealType) IOException(java.io.IOException) GameStatus(com.github.jakz.romlib.data.game.GameStatus) MouseEvent(java.awt.event.MouseEvent) AssetPacker(jack.rm.files.AssetPacker) ListCellRenderer(javax.swing.ListCellRenderer) Platform(com.github.jakz.romlib.data.platforms.Platform) TreeMap(java.util.TreeMap) Comparator(java.util.Comparator) Collections(java.util.Collections) Main(jack.rm.Main) GameSetManager(jack.rm.data.romset.GameSetManager) Settings(jack.rm.data.romset.Settings) Platform(com.github.jakz.romlib.data.platforms.Platform) GameSet(com.github.jakz.romlib.data.set.GameSet)

Example 2 with Platform

use of com.github.jakz.romlib.data.platforms.Platform 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

Platform (com.github.jakz.romlib.data.platforms.Platform)2 Platforms (com.github.jakz.romlib.data.platforms.Platforms)2 Feature (com.github.jakz.romlib.data.set.Feature)2 GameSet (com.github.jakz.romlib.data.set.GameSet)2 GlobalSettings (jack.rm.GlobalSettings)2 PluginRealType (jack.rm.plugins.PluginRealType)2 Asset (com.github.jakz.romlib.data.assets.Asset)1 AssetManager (com.github.jakz.romlib.data.assets.AssetManager)1 Drawable (com.github.jakz.romlib.data.game.Drawable)1 Game (com.github.jakz.romlib.data.game.Game)1 GameClone (com.github.jakz.romlib.data.game.GameClone)1 GameStatus (com.github.jakz.romlib.data.game.GameStatus)1 RomSize (com.github.jakz.romlib.data.game.RomSize)1 Attribute (com.github.jakz.romlib.data.game.attributes.Attribute)1 GameAttribute (com.github.jakz.romlib.data.game.attributes.GameAttribute)1 GameList (com.github.jakz.romlib.data.set.GameList)1 GameSetFeatures (com.github.jakz.romlib.data.set.GameSetFeatures)1 GameListAdapter (com.github.jakz.romlib.json.GameListAdapter)1 SearchPanel (com.github.jakz.romlib.ui.SearchPanel)1 Gson (com.google.gson.Gson)1