use of de.gurkenlabs.utiliti.swing.dialogs.SpritesheetImportPanel in project litiengine by gurkenlabs.
the class EditorScreen method importSpritesheets.
public void importSpritesheets() {
JFileChooser chooser;
try {
chooser = new JFileChooser(new File(this.getProjectPath()).getCanonicalPath());
FileFilter filter = new FileNameExtensionFilter(SPRITESHEET_FILE_NAME, ImageFormat.getAllExtensions());
chooser.setFileFilter(filter);
chooser.addChoosableFileFilter(filter);
chooser.setMultiSelectionEnabled(true);
if (chooser.showOpenDialog(Game.getScreenManager().getRenderComponent()) == JFileChooser.APPROVE_OPTION) {
SpritesheetImportPanel spritePanel = new SpritesheetImportPanel(chooser.getSelectedFiles());
int option = JOptionPane.showConfirmDialog(Game.getScreenManager().getRenderComponent(), spritePanel, Resources.get("menu_assets_editSprite"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
if (option != JOptionPane.OK_OPTION) {
return;
}
// TODO: somehow improve this to allow keeping the animation frames and only update the image
Collection<SpriteSheetInfo> sprites = spritePanel.getSpriteSheets();
for (SpriteSheetInfo info : sprites) {
this.getGameFile().getSpriteSheets().removeIf(x -> x.getName().equals(info.getName()));
this.getGameFile().getSpriteSheets().add(info);
log.log(Level.INFO, "imported spritesheet {0}", new Object[] { info.getName() });
}
this.loadSpriteSheets(sprites, true);
}
} catch (IOException e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
}
Aggregations