Search in sources :

Example 1 with Rom

use of com.github.jakz.romlib.data.game.Rom in project rom-manager by Jakz.

the class DigestVerifier method setup.

@Override
public void setup(GameSet romset) {
    HashCache<Rom> cache = romset.hashCache();
    VerifierOptions options = new VerifierOptions(true, false, false, true);
    DigestOptions doptions = new DigestOptions(options, true);
    Digester digester = new Digester(doptions);
    verifier = new Verifier<>(options, digester, cache);
}
Also used : Rom(com.github.jakz.romlib.data.game.Rom) VerifierOptions(com.pixbits.lib.io.archive.VerifierOptions) DigestOptions(com.pixbits.lib.io.digest.DigestOptions) Digester(com.pixbits.lib.io.digest.Digester)

Example 2 with Rom

use of com.github.jakz.romlib.data.game.Rom in project rom-manager by Jakz.

the class ClonesDialog method autoChoose.

public void autoChoose(ClonePolicy policy, ClonePriority priority) {
    if (policy == ClonePolicy.AUTO_SELECT_ALL)
        this.keep = this.clones.stream().collect(Collectors.toMap(c -> c, c -> false));
    List<List<ScanResult>> results = new ArrayList<>();
    LinkedList<ScanResult> current = null;
    /* create a list for each rom with clones */
    boolean alreadySet = false;
    for (ScanResult result : this.clones) {
        if (current == null || !current.peekLast().rom.equals(result.rom)) {
            if (current != null && !alreadySet)
                results.add(current);
            alreadySet = false;
            current = new LinkedList<>();
        }
        current.add(result);
        alreadySet |= keep.get(result);
    }
    if (current != null && !alreadySet)
        results.add(current);
    for (List<ScanResult> list : results) {
        ScanResult result = chooseBestClone(list, policy, priority);
        keep.put(result, true);
    }
    model.fireChanges();
    updateStatus();
}
Also used : Color(java.awt.Color) NimbusBooleanCellRenderer(com.pixbits.lib.ui.table.renderers.NimbusBooleanCellRenderer) Arrays(java.util.Arrays) JDialog(javax.swing.JDialog) HashMap(java.util.HashMap) TableCellRenderer(javax.swing.table.TableCellRenderer) SwingConstants(javax.swing.SwingConstants) Handle(com.pixbits.lib.io.archive.handles.Handle) ArrayList(java.util.ArrayList) GameSet(com.github.jakz.romlib.data.set.GameSet) PastelColorGenerator(com.pixbits.lib.ui.color.PastelColorGenerator) ArchiveHandle(com.pixbits.lib.io.archive.handles.ArchiveHandle) Map(java.util.Map) AbstractTableModel(javax.swing.table.AbstractTableModel) BorderLayout(java.awt.BorderLayout) LinkedList(java.util.LinkedList) JComboBox(javax.swing.JComboBox) Rom(com.github.jakz.romlib.data.game.Rom) BinaryHandle(com.pixbits.lib.io.archive.handles.BinaryHandle) ScanResult(jack.rm.files.ScanResult) BoxLayout(javax.swing.BoxLayout) JComponent(javax.swing.JComponent) NestedArchiveHandle(com.pixbits.lib.io.archive.handles.NestedArchiveHandle) Frame(java.awt.Frame) JButton(javax.swing.JButton) Predicate(java.util.function.Predicate) Set(java.util.Set) BorderFactory(javax.swing.BorderFactory) Component(java.awt.Component) Collectors(java.util.stream.Collectors) JScrollPane(javax.swing.JScrollPane) List(java.util.List) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) JLabel(javax.swing.JLabel) ColorGenerator(com.pixbits.lib.ui.color.ColorGenerator) JCheckBox(javax.swing.JCheckBox) Optional(java.util.Optional) JTable(javax.swing.JTable) Collections(java.util.Collections) Main(jack.rm.Main) JPanel(javax.swing.JPanel) GameSetManager(jack.rm.data.romset.GameSetManager) ScanResult(jack.rm.files.ScanResult) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List)

Example 3 with Rom

use of com.github.jakz.romlib.data.game.Rom in project rom-manager by Jakz.

the class ClonesDialog method activate.

public void activate(GameSet set, Set<ScanResult> clones) {
    this.set = set;
    this.keep.clear();
    this.clones.clear();
    // TODO: probably requires to be rewritten almost totally to manage multiple roms per game
    Set<Rom> romClones = clones.stream().map(c -> c.rom).collect(Collectors.toSet());
    this.clones = new ArrayList<>(clones);
    this.clones.addAll(set.stream().flatMap(g -> g.stream()).filter(r -> romClones.contains(r)).map(r -> new ScanResult(r, r.handle())).collect(Collectors.toList()));
    Collections.sort(this.clones);
    this.keep = this.clones.stream().collect(Collectors.toMap(c -> c, c -> false));
    this.colors = romClones.stream().collect(Collectors.toMap(c -> c, c -> colorGenerator.getColor()));
    updateStatus();
    model.fireChanges();
    this.setLocationRelativeTo(null);
    this.setVisible(true);
    Dialogs.showWarning("Clones Found", colors.size() + " clones have been found,\nplease specify which entries you want to keep", this);
}
Also used : Color(java.awt.Color) NimbusBooleanCellRenderer(com.pixbits.lib.ui.table.renderers.NimbusBooleanCellRenderer) Arrays(java.util.Arrays) JDialog(javax.swing.JDialog) HashMap(java.util.HashMap) TableCellRenderer(javax.swing.table.TableCellRenderer) SwingConstants(javax.swing.SwingConstants) Handle(com.pixbits.lib.io.archive.handles.Handle) ArrayList(java.util.ArrayList) GameSet(com.github.jakz.romlib.data.set.GameSet) PastelColorGenerator(com.pixbits.lib.ui.color.PastelColorGenerator) ArchiveHandle(com.pixbits.lib.io.archive.handles.ArchiveHandle) Map(java.util.Map) AbstractTableModel(javax.swing.table.AbstractTableModel) BorderLayout(java.awt.BorderLayout) LinkedList(java.util.LinkedList) JComboBox(javax.swing.JComboBox) Rom(com.github.jakz.romlib.data.game.Rom) BinaryHandle(com.pixbits.lib.io.archive.handles.BinaryHandle) ScanResult(jack.rm.files.ScanResult) BoxLayout(javax.swing.BoxLayout) JComponent(javax.swing.JComponent) NestedArchiveHandle(com.pixbits.lib.io.archive.handles.NestedArchiveHandle) Frame(java.awt.Frame) JButton(javax.swing.JButton) Predicate(java.util.function.Predicate) Set(java.util.Set) BorderFactory(javax.swing.BorderFactory) Component(java.awt.Component) Collectors(java.util.stream.Collectors) JScrollPane(javax.swing.JScrollPane) List(java.util.List) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) JLabel(javax.swing.JLabel) ColorGenerator(com.pixbits.lib.ui.color.ColorGenerator) JCheckBox(javax.swing.JCheckBox) Optional(java.util.Optional) JTable(javax.swing.JTable) Collections(java.util.Collections) Main(jack.rm.Main) JPanel(javax.swing.JPanel) GameSetManager(jack.rm.data.romset.GameSetManager) Rom(com.github.jakz.romlib.data.game.Rom) ScanResult(jack.rm.files.ScanResult)

Example 4 with Rom

use of com.github.jakz.romlib.data.game.Rom in project rom-manager by Jakz.

the class Scanner method foundRom.

private void foundRom(ScanResult result) {
    if (result == null)
        return;
    Rom rom = result.rom;
    Game game = rom.game();
    logger.i(LogTarget.rom(result.rom), "Found a match for " + result.handle);
    if (rom.isPresent() && !rom.handle().equals(result.handle)) {
        clones.add(result);
        logger.w(LogTarget.file(result.handle.path().getFileName()), "File contains a rom already present in romset: " + rom.handle());
        return;
    }
    result.assign();
    game.updateStatus();
}
Also used : Rom(com.github.jakz.romlib.data.game.Rom) Game(com.github.jakz.romlib.data.game.Game)

Example 5 with Rom

use of com.github.jakz.romlib.data.game.Rom in project rom-manager by Jakz.

the class RomTable method prepareRenderer.

@Override
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
    Component component = super.prepareRenderer(renderer, row, column);
    Rom rom = game.rom(row);
    // TODO: GameStatus.UNORGANZIED management for rom?
    component.setForeground(rom.isPresent() ? GameStatus.FOUND.color : GameStatus.MISSING.color);
    return component;
}
Also used : Rom(com.github.jakz.romlib.data.game.Rom) Component(java.awt.Component)

Aggregations

Rom (com.github.jakz.romlib.data.game.Rom)6 Handle (com.pixbits.lib.io.archive.handles.Handle)3 Component (java.awt.Component)3 GameSet (com.github.jakz.romlib.data.set.GameSet)2 ArchiveHandle (com.pixbits.lib.io.archive.handles.ArchiveHandle)2 BinaryHandle (com.pixbits.lib.io.archive.handles.BinaryHandle)2 NestedArchiveHandle (com.pixbits.lib.io.archive.handles.NestedArchiveHandle)2 ColorGenerator (com.pixbits.lib.ui.color.ColorGenerator)2 PastelColorGenerator (com.pixbits.lib.ui.color.PastelColorGenerator)2 NimbusBooleanCellRenderer (com.pixbits.lib.ui.table.renderers.NimbusBooleanCellRenderer)2 Main (jack.rm.Main)2 GameSetManager (jack.rm.data.romset.GameSetManager)2 ScanResult (jack.rm.files.ScanResult)2 BorderLayout (java.awt.BorderLayout)2 Color (java.awt.Color)2 Frame (java.awt.Frame)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2