use of de.gurkenlabs.utiliti.swing.dialogs.MapPropertyPanel in project litiengine by gurkenlabs.
the class Program method initMapMenu.
private static Menu initMapMenu() {
Menu mnMap = new Menu(Resources.get("menu_map"));
MenuItem imp = new MenuItem(Resources.get("menu_import"));
imp.addActionListener(a -> EditorScreen.instance().getMapComponent().importMap());
MenuItem exp = new MenuItem(Resources.get("menu_export"));
exp.addActionListener(a -> EditorScreen.instance().getMapComponent().exportMap());
MenuItem del2 = new MenuItem(Resources.get("menu_removeMap"));
del2.addActionListener(a -> EditorScreen.instance().getMapComponent().deleteMap());
MenuItem mapProps = new MenuItem(Resources.get("menu_properties"));
mapProps.setShortcut(new MenuShortcut(KeyEvent.VK_M));
mapProps.addActionListener(a -> {
if (EditorScreen.instance().getMapComponent().getMaps() == null || EditorScreen.instance().getMapComponent().getMaps().isEmpty()) {
return;
}
MapPropertyPanel panel = new MapPropertyPanel();
panel.bind(Game.getEnvironment().getMap());
int option = JOptionPane.showConfirmDialog(Game.getScreenManager().getRenderComponent(), panel, Resources.get("menu_mapProperties"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
if (option == JOptionPane.OK_OPTION) {
panel.saveChanges();
final String colorProp = Game.getEnvironment().getMap().getCustomProperty(MapProperty.AMBIENTCOLOR);
try {
if (Game.getEnvironment().getMap().getCustomProperty(MapProperty.AMBIENTALPHA) != null) {
int alpha = Integer.parseInt(Game.getEnvironment().getMap().getCustomProperty(MapProperty.AMBIENTALPHA));
Game.getEnvironment().getAmbientLight().setAlpha(alpha);
}
if (colorProp != null && !colorProp.isEmpty()) {
Color ambientColor = Color.decode(colorProp);
Game.getEnvironment().getAmbientLight().setColor(ambientColor);
}
} catch (final NumberFormatException nfe) {
log.log(Level.SEVERE, nfe.getLocalizedMessage(), nfe);
}
EditorScreen.instance().getMapComponent().loadMaps(EditorScreen.instance().getGameFile().getMaps());
EditorScreen.instance().getMapComponent().loadEnvironment((Map) Game.getEnvironment().getMap());
}
});
mnMap.add(imp);
mnMap.add(exp);
mnMap.add(del2);
mnMap.addSeparator();
mnMap.add(mapProps);
return mnMap;
}
Aggregations