mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-01-12 12:30:07 +00:00
Moved Map Editor UI into its own FXML and controller class -- tracking down some regressions but it is mostly still working OK.
This commit is contained in:
parent
25b83b7b61
commit
cf441192fc
@ -75,7 +75,7 @@ public class ApplicationMenuControllerImpl extends ApplicationMenuController {
|
||||
try {
|
||||
UIAction.actionPerformed(UIAction.MAIN_ACTIONS.Load);
|
||||
mainController.rebuildImageSelector();
|
||||
mainController.rebuildMapSelectors();
|
||||
mainController.mapController.rebuildMapSelectors();
|
||||
mainController.rebuildTileSelectors();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
||||
|
@ -5,33 +5,33 @@ import java.util.ResourceBundle;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.Event;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.control.Menu;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import org.badvision.outlaweditor.data.xml.Image;
|
||||
import org.badvision.outlaweditor.data.xml.Map;
|
||||
import org.badvision.outlaweditor.data.xml.Script;
|
||||
import org.badvision.outlaweditor.data.xml.Tile;
|
||||
|
||||
public abstract class ApplicationUIController {
|
||||
|
||||
public static ApplicationUIController getController() {
|
||||
return Application.instance.controller;
|
||||
}
|
||||
|
||||
abstract void rebuildMapSelectors();
|
||||
abstract void rebuildTileSelectors();
|
||||
|
||||
abstract void rebuildImageSelector();
|
||||
|
||||
abstract Editor getVisibleEditor();
|
||||
|
||||
abstract Editor getVisibleEditor();
|
||||
|
||||
@FXML // ResourceBundle that was given to the FXMLLoader
|
||||
protected ResourceBundle resources;
|
||||
@FXML ApplicationMenuController menuController;
|
||||
@FXML TileEditorTabController tileEditorController;
|
||||
|
||||
@FXML
|
||||
ApplicationMenuController menuController;
|
||||
@FXML
|
||||
TileEditorTabController tileController;
|
||||
@FXML
|
||||
MapEditorTabController mapController;
|
||||
|
||||
@FXML // URL location of the FXML file that was given to the FXMLLoader
|
||||
protected URL location;
|
||||
@FXML // fx:id="imageCategoryField"
|
||||
@ -48,24 +48,8 @@ public abstract class ApplicationUIController {
|
||||
protected ComboBox<Image> imageSelector; // Value injected by FXMLLoader
|
||||
@FXML // fx:id="imageWidthField"
|
||||
protected TextField imageWidthField; // Value injected by FXMLLoader
|
||||
@FXML // fx:id="mapEditorAnchorPane"
|
||||
protected AnchorPane mapEditorAnchorPane; // Value injected by FXMLLoader
|
||||
@FXML // fx:id="mapHeightField"
|
||||
protected TextField mapHeightField; // Value injected by FXMLLoader
|
||||
@FXML // fx:id="mapNameField"
|
||||
protected TextField mapNameField; // Value injected by FXMLLoader
|
||||
@FXML // fx:id="mapScriptsList"
|
||||
protected ListView<Script> mapScriptsList; // Value injected by FXMLLoader
|
||||
@FXML // fx:id="mapSelect"
|
||||
protected ComboBox<Map> mapSelect; // Value injected by FXMLLoader
|
||||
@FXML
|
||||
protected Menu mapSelectTile;
|
||||
@FXML // fx:id="mapWidthField"
|
||||
protected TextField mapWidthField; // Value injected by FXMLLoader
|
||||
@FXML // fx:id="mapWrapAround"
|
||||
protected CheckBox mapWrapAround; // Value injected by FXMLLoader
|
||||
|
||||
// Handler for MenuItem[javafx.scene.control.MenuItem@3a4bc91a] onAction
|
||||
|
||||
@FXML
|
||||
abstract public void imageBitMode(ActionEvent event);
|
||||
|
||||
@ -85,9 +69,6 @@ public abstract class ApplicationUIController {
|
||||
@FXML
|
||||
abstract public void imageShift(ActionEvent event);
|
||||
|
||||
@FXML
|
||||
abstract public void imageTabActivated(Event event);
|
||||
|
||||
// Handler for MenuItem[javafx.scene.control.MenuItem@547638c0] onAction
|
||||
@FXML
|
||||
abstract public void imageTogglePanZoom(ActionEvent event);
|
||||
@ -100,32 +81,6 @@ public abstract class ApplicationUIController {
|
||||
@FXML
|
||||
abstract public void imageZoomOut(ActionEvent event);
|
||||
|
||||
@FXML
|
||||
abstract public void mapDraw1(ActionEvent event);
|
||||
|
||||
@FXML
|
||||
abstract public void mapDraw3(ActionEvent event);
|
||||
|
||||
@FXML
|
||||
abstract public void mapDraw5(ActionEvent event);
|
||||
|
||||
@FXML
|
||||
abstract public void mapDrawFilledRectMode(ActionEvent event);
|
||||
|
||||
@FXML
|
||||
abstract public void mapTabActivated(Event event);
|
||||
|
||||
@FXML
|
||||
abstract public void mapTogglePanZoom(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button zoomInButton]] onAction
|
||||
@FXML
|
||||
abstract public void mapZoomIn(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button zoomOutButton]] onAction
|
||||
@FXML
|
||||
abstract public void mapZoomOut(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button]] onAction
|
||||
@FXML
|
||||
abstract public void onImageClonePressed(ActionEvent event);
|
||||
@ -146,41 +101,6 @@ public abstract class ApplicationUIController {
|
||||
@FXML
|
||||
abstract public void onImageSelected(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button]] onAction
|
||||
@FXML
|
||||
abstract public void onMapClonePressed(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button]] onAction
|
||||
@FXML
|
||||
abstract public void onMapCreatePressed(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button]] onAction
|
||||
@FXML
|
||||
abstract public void onMapDeletePressed(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button]] onAction
|
||||
@FXML
|
||||
abstract public void onMapExportPressed(ActionEvent event);
|
||||
|
||||
@FXML
|
||||
abstract public void onMapPreviewPressed(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button]] onAction
|
||||
@FXML
|
||||
abstract public void onMapScriptAddPressed(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button]] onAction
|
||||
@FXML
|
||||
abstract public void onMapScriptClonePressed(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button]] onAction
|
||||
@FXML
|
||||
abstract public void onMapScriptDeletePressed(ActionEvent event);
|
||||
|
||||
// Handler for ComboBox[id="tileSelect"] onAction
|
||||
@FXML
|
||||
abstract public void onMapSelected(ActionEvent event);
|
||||
|
||||
abstract public void platformChange();
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button moveButton]] onAction
|
||||
@ -199,28 +119,18 @@ public abstract class ApplicationUIController {
|
||||
@FXML
|
||||
abstract public void scrollImageUp(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button moveButton]] onAction
|
||||
@FXML
|
||||
abstract public void scrollMapDown(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button moveButton]] onAction
|
||||
@FXML
|
||||
abstract public void scrollMapLeft(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button moveButton]] onAction
|
||||
@FXML
|
||||
abstract public void scrollMapRight(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button moveButton]] onAction
|
||||
@FXML
|
||||
abstract public void scrollMapUp(ActionEvent event);
|
||||
|
||||
@FXML
|
||||
abstract public void imageDraw5BitMode(ActionEvent event);
|
||||
|
||||
@FXML
|
||||
abstract public void tileTabActivated(Event event);
|
||||
|
||||
@FXML
|
||||
abstract public void mapTabActivated(Event event);
|
||||
|
||||
@FXML
|
||||
abstract public void imageTabActivated(Event event);
|
||||
|
||||
@FXML // This method is called by the FXMLLoader when initialization is complete
|
||||
public void initialize() {
|
||||
assert imageCategoryField != null : "fx:id=\"imageCategoryField\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
||||
@ -230,17 +140,8 @@ public abstract class ApplicationUIController {
|
||||
assert imagePatternMenu != null : "fx:id=\"imagePatternMenu\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
||||
assert imageSelector != null : "fx:id=\"imageSelector\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
||||
assert imageWidthField != null : "fx:id=\"imageWidthField\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
||||
assert mapEditorAnchorPane != null : "fx:id=\"mapEditorAnchorPane\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
||||
assert mapHeightField != null : "fx:id=\"mapHeightField\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
||||
assert mapNameField != null : "fx:id=\"mapNameField\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
||||
assert mapScriptsList != null : "fx:id=\"mapScriptsList\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
||||
assert mapSelect != null : "fx:id=\"mapSelect\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
||||
assert mapSelectTile != null : "fx:id=\"mapSelectTile\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
||||
assert mapWidthField != null : "fx:id=\"mapWidthField\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
||||
assert mapWrapAround != null : "fx:id=\"mapWrapAround\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
||||
|
||||
// Initialize your logic here: all @FXML variables will have been injected
|
||||
|
||||
}
|
||||
|
||||
abstract void completeInflightOperations();
|
||||
|
@ -6,24 +6,18 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.Event;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.cell.ComboBoxListCell;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.image.WritableImage;
|
||||
import javafx.scene.input.DataFormat;
|
||||
import javafx.util.Callback;
|
||||
import static org.badvision.outlaweditor.Application.currentPlatform;
|
||||
import static org.badvision.outlaweditor.Application.gameData;
|
||||
import static org.badvision.outlaweditor.UIAction.*;
|
||||
import static org.badvision.outlaweditor.data.PropertyHelper.*;
|
||||
import org.badvision.outlaweditor.data.TileUtils;
|
||||
import org.badvision.outlaweditor.data.TilesetUtils;
|
||||
import org.badvision.outlaweditor.data.xml.Image;
|
||||
import org.badvision.outlaweditor.data.xml.Script;
|
||||
import org.badvision.outlaweditor.data.xml.Tile;
|
||||
|
||||
/**
|
||||
@ -33,8 +27,6 @@ import org.badvision.outlaweditor.data.xml.Tile;
|
||||
*/
|
||||
public class ApplicationUIControllerImpl extends ApplicationUIController {
|
||||
|
||||
public org.badvision.outlaweditor.data.xml.Map currentMap = null;
|
||||
public MapEditor currentMapEditor = null;
|
||||
public Image currentImage = null;
|
||||
public ImageEditor currentImageEditor = null;
|
||||
|
||||
@ -49,33 +41,6 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
|
||||
}
|
||||
});
|
||||
|
||||
mapSelect.setButtonCell(new ComboBoxListCell<org.badvision.outlaweditor.data.xml.Map>() {
|
||||
{
|
||||
super.setPrefWidth(125);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateItem(org.badvision.outlaweditor.data.xml.Map item, boolean empty) {
|
||||
textProperty().unbind();
|
||||
super.updateItem(item, empty);
|
||||
if (item != null) {
|
||||
textProperty().bind(mapNameField.textProperty());
|
||||
} else {
|
||||
setText(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
mapSelect.setCellFactory(new Callback<ListView<org.badvision.outlaweditor.data.xml.Map>, ListCell<org.badvision.outlaweditor.data.xml.Map>>() {
|
||||
@Override
|
||||
public ListCell<org.badvision.outlaweditor.data.xml.Map> call(ListView<org.badvision.outlaweditor.data.xml.Map> param) {
|
||||
return new EntitySelectorCell<org.badvision.outlaweditor.data.xml.Map>(mapNameField) {
|
||||
@Override
|
||||
public void finishUpdate(org.badvision.outlaweditor.data.xml.Map item) {
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
imageSelector.setButtonCell(new ComboBoxListCell<Image>() {
|
||||
{
|
||||
super.setPrefWidth(125);
|
||||
@ -167,55 +132,6 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapDraw1(ActionEvent event) {
|
||||
if (currentMapEditor != null) {
|
||||
currentMapEditor.setDrawMode(MapEditor.DrawMode.Pencil1px);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapDraw3(ActionEvent event) {
|
||||
if (currentMapEditor != null) {
|
||||
currentMapEditor.setDrawMode(MapEditor.DrawMode.Pencil3px);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapDraw5(ActionEvent event) {
|
||||
if (currentMapEditor != null) {
|
||||
currentMapEditor.setDrawMode(MapEditor.DrawMode.Pencil5px);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapDrawFilledRectMode(ActionEvent event) {
|
||||
if (currentMapEditor != null) {
|
||||
currentMapEditor.setDrawMode(MapEditor.DrawMode.FilledRect);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapTogglePanZoom(ActionEvent event) {
|
||||
if (currentMapEditor != null) {
|
||||
currentMapEditor.togglePanZoom();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapZoomIn(ActionEvent event) {
|
||||
if (currentMapEditor != null) {
|
||||
currentMapEditor.zoomIn();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapZoomOut(ActionEvent event) {
|
||||
if (currentMapEditor != null) {
|
||||
currentMapEditor.zoomOut();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onImageClonePressed(ActionEvent event) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
@ -258,81 +174,16 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
|
||||
setCurrentImage(imageSelector.getSelectionModel().getSelectedItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapClonePressed(ActionEvent event) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapCreatePressed(ActionEvent event) {
|
||||
org.badvision.outlaweditor.data.xml.Map m = new org.badvision.outlaweditor.data.xml.Map();
|
||||
m.setName("Untitled");
|
||||
gameData.getMap().add(m);
|
||||
m.setWidth(512);
|
||||
m.setHeight(512);
|
||||
setCurrentMap(m);
|
||||
rebuildMapSelectors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapDeletePressed(ActionEvent event) {
|
||||
if (currentMap == null) {
|
||||
return;
|
||||
}
|
||||
confirm("Delete map '" + currentMap.getName() + "'. Are you sure?", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
org.badvision.outlaweditor.data.xml.Map del = currentMap;
|
||||
setCurrentMap(null);
|
||||
Application.gameData.getMap().remove(del);
|
||||
rebuildMapSelectors();
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapExportPressed(ActionEvent event) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapPreviewPressed(ActionEvent event) {
|
||||
if (currentMapEditor == null) {
|
||||
return;
|
||||
}
|
||||
currentMapEditor.showPreview();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapScriptAddPressed(ActionEvent event) {
|
||||
createAndEditScript();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapScriptClonePressed(ActionEvent event) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapScriptDeletePressed(ActionEvent event) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapSelected(ActionEvent event) {
|
||||
setCurrentMap(mapSelect.getSelectionModel().getSelectedItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void platformChange() {
|
||||
for (Tile t : Application.gameData.getTile()) {
|
||||
TileUtils.redrawTile(t);
|
||||
}
|
||||
Tile tile = tileEditorController.getCurrentTile();
|
||||
Tile tile = tileController.getCurrentTile();
|
||||
rebuildTileSelectors();
|
||||
tileEditorController.setCurrentTile(tile);
|
||||
if (currentMapEditor != null) {
|
||||
currentMapEditor.redraw();
|
||||
tileController.setCurrentTile(tile);
|
||||
if (mapController.getCurrentEditor() != null) {
|
||||
mapController.getCurrentEditor().redraw();
|
||||
}
|
||||
rebuildImageSelector();
|
||||
}
|
||||
@ -365,112 +216,10 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scrollMapDown(ActionEvent event) {
|
||||
if (currentMapEditor != null) {
|
||||
currentMapEditor.scrollBy(0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scrollMapLeft(ActionEvent event) {
|
||||
if (currentMapEditor != null) {
|
||||
currentMapEditor.scrollBy(-1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scrollMapRight(ActionEvent event) {
|
||||
if (currentMapEditor != null) {
|
||||
currentMapEditor.scrollBy(1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scrollMapUp(ActionEvent event) {
|
||||
if (currentMapEditor != null) {
|
||||
currentMapEditor.scrollBy(0, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rebuildTileSelectors() {
|
||||
tileEditorController.rebuildTileSelectors();
|
||||
mapSelectTile.getItems().clear();
|
||||
for (final Tile t : Application.gameData.getTile()) {
|
||||
WritableImage img = TileUtils.getImage(t, currentPlatform);
|
||||
ImageView iv = new ImageView(img);
|
||||
MenuItem mapSelectItem = new MenuItem(t.getName(), iv);
|
||||
mapSelectItem.setGraphic(new ImageView(TileUtils.getImage(t, currentPlatform)));
|
||||
mapSelectItem.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
if (currentMapEditor != null) {
|
||||
currentMapEditor.setCurrentTile(t);
|
||||
}
|
||||
}
|
||||
});
|
||||
mapSelectTile.getItems().add(mapSelectItem);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentMap(org.badvision.outlaweditor.data.xml.Map m) {
|
||||
if (currentMap != null && currentMap.equals(m)) {
|
||||
return;
|
||||
}
|
||||
// mapEditorAnchorPane.getChildren().clear();
|
||||
currentMap = m;
|
||||
if (currentMapEditor != null) {
|
||||
currentMapEditor.unregister();
|
||||
}
|
||||
if (m == null) {
|
||||
bind(mapHeightField.textProperty(), null);
|
||||
bind(mapNameField.textProperty(), null);
|
||||
bind(mapWidthField.textProperty(), null);
|
||||
bind(mapWrapAround.selectedProperty(), null);
|
||||
mapHeightField.setDisable(true);
|
||||
mapNameField.setDisable(true);
|
||||
mapWidthField.setDisable(true);
|
||||
mapWrapAround.setDisable(true);
|
||||
currentMapEditor = null;
|
||||
} else {
|
||||
if (m.getHeight() == null) {
|
||||
m.setHeight(512);
|
||||
}
|
||||
if (m.getWidth() == null) {
|
||||
m.setWidth(512);
|
||||
}
|
||||
if (m.getName() == null) {
|
||||
m.setName("Untitled");
|
||||
}
|
||||
try {
|
||||
mapHeightField.setDisable(false);
|
||||
mapNameField.setDisable(false);
|
||||
mapWidthField.setDisable(false);
|
||||
mapWrapAround.setDisable(false);
|
||||
// bind(mapHeightField.textProperty(), intProp(m, "height"));
|
||||
bind(mapNameField.textProperty(), stringProp(m, "name"));
|
||||
// bind(mapWidthField.textProperty(), intProp(m, "width"));
|
||||
// bind(mapWrapAround.selectedProperty(),boolProp(m, "wrap"));
|
||||
} catch (NoSuchMethodException ex) {
|
||||
Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
currentMapEditor = new MapEditor();
|
||||
currentMapEditor.setEntity(m);
|
||||
currentMapEditor.buildEditorUI(mapEditorAnchorPane);
|
||||
}
|
||||
redrawMapScripts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rebuildMapSelectors() {
|
||||
mapSelect.getItems().clear();
|
||||
mapSelect.getItems().addAll(Application.gameData.getMap());
|
||||
mapSelect.getSelectionModel().select(getCurrentMap());
|
||||
}
|
||||
|
||||
public org.badvision.outlaweditor.data.xml.Map getCurrentMap() {
|
||||
return currentMap;
|
||||
tileController.rebuildTileSelectors();
|
||||
mapController.rebuildTileSelectors();
|
||||
}
|
||||
|
||||
private void setCurrentImage(Image i) {
|
||||
@ -531,8 +280,8 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
|
||||
|
||||
@Override
|
||||
public void completeInflightOperations() {
|
||||
if (currentMapEditor != null) {
|
||||
currentMapEditor.currentMap.updateBackingMap();
|
||||
if (mapController.getCurrentEditor() != null) {
|
||||
mapController.getCurrentEditor().currentMap.updateBackingMap();
|
||||
}
|
||||
}
|
||||
|
||||
@ -563,50 +312,14 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
|
||||
case image:
|
||||
return currentImageEditor;
|
||||
case map:
|
||||
return currentMapEditor;
|
||||
return mapController.getCurrentEditor();
|
||||
case tile:
|
||||
return tileEditorController.getCurrentTileEditor();
|
||||
return tileController.getCurrentTileEditor();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final DataFormat SCRIPT_DATA_FORMAT = new DataFormat("MythosScript");
|
||||
public void redrawMapScripts() {
|
||||
mapScriptsList.setOnEditStart(new EventHandler<ListView.EditEvent<Script>>() {
|
||||
@Override
|
||||
public void handle(ListView.EditEvent<Script> event) {
|
||||
UIAction.editScript(event.getSource().getItems().get(event.getIndex()));
|
||||
}
|
||||
});
|
||||
final TransferHelper<Script> scriptDragDrop = new TransferHelper<>(Script.class);
|
||||
mapScriptsList.setCellFactory(new Callback<ListView<Script>, ListCell<Script>>() {
|
||||
@Override
|
||||
public ListCell<Script> call(ListView<Script> param) {
|
||||
final ListCell<Script> cell = new ListCell<Script>() {
|
||||
@Override
|
||||
protected void updateItem(Script item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (empty || item == null) {
|
||||
setText("");
|
||||
} else {
|
||||
setText(item.getName());
|
||||
scriptDragDrop.registerDragSupport(this, item);
|
||||
}
|
||||
}
|
||||
};
|
||||
return cell;
|
||||
}
|
||||
});
|
||||
if (currentMap == null) {
|
||||
mapScriptsList.getItems().clear();
|
||||
} else {
|
||||
if (mapScriptsList.getItems() != null && currentMap.getScripts() != null) {
|
||||
mapScriptsList.getItems().setAll(currentMap.getScripts().getScript());
|
||||
} else {
|
||||
mapScriptsList.getItems().clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract public static class EntitySelectorCell<T> extends ComboBoxListCell<T> {
|
||||
|
||||
@ -652,4 +365,5 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
|
||||
public void finishUpdate(T item) {
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,134 @@
|
||||
package org.badvision.outlaweditor;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.control.Menu;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import org.badvision.outlaweditor.data.xml.Map;
|
||||
import org.badvision.outlaweditor.data.xml.Script;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author blurry
|
||||
*/
|
||||
public abstract class MapEditorTabController {
|
||||
private MapEditor currentEditor;
|
||||
public MapEditor getCurrentEditor() {
|
||||
return currentEditor;
|
||||
}
|
||||
public void setCurrentEditor(MapEditor editor) {
|
||||
currentEditor = editor;
|
||||
}
|
||||
public abstract Map getCurrentMap();
|
||||
public abstract void setCurrentMap(Map m);
|
||||
public abstract void rebuildMapSelectors();
|
||||
public abstract void redrawMapScripts();
|
||||
|
||||
@FXML // fx:id="mapEditorAnchorPane"
|
||||
protected AnchorPane mapEditorAnchorPane; // Value injected by FXMLLoader
|
||||
@FXML // fx:id="mapHeightField"
|
||||
protected TextField mapHeightField; // Value injected by FXMLLoader
|
||||
@FXML // fx:id="mapNameField"
|
||||
protected TextField mapNameField; // Value injected by FXMLLoader
|
||||
@FXML // fx:id="mapScriptsList"
|
||||
protected ListView<Script> mapScriptsList; // Value injected by FXMLLoader
|
||||
@FXML // fx:id="mapSelect"
|
||||
protected ComboBox<Map> mapSelect; // Value injected by FXMLLoader
|
||||
@FXML
|
||||
protected Menu mapSelectTile;
|
||||
@FXML // fx:id="mapWidthField"
|
||||
protected TextField mapWidthField; // Value injected by FXMLLoader
|
||||
@FXML // fx:id="mapWrapAround"
|
||||
protected CheckBox mapWrapAround; // Value injected by FXMLLoader
|
||||
|
||||
@FXML
|
||||
abstract public void mapDraw1(ActionEvent event);
|
||||
|
||||
@FXML
|
||||
abstract public void mapDraw3(ActionEvent event);
|
||||
|
||||
@FXML
|
||||
abstract public void mapDraw5(ActionEvent event);
|
||||
|
||||
@FXML
|
||||
abstract public void mapDrawFilledRectMode(ActionEvent event);
|
||||
|
||||
@FXML
|
||||
abstract public void mapTogglePanZoom(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button zoomInButton]] onAction
|
||||
@FXML
|
||||
abstract public void mapZoomIn(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button zoomOutButton]] onAction
|
||||
@FXML
|
||||
abstract public void mapZoomOut(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button]] onAction
|
||||
@FXML
|
||||
abstract public void onMapClonePressed(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button]] onAction
|
||||
@FXML
|
||||
abstract public void onMapCreatePressed(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button]] onAction
|
||||
@FXML
|
||||
abstract public void onMapDeletePressed(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button]] onAction
|
||||
@FXML
|
||||
abstract public void onMapExportPressed(ActionEvent event);
|
||||
|
||||
@FXML
|
||||
abstract public void onMapPreviewPressed(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button]] onAction
|
||||
@FXML
|
||||
abstract public void onMapScriptAddPressed(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button]] onAction
|
||||
@FXML
|
||||
abstract public void onMapScriptClonePressed(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button]] onAction
|
||||
@FXML
|
||||
abstract public void onMapScriptDeletePressed(ActionEvent event);
|
||||
|
||||
// Handler for ComboBox[id="tileSelect"] onAction
|
||||
@FXML
|
||||
abstract public void onMapSelected(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button moveButton]] onAction
|
||||
@FXML
|
||||
abstract public void scrollMapDown(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button moveButton]] onAction
|
||||
@FXML
|
||||
abstract public void scrollMapLeft(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button moveButton]] onAction
|
||||
@FXML
|
||||
abstract public void scrollMapRight(ActionEvent event);
|
||||
|
||||
// Handler for Button[Button[id=null, styleClass=button moveButton]] onAction
|
||||
@FXML
|
||||
abstract public void scrollMapUp(ActionEvent event);
|
||||
|
||||
protected void initalize() {
|
||||
assert mapEditorAnchorPane != null : "fx:id=\"mapEditorAnchorPane\" was not injected: check your FXML file 'mapEditorTab.fxml'.";
|
||||
assert mapHeightField != null : "fx:id=\"mapHeightField\" was not injected: check your FXML file 'mapEditorTab.fxml'.";
|
||||
assert mapNameField != null : "fx:id=\"mapNameField\" was not injected: check your FXML file 'mapEditorTab.fxml'.";
|
||||
assert mapScriptsList != null : "fx:id=\"mapScriptsList\" was not injected: check your FXML file 'mapEditorTab.fxml'.";
|
||||
assert mapSelect != null : "fx:id=\"mapSelect\" was not injected: check your FXML file 'mapEditorTab.fxml'.";
|
||||
assert mapSelectTile != null : "fx:id=\"mapSelectTile\" was not injected: check your FXML file 'mapEditorTab.fxml'.";
|
||||
assert mapWidthField != null : "fx:id=\"mapWidthField\" was not injected: check your FXML file 'mapEditorTab.fxml'.";
|
||||
assert mapWrapAround != null : "fx:id=\"mapWrapAround\" was not injected: check your FXML file 'mapEditorTab.fxml'.";
|
||||
}
|
||||
|
||||
abstract void rebuildTileSelectors();
|
||||
}
|
@ -0,0 +1,327 @@
|
||||
package org.badvision.outlaweditor;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.control.cell.ComboBoxListCell;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.image.WritableImage;
|
||||
import javafx.util.Callback;
|
||||
import static org.badvision.outlaweditor.Application.currentPlatform;
|
||||
import static org.badvision.outlaweditor.Application.gameData;
|
||||
import static org.badvision.outlaweditor.UIAction.confirm;
|
||||
import static org.badvision.outlaweditor.UIAction.createAndEditScript;
|
||||
import static org.badvision.outlaweditor.data.PropertyHelper.bind;
|
||||
import static org.badvision.outlaweditor.data.PropertyHelper.stringProp;
|
||||
import org.badvision.outlaweditor.data.TileUtils;
|
||||
import org.badvision.outlaweditor.data.xml.Script;
|
||||
import org.badvision.outlaweditor.data.xml.Tile;
|
||||
import org.badvision.outlaweditor.data.xml.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author blurry
|
||||
*/
|
||||
public class MapEditorTabControllerImpl extends MapEditorTabController {
|
||||
|
||||
@Override
|
||||
public void mapDraw1(ActionEvent event) {
|
||||
if (getCurrentEditor() != null) {
|
||||
getCurrentEditor().setDrawMode(MapEditor.DrawMode.Pencil1px);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapDraw3(ActionEvent event) {
|
||||
if (getCurrentEditor() != null) {
|
||||
getCurrentEditor().setDrawMode(MapEditor.DrawMode.Pencil3px);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapDraw5(ActionEvent event) {
|
||||
if (getCurrentEditor() != null) {
|
||||
getCurrentEditor().setDrawMode(MapEditor.DrawMode.Pencil5px);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapDrawFilledRectMode(ActionEvent event) {
|
||||
if (getCurrentEditor() != null) {
|
||||
getCurrentEditor().setDrawMode(MapEditor.DrawMode.FilledRect);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapTogglePanZoom(ActionEvent event) {
|
||||
if (getCurrentEditor() != null) {
|
||||
getCurrentEditor().togglePanZoom();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapZoomIn(ActionEvent event) {
|
||||
if (getCurrentEditor() != null) {
|
||||
getCurrentEditor().zoomIn();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapZoomOut(ActionEvent event) {
|
||||
if (getCurrentEditor() != null) {
|
||||
getCurrentEditor().zoomOut();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapClonePressed(ActionEvent event) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapCreatePressed(ActionEvent event) {
|
||||
org.badvision.outlaweditor.data.xml.Map m = new org.badvision.outlaweditor.data.xml.Map();
|
||||
m.setName("Untitled");
|
||||
gameData.getMap().add(m);
|
||||
m.setWidth(512);
|
||||
m.setHeight(512);
|
||||
setCurrentMap(m);
|
||||
rebuildMapSelectors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapDeletePressed(ActionEvent event) {
|
||||
final Map currentMap = getCurrentMap();
|
||||
if (currentMap == null) {
|
||||
return;
|
||||
}
|
||||
confirm("Delete map '" + currentMap.getName() + "'. Are you sure?", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
org.badvision.outlaweditor.data.xml.Map del = currentMap;
|
||||
setCurrentMap(null);
|
||||
Application.gameData.getMap().remove(del);
|
||||
rebuildMapSelectors();
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapExportPressed(ActionEvent event) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapPreviewPressed(ActionEvent event) {
|
||||
if (getCurrentEditor() == null) {
|
||||
return;
|
||||
}
|
||||
getCurrentEditor().showPreview();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapScriptAddPressed(ActionEvent event) {
|
||||
createAndEditScript();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapScriptClonePressed(ActionEvent event) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapScriptDeletePressed(ActionEvent event) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapSelected(ActionEvent event) {
|
||||
setCurrentMap(mapSelect.getSelectionModel().getSelectedItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scrollMapDown(ActionEvent event) {
|
||||
if (getCurrentEditor() != null) {
|
||||
getCurrentEditor().scrollBy(0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scrollMapLeft(ActionEvent event) {
|
||||
if (getCurrentEditor() != null) {
|
||||
getCurrentEditor().scrollBy(-1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scrollMapRight(ActionEvent event) {
|
||||
if (getCurrentEditor() != null) {
|
||||
getCurrentEditor().scrollBy(1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scrollMapUp(ActionEvent event) {
|
||||
if (getCurrentEditor() != null) {
|
||||
getCurrentEditor().scrollBy(0, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getCurrentMap() {
|
||||
if (getCurrentEditor() == null) {
|
||||
return null;
|
||||
} else {
|
||||
return getCurrentEditor().currentMap.getBackingMap();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentMap(Map m) {
|
||||
if (getCurrentMap() != null && getCurrentMap().equals(m)) {
|
||||
return;
|
||||
}
|
||||
// mapEditorAnchorPane.getChildren().clear();
|
||||
if (getCurrentEditor() != null) {
|
||||
getCurrentEditor().unregister();
|
||||
}
|
||||
if (m == null) {
|
||||
bind(mapHeightField.textProperty(), null);
|
||||
bind(mapNameField.textProperty(), null);
|
||||
bind(mapWidthField.textProperty(), null);
|
||||
bind(mapWrapAround.selectedProperty(), null);
|
||||
mapHeightField.setDisable(true);
|
||||
mapNameField.setDisable(true);
|
||||
mapWidthField.setDisable(true);
|
||||
mapWrapAround.setDisable(true);
|
||||
setCurrentEditor(null);
|
||||
} else {
|
||||
if (m.getHeight() == null) {
|
||||
m.setHeight(512);
|
||||
}
|
||||
if (m.getWidth() == null) {
|
||||
m.setWidth(512);
|
||||
}
|
||||
if (m.getName() == null) {
|
||||
m.setName("Untitled");
|
||||
}
|
||||
try {
|
||||
mapHeightField.setDisable(false);
|
||||
mapNameField.setDisable(false);
|
||||
mapWidthField.setDisable(false);
|
||||
mapWrapAround.setDisable(false);
|
||||
// bind(mapHeightField.textProperty(), intProp(m, "height"));
|
||||
bind(mapNameField.textProperty(), stringProp(m, "name"));
|
||||
// bind(mapWidthField.textProperty(), intProp(m, "width"));
|
||||
// bind(mapWrapAround.selectedProperty(),boolProp(m, "wrap"));
|
||||
} catch (NoSuchMethodException ex) {
|
||||
Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
MapEditor e = new MapEditor();
|
||||
e.setEntity(m);
|
||||
e.buildEditorUI(mapEditorAnchorPane);
|
||||
setCurrentEditor(e);
|
||||
}
|
||||
redrawMapScripts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rebuildMapSelectors() {
|
||||
mapSelect.getItems().clear();
|
||||
mapSelect.getItems().addAll(Application.gameData.getMap());
|
||||
mapSelect.getSelectionModel().select(getCurrentMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initalize() {
|
||||
super.initalize();
|
||||
mapSelect.setButtonCell(new ComboBoxListCell<org.badvision.outlaweditor.data.xml.Map>() {
|
||||
{
|
||||
super.setPrefWidth(125);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateItem(org.badvision.outlaweditor.data.xml.Map item, boolean empty) {
|
||||
textProperty().unbind();
|
||||
super.updateItem(item, empty);
|
||||
if (item != null) {
|
||||
textProperty().bind(mapNameField.textProperty());
|
||||
} else {
|
||||
setText(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
mapSelect.setCellFactory(new Callback<ListView<org.badvision.outlaweditor.data.xml.Map>, ListCell<org.badvision.outlaweditor.data.xml.Map>>() {
|
||||
@Override
|
||||
public ListCell<org.badvision.outlaweditor.data.xml.Map> call(ListView<org.badvision.outlaweditor.data.xml.Map> param) {
|
||||
return new ApplicationUIControllerImpl.EntitySelectorCell<org.badvision.outlaweditor.data.xml.Map>(mapNameField) {
|
||||
@Override
|
||||
public void finishUpdate(org.badvision.outlaweditor.data.xml.Map item) {
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
void rebuildTileSelectors() {
|
||||
mapSelectTile.getItems().clear();
|
||||
for (final Tile t : Application.gameData.getTile()) {
|
||||
WritableImage img = TileUtils.getImage(t, currentPlatform);
|
||||
ImageView iv = new ImageView(img);
|
||||
MenuItem mapSelectItem = new MenuItem(t.getName(), iv);
|
||||
mapSelectItem.setGraphic(new ImageView(TileUtils.getImage(t, currentPlatform)));
|
||||
mapSelectItem.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
if (getCurrentEditor() != null) {
|
||||
getCurrentEditor().setCurrentTile(t);
|
||||
}
|
||||
}
|
||||
});
|
||||
mapSelectTile.getItems().add(mapSelectItem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redrawMapScripts() {
|
||||
mapScriptsList.setOnEditStart(new EventHandler<ListView.EditEvent<Script>>() {
|
||||
@Override
|
||||
public void handle(ListView.EditEvent<Script> event) {
|
||||
UIAction.editScript(event.getSource().getItems().get(event.getIndex()));
|
||||
}
|
||||
});
|
||||
final TransferHelper<Script> scriptDragDrop = new TransferHelper<>(Script.class);
|
||||
mapScriptsList.setCellFactory(new Callback<ListView<Script>, ListCell<Script>>() {
|
||||
@Override
|
||||
public ListCell<Script> call(ListView<Script> param) {
|
||||
final ListCell<Script> cell = new ListCell<Script>() {
|
||||
@Override
|
||||
protected void updateItem(Script item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (empty || item == null) {
|
||||
setText("");
|
||||
} else {
|
||||
setText(item.getName());
|
||||
scriptDragDrop.registerDragSupport(this, item);
|
||||
}
|
||||
}
|
||||
};
|
||||
return cell;
|
||||
}
|
||||
});
|
||||
if (getCurrentMap() == null) {
|
||||
mapScriptsList.getItems().clear();
|
||||
} else {
|
||||
if (mapScriptsList.getItems() != null && getCurrentMap().getScripts() != null) {
|
||||
mapScriptsList.getItems().setAll(getCurrentMap().getScripts().getScript());
|
||||
} else {
|
||||
mapScriptsList.getItems().clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -135,6 +135,6 @@ public class MythosEditor {
|
||||
}
|
||||
script.setName(name);
|
||||
System.out.println("Function title changed! >> "+name);
|
||||
Application.instance.controller.redrawMapScripts();
|
||||
Application.instance.controller.mapController.redrawMapScripts();
|
||||
}
|
||||
}
|
||||
|
@ -81,12 +81,12 @@ public class UIAction {
|
||||
}
|
||||
currentSaveFile = f;
|
||||
GameData newData = JAXB.unmarshal(currentSaveFile, GameData.class);
|
||||
Application.instance.controller.setCurrentMap(null);
|
||||
Application.instance.controller.tileEditorController.setCurrentTile(null);
|
||||
Application.instance.controller.mapController.setCurrentMap(null);
|
||||
Application.instance.controller.tileController.setCurrentTile(null);
|
||||
TilesetUtils.clear();
|
||||
Application.gameData = newData;
|
||||
Application.instance.controller.rebuildTileSelectors();
|
||||
Application.instance.controller.rebuildMapSelectors();
|
||||
Application.instance.controller.mapController.rebuildMapSelectors();
|
||||
break;
|
||||
case Quit:
|
||||
quit();
|
||||
@ -201,10 +201,10 @@ public class UIAction {
|
||||
public static Script createAndEditScript() {
|
||||
Script script = new Script();
|
||||
script.setName("New Script");
|
||||
if (Application.instance.controller.currentMap.getScripts() == null) {
|
||||
Application.instance.controller.currentMap.setScripts(new Map.Scripts());
|
||||
if (Application.instance.controller.mapController.getCurrentMap().getScripts() == null) {
|
||||
Application.instance.controller.mapController.getCurrentMap().setScripts(new Map.Scripts());
|
||||
}
|
||||
Application.instance.controller.currentMap.getScripts().getScript().add(script);
|
||||
Application.instance.controller.mapController.getCurrentMap().getScripts().getScript().add(script);
|
||||
return editScript(script);
|
||||
}
|
||||
|
||||
|
@ -10,100 +10,17 @@
|
||||
<children>
|
||||
<VBox prefHeight="500.0" prefWidth="800.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<fx:include source="Menubar.fxml"/>
|
||||
<fx:include fx:id="menu" source="Menubar.fxml"/>
|
||||
<TabPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="455.0" prefWidth="676.9998779296875" tabClosingPolicy="UNAVAILABLE" VBox.vgrow="ALWAYS">
|
||||
<tabs>
|
||||
<Tab onSelectionChanged="#tileTabActivated" text="Tiles">
|
||||
<content>
|
||||
<fx:include fx:id="tileEditor" source="tileEditorTab.fxml"/>
|
||||
<fx:include fx:id="tile" source="tileEditorTab.fxml"/>
|
||||
</content>
|
||||
</Tab>
|
||||
<Tab onSelectionChanged="#mapTabActivated" text="Maps">
|
||||
<content>
|
||||
<AnchorPane id="mapsTab" minHeight="0.0" minWidth="0.0">
|
||||
<children>
|
||||
<VBox prefHeight="200.0" prefWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<ToolBar prefWidth="677.0">
|
||||
<items>
|
||||
<Label text="Map:" />
|
||||
<ComboBox fx:id="mapSelect" minWidth="125.0" onAction="#onMapSelected">
|
||||
<items>
|
||||
<FXCollections fx:factory="observableArrayList">
|
||||
<String fx:value="Item 1" />
|
||||
<String fx:value="Item 2" />
|
||||
<String fx:value="Item 3" />
|
||||
</FXCollections>
|
||||
</items>
|
||||
</ComboBox>
|
||||
<Button mnemonicParsing="false" onAction="#onMapCreatePressed" text="Create new" />
|
||||
<Button mnemonicParsing="false" onAction="#onMapClonePressed" text="Clone" />
|
||||
<Button mnemonicParsing="false" onAction="#onMapExportPressed" text="Export" />
|
||||
<Button mnemonicParsing="false" onAction="#onMapDeletePressed" text="Delete" />
|
||||
<Button mnemonicParsing="false" onAction="#onMapPreviewPressed" text="Preview" />
|
||||
<MenuButton mnemonicParsing="false" text="Tools">
|
||||
<items>
|
||||
<Menu fx:id="mapSelectTile" mnemonicParsing="false" text="Change tile" />
|
||||
<Menu mnemonicParsing="false" text="Draw mode">
|
||||
<items>
|
||||
<MenuItem mnemonicParsing="false" onAction="#mapDraw1" text="Radius 1" />
|
||||
<MenuItem mnemonicParsing="false" onAction="#mapDraw3" text="Radius 3" />
|
||||
<MenuItem mnemonicParsing="false" onAction="#mapDraw5" text="Radius 5" />
|
||||
<MenuItem mnemonicParsing="false" onAction="#mapDrawFilledRectMode" text="Filled Rectangle" />
|
||||
</items>
|
||||
</Menu>
|
||||
<MenuItem mnemonicParsing="false" onAction="#mapTogglePanZoom" text="Toggle pan/zoom controls" />
|
||||
</items>
|
||||
</MenuButton>
|
||||
</items>
|
||||
</ToolBar>
|
||||
<HBox prefHeight="389.0" prefWidth="677.0" VBox.vgrow="ALWAYS">
|
||||
<children>
|
||||
<AnchorPane prefHeight="200.0" prefWidth="200.0" HBox.hgrow="NEVER">
|
||||
<children>
|
||||
<Label text="Name" AnchorPane.leftAnchor="4.0" AnchorPane.topAnchor="14.0" />
|
||||
<TextField id="mapNameFiled" fx:id="mapNameField" layoutX="53.0" layoutY="11.0" prefWidth="147.0" />
|
||||
<TextField fx:id="mapWidthField" layoutX="53.0" layoutY="33.0" prefWidth="147.0" />
|
||||
<Label layoutX="4.0" layoutY="36.0" text="Width" />
|
||||
<TextField fx:id="mapHeightField" layoutX="53.0" layoutY="55.0" prefWidth="147.0" />
|
||||
<Label layoutX="4.0" layoutY="58.0" text="Height" />
|
||||
<CheckBox fx:id="mapWrapAround" contentDisplay="RIGHT" layoutX="4.0" layoutY="77.0" mnemonicParsing="false" text="Wrap at edges" />
|
||||
<Separator layoutX="4.0" layoutY="101.0" prefWidth="189.0" />
|
||||
<Label layoutX="4.0" layoutY="108.0" text="Scripts" />
|
||||
<ScrollPane fitToHeight="true" fitToWidth="true" prefHeight="232.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="157.0">
|
||||
<content>
|
||||
<AnchorPane id="Content" minHeight="0.0" minWidth="0.0" prefHeight="200.0" prefWidth="200.0">
|
||||
<children>
|
||||
<ListView fx:id="mapScriptsList" editable="true" prefHeight="217.0" prefWidth="199.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</content>
|
||||
</ScrollPane>
|
||||
<ToolBar layoutY="124.0" prefWidth="200.0">
|
||||
<items>
|
||||
<Button mnemonicParsing="false" onAction="#onMapScriptAddPressed" text="+" />
|
||||
<Button mnemonicParsing="false" onAction="#onMapScriptDeletePressed" text="-" />
|
||||
<Button mnemonicParsing="false" onAction="#onMapScriptClonePressed" text="Clone" />
|
||||
</items>
|
||||
</ToolBar>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<AnchorPane fx:id="mapEditorAnchorPane" prefHeight="389.0" prefWidth="477.0000999999975" HBox.hgrow="SOMETIMES">
|
||||
<children>
|
||||
<Button alignment="TOP_CENTER" layoutX="265.0" mnemonicParsing="false" onAction="#scrollMapUp" styleClass="moveButton" text="Up" AnchorPane.topAnchor="5.0" />
|
||||
<Button layoutY="185.0" mnemonicParsing="false" onAction="#scrollMapLeft" rotate="270.0" styleClass="moveButton" text="Left" AnchorPane.leftAnchor="-20.0" />
|
||||
<Button layoutX="265.0" mnemonicParsing="false" onAction="#scrollMapDown" rotate="180.0" styleClass="moveButton" text="Down" AnchorPane.bottomAnchor="5.0" />
|
||||
<Button layoutY="175.0" mnemonicParsing="false" onAction="#scrollMapRight" rotate="90.0" styleClass="moveButton" text="Right" AnchorPane.rightAnchor="-15.0" />
|
||||
<Button mnemonicParsing="false" onAction="#mapZoomIn" styleClass="zoomInButton" text="+" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="5.0" />
|
||||
<Button mnemonicParsing="false" onAction="#mapZoomOut" prefHeight="23.999908447265625" styleClass="zoomOutButton" text="-" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="30.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
</VBox>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<fx:include fx:id="map" source="mapEditorTab.fxml"/>
|
||||
</content>
|
||||
</Tab>
|
||||
<Tab onSelectionChanged="#imageTabActivated" text="Images">
|
||||
|
84
OutlawEditor/src/main/resources/mapEditorTab.fxml
Normal file
84
OutlawEditor/src/main/resources/mapEditorTab.fxml
Normal file
@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import java.util.*?>
|
||||
<?import javafx.scene.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
<AnchorPane id="mapsTab" minHeight="0.0" minWidth="0.0" prefHeight="420.0000999999975" prefWidth="677.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.badvision.outlaweditor.MapEditorTabControllerImpl">
|
||||
<children>
|
||||
<VBox prefHeight="200.0" prefWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<ToolBar prefWidth="677.0">
|
||||
<items>
|
||||
<Label text="Map:" />
|
||||
<ComboBox fx:id="mapSelect" minWidth="125.0" onAction="#onMapSelected"/>
|
||||
<Button mnemonicParsing="false" onAction="#onMapCreatePressed" text="Create new" />
|
||||
<Button mnemonicParsing="false" onAction="#onMapClonePressed" text="Clone" />
|
||||
<Button mnemonicParsing="false" onAction="#onMapExportPressed" text="Export" />
|
||||
<Button mnemonicParsing="false" onAction="#onMapDeletePressed" text="Delete" />
|
||||
<Button mnemonicParsing="false" onAction="#onMapPreviewPressed" text="Preview" />
|
||||
<MenuButton mnemonicParsing="false" text="Tools">
|
||||
<items>
|
||||
<Menu fx:id="mapSelectTile" mnemonicParsing="false" text="Change tile" />
|
||||
<Menu mnemonicParsing="false" text="Draw mode">
|
||||
<items>
|
||||
<MenuItem mnemonicParsing="false" onAction="#mapDraw1" text="Radius 1" />
|
||||
<MenuItem mnemonicParsing="false" onAction="#mapDraw3" text="Radius 3" />
|
||||
<MenuItem mnemonicParsing="false" onAction="#mapDraw5" text="Radius 5" />
|
||||
<MenuItem mnemonicParsing="false" onAction="#mapDrawFilledRectMode" text="Filled Rectangle" />
|
||||
</items>
|
||||
</Menu>
|
||||
<MenuItem mnemonicParsing="false" onAction="#mapTogglePanZoom" text="Toggle pan/zoom controls" />
|
||||
</items>
|
||||
</MenuButton>
|
||||
</items>
|
||||
</ToolBar>
|
||||
<HBox prefHeight="389.0" prefWidth="677.0" VBox.vgrow="ALWAYS">
|
||||
<children>
|
||||
<AnchorPane prefHeight="200.0" prefWidth="200.0" HBox.hgrow="NEVER">
|
||||
<children>
|
||||
<Label text="Name" AnchorPane.leftAnchor="4.0" AnchorPane.topAnchor="14.0" />
|
||||
<TextField id="mapNameFiled" fx:id="mapNameField" layoutX="53.0" layoutY="11.0" prefWidth="147.0" />
|
||||
<TextField fx:id="mapWidthField" layoutX="53.0" layoutY="33.0" prefWidth="147.0" />
|
||||
<Label layoutX="4.0" layoutY="36.0" text="Width" />
|
||||
<TextField fx:id="mapHeightField" layoutX="53.0" layoutY="55.0" prefWidth="147.0" />
|
||||
<Label layoutX="4.0" layoutY="58.0" text="Height" />
|
||||
<CheckBox fx:id="mapWrapAround" contentDisplay="RIGHT" layoutX="4.0" layoutY="77.0" mnemonicParsing="false" text="Wrap at edges" />
|
||||
<Separator layoutX="4.0" layoutY="101.0" prefWidth="189.0" />
|
||||
<Label layoutX="4.0" layoutY="108.0" text="Scripts" />
|
||||
<ScrollPane fitToHeight="true" fitToWidth="true" prefHeight="232.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="157.0">
|
||||
<content>
|
||||
<AnchorPane id="Content" minHeight="0.0" minWidth="0.0" prefHeight="200.0" prefWidth="200.0">
|
||||
<children>
|
||||
<ListView fx:id="mapScriptsList" editable="true" prefHeight="217.0" prefWidth="199.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</content>
|
||||
</ScrollPane>
|
||||
<ToolBar layoutY="124.0" prefWidth="200.0">
|
||||
<items>
|
||||
<Button mnemonicParsing="false" onAction="#onMapScriptAddPressed" text="+" />
|
||||
<Button mnemonicParsing="false" onAction="#onMapScriptDeletePressed" text="-" />
|
||||
<Button mnemonicParsing="false" onAction="#onMapScriptClonePressed" text="Clone" />
|
||||
</items>
|
||||
</ToolBar>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<AnchorPane fx:id="mapEditorAnchorPane" prefHeight="389.0" prefWidth="477.0000999999975" HBox.hgrow="SOMETIMES">
|
||||
<children>
|
||||
<Button alignment="TOP_CENTER" layoutX="265.0" mnemonicParsing="false" onAction="#scrollMapUp" styleClass="moveButton" text="Up" AnchorPane.topAnchor="5.0" />
|
||||
<Button layoutY="185.0" mnemonicParsing="false" onAction="#scrollMapLeft" rotate="270.0" styleClass="moveButton" text="Left" AnchorPane.leftAnchor="-20.0" />
|
||||
<Button layoutX="265.0" mnemonicParsing="false" onAction="#scrollMapDown" rotate="180.0" styleClass="moveButton" text="Down" AnchorPane.bottomAnchor="5.0" />
|
||||
<Button layoutY="175.0" mnemonicParsing="false" onAction="#scrollMapRight" rotate="90.0" styleClass="moveButton" text="Right" AnchorPane.rightAnchor="-15.0" />
|
||||
<Button mnemonicParsing="false" onAction="#mapZoomIn" styleClass="zoomInButton" text="+" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="5.0" />
|
||||
<Button mnemonicParsing="false" onAction="#mapZoomOut" prefHeight="23.999908447265625" styleClass="zoomOutButton" text="-" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="30.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
</VBox>
|
||||
</children>
|
||||
</AnchorPane>
|
Loading…
x
Reference in New Issue
Block a user