Search in sources :

Example 1 with Settings

use of jack.rm.data.romset.Settings in project rom-manager by Jakz.

the class InfoPanel method buildPopupMenu.

public void buildPopupMenu() {
    customPopup.removeAll();
    JMenu embedded = new JMenu("Embedded");
    customPopup.add(embedded);
    JMenu custom = new JMenu("Custom");
    customPopup.add(custom);
    Attribute[] cattributes = new Attribute[] { GameAttribute.GENRE, GameAttribute.TAG, GameAttribute.EXPORT_TITLE };
    MyGameSetFeatures helper = set.helper();
    Settings settings = helper.settings();
    List<Attribute> enabledAttribs = settings.getRomAttributes();
    Stream<Attribute> eattributes = Arrays.stream(set.getSupportedAttributes());
    Runnable menuItemPostAction = () -> {
        buildMainLayout();
        buildFields();
        pFields.revalidate();
        updateFields(game);
        buildPopupMenu();
    };
    for (Attribute cattrib : cattributes) {
        JMenuItem item = null;
        if (enabledAttribs.contains(cattrib)) {
            item = new JMenuItem("Remove \'" + cattrib.getCaption() + "\'");
            item.addActionListener(e -> {
                settings.getRomAttributes().remove(cattrib);
                set.stream().forEach(r -> r.clearCustomAttribute(cattrib));
                menuItemPostAction.run();
            });
        } else {
            item = new JMenuItem("Add \'" + cattrib.getCaption() + "\'");
            item.addActionListener(e -> {
                settings.getRomAttributes().add(cattrib);
                menuItemPostAction.run();
            });
        }
        custom.add(item);
    }
    eattributes.forEach(eattrib -> {
        JMenuItem item = null;
        if (enabledAttribs.contains(eattrib)) {
            item = new JMenuItem("Hide \'" + eattrib.getCaption() + "\'");
            item.addActionListener(e -> {
                settings.getRomAttributes().remove(eattrib);
                menuItemPostAction.run();
            });
        } else {
            item = new JMenuItem("Show \'" + eattrib.getCaption() + "\'");
            item.addActionListener(e -> {
                List<Attribute> newAttributes = Arrays.stream(set.getSupportedAttributes()).filter(ee -> enabledAttribs.contains(ee) || ee == eattrib).collect(Collectors.toList());
                enabledAttribs.stream().filter(ee -> !Arrays.asList(set.getSupportedAttributes()).contains(ee)).forEach(newAttributes::add);
                enabledAttribs.clear();
                enabledAttribs.addAll(newAttributes);
                menuItemPostAction.run();
            });
        }
        embedded.add(item);
    });
}
Also used : Color(java.awt.Color) Arrays(java.util.Arrays) URL(java.net.URL) JToggleButton(javax.swing.JToggleButton) MyGameSetFeatures(jack.rm.data.romset.MyGameSetFeatures) GameSet(com.github.jakz.romlib.data.set.GameSet) MouseAdapter(java.awt.event.MouseAdapter) RomDownloaderPlugin(jack.rm.plugins.types.RomDownloaderPlugin) BorderLayout(java.awt.BorderLayout) Feature(com.github.jakz.romlib.data.set.Feature) Icon(com.github.jakz.romlib.ui.Icon) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage) Set(java.util.Set) JMenu(javax.swing.JMenu) BorderFactory(javax.swing.BorderFactory) Collectors(java.util.stream.Collectors) Box(javax.swing.Box) Dimension(java.awt.Dimension) List(java.util.List) Stream(java.util.stream.Stream) Graphics(java.awt.Graphics) JPanel(javax.swing.JPanel) ActionListener(java.awt.event.ActionListener) GameAttribute(com.github.jakz.romlib.data.game.attributes.GameAttribute) Asset(com.github.jakz.romlib.data.assets.Asset) Game(com.github.jakz.romlib.data.game.Game) Attribute(com.github.jakz.romlib.data.game.attributes.Attribute) SwingConstants(javax.swing.SwingConstants) SwingUtilities(javax.swing.SwingUtilities) JMenuItem(javax.swing.JMenuItem) RomAttribute(com.github.jakz.romlib.data.game.attributes.RomAttribute) ImageIcon(javax.swing.ImageIcon) AssetData(com.github.jakz.romlib.data.assets.AssetData) BoxLayout(javax.swing.BoxLayout) Mediator(jack.rm.gui.Mediator) Desktop(java.awt.Desktop) JButton(javax.swing.JButton) MigLayout(net.miginfocom.swing.MigLayout) JPopupMenu(javax.swing.JPopupMenu) PluginRealType(jack.rm.plugins.PluginRealType) GameStatus(com.github.jakz.romlib.data.game.GameStatus) ActionEvent(java.awt.event.ActionEvent) MouseEvent(java.awt.event.MouseEvent) JScrollPane(javax.swing.JScrollPane) JLabel(javax.swing.JLabel) AssetManager(com.github.jakz.romlib.data.assets.AssetManager) Main(jack.rm.Main) GameSetManager(jack.rm.data.romset.GameSetManager) Settings(jack.rm.data.romset.Settings) GameAttribute(com.github.jakz.romlib.data.game.attributes.GameAttribute) Attribute(com.github.jakz.romlib.data.game.attributes.Attribute) RomAttribute(com.github.jakz.romlib.data.game.attributes.RomAttribute) MyGameSetFeatures(jack.rm.data.romset.MyGameSetFeatures) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) Settings(jack.rm.data.romset.Settings)

Example 2 with Settings

use of jack.rm.data.romset.Settings in project rom-manager by Jakz.

the class Organizer method cleanup.

public void cleanup() {
    MyGameSetFeatures helper = set.helper();
    Settings settings = helper.settings();
    Set<CleanupPlugin> plugins = settings.plugins.getEnabledPlugins(PluginRealType.ROMSET_CLEANUP);
    plugins.stream().forEach(p -> p.execute(set));
}
Also used : CleanupPlugin(jack.rm.plugins.types.CleanupPlugin) MyGameSetFeatures(jack.rm.data.romset.MyGameSetFeatures) Settings(jack.rm.data.romset.Settings)

Example 3 with Settings

use of jack.rm.data.romset.Settings 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 4 with Settings

use of jack.rm.data.romset.Settings in project rom-manager by Jakz.

the class InfoPanel method buildFields.

void buildFields() {
    MyGameSetFeatures helper = set.helper();
    Settings settings = helper.settings();
    List<Attribute> attributes = settings.getRomAttributes();
    fields = attributes.stream().map(a -> buildField(a, true)).collect(Collectors.toList());
    /* add file name and path attributes only if there is a single rom per game */
    if (set.hasFeature(Feature.SINGLE_ROM_PER_GAME)) {
        // TODO: hardcoded for now
        fields.add(buildField(RomAttribute.CRC, false));
        fields.add(buildField(GameAttribute.PATH, false));
    }
    pFields.removeAll();
    pFields.setLayout(new MigLayout());
    for (AttributeField field : fields) {
        pFields.add(field.title, "span 4");
        if (field.deleteButton != null) {
            pFields.add(field.getComponent(), "span 8, growx");
            pFields.add(field.deleteButton, "wrap");
        } else
            pFields.add(field.getComponent(), "span 9, growx, wrap");
    }
    pFields.add(addCustomFieldButton);
    pFields.add(editButton);
    pFields.add(resetCustomFieldsButton);
}
Also used : GameAttribute(com.github.jakz.romlib.data.game.attributes.GameAttribute) Attribute(com.github.jakz.romlib.data.game.attributes.Attribute) RomAttribute(com.github.jakz.romlib.data.game.attributes.RomAttribute) MyGameSetFeatures(jack.rm.data.romset.MyGameSetFeatures) MigLayout(net.miginfocom.swing.MigLayout) Settings(jack.rm.data.romset.Settings)

Example 5 with Settings

use of jack.rm.data.romset.Settings in project rom-manager by Jakz.

the class SetInfoPanel method updateFields.

public void updateFields(GameSet set) {
    this.set = set;
    MyGameSetFeatures helper = set.helper();
    Settings settings = helper.settings();
    if (settings.romsPath != null)
        romsPathButton.setPath(settings.romsPath);
    else
        romsPathButton.clear();
}
Also used : MyGameSetFeatures(jack.rm.data.romset.MyGameSetFeatures) Settings(jack.rm.data.romset.Settings)

Aggregations

Settings (jack.rm.data.romset.Settings)6 MyGameSetFeatures (jack.rm.data.romset.MyGameSetFeatures)5 GameSet (com.github.jakz.romlib.data.set.GameSet)3 CleanupPlugin (jack.rm.plugins.types.CleanupPlugin)3 Set (java.util.Set)3 Game (com.github.jakz.romlib.data.game.Game)2 Attribute (com.github.jakz.romlib.data.game.attributes.Attribute)2 GameAttribute (com.github.jakz.romlib.data.game.attributes.GameAttribute)2 RomAttribute (com.github.jakz.romlib.data.game.attributes.RomAttribute)2 Main (jack.rm.Main)2 PluginRealType (jack.rm.plugins.PluginRealType)2 Files (java.nio.file.Files)2 Arrays (java.util.Arrays)2 Collectors (java.util.stream.Collectors)2 Asset (com.github.jakz.romlib.data.assets.Asset)1 AssetData (com.github.jakz.romlib.data.assets.AssetData)1 AssetManager (com.github.jakz.romlib.data.assets.AssetManager)1 GameStatus (com.github.jakz.romlib.data.game.GameStatus)1 Feature (com.github.jakz.romlib.data.set.Feature)1 GameSetFeatures (com.github.jakz.romlib.data.set.GameSetFeatures)1