use of com.github.jakz.romlib.data.set.GameSet 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);
}
}
}
use of com.github.jakz.romlib.data.set.GameSet in project rom-manager by Jakz.
the class RomSetListCellRenderer method getListCellRendererComponent.
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel c = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
GameSet set = (GameSet) value;
if (set != null)
c.setIcon(set.platform().getIcon());
return c;
}
Aggregations