Search in sources :

Example 6 with GameSet

use of com.github.jakz.romlib.data.set.GameSet 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) 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) JPanel(javax.swing.JPanel) CardLayout(java.awt.CardLayout) JSplitPane(javax.swing.JSplitPane) Game(com.github.jakz.romlib.data.game.Game) GameListModel(jack.rm.gui.gamelist.GameListModel) 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) 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 7 with GameSet

use of com.github.jakz.romlib.data.set.GameSet in project rom-manager by Jakz.

the class MoveUnknownFilesPlugin method execute.

@Override
public void execute(GameSet set) {
    try {
        counter = 0;
        if (!Files.exists(path) || !Files.isDirectory(path))
            Files.createDirectory(path);
        Set<Path> existing = set.romStream().filter(r -> r.isPresent()).map(r -> r.handle().path()).collect(Collectors.toSet());
        Settings settings = getGameSetSettings();
        Set<Path> total = new FolderScanner(FileSystems.getDefault().getPathMatcher("glob:*.*"), settings.getIgnoredPaths(), true).scan(settings.romsPath);
        total.removeAll(existing);
        total.stream().filter(f -> !f.getParent().equals(path)).forEach(f -> {
            Path dest = path.resolve(f.getFileName());
            int i = 1;
            while (Files.exists(dest)) dest = path.resolve(f.getFileName().toString() + (i++));
            try {
                Files.move(f, dest);
                ++counter;
            } catch (IOException e) {
                e.printStackTrace();
            /* TODO: log */
            }
        });
        message("Moved " + counter + " unknown files");
    } catch (IOException e) {
        e.printStackTrace();
    // TODO: log
    }
}
Also used : Path(java.nio.file.Path) Arrays(java.util.Arrays) CleanupPlugin(jack.rm.plugins.types.CleanupPlugin) Files(java.nio.file.Files) ExposedParameter(com.pixbits.lib.plugin.ExposedParameter) Set(java.util.Set) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) HashSet(java.util.HashSet) GameSet(com.github.jakz.romlib.data.set.GameSet) FolderScanner(com.pixbits.lib.io.FolderScanner) Path(java.nio.file.Path) PluginWithIgnorePaths(jack.rm.plugins.PluginWithIgnorePaths) FileSystems(java.nio.file.FileSystems) Settings(jack.rm.data.romset.Settings) FolderScanner(com.pixbits.lib.io.FolderScanner) IOException(java.io.IOException) Settings(jack.rm.data.romset.Settings)

Example 8 with GameSet

use of com.github.jakz.romlib.data.set.GameSet in project rom-manager by Jakz.

the class ClrMamePlugin method buildRomSets.

@Override
public GameSet[] buildRomSets(List<DatParserPlugin> datParsers) {
    DatParserPlugin datParser = this.findDatParser(datParsers, "clr-mame-pro-nointro");
    List<GameSet> sets = new ArrayList<>();
    {
        DataSupplier parser = datParser.buildDatLoader("clr-mame-pro-nointro");
        DatFormat format = parser.getFormat();
        sets.add(new GameSet(Platforms.GG, KnownProviders.NO_INTRO.derive("", "", "", null), parser, format, GG_ATTRIBUTES, AssetManager.DUMMY, s -> new MyGameSetFeatures(s, Feature.FINITE_SIZE_SET)));
    }
    {
        DataSupplier parser = datParser.buildDatLoader("clr-mame-pro-nointro");
        DatFormat format = parser.getFormat();
        sets.add(new GameSet(Platforms.LYNX, KnownProviders.NO_INTRO.derive("", "", "", null), parser, format, GG_ATTRIBUTES, AssetManager.DUMMY, s -> new MyGameSetFeatures(s, Feature.FINITE_SIZE_SET)));
    }
    {
        DataSupplier parser = findDatParser(datParsers, "logiqx-xml").buildDatLoader("logiqx-xml");
        DatFormat format = parser.getFormat();
        sets.add(new GameSet(Platforms.MD, KnownProviders.NO_INTRO.derive("", "", "", null), parser, format, GG_ATTRIBUTES, AssetManager.DUMMY, s -> new MyGameSetFeatures(s, Feature.FINITE_SIZE_SET)));
    }
    {
        DataSupplier parser = findDatParser(datParsers, "logiqx-xml").buildDatLoader("logiqx-xml");
        // TODO: this should be added only if XMDB is not present
        parser = parser.apply(new NormalizedTitleCloneSetCreator());
        DatFormat format = parser.getFormat();
        sets.add(new GameSet(Platforms.NDS, KnownProviders.NO_INTRO.derive("", "", "", null), parser, format, GG_ATTRIBUTES, AssetManager.DUMMY, s -> new MyGameSetFeatures(s, Feature.FINITE_SIZE_SET)));
    }
    {
        DataSupplier parser = findDatParser(datParsers, "logiqx-xml").buildDatLoader("logiqx-xml");
        DatFormat format = parser.getFormat();
        sets.add(new GameSet(Platforms.PSP, KnownProviders.NO_INTRO.derive("", "", "", null), parser, format, GG_ATTRIBUTES, AssetManager.DUMMY, s -> new MyGameSetFeatures(s)));
    }
    {
        DataSupplier parser = findDatParser(datParsers, "logiqx-xml").buildDatLoader("logiqx-xml");
        DatFormat format = parser.getFormat();
        sets.add(new GameSet(Platforms.PSP, KnownProviders.NO_INTRO.derive("With Clones", "with-clones", "", null), parser, format, GG_ATTRIBUTES, AssetManager.DUMMY, s -> new MyGameSetFeatures(s)));
    }
    {
        DataSupplier parser = findDatParser(datParsers, "logiqx-xml").buildDatLoader("logiqx-xml");
        DatFormat format = parser.getFormat();
        sets.add(new GameSet(Platforms.N64, KnownProviders.NO_INTRO.derive("", "", "", null), parser, format, GG_ATTRIBUTES, AssetManager.DUMMY, s -> new MyGameSetFeatures(s)));
    }
    {
        DataSupplier parser = findDatParser(datParsers, "logiqx-xml").buildDatLoader("logiqx-xml");
        DatFormat format = parser.getFormat();
        sets.add(new GameSet(Platforms._3DS, KnownProviders.NO_INTRO.derive("", "", "", null), parser, format, GG_ATTRIBUTES, AssetManager.DUMMY, s -> new MyGameSetFeatures(s)));
    }
    {
        DataSupplier parser = findDatParser(datParsers, "logiqx-xml").buildDatLoader("logiqx-xml");
        parser = parser.apply(new RedumpAggregatorByDisks());
        parser = parser.apply(new NormalizedTitleCloneSetCreator());
        DatFormat format = parser.getFormat();
        final Attribute[] PC_ATTRIBUTES = { GameAttribute.TITLE, GameAttribute.SIZE, GameAttribute.LOCATION, GameAttribute.LANGUAGE, GameAttribute.VERSION, GameAttribute.VERSION_NUMBER };
        sets.add(new GameSet(Platforms.IBM_PC, KnownProviders.REDUMP.derive("", "", "", new Provider.Source("http://redump.org/datfile/pc/")), parser, format, PC_ATTRIBUTES, AssetManager.DUMMY, s -> new MyGameSetFeatures(s)));
    }
    {
        DataSupplier parser = findDatParser(datParsers, "logiqx-xml").buildDatLoader("logiqx-xml");
        parser = parser.apply(new RedumpAggregatorByDisks());
        parser = parser.apply(new NormalizedTitleCloneSetCreator());
        DatFormat format = parser.getFormat();
        final Attribute[] PC_ATTRIBUTES = { GameAttribute.TITLE, GameAttribute.SIZE, GameAttribute.LOCATION, GameAttribute.LANGUAGE, GameAttribute.VERSION, GameAttribute.VERSION_NUMBER };
        sets.add(new GameSet(Platforms.PS2, KnownProviders.REDUMP.derive("", "", "", null), parser, format, PC_ATTRIBUTES, AssetManager.DUMMY, s -> new MyGameSetFeatures(s)));
        sets.add(new GameSet(Platforms.GC, KnownProviders.REDUMP.derive("", "", "", new Provider.Source("http://redump.org/datfile/gc/")), parser, format, PC_ATTRIBUTES, AssetManager.DUMMY, s -> new MyGameSetFeatures(s)));
    }
    {
        DataSupplier parser = findDatParser(datParsers, "logiqx-xml").buildDatLoader("logiqx-xml");
        parser = parser.apply(new GoodOldDaysFixer());
        parser = parser.apply(new GoodOldDaysFixer.CloneCreator());
        DatFormat format = parser.getFormat();
        final Attribute[] PC_ATTRIBUTES = { GameAttribute.TITLE, GameAttribute.SIZE, GameAttribute.LOCATION, GameAttribute.LANGUAGE, GameAttribute.RELEASE_DATE, GameAttribute.DESCRIPTION, GameAttribute.COMMENT };
        sets.add(new GameSet(Platforms.IBM_PC, KnownProviders.GOOD_OLD_DAYS, parser, format, PC_ATTRIBUTES, AssetManager.DUMMY, s -> new MyGameSetFeatures(s, GameID.Generator.BY_RELEASE_NUMBER, Feature.FINITE_SIZE_SET)));
    }
    return sets.toArray(new GameSet[sets.size()]);
}
Also used : NormalizedTitleCloneSetCreator(com.github.jakz.romlib.data.cataloguers.impl.NormalizedTitleCloneSetCreator) DataSupplier(com.github.jakz.romlib.data.set.DataSupplier) RedumpAggregatorByDisks(com.github.jakz.romlib.data.cataloguers.impl.RedumpAggregatorByDisks) MyGameSetFeatures(jack.rm.data.romset.MyGameSetFeatures) ArrayList(java.util.ArrayList) DatFormat(com.github.jakz.romlib.data.set.DatFormat) GoodOldDaysFixer(com.github.jakz.romlib.data.cataloguers.impl.GoodOldDaysFixer) DatParserPlugin(jack.rm.plugins.types.DatParserPlugin) GameSet(com.github.jakz.romlib.data.set.GameSet)

Example 9 with GameSet

use of com.github.jakz.romlib.data.set.GameSet in project rom-manager by Jakz.

the class Main method loadRomSet.

public static void loadRomSet(GameSet romSet) throws FileNotFoundException, IOException {
    if (current != null)
        setManager.saveSetStatus(current);
    GameSet set = setManager.loadSet(romSet);
    current = set;
    boolean wasInit = setManager.loadSetStatus(set);
    MyGameSetFeatures helper = set.helper();
    helper.pluginStateChanged();
    mainFrame.romSetLoaded(set);
    MyGameSetFeatures features = set.helper();
    features.organizer().computeStatus();
    helper.scanner().scanForRoms(!wasInit && GlobalSettings.settings.shouldScanWhenLoadingRomset());
    downloader = new MyAssetDownloader(set);
/*List<Game> favourites = set.filter("is:fav");
    Fetcher<GameEntry> source = new MultipleGameSource(favourites);
    Mutuator<GameEntry> sorter = new OrganizeByAttribute(GameAttribute.TAG, false);
    Mutuator<GameEntry> renamer = new RenameByExportTitle();
    Dumper<GameEntry> dumper = new GameConsolidator(Paths.get("/Users/jack/Desktop/everdrive"));
    Workflow<GameEntry> workflow = new Workflow<>(source,dumper);
    workflow.addStep(new LogOperation());
    workflow.addStep(sorter);
    workflow.addStep(renamer);
    workflow.addStep(e -> {
      Game g = e.getGame();
      if (g.hasAnyCustomAttribute() && !g.isFavourite())
        System.out.println("Missing favorite on "+g.getTitle());
      return e;
    });
    workflow.execute();
    java.lang.System.exit(0);*/
/*List<Rom> favourites = set.filter("is:fav");*/
/*List<Rom> favs = set.filter("is:fav");
    final Optional<Integer> c = Optional.of(0);
    Fetcher<RomHandle> source = new MultipleRomSource(favs);
    Dumper<RomHandle> dumper = new RomConsolidator(Paths.get("/Volumes/Vicky/nds"));
    Workflow<RomHandle> workflow = new Workflow<>(source, dumper);
    workflow.addStep(rh -> { java.lang.System.out.println(c.get()+" of "+favs.size()); return rh; });
    workflow.execute();*/
// IPSPatchOperation ipsOperation = new IPSPatchOperation();
// ipsOperation.toggleAutomaticPatching(true);
// workflow.addBenchmarkedStep(new LogOperation());
// workflow.addBenchmarkedStep(ipsOperation);
// workflow.addBenchmarkedStep(new GBASleepHackOperation());
// workflow.addBenchmarkedStep(new TrimOperation(new byte[] {0x00, (byte)0xff}));
// workflow.addStep(new SortByAttributeOperation(RomAttribute.TAG, false));
// workflow.execute();
// java.lang.System.exit(0);
/*
    try
    {
      BinaryBuffer buffer = new BinaryBuffer("/Users/jack/Documents/Dev/gba/sma-m.gba", BinaryBuffer.Mode.WRITE, ByteOrder.LITTLE_ENDIAN);
      java.lang.System.out.println(buffer.length());
      new GBASleepHack().patch(buffer);
      buffer.close();
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
    
    java.lang.System.exit(0);*/
}
Also used : MyGameSetFeatures(jack.rm.data.romset.MyGameSetFeatures) MyAssetDownloader(jack.rm.files.MyAssetDownloader) GameSet(com.github.jakz.romlib.data.set.GameSet)

Example 10 with GameSet

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

GameSet (com.github.jakz.romlib.data.set.GameSet)12 Arrays (java.util.Arrays)8 List (java.util.List)7 Feature (com.github.jakz.romlib.data.set.Feature)6 ArrayList (java.util.ArrayList)6 Game (com.github.jakz.romlib.data.game.Game)5 MyGameSetFeatures (jack.rm.data.romset.MyGameSetFeatures)5 IOException (java.io.IOException)5 Map (java.util.Map)5 Collectors (java.util.stream.Collectors)5 Drawable (com.github.jakz.romlib.data.game.Drawable)4 Platforms (com.github.jakz.romlib.data.platforms.Platforms)4 Main (jack.rm.Main)4 Predicate (java.util.function.Predicate)4 Attribute (com.github.jakz.romlib.data.game.attributes.Attribute)3 GameAttribute (com.github.jakz.romlib.data.game.attributes.GameAttribute)3 GameSetManager (jack.rm.data.romset.GameSetManager)3 Settings (jack.rm.data.romset.Settings)3 GameListData (jack.rm.gui.gamelist.GameListData)3 Text (jack.rm.i18n.Text)3