mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-10-11 18:23:48 +00:00
Total completion of refactoring, got all the bugs out of the refactored classes (finally!) :-)
This commit is contained in:
parent
a096d73ae5
commit
ddf5ac1128
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* 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.ui;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import javafx.scene.control.ListCell;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.scene.control.cell.ComboBoxListCell;
|
||||||
|
import org.badvision.outlaweditor.data.PropertyHelper;
|
||||||
|
import org.badvision.outlaweditor.ui.impl.ApplicationUIControllerImpl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author blurry
|
||||||
|
*/
|
||||||
|
public abstract class EntitySelectorCell<T> extends ComboBoxListCell<T> {
|
||||||
|
static Map<TextField, Object> lastSelected = new HashMap<>();
|
||||||
|
TextField nameField;
|
||||||
|
|
||||||
|
public EntitySelectorCell(TextField tileNameField) {
|
||||||
|
super.setPrefWidth(125);
|
||||||
|
nameField = tileNameField;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateSelected(boolean sel) {
|
||||||
|
if (sel) {
|
||||||
|
Object o = lastSelected.get(nameField);
|
||||||
|
if (o != null && !o.equals(getItem())) {
|
||||||
|
((ListCell) o).updateSelected(false);
|
||||||
|
}
|
||||||
|
textProperty().unbind();
|
||||||
|
textProperty().bind(nameField.textProperty());
|
||||||
|
lastSelected.put(nameField, this);
|
||||||
|
} else {
|
||||||
|
updateItem(getItem(), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateItem(T item, boolean empty) {
|
||||||
|
textProperty().unbind();
|
||||||
|
super.updateItem(item, empty);
|
||||||
|
if (item != null && !(item instanceof String)) {
|
||||||
|
try {
|
||||||
|
textProperty().bind(PropertyHelper.stringProp(item, "name"));
|
||||||
|
} catch (NoSuchMethodException ex) {
|
||||||
|
Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
finishUpdate(item);
|
||||||
|
} else {
|
||||||
|
setText(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void finishUpdate(T item) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -127,7 +127,7 @@ public abstract class MapEditorTabController {
|
|||||||
@FXML
|
@FXML
|
||||||
abstract public void scrollMapUp(ActionEvent event);
|
abstract public void scrollMapUp(ActionEvent event);
|
||||||
|
|
||||||
protected void initalize() {
|
public void initalize() {
|
||||||
assert mapEditorAnchorPane != null : "fx:id=\"mapEditorAnchorPane\" was not injected: check your FXML file 'mapEditorTab.fxml'.";
|
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 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 mapNameField != null : "fx:id=\"mapNameField\" was not injected: check your FXML file 'mapEditorTab.fxml'.";
|
||||||
|
@ -85,4 +85,7 @@ public abstract class TileEditorTabController {
|
|||||||
|
|
||||||
abstract public void rebuildTileSelectors();
|
abstract public void rebuildTileSelectors();
|
||||||
|
|
||||||
|
public void initalize() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,9 @@
|
|||||||
package org.badvision.outlaweditor.ui.impl;
|
package org.badvision.outlaweditor.ui.impl;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import javafx.event.Event;
|
import javafx.event.Event;
|
||||||
import javafx.scene.control.ListCell;
|
|
||||||
import javafx.scene.control.TextField;
|
|
||||||
import javafx.scene.control.cell.ComboBoxListCell;
|
|
||||||
import javafx.scene.input.DataFormat;
|
import javafx.scene.input.DataFormat;
|
||||||
import org.badvision.outlaweditor.Application;
|
import org.badvision.outlaweditor.Application;
|
||||||
import org.badvision.outlaweditor.Editor;
|
import org.badvision.outlaweditor.Editor;
|
||||||
import static org.badvision.outlaweditor.data.PropertyHelper.*;
|
|
||||||
import org.badvision.outlaweditor.data.TileUtils;
|
import org.badvision.outlaweditor.data.TileUtils;
|
||||||
import org.badvision.outlaweditor.data.TilesetUtils;
|
import org.badvision.outlaweditor.data.TilesetUtils;
|
||||||
import org.badvision.outlaweditor.data.xml.Tile;
|
import org.badvision.outlaweditor.data.xml.Tile;
|
||||||
@ -34,6 +26,9 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
|
|||||||
rebuildTileSelectors();
|
rebuildTileSelectors();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
tileController.initalize();
|
||||||
|
mapController.initalize();
|
||||||
|
imageController.initalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -127,51 +122,6 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
|
|||||||
|
|
||||||
public static final DataFormat SCRIPT_DATA_FORMAT = new DataFormat("MythosScript");
|
public static final DataFormat SCRIPT_DATA_FORMAT = new DataFormat("MythosScript");
|
||||||
|
|
||||||
abstract public static class EntitySelectorCell<T> extends ComboBoxListCell<T> {
|
|
||||||
|
|
||||||
static Map<TextField, Object> lastSelected = new HashMap<>();
|
|
||||||
TextField nameField;
|
|
||||||
|
|
||||||
public EntitySelectorCell(TextField tileNameField) {
|
|
||||||
super.setPrefWidth(125);
|
|
||||||
nameField = tileNameField;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateSelected(boolean sel) {
|
|
||||||
if (sel) {
|
|
||||||
Object o = lastSelected.get(nameField);
|
|
||||||
if (o != null && !o.equals(getItem())) {
|
|
||||||
((ListCell) o).updateSelected(false);
|
|
||||||
}
|
|
||||||
textProperty().unbind();
|
|
||||||
textProperty().bind(nameField.textProperty());
|
|
||||||
lastSelected.put(nameField, this);
|
|
||||||
} else {
|
|
||||||
updateItem(getItem(), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateItem(T item, boolean empty) {
|
|
||||||
textProperty().unbind();
|
|
||||||
super.updateItem(item, empty);
|
|
||||||
if (item != null && !(item instanceof String)) {
|
|
||||||
try {
|
|
||||||
textProperty().bind(stringProp(item, "name"));
|
|
||||||
} catch (NoSuchMethodException ex) {
|
|
||||||
Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
finishUpdate(item);
|
|
||||||
} else {
|
|
||||||
setText(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void finishUpdate(T item) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearData() {
|
public void clearData() {
|
||||||
tileController.setCurrentTile(null);
|
tileController.setCurrentTile(null);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.badvision.outlaweditor.ui.impl;
|
package org.badvision.outlaweditor.ui.impl;
|
||||||
|
|
||||||
|
import org.badvision.outlaweditor.ui.EntitySelectorCell;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
@ -52,7 +53,7 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
|
|||||||
imageSelector.setCellFactory(new Callback<ListView<Image>, ListCell<Image>>() {
|
imageSelector.setCellFactory(new Callback<ListView<Image>, ListCell<Image>>() {
|
||||||
@Override
|
@Override
|
||||||
public ListCell<Image> call(ListView<Image> param) {
|
public ListCell<Image> call(ListView<Image> param) {
|
||||||
return new ApplicationUIControllerImpl.EntitySelectorCell<Image>(imageNameField) {
|
return new EntitySelectorCell<Image>(imageNameField) {
|
||||||
@Override
|
@Override
|
||||||
public void finishUpdate(Image item) {
|
public void finishUpdate(Image item) {
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.badvision.outlaweditor.ui.impl;
|
package org.badvision.outlaweditor.ui.impl;
|
||||||
|
|
||||||
|
import org.badvision.outlaweditor.ui.EntitySelectorCell;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
@ -185,6 +186,7 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void completeInflightOperations() {
|
public void completeInflightOperations() {
|
||||||
if (getCurrentEditor() != null) {
|
if (getCurrentEditor() != null) {
|
||||||
getCurrentEditor().getCurrentMap().updateBackingMap();
|
getCurrentEditor().getCurrentMap().updateBackingMap();
|
||||||
@ -248,7 +250,7 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initalize() {
|
public void initalize() {
|
||||||
super.initalize();
|
super.initalize();
|
||||||
mapSelect.setButtonCell(new ComboBoxListCell<org.badvision.outlaweditor.data.xml.Map>() {
|
mapSelect.setButtonCell(new ComboBoxListCell<org.badvision.outlaweditor.data.xml.Map>() {
|
||||||
{
|
{
|
||||||
@ -256,7 +258,7 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateItem(org.badvision.outlaweditor.data.xml.Map item, boolean empty) {
|
public void updateItem(Map item, boolean empty) {
|
||||||
textProperty().unbind();
|
textProperty().unbind();
|
||||||
super.updateItem(item, empty);
|
super.updateItem(item, empty);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
@ -266,12 +268,12 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mapSelect.setCellFactory(new Callback<ListView<org.badvision.outlaweditor.data.xml.Map>, ListCell<org.badvision.outlaweditor.data.xml.Map>>() {
|
mapSelect.setCellFactory(new Callback<ListView<Map>, ListCell<Map>>() {
|
||||||
@Override
|
@Override
|
||||||
public ListCell<org.badvision.outlaweditor.data.xml.Map> call(ListView<org.badvision.outlaweditor.data.xml.Map> param) {
|
public ListCell<org.badvision.outlaweditor.data.xml.Map> call(ListView<Map> param) {
|
||||||
return new ApplicationUIControllerImpl.EntitySelectorCell<org.badvision.outlaweditor.data.xml.Map>(mapNameField) {
|
return new EntitySelectorCell<Map>(mapNameField) {
|
||||||
@Override
|
@Override
|
||||||
public void finishUpdate(org.badvision.outlaweditor.data.xml.Map item) {
|
public void finishUpdate(Map item) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.badvision.outlaweditor.ui.impl;
|
package org.badvision.outlaweditor.ui.impl;
|
||||||
|
|
||||||
|
import org.badvision.outlaweditor.ui.EntitySelectorCell;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -156,7 +157,7 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
|
|||||||
tileSelector.setCellFactory(new Callback<ListView<Tile>, ListCell<Tile>>() {
|
tileSelector.setCellFactory(new Callback<ListView<Tile>, ListCell<Tile>>() {
|
||||||
@Override
|
@Override
|
||||||
public ListCell<Tile> call(ListView<Tile> param) {
|
public ListCell<Tile> call(ListView<Tile> param) {
|
||||||
return new ApplicationUIControllerImpl.EntitySelectorCell<Tile>(tileNameField) {
|
return new EntitySelectorCell<Tile>(tileNameField) {
|
||||||
@Override
|
@Override
|
||||||
public void finishUpdate(Tile item) {
|
public void finishUpdate(Tile item) {
|
||||||
setGraphic(new ImageView(TileUtils.getImage(item, Application.currentPlatform)));
|
setGraphic(new ImageView(TileUtils.getImage(item, Application.currentPlatform)));
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import javafx.scene.web.*?>
|
<?import javafx.scene.web.*?>
|
||||||
|
|
||||||
<AnchorPane id="AnchorPane" prefHeight="748.0" prefWidth="1024.0" styleClass="mainFxmlClass" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="org.badvision.outlaweditor.MythosScriptEditorController">
|
<AnchorPane id="AnchorPane" prefHeight="748.0" prefWidth="1024.0" styleClass="mainFxmlClass" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="org.badvision.outlaweditor.ui.MythosScriptEditorController">
|
||||||
<!-- <stylesheets>
|
<!-- <stylesheets>
|
||||||
<URL value="@/styles/mythosscripteditor.css"/>
|
<URL value="@/styles/mythosscripteditor.css"/>
|
||||||
</stylesheets>-->
|
</stylesheets>-->
|
||||||
|
Loading…
Reference in New Issue
Block a user