Broke tile editor off to its own UI fxml and controller class

This commit is contained in:
Brendan Robert 2014-05-10 02:37:42 -05:00
parent 101ca8c87c
commit a4ba117d60
7 changed files with 336 additions and 322 deletions

View File

@ -5,8 +5,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.event.ActionEvent;
import org.badvision.outlaweditor.apple.AppleTileRenderer;
import org.badvision.outlaweditor.data.TileUtils;
import org.badvision.outlaweditor.data.xml.Tile;
/**
*
@ -18,42 +16,28 @@ public class ApplicationMenuControllerImpl extends ApplicationMenuController {
public void onChangePlatformAppleSolid(ActionEvent event) {
AppleTileRenderer.useSolidPalette = true;
Application.currentPlatform = Platform.AppleII;
platformChange();
ApplicationUIController.getController().platformChange();
}
@Override
public void onChangePlatformAppleText(ActionEvent event) {
AppleTileRenderer.useSolidPalette = false;
Application.currentPlatform = Platform.AppleII;
platformChange();
ApplicationUIController.getController().platformChange();
}
@Override
public void onChangePlatformAppleDHGRSolid(ActionEvent event) {
AppleTileRenderer.useSolidPalette = true;
Application.currentPlatform = Platform.AppleII_DHGR;
platformChange();
ApplicationUIController.getController().platformChange();
}
@Override
public void onChangePlatformAppleDHGRText(ActionEvent event) {
AppleTileRenderer.useSolidPalette = false;
Application.currentPlatform = Platform.AppleII_DHGR;
platformChange();
}
private void platformChange() {
for (Tile t : Application.gameData.getTile()) {
TileUtils.redrawTile(t);
}
ApplicationUIController mainController = ApplicationUIController.getController();
Tile tile = mainController.getCurrentTile();
mainController.rebuildTileSelectors();
mainController.setCurrentTile(tile);
if (mainController.getCurrentMapEditor() != null) {
mainController.getCurrentMapEditor().redraw();
}
mainController.rebuildImageSelector();
ApplicationUIController.getController().platformChange();
}
@Override
@ -106,9 +90,7 @@ public class ApplicationMenuControllerImpl extends ApplicationMenuController {
@Override
public void onFileSave(ActionEvent event) {
ApplicationUIController mainController = ApplicationUIController.getController();
if (mainController.getCurrentMapEditor() != null) {
mainController.getCurrentMapEditor().currentMap.updateBackingMap();
}
mainController.completeInflightOperations();
try {
UIAction.actionPerformed(UIAction.MAIN_ACTIONS.Save);
} catch (IOException ex) {

View File

@ -10,7 +10,6 @@ import javafx.scene.control.ComboBox;
import javafx.scene.control.ListView;
import javafx.scene.control.Menu;
import javafx.scene.control.TextField;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import org.badvision.outlaweditor.data.xml.Image;
import org.badvision.outlaweditor.data.xml.Map;
@ -22,15 +21,8 @@ public abstract class ApplicationUIController {
return Application.instance.controller;
}
abstract public MapEditor getCurrentMapEditor();
abstract public void setCurrentTile(Tile tile);
abstract public Tile getCurrentTile();
abstract void rebuildMapSelectors();
abstract void rebuildTileSelectors();
abstract void rebuildImageSelector();
abstract Editor getVisibleEditor();
@ -38,6 +30,8 @@ public abstract class ApplicationUIController {
@FXML // ResourceBundle that was given to the FXMLLoader
protected ResourceBundle resources;
@FXML ApplicationMenuController menuController;
@FXML TileEditorTabController tileEditorController;
@FXML // URL location of the FXML file that was given to the FXMLLoader
protected URL location;
@FXML // fx:id="imageCategoryField"
@ -70,20 +64,6 @@ public abstract class ApplicationUIController {
protected TextField mapWidthField; // Value injected by FXMLLoader
@FXML // fx:id="mapWrapAround"
protected CheckBox mapWrapAround; // Value injected by FXMLLoader
@FXML // fx:id="tileCategoryField"
protected TextField tileCategoryField; // Value injected by FXMLLoader
@FXML // fx:id="tileEditorAnchorPane"
protected AnchorPane tileEditorAnchorPane; // Value injected by FXMLLoader
@FXML // fx:id="tileIdField"
protected TextField tileIdField; // Value injected by FXMLLoader
@FXML // fx:id="tileNameField"
protected TextField tileNameField; // Value injected by FXMLLoader
@FXML // fx:id="tileObstructionField"
protected CheckBox tileObstructionField; // Value injected by FXMLLoader
@FXML // fx:id="tilePatternMenu"
protected Menu tilePatternMenu; // Value injected by FXMLLoader
@FXML // fx:id="tileSelector"
protected ComboBox<Tile> tileSelector; // Value injected by FXMLLoader
// Handler for MenuItem[javafx.scene.control.MenuItem@3a4bc91a] onAction
@FXML
@ -146,10 +126,6 @@ public abstract class ApplicationUIController {
@FXML
abstract public void mapZoomOut(ActionEvent event);
// Handler for ComboBox[fx:id="tileSelector"] onAction
@FXML
abstract public void onCurrentTileSelected(ActionEvent event);
// Handler for Button[Button[id=null, styleClass=button]] onAction
@FXML
abstract public void onImageClonePressed(ActionEvent event);
@ -205,21 +181,7 @@ public abstract class ApplicationUIController {
@FXML
abstract public void onMapSelected(ActionEvent event);
// Handler for Button[Button[id=null, styleClass=button]] onAction
@FXML
abstract public void onTileClonePressed(ActionEvent event);
// Handler for Button[Button[id=null, styleClass=button]] onAction
@FXML
abstract public void onTileCreatePressed(ActionEvent event);
// Handler for Button[Button[id=null, styleClass=button]] onAction
@FXML
abstract public void onTileDeletePressed(ActionEvent event);
// Handler for Button[Button[id=null, styleClass=button]] onAction
@FXML
abstract public void onTileExportPressed(ActionEvent event);
abstract public void platformChange();
// Handler for Button[Button[id=null, styleClass=button moveButton]] onAction
@FXML
@ -253,28 +215,12 @@ public abstract class ApplicationUIController {
@FXML
abstract public void scrollMapUp(ActionEvent event);
// Handler for MenuItem[javafx.scene.control.MenuItem@3b007e44] onAction
@FXML
abstract public void tileBitMode(ActionEvent event);
// Handler for MenuItem[javafx.scene.control.MenuItem@4771c0b8] onAction
@FXML
abstract public void tileDraw1BitMode(ActionEvent event);
// Handler for MenuItem[javafx.scene.control.MenuItem@766bd19d] onAction
@FXML
abstract public void tileDraw3BitMode(ActionEvent event);
@FXML
abstract public void imageDraw5BitMode(ActionEvent event);
@FXML
abstract public void tileTabActivated(Event event);
// Handler for MenuItem[javafx.scene.control.MenuItem@622410f1] onAction
@FXML
abstract public void tileShift(ActionEvent 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'.";
@ -292,15 +238,10 @@ public abstract class ApplicationUIController {
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'.";
assert tileCategoryField != null : "fx:id=\"tileCategoryField\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
assert tileEditorAnchorPane != null : "fx:id=\"tileEditorAnchorPane\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
assert tileIdField != null : "fx:id=\"tileIdField\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
assert tileNameField != null : "fx:id=\"tileNameField\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
assert tileObstructionField != null : "fx:id=\"tileObstructionField\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
assert tilePatternMenu != null : "fx:id=\"tilePatternMenu\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
assert tileSelector != null : "fx:id=\"tileSelector\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
// Initialize your logic here: all @FXML variables will have been injected
}
abstract void completeInflightOperations();
}

View File

@ -1,6 +1,5 @@
package org.badvision.outlaweditor;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
@ -24,7 +23,6 @@ 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.PlatformData;
import org.badvision.outlaweditor.data.xml.Script;
import org.badvision.outlaweditor.data.xml.Tile;
@ -35,8 +33,6 @@ import org.badvision.outlaweditor.data.xml.Tile;
*/
public class ApplicationUIControllerImpl extends ApplicationUIController {
public Tile currentTile = null;
public TileEditor currentTileEditor = null;
public org.badvision.outlaweditor.data.xml.Map currentMap = null;
public MapEditor currentMapEditor = null;
public Image currentImage = null;
@ -52,33 +48,6 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
rebuildTileSelectors();
}
});
tileSelector.setButtonCell(new ComboBoxListCell<Tile>() {
{
super.setPrefWidth(125);
}
@Override
public void updateItem(Tile item, boolean empty) {
textProperty().unbind();
super.updateItem(item, empty);
if (item != null) {
textProperty().bind(tileNameField.textProperty());
} else {
setText(null);
}
}
});
tileSelector.setCellFactory(new Callback<ListView<Tile>, ListCell<Tile>>() {
@Override
public ListCell<Tile> call(ListView<Tile> param) {
return new EntitySelectorCell<Tile>(tileNameField) {
@Override
public void finishUpdate(Tile item) {
setGraphic(new ImageView(TileUtils.getImage(item, Application.currentPlatform)));
}
};
}
});
mapSelect.setButtonCell(new ComboBoxListCell<org.badvision.outlaweditor.data.xml.Map>() {
{
@ -247,11 +216,6 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
}
}
@Override
public void onCurrentTileSelected(ActionEvent event) {
setCurrentTile(tileSelector.getSelectionModel().getSelectedItem());
}
@Override
public void onImageClonePressed(ActionEvent event) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
@ -360,58 +324,17 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
}
@Override
public void onTileClonePressed(ActionEvent event) {
if (currentTile == null) {
return;
public void platformChange() {
for (Tile t : Application.gameData.getTile()) {
TileUtils.redrawTile(t);
}
Tile t = new Tile();
TileUtils.getId(t);
t.setName(currentTile.getName() + " (clone)");
t.setObstruction(currentTile.isObstruction());
t.getCategory().addAll(currentTile.getCategory());
for (PlatformData d : currentTile.getDisplayData()) {
PlatformData p = new PlatformData();
p.setHeight(d.getHeight());
p.setWidth(d.getWidth());
p.setPlatform(d.getPlatform());
p.setValue(Arrays.copyOf(d.getValue(), d.getValue().length));
t.getDisplayData().add(p);
}
TilesetUtils.add(t);
Tile tile = tileEditorController.getCurrentTile();
rebuildTileSelectors();
setCurrentTile(t);
tileEditorController.setCurrentTile(tile);
if (currentMapEditor != null) {
currentMapEditor.redraw();
}
@Override
public void onTileCreatePressed(ActionEvent event) {
Tile t = TileUtils.newTile();
t.setName("Untitled");
TilesetUtils.add(t);
rebuildTileSelectors();
setCurrentTile(t);
}
@Override
public void onTileDeletePressed(ActionEvent event) {
if (currentTile == null) {
return;
}
confirm("Delete tile '" + currentTile.getName() + "'. Are you sure?", new Runnable() {
@Override
public void run() {
Tile del = currentTile;
setCurrentTile(null);
Application.gameData.getTile().remove(del);
rebuildTileSelectors();
}
}, null);
}
@Override
public void onTileExportPressed(ActionEvent event) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
rebuildImageSelector();
}
@Override
@ -470,96 +393,9 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
}
}
@Override
public void tileBitMode(ActionEvent event) {
if (currentTileEditor != null) {
currentTileEditor.setDrawMode(TileEditor.DrawMode.Toggle);
}
}
@Override
public void tileDraw1BitMode(ActionEvent event) {
if (currentTileEditor != null) {
currentTileEditor.setDrawMode(TileEditor.DrawMode.Pencil1px);
}
}
@Override
public void tileDraw3BitMode(ActionEvent event) {
if (currentTileEditor != null) {
currentTileEditor.setDrawMode(TileEditor.DrawMode.Pencil3px);
}
}
@Override
public void tileShift(ActionEvent event) {
if (currentTileEditor != null) {
currentTileEditor.showShiftUI();
}
}
private void setCurrentTileEditor(TileEditor editor) {
if (editor != null) {
editor.buildEditorUI(tileEditorAnchorPane);
editor.buildPatternSelector(tilePatternMenu);
}
currentTileEditor = editor;
}
@Override
public Tile getCurrentTile() {
return currentTile;
}
@Override
public void setCurrentTile(Tile t) {
tileSelector.getSelectionModel().select(t);
if (t != null && t.equals(currentTile)) {
return;
}
tileEditorAnchorPane.getChildren().clear();
if (t == null) {
bind(tileIdField.textProperty(), null);
bind(tileCategoryField.textProperty(), null);
bind(tileObstructionField.selectedProperty(), null);
bind(tileNameField.textProperty(), null);
tileIdField.setDisable(true);
tileCategoryField.setDisable(true);
tileObstructionField.setDisable(true);
tileNameField.setDisable(true);
setCurrentTileEditor(null);
} else {
if (t.isObstruction() == null) {
t.setObstruction(false);
}
try {
tileIdField.setDisable(false);
tileCategoryField.setDisable(false);
tileObstructionField.setDisable(false);
tileNameField.setDisable(false);
bind(tileIdField.textProperty(), stringProp(t, "id"));
bind(tileCategoryField.textProperty(), categoryProp(t, "category"));
bind(tileObstructionField.selectedProperty(), boolProp(t, "obstruction"));
bind(tileNameField.textProperty(), stringProp(t, "name"));
TileEditor editor = Application.currentPlatform.tileEditor.newInstance();
editor.setEntity(t);
setCurrentTileEditor(editor);
} catch (NoSuchMethodException ex) {
Logger.getLogger(ApplicationUIController.class.getName()).log(Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
}
}
currentTile = t;
}
@Override
public void rebuildTileSelectors() {
tileSelector.getItems().clear();
tileSelector.getItems().addAll(Application.gameData.getTile());
tileSelector.getSelectionModel().select(getCurrentTile());
tileEditorController.rebuildTileSelectors();
mapSelectTile.getItems().clear();
for (final Tile t : Application.gameData.getTile()) {
WritableImage img = TileUtils.getImage(t, currentPlatform);
@ -694,8 +530,10 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
}
@Override
public MapEditor getCurrentMapEditor() {
return currentMapEditor;
public void completeInflightOperations() {
if (currentMapEditor != null) {
currentMapEditor.currentMap.updateBackingMap();
}
}
public static enum TABS {
@ -727,7 +565,7 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
case map:
return currentMapEditor;
case tile:
return currentTileEditor;
return tileEditorController.getCurrentTileEditor();
}
return null;
}

View File

@ -0,0 +1,83 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
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.Menu;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import org.badvision.outlaweditor.data.xml.Tile;
/**
*
* @author blurry
*/
public abstract class TileEditorTabController {
private Tile currentTile;
public Tile getCurrentTile() {
return currentTile;
}
public void setCurrentTile(Tile tile) {
currentTile = tile;
}
private TileEditor currentEditor;
public TileEditor getCurrentTileEditor() {
return currentEditor;
}
public void setCurrentTileEditor(TileEditor editor) {
currentEditor = editor;
}
@FXML // fx:id="tileCategoryField"
protected TextField tileCategoryField; // Value injected by FXMLLoader
@FXML // fx:id="tileEditorAnchorPane"
protected AnchorPane tileEditorAnchorPane; // Value injected by FXMLLoader
@FXML // fx:id="tileIdField"
protected TextField tileIdField; // Value injected by FXMLLoader
@FXML // fx:id="tileNameField"
protected TextField tileNameField; // Value injected by FXMLLoader
@FXML // fx:id="tileObstructionField"
protected CheckBox tileObstructionField; // Value injected by FXMLLoader
@FXML // fx:id="tilePatternMenu"
protected Menu tilePatternMenu; // Value injected by FXMLLoader
@FXML // fx:id="tileSelector"
protected ComboBox<Tile> tileSelector; // Value injected by FXMLLoader
@FXML
abstract public void onCurrentTileSelected(ActionEvent event);
@FXML
abstract public void onTileCreatePressed(ActionEvent event);
@FXML
abstract public void onTileExportPressed(ActionEvent event);
@FXML
abstract public void onTileClonePressed(ActionEvent event);
@FXML
abstract public void onTileDeletePressed(ActionEvent event);
@FXML
abstract public void tileBitMode(ActionEvent event);
@FXML
abstract public void tileDraw1BitMode(ActionEvent event);
@FXML
abstract public void tileDraw3BitMode(ActionEvent event);
@FXML
abstract public void tileShift(ActionEvent event);
abstract public void rebuildTileSelectors();
}

View File

@ -0,0 +1,224 @@
package org.badvision.outlaweditor;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.event.ActionEvent;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.control.cell.ComboBoxListCell;
import javafx.scene.image.ImageView;
import javafx.util.Callback;
import static org.badvision.outlaweditor.UIAction.confirm;
import static org.badvision.outlaweditor.data.PropertyHelper.bind;
import static org.badvision.outlaweditor.data.PropertyHelper.boolProp;
import static org.badvision.outlaweditor.data.PropertyHelper.categoryProp;
import static org.badvision.outlaweditor.data.PropertyHelper.stringProp;
import org.badvision.outlaweditor.data.TileUtils;
import org.badvision.outlaweditor.data.TilesetUtils;
import org.badvision.outlaweditor.data.xml.PlatformData;
import org.badvision.outlaweditor.data.xml.Tile;
/**
* FXML Controller class for tile editor tab
*
* @author blurry
*/
public class TileEditorTabControllerImpl extends TileEditorTabController {
@Override
public void onCurrentTileSelected(ActionEvent event) {
setCurrentTile(tileSelector.getSelectionModel().getSelectedItem());
}
@Override
public void onTileClonePressed(ActionEvent event) {
ApplicationUIController mainController = ApplicationUIController.getController();
if (getCurrentTile() == null) {
return;
}
Tile t = new Tile();
TileUtils.getId(t);
t.setName(getCurrentTile().getName() + " (clone)");
t.setObstruction(getCurrentTile().isObstruction());
t.getCategory().addAll(getCurrentTile().getCategory());
for (PlatformData d : getCurrentTile().getDisplayData()) {
PlatformData p = new PlatformData();
p.setHeight(d.getHeight());
p.setWidth(d.getWidth());
p.setPlatform(d.getPlatform());
p.setValue(Arrays.copyOf(d.getValue(), d.getValue().length));
t.getDisplayData().add(p);
}
TilesetUtils.add(t);
mainController.rebuildTileSelectors();
setCurrentTile(t);
}
@Override
public void onTileCreatePressed(ActionEvent event) {
ApplicationUIController mainController = ApplicationUIController.getController();
Tile t = TileUtils.newTile();
t.setName("Untitled");
TilesetUtils.add(t);
mainController.rebuildTileSelectors();
setCurrentTile(t);
}
@Override
public void onTileDeletePressed(ActionEvent event) {
final ApplicationUIController mainController = ApplicationUIController.getController();
if (getCurrentTile() == null) {
return;
}
confirm("Delete tile '" + getCurrentTile().getName() + "'. Are you sure?", new Runnable() {
@Override
public void run() {
Tile del = getCurrentTile();
setCurrentTile(null);
Application.gameData.getTile().remove(del);
mainController.rebuildTileSelectors();
}
}, null);
}
@Override
public void tileBitMode(ActionEvent event) {
ApplicationUIController mainController = ApplicationUIController.getController();
if (getCurrentTileEditor() != null) {
getCurrentTileEditor().setDrawMode(TileEditor.DrawMode.Toggle);
}
}
@Override
public void tileDraw1BitMode(ActionEvent event) {
ApplicationUIController mainController = ApplicationUIController.getController();
if (getCurrentTileEditor() != null) {
getCurrentTileEditor().setDrawMode(TileEditor.DrawMode.Pencil1px);
}
}
@Override
public void tileDraw3BitMode(ActionEvent event) {
ApplicationUIController mainController = ApplicationUIController.getController();
if (getCurrentTileEditor() != null) {
getCurrentTileEditor().setDrawMode(TileEditor.DrawMode.Pencil3px);
}
}
@Override
public void tileShift(ActionEvent event) {
ApplicationUIController mainController = ApplicationUIController.getController();
if (getCurrentTileEditor() != null) {
getCurrentTileEditor().showShiftUI();
}
}
@Override
public void onTileExportPressed(ActionEvent event) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
/**
* Initializes the controller class.
*/
public void initialize() {
assert tileCategoryField != null : "fx:id=\"tileCategoryField\" was not injected: check your FXML file 'tileEditorTab.fxml'.";
assert tileEditorAnchorPane != null : "fx:id=\"tileEditorAnchorPane\" was not injected: check your FXML file 'tileEditorTab.fxml'.";
assert tileIdField != null : "fx:id=\"tileIdField\" was not injected: check your FXML file 'tileEditorTab.fxml'.";
assert tileNameField != null : "fx:id=\"tileNameField\" was not injected: check your FXML file 'tileEditorTab.fxml'.";
assert tileObstructionField != null : "fx:id=\"tileObstructionField\" was not injected: check your FXML file 'tileEditorTab.fxml'.";
assert tilePatternMenu != null : "fx:id=\"tilePatternMenu\" was not injected: check your FXML file 'tileEditorTab.fxml'.";
assert tileSelector != null : "fx:id=\"tileSelector\" was not injected: check your FXML file 'tileEditorTab.fxml'.";
tileSelector.setButtonCell(new ComboBoxListCell<Tile>() {
{
super.setPrefWidth(125);
}
@Override
public void updateItem(Tile item, boolean empty) {
textProperty().unbind();
super.updateItem(item, empty);
if (item != null) {
textProperty().bind(tileNameField.textProperty());
} else {
setText(null);
}
}
});
tileSelector.setCellFactory(new Callback<ListView<Tile>, ListCell<Tile>>() {
@Override
public ListCell<Tile> call(ListView<Tile> param) {
return new ApplicationUIControllerImpl.EntitySelectorCell<Tile>(tileNameField) {
@Override
public void finishUpdate(Tile item) {
setGraphic(new ImageView(TileUtils.getImage(item, Application.currentPlatform)));
}
};
}
});
}
@Override
public void setCurrentTileEditor(TileEditor editor) {
if (editor != null) {
editor.buildEditorUI(tileEditorAnchorPane);
editor.buildPatternSelector(tilePatternMenu);
}
super.setCurrentTileEditor(editor);
}
@Override
public void setCurrentTile(Tile t) {
tileSelector.getSelectionModel().select(t);
if (t != null && t.equals(getCurrentTile())) {
return;
}
tileEditorAnchorPane.getChildren().clear();
if (t == null) {
bind(tileIdField.textProperty(), null);
bind(tileCategoryField.textProperty(), null);
bind(tileObstructionField.selectedProperty(), null);
bind(tileNameField.textProperty(), null);
tileIdField.setDisable(true);
tileCategoryField.setDisable(true);
tileObstructionField.setDisable(true);
tileNameField.setDisable(true);
setCurrentTileEditor(null);
} else {
if (t.isObstruction() == null) {
t.setObstruction(false);
}
try {
tileIdField.setDisable(false);
tileCategoryField.setDisable(false);
tileObstructionField.setDisable(false);
tileNameField.setDisable(false);
bind(tileIdField.textProperty(), stringProp(t, "id"));
bind(tileCategoryField.textProperty(), categoryProp(t, "category"));
bind(tileObstructionField.selectedProperty(), boolProp(t, "obstruction"));
bind(tileNameField.textProperty(), stringProp(t, "name"));
TileEditor editor = Application.currentPlatform.tileEditor.newInstance();
editor.setEntity(t);
setCurrentTileEditor(editor);
} catch (NoSuchMethodException ex) {
Logger.getLogger(ApplicationUIController.class.getName()).log(Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
}
}
super.setCurrentTile(t);
}
@Override
public void rebuildTileSelectors() {
tileSelector.getItems().clear();
tileSelector.getItems().addAll(Application.gameData.getTile());
tileSelector.getSelectionModel().select(getCurrentTile());
}
}

View File

@ -82,7 +82,7 @@ public class UIAction {
currentSaveFile = f;
GameData newData = JAXB.unmarshal(currentSaveFile, GameData.class);
Application.instance.controller.setCurrentMap(null);
Application.instance.controller.setCurrentTile(null);
Application.instance.controller.tileEditorController.setCurrentTile(null);
TilesetUtils.clear();
Application.gameData = newData;
Application.instance.controller.rebuildTileSelectors();

View File

@ -15,61 +15,7 @@
<tabs>
<Tab onSelectionChanged="#tileTabActivated" text="Tiles">
<content>
<AnchorPane id="tilesTab" minHeight="0.0" minWidth="0.0" prefHeight="420.0000999999975" prefWidth="677.0">
<children>
<VBox prefHeight="420.0000999999975" prefWidth="677.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<ToolBar prefWidth="686.0">
<items>
<Label text="Tile:" />
<ComboBox fx:id="tileSelector" minWidth="125.0" onAction="#onCurrentTileSelected">
<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="#onTileCreatePressed" text="Create new" />
<Button mnemonicParsing="false" onAction="#onTileExportPressed" text="Export" />
<Button mnemonicParsing="false" onAction="#onTileClonePressed" prefWidth="64.9998779296875" text="Clone" />
<Button mnemonicParsing="false" onAction="#onTileDeletePressed" text="Delete" />
<MenuButton mnemonicParsing="false" text="Tools">
<items>
<Menu fx:id="tilePatternMenu" mnemonicParsing="false" text="Pattern" />
<Menu mnemonicParsing="false" text="Draw mode">
<items>
<MenuItem mnemonicParsing="false" onAction="#tileBitMode" text="Bit Toggle" />
<MenuItem mnemonicParsing="false" onAction="#tileDraw1BitMode" text="1 bit-wide" />
<MenuItem mnemonicParsing="false" onAction="#tileDraw3BitMode" text="3 bit wide" />
</items>
</Menu>
<MenuItem mnemonicParsing="false" onAction="#tileShift" text="Shift..." />
</items>
</MenuButton>
</items>
</ToolBar>
<HBox prefHeight="387.0" prefWidth="677.0" VBox.vgrow="ALWAYS">
<children>
<AnchorPane id="imageDetailsPane" prefHeight="200.0" prefWidth="200.0">
<children>
<Label layoutX="5.0" layoutY="5.0" prefHeight="29.0" prefWidth="37.0" text="Name" />
<TextField id="" fx:id="tileNameField" layoutX="54.0" layoutY="5.0" prefWidth="147.0" />
<Label layoutX="5.0" layoutY="33.0" prefHeight="29.0" prefWidth="46.0" text="ID" />
<TextField fx:id="tileIdField" layoutX="54.0" layoutY="36.0" prefWidth="147.0" />
<Label layoutX="5.0" layoutY="72.0" text="Category" />
<TextField fx:id="tileCategoryField" layoutX="64.0" layoutY="67.0" prefHeight="26.0" prefWidth="137.0" />
<CheckBox fx:id="tileObstructionField" layoutX="6.0" layoutY="98.0" mnemonicParsing="false" text="Physical Obstruction" />
</children>
</AnchorPane>
<AnchorPane fx:id="tileEditorAnchorPane" prefHeight="387.0" prefWidth="477.0000999999975" HBox.hgrow="ALWAYS" />
</children>
</HBox>
</children>
</VBox>
</children>
</AnchorPane>
<fx:include fx:id="tileEditor" source="tileEditorTab.fxml"/>
</content>
</Tab>
<Tab onSelectionChanged="#mapTabActivated" text="Maps">