Changed category to a single value and added auto-sort in the tile and image selectors

This commit is contained in:
Brendan Robert 2015-03-08 18:58:21 -05:00
parent d6091a87a1
commit 6bc3b87329
9 changed files with 104 additions and 131 deletions

View File

@ -4,23 +4,15 @@
*/ */
package org.badvision.outlaweditor.data; package org.badvision.outlaweditor.data;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.beans.property.Property; import javafx.beans.property.Property;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.adapter.JavaBeanBooleanProperty; import javafx.beans.property.adapter.JavaBeanBooleanProperty;
import javafx.beans.property.adapter.JavaBeanBooleanPropertyBuilder; import javafx.beans.property.adapter.JavaBeanBooleanPropertyBuilder;
import javafx.beans.property.adapter.JavaBeanIntegerProperty; import javafx.beans.property.adapter.JavaBeanIntegerProperty;
import javafx.beans.property.adapter.JavaBeanIntegerPropertyBuilder; import javafx.beans.property.adapter.JavaBeanIntegerPropertyBuilder;
import javafx.beans.property.adapter.JavaBeanStringProperty; import javafx.beans.property.adapter.JavaBeanStringProperty;
import javafx.beans.property.adapter.JavaBeanStringPropertyBuilder; import javafx.beans.property.adapter.JavaBeanStringPropertyBuilder;
import org.badvision.outlaweditor.ui.ApplicationUIController;
/** /**
* *
@ -36,59 +28,6 @@ public class PropertyHelper {
return new JavaBeanBooleanPropertyBuilder().bean(t).name(fieldName).build(); return new JavaBeanBooleanPropertyBuilder().bean(t).name(fieldName).build();
} }
public static Property categoryProp(final Object t, String fieldName) throws NoSuchMethodException {
final String camel = fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
SimpleStringProperty prop = new SimpleStringProperty() {
@Override
public String get() {
try {
Method getter = t.getClass().getMethod("get" + camel);
List<String> list = (List<String>) getter.invoke(t);
String out = "";
for (String s : list) {
if (out.length() > 0) {
out += ",";
}
out += s;
}
return out;
} catch (NoSuchMethodException ex) {
Logger.getLogger(ApplicationUIController.class.getName()).log(Level.SEVERE, null, ex);
} catch (SecurityException ex) {
Logger.getLogger(ApplicationUIController.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(ApplicationUIController.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalArgumentException ex) {
Logger.getLogger(ApplicationUIController.class.getName()).log(Level.SEVERE, null, ex);
} catch (InvocationTargetException ex) {
Logger.getLogger(ApplicationUIController.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
@Override
public void set(String string) {
try {
Method getter = t.getClass().getMethod("get" + camel);
List<String> list = (List<String>) getter.invoke(t);
list.clear();
Collections.addAll(list, string.split(","));
} catch (NoSuchMethodException ex) {
Logger.getLogger(ApplicationUIController.class.getName()).log(Level.SEVERE, null, ex);
} catch (SecurityException ex) {
Logger.getLogger(ApplicationUIController.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(ApplicationUIController.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalArgumentException ex) {
Logger.getLogger(ApplicationUIController.class.getName()).log(Level.SEVERE, null, ex);
} catch (InvocationTargetException ex) {
Logger.getLogger(ApplicationUIController.class.getName()).log(Level.SEVERE, null, ex);
}
}
};
return prop;
}
public static JavaBeanStringProperty stringProp(Object t, String fieldName) throws NoSuchMethodException { public static JavaBeanStringProperty stringProp(Object t, String fieldName) throws NoSuchMethodException {
return new JavaBeanStringPropertyBuilder().bean(t).name(fieldName).build(); return new JavaBeanStringPropertyBuilder().bean(t).name(fieldName).build();
} }

View File

@ -45,7 +45,7 @@ public class TileUtils {
public static Map<Platform, WritableImage> getDisplay(Tile t) { public static Map<Platform, WritableImage> getDisplay(Tile t) {
if (display.get(getId(t)) == null) { if (display.get(getId(t)) == null) {
display.put(getId(t), new EnumMap<Platform, WritableImage>(Platform.class)); display.put(getId(t), new EnumMap<>(Platform.class));
} }
return display.get(getId(t)); return display.get(getId(t));
} }

View File

@ -3,13 +3,13 @@
* To change this template file, choose Tools | Templates * To change this template file, choose Tools | Templates
* and open the template in the editor. * and open the template in the editor.
*/ */
package org.badvision.outlaweditor.ui; package org.badvision.outlaweditor.ui;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javafx.beans.binding.Bindings;
import javafx.scene.control.ListCell; import javafx.scene.control.ListCell;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.scene.control.cell.ComboBoxListCell; import javafx.scene.control.cell.ComboBoxListCell;
@ -21,27 +21,33 @@ import org.badvision.outlaweditor.ui.impl.ApplicationUIControllerImpl;
* @author blurry * @author blurry
*/ */
public abstract class EntitySelectorCell<T> extends ComboBoxListCell<T> { public abstract class EntitySelectorCell<T> extends ComboBoxListCell<T> {
static Map<TextField, Object> lastSelected = new HashMap<>();
TextField nameField;
public EntitySelectorCell(TextField tileNameField) { static Map<TextField, Object> lastSelected = new HashMap<>();
TextField nameField, categoryField;
public EntitySelectorCell(TextField tileNameField, TextField categoryNameField) {
super.setPrefWidth(125); super.setPrefWidth(125);
nameField = tileNameField; nameField = tileNameField;
categoryField = categoryNameField;
} }
@Override @Override
public void updateSelected(boolean sel) { public void updateSelected(boolean sel) {
if (sel) { // if (sel) {
Object o = lastSelected.get(nameField); // Object o = lastSelected.get(nameField);
if (o != null && !o.equals(getItem())) { // if (o != null && !o.equals(getItem())) {
((ListCell) o).updateSelected(false); // ((ListCell) o).updateSelected(false);
} // }
textProperty().unbind(); // textProperty().unbind();
textProperty().bind(nameField.textProperty()); // if (categoryField != null) {
lastSelected.put(nameField, this); // textProperty().bind(Bindings.concat(categoryField.textProperty(), "/", nameField.textProperty()));
} else { // } else {
// textProperty().bind(Bindings.concat(nameField.textProperty()));
// }
// lastSelected.put(nameField, this);
// } else {
updateItem(getItem(), false); updateItem(getItem(), false);
} // }
} }
@Override @Override
@ -50,7 +56,17 @@ public abstract class EntitySelectorCell<T> extends ComboBoxListCell<T> {
super.updateItem(item, empty); super.updateItem(item, empty);
if (item != null && !(item instanceof String)) { if (item != null && !(item instanceof String)) {
try { try {
textProperty().bind(PropertyHelper.stringProp(item, "name")); if (categoryField != null) {
textProperty().bind(
Bindings.concat(
PropertyHelper.stringProp(item, "category"),
"/",
PropertyHelper.stringProp(item, "name")
)
);
} else {
textProperty().bind(PropertyHelper.stringProp(item, "name"));
}
} catch (NoSuchMethodException ex) { } catch (NoSuchMethodException ex) {
Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
} }

View File

@ -1,18 +1,22 @@
package org.badvision.outlaweditor.ui.impl; package org.badvision.outlaweditor.ui.impl;
import java.util.List;
import org.badvision.outlaweditor.ui.EntitySelectorCell; 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.beans.binding.Bindings;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.scene.control.ListView; import javafx.scene.control.ListView;
import javafx.scene.control.cell.ComboBoxListCell; import javafx.scene.control.cell.ComboBoxListCell;
import javafx.util.StringConverter;
import org.badvision.outlaweditor.Application; import org.badvision.outlaweditor.Application;
import org.badvision.outlaweditor.Editor; import org.badvision.outlaweditor.Editor;
import org.badvision.outlaweditor.ImageEditor; import org.badvision.outlaweditor.ImageEditor;
import static org.badvision.outlaweditor.Application.currentPlatform; import static org.badvision.outlaweditor.Application.currentPlatform;
import static org.badvision.outlaweditor.ui.UIAction.confirm; import static org.badvision.outlaweditor.ui.UIAction.confirm;
import static org.badvision.outlaweditor.data.PropertyHelper.bind; import static org.badvision.outlaweditor.data.PropertyHelper.bind;
import static org.badvision.outlaweditor.data.PropertyHelper.categoryProp;
import static org.badvision.outlaweditor.data.PropertyHelper.stringProp; import static org.badvision.outlaweditor.data.PropertyHelper.stringProp;
import org.badvision.outlaweditor.data.xml.Image; import org.badvision.outlaweditor.data.xml.Image;
import org.badvision.outlaweditor.ui.ImageEditorTabController; import org.badvision.outlaweditor.ui.ImageEditorTabController;
@ -26,31 +30,27 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
public Image currentImage = null; public Image currentImage = null;
public ImageEditor currentImageEditor = null; public ImageEditor currentImageEditor = null;
ChangeListener rebuildListener = (ObservableValue value, Object oldValue, Object newValue) -> rebuildImageSelector();
/** /**
* Initializes the controller class. * Initializes the controller class.
*/ */
public void initialize() { public void initialize() {
super.initalize(); super.initalize();
imageSelector.setButtonCell(new ComboBoxListCell<Image>() { imageSelector.setCellFactory((ListView<Image> param) -> new EntitySelectorCell<Image>(imageNameField, imageCategoryField) {
{ @Override
super.setPrefWidth(125); public void finishUpdate(Image item) {
}
});
imageSelector.setConverter(new StringConverter<Image>() {
@Override
public String toString(Image object) {
return String.valueOf(object.getCategory()) + "/" + String.valueOf(object.getName());
} }
@Override @Override
public void updateItem(Image item, boolean empty) { public Image fromString(String string) {
textProperty().unbind(); return null;
super.updateItem(item, empty);
if (item != null) {
textProperty().bind(imageNameField.textProperty());
} else {
setText(null);
}
}
});
imageSelector.setCellFactory((ListView<Image> param) -> new EntitySelectorCell<Image>(imageNameField) {
@Override
public void finishUpdate(Image item) {
} }
}); });
} }
@ -165,6 +165,8 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
} }
private void setCurrentImage(Image i) { private void setCurrentImage(Image i) {
imageNameField.textProperty().removeListener(rebuildListener);
imageCategoryField.textProperty().removeListener(rebuildListener);
if (currentImage != null && currentImage.equals(i)) { if (currentImage != null && currentImage.equals(i)) {
return; return;
} }
@ -193,7 +195,7 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
imageNameField.setDisable(false); imageNameField.setDisable(false);
imageWidthField.setDisable(false); imageWidthField.setDisable(false);
bind(imageNameField.textProperty(), stringProp(i, "name")); bind(imageNameField.textProperty(), stringProp(i, "name"));
bind(imageCategoryField.textProperty(), categoryProp(i, "category")); bind(imageCategoryField.textProperty(), stringProp(i, "category"));
} catch (NoSuchMethodException ex) { } catch (NoSuchMethodException ex) {
Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
} }
@ -207,6 +209,8 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
currentImageEditor.buildPatternSelector(imagePatternMenu); currentImageEditor.buildPatternSelector(imagePatternMenu);
imageEditorZoomGroup.setScaleX(1.0); imageEditorZoomGroup.setScaleX(1.0);
imageEditorZoomGroup.setScaleY(1.0); imageEditorZoomGroup.setScaleY(1.0);
imageNameField.textProperty().addListener(rebuildListener);
imageCategoryField.textProperty().addListener(rebuildListener);
} }
} }
@ -218,7 +222,14 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
public void rebuildImageSelector() { public void rebuildImageSelector() {
Image i = getCurrentImage(); Image i = getCurrentImage();
imageSelector.getItems().clear(); imageSelector.getItems().clear();
imageSelector.getItems().addAll(Application.gameData.getImage()); List<Image> allImages = Application.gameData.getImage();
allImages.sort((Image o1, Image o2) -> {
int c1 = String.valueOf(o1.getCategory()).compareTo(String.valueOf(o2.getCategory()));
if (c1 != 0) return c1;
return String.valueOf(o1.getName()).compareTo(String.valueOf(o2.getName()));
});
imageSelector.getItems().addAll(allImages);
imageSelector.getSelectionModel().select(i); imageSelector.getSelectionModel().select(i);
} }

View File

@ -267,7 +267,7 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
} }
} }
}); });
mapSelect.setCellFactory((ListView<Map> param) -> new EntitySelectorCell<Map>(mapNameField) { mapSelect.setCellFactory((ListView<Map> param) -> new EntitySelectorCell<Map>(mapNameField, null) {
@Override @Override
public void finishUpdate(Map item) { public void finishUpdate(Map item) {
} }

View File

@ -2,20 +2,20 @@ package org.badvision.outlaweditor.ui.impl;
import org.badvision.outlaweditor.ui.EntitySelectorCell; import org.badvision.outlaweditor.ui.EntitySelectorCell;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView; import javafx.scene.control.ListView;
import javafx.scene.control.cell.ComboBoxListCell;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
import javafx.util.Callback; import javafx.util.StringConverter;
import org.badvision.outlaweditor.Application; import org.badvision.outlaweditor.Application;
import org.badvision.outlaweditor.TileEditor; import org.badvision.outlaweditor.TileEditor;
import static org.badvision.outlaweditor.ui.UIAction.confirm; import static org.badvision.outlaweditor.ui.UIAction.confirm;
import static org.badvision.outlaweditor.data.PropertyHelper.bind; import static org.badvision.outlaweditor.data.PropertyHelper.bind;
import static org.badvision.outlaweditor.data.PropertyHelper.boolProp; 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 static org.badvision.outlaweditor.data.PropertyHelper.stringProp;
import org.badvision.outlaweditor.data.TileUtils; import org.badvision.outlaweditor.data.TileUtils;
import org.badvision.outlaweditor.data.TilesetUtils; import org.badvision.outlaweditor.data.TilesetUtils;
@ -31,6 +31,8 @@ import org.badvision.outlaweditor.ui.TileEditorTabController;
*/ */
public class TileEditorTabControllerImpl extends TileEditorTabController { public class TileEditorTabControllerImpl extends TileEditorTabController {
ChangeListener rebuildListener = (ObservableValue value, Object oldValue, Object newValue) -> rebuildTileSelectors();
@Override @Override
public void onCurrentTileSelected(ActionEvent event) { public void onCurrentTileSelected(ActionEvent event) {
setCurrentTile(tileSelector.getSelectionModel().getSelectedItem()); setCurrentTile(tileSelector.getSelectionModel().getSelectedItem());
@ -48,7 +50,7 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
t.setObstruction(getCurrentTile().isObstruction()); t.setObstruction(getCurrentTile().isObstruction());
t.setSprite(getCurrentTile().isSprite()); t.setSprite(getCurrentTile().isSprite());
t.setBlocker(getCurrentTile().isBlocker()); t.setBlocker(getCurrentTile().isBlocker());
t.getCategory().addAll(getCurrentTile().getCategory()); t.setCategory(getCurrentTile().getCategory());
getCurrentTile().getDisplayData().stream().map((d) -> { getCurrentTile().getDisplayData().stream().map((d) -> {
PlatformData p = new PlatformData(); PlatformData p = new PlatformData();
p.setHeight(d.getHeight()); p.setHeight(d.getHeight());
@ -90,7 +92,6 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
@Override @Override
public void tileBitMode(ActionEvent event) { public void tileBitMode(ActionEvent event) {
ApplicationUIController mainController = ApplicationUIController.getController();
if (getCurrentTileEditor() != null) { if (getCurrentTileEditor() != null) {
getCurrentTileEditor().setDrawMode(TileEditor.DrawMode.Toggle); getCurrentTileEditor().setDrawMode(TileEditor.DrawMode.Toggle);
} }
@ -98,7 +99,6 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
@Override @Override
public void tileDraw1BitMode(ActionEvent event) { public void tileDraw1BitMode(ActionEvent event) {
ApplicationUIController mainController = ApplicationUIController.getController();
if (getCurrentTileEditor() != null) { if (getCurrentTileEditor() != null) {
getCurrentTileEditor().setDrawMode(TileEditor.DrawMode.Pencil1px); getCurrentTileEditor().setDrawMode(TileEditor.DrawMode.Pencil1px);
} }
@ -106,7 +106,6 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
@Override @Override
public void tileDraw3BitMode(ActionEvent event) { public void tileDraw3BitMode(ActionEvent event) {
ApplicationUIController mainController = ApplicationUIController.getController();
if (getCurrentTileEditor() != null) { if (getCurrentTileEditor() != null) {
getCurrentTileEditor().setDrawMode(TileEditor.DrawMode.Pencil3px); getCurrentTileEditor().setDrawMode(TileEditor.DrawMode.Pencil3px);
} }
@ -114,7 +113,6 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
@Override @Override
public void tileShift(ActionEvent event) { public void tileShift(ActionEvent event) {
ApplicationUIController mainController = ApplicationUIController.getController();
if (getCurrentTileEditor() != null) { if (getCurrentTileEditor() != null) {
getCurrentTileEditor().showShiftUI(); getCurrentTileEditor().showShiftUI();
} }
@ -138,31 +136,25 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
assert tileBlockerField != null : "fx:id=\"tileBlockerField\" was not injected: check your FXML file 'tileEditorTab.fxml'."; assert tileBlockerField != null : "fx:id=\"tileBlockerField\" 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 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'."; 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((ListView<Tile> param) -> { tileSelector.setCellFactory((ListView<Tile> param) -> {
return new EntitySelectorCell<Tile>(tileNameField) { return new EntitySelectorCell<Tile>(tileNameField, tileCategoryField) {
@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)));
} }
}; };
}); });
tileSelector.setConverter(new StringConverter<Tile>() {
@Override
public String toString(Tile object) {
return String.valueOf(object.getCategory() + "/" + object.getName());
}
@Override
public Tile fromString(String string) {
return null;
}
});
} }
@Override @Override
@ -176,6 +168,8 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
@Override @Override
public void setCurrentTile(Tile t) { public void setCurrentTile(Tile t) {
tileNameField.textProperty().removeListener(rebuildListener);
tileCategoryField.textProperty().removeListener(rebuildListener);
tileSelector.getSelectionModel().select(t); tileSelector.getSelectionModel().select(t);
if (t != null && t.equals(getCurrentTile())) { if (t != null && t.equals(getCurrentTile())) {
return; return;
@ -188,6 +182,7 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
bind(tileSpriteField.selectedProperty(), null); bind(tileSpriteField.selectedProperty(), null);
bind(tileBlockerField.selectedProperty(), null); bind(tileBlockerField.selectedProperty(), null);
bind(tileNameField.textProperty(), null); bind(tileNameField.textProperty(), null);
tileIdField.setDisable(true); tileIdField.setDisable(true);
tileCategoryField.setDisable(true); tileCategoryField.setDisable(true);
tileObstructionField.setDisable(true); tileObstructionField.setDisable(true);
@ -213,7 +208,7 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
tileBlockerField.setDisable(false); tileBlockerField.setDisable(false);
tileNameField.setDisable(false); tileNameField.setDisable(false);
bind(tileIdField.textProperty(), stringProp(t, "id")); bind(tileIdField.textProperty(), stringProp(t, "id"));
bind(tileCategoryField.textProperty(), categoryProp(t, "category")); bind(tileCategoryField.textProperty(), stringProp(t, "category"));
bind(tileObstructionField.selectedProperty(), boolProp(t, "obstruction")); bind(tileObstructionField.selectedProperty(), boolProp(t, "obstruction"));
bind(tileSpriteField.selectedProperty(), boolProp(t, "sprite")); bind(tileSpriteField.selectedProperty(), boolProp(t, "sprite"));
bind(tileBlockerField.selectedProperty(), boolProp(t, "blocker")); bind(tileBlockerField.selectedProperty(), boolProp(t, "blocker"));
@ -221,6 +216,8 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
TileEditor editor = Application.currentPlatform.tileEditor.newInstance(); TileEditor editor = Application.currentPlatform.tileEditor.newInstance();
editor.setEntity(t); editor.setEntity(t);
setCurrentTileEditor(editor); setCurrentTileEditor(editor);
tileNameField.textProperty().addListener(rebuildListener);
tileCategoryField.textProperty().addListener(rebuildListener);
} catch (NoSuchMethodException ex) { } catch (NoSuchMethodException ex) {
Logger.getLogger(ApplicationUIController.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(ApplicationUIController.class.getName()).log(Level.SEVERE, null, ex);
} catch (InstantiationException | IllegalAccessException ex) { } catch (InstantiationException | IllegalAccessException ex) {
@ -233,7 +230,15 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
@Override @Override
public void rebuildTileSelectors() { public void rebuildTileSelectors() {
tileSelector.getItems().clear(); tileSelector.getItems().clear();
tileSelector.getItems().addAll(Application.gameData.getTile()); List<Tile> allTiles = Application.gameData.getTile();
tileSelector.getSelectionModel().select(getCurrentTile()); allTiles.sort((Tile o1, Tile o2) -> {
int c1 = String.valueOf(o1.getCategory()).compareTo(String.valueOf(o2.getCategory()));
if (c1 != 0) {
return c1;
}
return String.valueOf(o1.getName()).compareTo(String.valueOf(o2.getName()));
});
tileSelector.getItems().addAll(allTiles);
tileSelector.getSelectionModel().select(allTiles.indexOf(getCurrentTile()));
} }
} }

View File

@ -13,7 +13,7 @@
<ToolBar prefWidth="686.0"> <ToolBar prefWidth="686.0">
<items> <items>
<Label text="Image:" /> <Label text="Image:" />
<ComboBox id="tileSelect" fx:id="imageSelector" onAction="#onImageSelected" /> <ComboBox id="tileSelect" fx:id="imageSelector" onAction="#onImageSelected" prefHeight="26.0" prefWidth="271.0" />
<Button mnemonicParsing="false" onAction="#onImageCreatePressed" text="Create new" /> <Button mnemonicParsing="false" onAction="#onImageCreatePressed" text="Create new" />
<Button mnemonicParsing="false" onAction="#onImageClonePressed" text="Clone" /> <Button mnemonicParsing="false" onAction="#onImageClonePressed" text="Clone" />
<Button mnemonicParsing="false" onAction="#onImageExportPressed" text="Export" /> <Button mnemonicParsing="false" onAction="#onImageExportPressed" text="Export" />

View File

@ -4,10 +4,10 @@
elementFormDefault="qualified" targetNamespace="outlaw" xmlns:tns="outlaw" attributeFormDefault="unqualified"> elementFormDefault="qualified" targetNamespace="outlaw" xmlns:tns="outlaw" attributeFormDefault="unqualified">
<xs:complexType name="image"> <xs:complexType name="image">
<xs:sequence> <xs:sequence>
<xs:element name="category" type="xs:string" maxOccurs="unbounded" minOccurs="0"/>
<xs:element name="displayData" type="tns:platformData" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="displayData" type="tns:platformData" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence> </xs:sequence>
<xs:attribute name="name" type="xs:NMTOKEN"/> <xs:attribute name="name" type="xs:NMTOKEN"/>
<xs:attribute name="category" type="xs:string"/>
</xs:complexType> </xs:complexType>
<xs:complexType name="tile"> <xs:complexType name="tile">
<xs:complexContent> <xs:complexContent>
@ -32,6 +32,7 @@
<xs:sequence> <xs:sequence>
<xs:element name="name" type="xs:string"/> <xs:element name="name" type="xs:string"/>
<xs:element name="description" type="xs:string" minOccurs="0"/> <xs:element name="description" type="xs:string" minOccurs="0"/>
<xs:element name="category" type="xs:string" minOccurs="0"/>
<xs:element name="block" type="tns:block"/> <xs:element name="block" type="tns:block"/>
<xs:element name="locationTrigger" minOccurs="0" maxOccurs="unbounded"> <xs:element name="locationTrigger" minOccurs="0" maxOccurs="unbounded">
<xs:complexType> <xs:complexType>
@ -71,6 +72,7 @@
<xs:attribute name="name" type="xs:string"/> <xs:attribute name="name" type="xs:string"/>
<xs:attribute name="width" type="xs:int"/> <xs:attribute name="width" type="xs:int"/>
<xs:attribute name="height" type="xs:int"/> <xs:attribute name="height" type="xs:int"/>
<xs:attribute name="category" type="xs:string"/>
<xs:attribute name="wrap" type="xs:boolean" default="false"/> <xs:attribute name="wrap" type="xs:boolean" default="false"/>
<xs:attribute name="startX" type="xs:int" default="0"/> <xs:attribute name="startX" type="xs:int" default="0"/>
<xs:attribute name="startY" type="xs:int" default="0"/> <xs:attribute name="startY" type="xs:int" default="0"/>

View File

@ -11,7 +11,7 @@
<ToolBar prefWidth="686.0"> <ToolBar prefWidth="686.0">
<items> <items>
<Label text="Tile:" /> <Label text="Tile:" />
<ComboBox fx:id="tileSelector" minWidth="125.0" onAction="#onCurrentTileSelected" /> <ComboBox fx:id="tileSelector" minWidth="125.0" onAction="#onCurrentTileSelected" prefHeight="26.0" prefWidth="267.0" />
<Button mnemonicParsing="false" onAction="#onTileCreatePressed" text="Create new" /> <Button mnemonicParsing="false" onAction="#onTileCreatePressed" text="Create new" />
<Button mnemonicParsing="false" onAction="#onTileExportPressed" text="Export" /> <Button mnemonicParsing="false" onAction="#onTileExportPressed" text="Export" />
<Button mnemonicParsing="false" onAction="#onTileClonePressed" prefWidth="64.9998779296875" text="Clone" /> <Button mnemonicParsing="false" onAction="#onTileClonePressed" prefWidth="64.9998779296875" text="Clone" />