use of de.gurkenlabs.utiliti.swing.dialogs.GridEditPanel in project litiengine by gurkenlabs.
the class Program method initViewMenu.
private static Menu initViewMenu() {
Menu mnView = new Menu(Resources.get("menu_view"));
CheckboxMenuItem snapToGrid = new CheckboxMenuItem(Resources.get("menu_snapGrid"));
snapToGrid.setState(userPreferences.isSnapGrid());
EditorScreen.instance().getMapComponent().setSnapToGrid(snapToGrid.getState());
snapToGrid.addItemListener(e -> {
EditorScreen.instance().getMapComponent().setSnapToGrid(snapToGrid.getState());
userPreferences.setSnapGrid(snapToGrid.getState());
});
CheckboxMenuItem renderGrid = new CheckboxMenuItem(Resources.get("menu_renderGrid"));
renderGrid.setState(userPreferences.isShowGrid());
EditorScreen.instance().getMapComponent().setRenderGrid(renderGrid.getState());
renderGrid.setShortcut(new MenuShortcut(KeyEvent.VK_G));
renderGrid.addItemListener(e -> {
EditorScreen.instance().getMapComponent().setRenderGrid(renderGrid.getState());
userPreferences.setShowGrid(renderGrid.getState());
});
CheckboxMenuItem renderCollision = new CheckboxMenuItem(Resources.get("menu_renderCollisionBoxes"));
renderCollision.setState(userPreferences.isRenderBoundingBoxes());
EditorScreen.instance().getMapComponent().setRenderCollisionBoxes(renderCollision.getState());
renderCollision.setShortcut(new MenuShortcut(KeyEvent.VK_H));
renderCollision.addItemListener(e -> {
EditorScreen.instance().getMapComponent().setRenderCollisionBoxes(renderCollision.getState());
userPreferences.setRenderBoundingBoxes(renderCollision.getState());
});
MenuItem setGrid = new MenuItem(Resources.get("menu_gridSize"));
setGrid.addActionListener(a -> {
GridEditPanel panel = new GridEditPanel(EditorScreen.instance().getMapComponent().getGridSize());
int option = JOptionPane.showConfirmDialog(Game.getScreenManager().getRenderComponent(), panel, Resources.get("menu_gridSettings"), JOptionPane.DEFAULT_OPTION);
if (option == JOptionPane.OK_OPTION) {
EditorScreen.instance().getMapComponent().setGridSize(panel.getGridSize());
}
});
MenuItem zoomIn = new MenuItem(Resources.get("menu_zoomIn"));
zoomIn.setShortcut(new MenuShortcut(KeyEvent.VK_PLUS));
zoomIn.addActionListener(a -> EditorScreen.instance().getMapComponent().zoomIn());
MenuItem zoomOut = new MenuItem(Resources.get("menu_zoomOut"));
zoomOut.setShortcut(new MenuShortcut(KeyEvent.VK_MINUS));
zoomOut.addActionListener(a -> EditorScreen.instance().getMapComponent().zoomOut());
mnView.add(snapToGrid);
mnView.add(renderGrid);
mnView.add(renderCollision);
mnView.add(setGrid);
mnView.addSeparator();
mnView.add(zoomIn);
mnView.add(zoomOut);
return mnView;
}
Aggregations