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);*/
}
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());
}
});
}
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);
}
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);
}
}
}
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();
}
});
}
Aggregations