use of com.github.jakz.romlib.data.game.Game in project rom-manager by Jakz.
the class GameConsolidator method accept.
public void accept(GameEntry handle) {
Game game = handle.getGame();
// TODO: broken with new management
game.stream().forEach(rom -> {
try {
Path finalPath = handle.getFinalPath(destination);
if (!overwrite && Files.exists(finalPath))
return;
Files.createDirectories(finalPath.getParent());
if (handle.hasBeenModified()) {
Files.move(handle.getPath(), finalPath, StandardCopyOption.REPLACE_EXISTING);
} else {
Handle path = rom.handle();
if (!path.isArchive())
Files.copy(path.path(), finalPath, StandardCopyOption.REPLACE_EXISTING);
else
Files.copy(path.getInputStream(), finalPath, StandardCopyOption.REPLACE_EXISTING);
}
// if (handle.getBuffer() == null)
// handle.prepareBuffer();
// Files.deleteIfExists(handle.getPath());
} catch (Exception e) {
System.out.println("Error on " + rom.handle().toString());
if (e.getCause() != e)
e.getCause().printStackTrace();
else
e.printStackTrace();
}
});
}
use of com.github.jakz.romlib.data.game.Game in project rom-manager by Jakz.
the class InfoPanel method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
Object src = e.getSource();
if (src == downloadButton) {
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();
}
} else if (src == openFolderButton) {
Main.openFolder(game.rom().handle().path().getParent().toFile());
// TODO: Main.openFolder(rom.getHandle().path().getParent().toFile());
} else if (src == openArchiveButton) {
// TODO: Main.openFolder(rom.getHandle().path().toFile());
} else if (src == assetsButton) {
if (game != null)
Main.downloader.downloadArt(game);
}
}
use of com.github.jakz.romlib.data.game.Game 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);
});
}
use of com.github.jakz.romlib.data.game.Game in project rom-manager by Jakz.
the class MyGameSetFeatures method pluginStateChanged.
public void pluginStateChanged() {
Settings settings = Main.setManager.settings(set);
if (settings.getSearchPlugin() != null) {
List<SearchPredicate<Game>> predicates = new ArrayList<>();
SearchPlugin plugin = settings.plugins.getEnabledPlugin(PluginRealType.SEARCH);
SearchParser<Game> parser = plugin.getSearcher();
Set<SearchPredicatesPlugin> predicatePlugins = settings.plugins.getEnabledPlugins(PluginRealType.SEARCH_PREDICATES);
predicatePlugins.stream().flatMap(p -> p.getPredicates().stream()).forEach(predicates::add);
searcher = new Searcher<>(parser, predicates);
} else
searcher = new DummySearcher<>();
if (settings.getRenamer() != null)
renamer = settings.getRenamer();
else
renamer = GameRenamer.DUMMY;
if (settings.getFolderOrganizer() != null)
mover = settings.getFolderOrganizer();
else
mover = GameMover.DUMMY;
scanner = new Scanner(set);
}
use of com.github.jakz.romlib.data.game.Game 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();
}
Aggregations