Skip to content

Commit fdf3142

Browse files
committed
Added shortcuts to the gui.
1 parent 93b8e69 commit fdf3142

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

FantasyWorldSimulation/src/jfws/editor/map/MapEditorController.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import javafx.fxml.FXML;
55
import javafx.scene.canvas.Canvas;
66
import javafx.scene.control.*;
7-
import javafx.scene.input.MouseEvent;
7+
import javafx.scene.input.*;
88
import javafx.stage.FileChooser;
99
import jfws.features.elevation.ElevationColorSelector;
1010
import jfws.features.elevation.ElevationInterpolator;
@@ -71,7 +71,16 @@ enum MapType {
7171
private Spinner<Integer> hillNoiseSpinner;
7272

7373
@FXML
74-
private MenuItem viewRegionMapItem, viewSketchMapItem;
74+
private MenuItem viewRegionMapItem;
75+
76+
@FXML
77+
private MenuItem viewSketchMapItem;
78+
79+
@FXML
80+
private MenuItem loadMapItem;
81+
82+
@FXML
83+
private MenuItem saveMapItem;
7584

7685
private FileChooser fileChooser = new FileChooser();
7786
private FileUtils fileUtils = new ApacheFileUtils();
@@ -142,6 +151,9 @@ private void initialize() {
142151
CanvasRenderer canvasRenderer = new CanvasRenderer(sketchMapCanvas.getGraphicsContext2D());
143152
mapRenderer = new MapRenderer(canvasRenderer, WORLD_TO_SCREEN, BORDER_BETWEEN_CELLS);
144153

154+
loadMapItem.setAccelerator(new KeyCodeCombination(KeyCode.L, KeyCombination.CONTROL_DOWN));
155+
saveMapItem.setAccelerator(new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN));
156+
145157
updateHistory();
146158
updateViewControls();
147159
render();
@@ -220,7 +232,6 @@ public void onSaveMap() {
220232
try {
221233
sketchConverter.save(file, sketchMap);
222234
} catch (IOException e) {
223-
e.printStackTrace();
224235
log.error("onSaveMap(): ", e);
225236
}
226237
}
@@ -229,6 +240,11 @@ public void onSaveMap() {
229240
}
230241
}
231242

243+
@FXML
244+
public void onReloadTerrainTypes() {
245+
log.info("onReloadTerrainTypes()");
246+
}
247+
232248
@FXML
233249
public void onTerrainTypeSelected() {
234250
String selectedName = terrainTypeComboBox.getSelectionModel().getSelectedItem();

FantasyWorldSimulation/src/jfws/editor/map/map-editor.fxml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
<menus>
2727
<Menu mnemonicParsing="false" text="File">
2828
<items>
29-
<MenuItem mnemonicParsing="false" onAction="#onLoadMap" text="Load Map" />
30-
<MenuItem mnemonicParsing="false" onAction="#onSaveMap" text="Save Map" />
29+
<MenuItem fx:id="loadMapItem" mnemonicParsing="false" onAction="#onLoadMap" text="Load Map" />
30+
<MenuItem fx:id="saveMapItem" mnemonicParsing="false" onAction="#onSaveMap" text="Save Map" />
3131
</items>
3232
</Menu>
3333
<Menu mnemonicParsing="false" text="View">

0 commit comments

Comments
 (0)