Search in sources :

Example 11 with MyGameSetFeatures

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

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

the class InfoPanel method buildButtons.

public void buildButtons() {
    buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.LINE_AXIS));
    for (int i = 0; i < buttonLabels.length; ++i) {
        buttons[i] = new JButton(buttonLabels[i]);
        buttonsPanel.add(buttons[i]);
        buttons[i].setEnabled(false);
    }
    buttons[0].addActionListener(e -> {
        try {
            MyGameSetFeatures helper = set.helper();
            Set<RomDownloaderPlugin> downloaders = helper.settings().plugins.getEnabledPlugins(PluginRealType.ROM_DOWNLOADER);
            URL url = downloaders.stream().filter(p -> p.isPlatformSupported(set.platform())).findFirst().get().getDownloadURL(set.platform(), game);
            Desktop.getDesktop().browse(url.toURI());
        } catch (Exception ee) {
            ee.printStackTrace();
        }
    });
    buttons[1].addActionListener(e -> {
        if (game != null)
            Main.downloader.downloadArt(game);
    });
    buttons[2].addActionListener(e -> {
        Main.openFolder(game.rom().handle().path().getParent().toFile());
    // TODO: Main.openFolder(rom.getHandle().path().getParent().toFile());
    });
    buttons[3].addActionListener(e -> {
    // TODO: Main.openFolder(rom.getHandle().path().toFile());
    });
    buttons[4].addActionListener(e -> {
        if (game != null) {
            game.forgetStatus();
            SwingUtilities.invokeLater(() -> mediator.repaint());
        }
    });
}
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) BoxLayout(javax.swing.BoxLayout) MyGameSetFeatures(jack.rm.data.romset.MyGameSetFeatures) JButton(javax.swing.JButton) RomDownloaderPlugin(jack.rm.plugins.types.RomDownloaderPlugin) URL(java.net.URL)

Example 13 with MyGameSetFeatures

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

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

the class MainFrame method buildMenu.

private void buildMenu(final GameSet set) {
    MenuElement.clearListeners();
    romsMenu.removeAll();
    if (set != null) {
        romsMenu.add(MenuElement.ROMS_SCAN_FOR_ROMS.item);
        romsMenu.add(MenuElement.ROMS_SCAN_FOR_NEW_ROMS.item);
        JMenuItem refreshStatus = new JMenuItem("Refresh status");
        refreshStatus.addActionListener(e -> {
            for (Game game : set) game.updateStatus();
            SwingUtilities.invokeLater(() -> repaint());
        });
        romsMenu.add(refreshStatus);
        romsMenu.addSeparator();
        JMenuItem renameRoms = new JMenuItem(Text.MENU_ROMS_RENAME.text());
        renameRoms.addActionListener(e -> {
            MyGameSetFeatures helper = set.helper();
            helper.organizer().organize();
            rebuildGameList();
        });
        romsMenu.add(renameRoms);
        JMenuItem cleanupRoms = new JMenuItem(Text.MENU_ROMS_CLEANUP.text());
        cleanupRoms.addActionListener(e -> {
            MyGameSetFeatures helper = set.helper();
            helper.organizer().cleanup();
        });
        romsMenu.add(cleanupRoms);
        romsMenu.addSeparator();
        romsMenu.add(romsExportSubmenu);
        JMenuItem exportFavorites = new JMenuItem("Export favourites");
        exportFavorites.addActionListener(e -> {
            exportList(r -> r.isFavourite());
        });
        romsExportSubmenu.add(exportFavorites);
        JMenuItem exportFound = new JMenuItem(Text.MENU_ROMS_EXPORT_FOUND.text());
        exportFound.addActionListener(e -> {
            exportList(r -> r.getStatus().isComplete());
        });
        romsExportSubmenu.add(exportFound);
        JMenuItem exportMissing = new JMenuItem(Text.MENU_ROMS_EXPORT_MISSING.text());
        exportMissing.addActionListener(e -> {
            exportList(r -> !r.getStatus().isComplete());
        });
        romsExportSubmenu.add(exportMissing);
        romsMenu.addSeparator();
        MenuElement.addListeners();
    }
    JMenuItem menuExit = new JMenuItem(Text.MENU_ROMS_EXIT.text());
    romsMenu.add(menuExit);
    menuExit.addActionListener(e -> java.lang.System.exit(0));
    viewMenu.clear();
    viewMenu.rebuild(set, gameListPanel.data().getMode(), gameListPanel.isTreeMode());
    toolsMenu.removeAll();
    MenuElement.TOOLS_GLOBAL_SETTINGS.item.addActionListener(e -> Main.gsettingsView.showMe());
    toolsMenu.add(MenuElement.TOOLS_GLOBAL_SETTINGS.item);
    if (set != null) {
        MenuElement.TOOLS_OPTIONS.item.addActionListener(e -> optionsFrame.showMe());
        toolsMenu.add(MenuElement.TOOLS_OPTIONS.item);
        MenuElement.TOOLS_SHOW_MESSAGES.item.addActionListener(e -> toggleLogPanel(((JMenuItem) e.getSource()).isSelected()));
        toolsMenu.add(MenuElement.TOOLS_SHOW_MESSAGES.item);
        MenuElement.TOOLS_CONSOLE.item.addActionListener(e -> toggleConsole(((JMenuItem) e.getSource()).isSelected()));
        toolsMenu.add(MenuElement.TOOLS_CONSOLE.item);
        JMenu assetsMenu = new JMenu(Text.MENU_TOOLS_ASSETS.text());
        assetsMenu.add(MenuElement.TOOLS_DOWNLOAD_ASSETS.item);
        MenuElement.TOOLS_DOWNLOAD_ASSETS.item.addActionListener(e -> Main.downloader.start());
        assetsMenu.add(MenuElement.TOOLS_PACK_ASSETS.item);
        MenuElement.TOOLS_PACK_ASSETS.item.addActionListener(e -> AssetPacker.packAssets(set));
        toolsMenu.addSeparator();
        toolsMenu.add(assetsMenu);
        // TODO: localize
        JMenu pluginsMenu = new JMenu("Plugins");
        Map<String, List<OperationalPlugin>> plugins = new TreeMap<>();
        getGameSetSettings().plugins.stream().filter(p -> p.isEnabled() && p instanceof OperationalPlugin).map(p -> (OperationalPlugin) p).forEach(p -> {
            String key = p.getSubmenuCaption();
            plugins.computeIfAbsent(key, k -> new ArrayList<>()).add(p);
        });
        plugins.values().forEach(l -> Collections.sort(l, new Comparator<OperationalPlugin>() {

            @Override
            public int compare(OperationalPlugin o1, OperationalPlugin o2) {
                return o1.getMenuCaption().compareTo(o2.getMenuCaption());
            }
        }));
        plugins.entrySet().forEach(e -> {
            JMenu menu = new JMenu(e.getKey());
            e.getValue().forEach(p -> {
                JMenuItem item = new JMenuItem(p.getMenuCaption());
                item.addActionListener(ee -> p.execute(set));
                menu.add(item);
            });
            pluginsMenu.add(menu);
        });
        if (pluginsMenu.getItemCount() != 0) {
            toolsMenu.addSeparator();
            toolsMenu.add(pluginsMenu);
        }
    }
}
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) Game(com.github.jakz.romlib.data.game.Game) MyGameSetFeatures(jack.rm.data.romset.MyGameSetFeatures) OperationalPlugin(jack.rm.plugins.OperationalPlugin) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) JMenuItem(javax.swing.JMenuItem) TreeMap(java.util.TreeMap) JMenu(javax.swing.JMenu) Comparator(java.util.Comparator)

Example 15 with MyGameSetFeatures

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

the class OptionsFrame method rebuildGUIComponents.

public void rebuildGUIComponents() {
    int tabCount = tabs.getTabCount();
    for (int i = 2; i < tabCount; ++i) tabs.removeTabAt(2);
    MyGameSetFeatures helper = set.helper();
    manager.stream().map(b -> helper.settings().plugins.getPlugin(b.getID())).filter(p -> p.isPresent() && p.get().isEnabled()).forEach(p -> {
        PluginOptionsPanel panel = p.get().getGUIPanel();
        if (panel != null) {
            tabs.addTab(panel.getTitle(), panel);
            panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
            panel.updateFields();
        }
    });
}
Also used : ActualPluginBuilder(jack.rm.plugins.ActualPluginBuilder) ActionListener(java.awt.event.ActionListener) JButton(javax.swing.JButton) PluginManager(com.pixbits.lib.plugin.PluginManager) BorderFactory(javax.swing.BorderFactory) MyGameSetFeatures(jack.rm.data.romset.MyGameSetFeatures) ComponentEvent(java.awt.event.ComponentEvent) ActualPlugin(jack.rm.plugins.ActualPlugin) ActionEvent(java.awt.event.ActionEvent) GridLayout(java.awt.GridLayout) GameSet(com.github.jakz.romlib.data.set.GameSet) Dimension(java.awt.Dimension) ComponentListener(java.awt.event.ComponentListener) JLabel(javax.swing.JLabel) JTabbedPane(javax.swing.JTabbedPane) Text(jack.rm.i18n.Text) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) Main(jack.rm.Main) JPanel(javax.swing.JPanel) GameSetManager(jack.rm.data.romset.GameSetManager) MyGameSetFeatures(jack.rm.data.romset.MyGameSetFeatures)

Aggregations

MyGameSetFeatures (jack.rm.data.romset.MyGameSetFeatures)16 GameSet (com.github.jakz.romlib.data.set.GameSet)8 Settings (jack.rm.data.romset.Settings)7 Dimension (java.awt.Dimension)6 Game (com.github.jakz.romlib.data.game.Game)5 Attribute (com.github.jakz.romlib.data.game.attributes.Attribute)5 GameAttribute (com.github.jakz.romlib.data.game.attributes.GameAttribute)5 Feature (com.github.jakz.romlib.data.set.Feature)5 Main (jack.rm.Main)5 GameSetManager (jack.rm.data.romset.GameSetManager)5 BorderLayout (java.awt.BorderLayout)5 Arrays (java.util.Arrays)5 List (java.util.List)5 JMenuItem (javax.swing.JMenuItem)5 Asset (com.github.jakz.romlib.data.assets.Asset)4 RomAttribute (com.github.jakz.romlib.data.game.attributes.RomAttribute)4 PluginRealType (jack.rm.plugins.PluginRealType)4 Color (java.awt.Color)4 ActionEvent (java.awt.event.ActionEvent)4 ActionListener (java.awt.event.ActionListener)4