mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-08-26 03:28:57 +00:00
Merge branch 'master' of https://github.com/badvision/lawless-legends
This commit is contained in:
commit
bea1cc29e5
@ -4,6 +4,7 @@
|
||||
*/
|
||||
package org.badvision.outlaweditor;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import javafx.scene.control.Menu;
|
||||
import org.badvision.outlaweditor.data.xml.Image;
|
||||
import org.badvision.outlaweditor.data.xml.PlatformData;
|
||||
@ -19,6 +20,10 @@ public abstract class ImageEditor extends Editor<Image, ImageEditor.DrawMode> {
|
||||
Toggle, Pencil1px, Pencil3px, Pencil5px, Rectangle, Circle, Stamp
|
||||
}
|
||||
|
||||
abstract public EnumMap getState();
|
||||
|
||||
abstract public void setState(EnumMap oldState);
|
||||
|
||||
abstract public void buildPatternSelector(Menu tilePatternMenu);
|
||||
|
||||
public abstract void togglePanZoom();
|
||||
|
@ -4,6 +4,7 @@ import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
@ -44,6 +45,7 @@ public class AppleImageEditor extends ImageEditor implements EventHandler<MouseE
|
||||
protected double zoom = 1.0;
|
||||
protected int xScale = 2;
|
||||
protected int yScale = 2;
|
||||
public static enum StateVars{PATTERN, DRAW_MODE};
|
||||
|
||||
public Platform getPlatform() {
|
||||
return Platform.AppleII;
|
||||
@ -66,21 +68,41 @@ public class AppleImageEditor extends ImageEditor implements EventHandler<MouseE
|
||||
public void buildPatternSelector(Menu tilePatternMenu) {
|
||||
FillPattern.buildMenu(tilePatternMenu, (FillPattern object) -> {
|
||||
changeCurrentPattern(object);
|
||||
state.put(StateVars.PATTERN, object);
|
||||
});
|
||||
}
|
||||
|
||||
public void changeCurrentPattern(FillPattern pattern) {
|
||||
if (pattern == null) return;
|
||||
currentFillPattern = pattern.getBytePattern();
|
||||
hiBitMatters = pattern.hiBitMatters;
|
||||
lastActionX = -1;
|
||||
lastActionY = -1;
|
||||
}
|
||||
|
||||
EnumMap<StateVars, Object> state = new EnumMap<>(StateVars.class);
|
||||
@Override
|
||||
public EnumMap getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setState(EnumMap oldState) {
|
||||
state.putAll(oldState);
|
||||
changeCurrentPattern((FillPattern) state.get(StateVars.PATTERN));
|
||||
_setDrawMode((DrawMode) state.get(StateVars.DRAW_MODE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDrawMode(DrawMode drawMode) {
|
||||
_setDrawMode(drawMode);
|
||||
state.put(StateVars.DRAW_MODE, drawMode);
|
||||
}
|
||||
|
||||
private void _setDrawMode(DrawMode drawMode) {
|
||||
currentDrawMode = drawMode;
|
||||
lastActionX = -1;
|
||||
lastActionY = -1;
|
||||
lastActionY = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,23 +4,15 @@
|
||||
*/
|
||||
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.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javafx.beans.property.Property;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.adapter.JavaBeanBooleanProperty;
|
||||
import javafx.beans.property.adapter.JavaBeanBooleanPropertyBuilder;
|
||||
import javafx.beans.property.adapter.JavaBeanIntegerProperty;
|
||||
import javafx.beans.property.adapter.JavaBeanIntegerPropertyBuilder;
|
||||
import javafx.beans.property.adapter.JavaBeanStringProperty;
|
||||
import javafx.beans.property.adapter.JavaBeanStringPropertyBuilder;
|
||||
import org.badvision.outlaweditor.ui.ApplicationUIController;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -36,64 +28,11 @@ public class PropertyHelper {
|
||||
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 {
|
||||
return new JavaBeanStringPropertyBuilder().bean(t).name(fieldName).build();
|
||||
}
|
||||
|
||||
static private Map<Property, Property> boundProperties = new HashMap<>();
|
||||
private static final Map<Property, Property> boundProperties = new HashMap<>();
|
||||
|
||||
static public void bind(Property formProp, Property sourceProp) {
|
||||
if (boundProperties.containsKey(formProp)) {
|
||||
|
@ -45,7 +45,7 @@ public class TileUtils {
|
||||
|
||||
public static Map<Platform, WritableImage> getDisplay(Tile t) {
|
||||
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));
|
||||
}
|
||||
|
@ -3,14 +3,13 @@
|
||||
* 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.beans.binding.Bindings;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.cell.ComboBoxListCell;
|
||||
import org.badvision.outlaweditor.data.PropertyHelper;
|
||||
@ -21,27 +20,19 @@ 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) {
|
||||
static Map<TextField, Object> lastSelected = new HashMap<>();
|
||||
TextField nameField, categoryField;
|
||||
|
||||
public EntitySelectorCell(TextField tileNameField, TextField categoryNameField) {
|
||||
super.setPrefWidth(125);
|
||||
nameField = tileNameField;
|
||||
categoryField = categoryNameField;
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
updateItem(getItem(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -50,7 +41,17 @@ public abstract class EntitySelectorCell<T> extends ComboBoxListCell<T> {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null && !(item instanceof String)) {
|
||||
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) {
|
||||
Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@ -62,5 +63,5 @@ public abstract class EntitySelectorCell<T> extends ComboBoxListCell<T> {
|
||||
|
||||
public void finishUpdate(T item) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Menu;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.TextField;
|
||||
@ -37,19 +38,22 @@ public abstract class ImageEditorTabController {
|
||||
protected ComboBox<Image> imageSelector; // Value injected by FXMLLoader
|
||||
@FXML // fx:id="imageWidthField"
|
||||
protected TextField imageWidthField; // Value injected by FXMLLoader
|
||||
@FXML
|
||||
protected Label zoomLabel;
|
||||
|
||||
@FXML
|
||||
public void initalize() {
|
||||
assert imageCategoryField != null : "fx:id=\"imageCategoryField\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
||||
assert imageEditorAnchorPane != null : "fx:id=\"imageEditorAnchorPane\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
||||
assert imageHeightField != null : "fx:id=\"imageHeightField\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
||||
assert imageNameField != null : "fx:id=\"imageNameField\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
||||
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 imageEditorScrollPane != null : "fx:id\"imageEditorScrollPane\" was not injected: check your FXML file 'ApplicationUI.fxml'";
|
||||
assert imageEditorZoomGroup != null : "fx:id\"imageEditorZoomGroup\" was not injected: check your FXML file 'ApplicationUI.fxml'";
|
||||
assert imageEditorScrollAnchorPane != null : "fx:id\"imageEditorScrollAnchorPane\" was not injected: check your FXML file 'ApplicationUI.fxml'";
|
||||
assert imageCategoryField != null : "fx:id=\"imageCategoryField\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
|
||||
assert imageEditorAnchorPane != null : "fx:id=\"imageEditorAnchorPane\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
|
||||
assert imageHeightField != null : "fx:id=\"imageHeightField\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
|
||||
assert imageNameField != null : "fx:id=\"imageNameField\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
|
||||
assert imagePatternMenu != null : "fx:id=\"imagePatternMenu\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
|
||||
assert imageSelector != null : "fx:id=\"imageSelector\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
|
||||
assert imageWidthField != null : "fx:id=\"imageWidthField\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
|
||||
assert imageEditorScrollPane != null : "fx:id\"imageEditorScrollPane\" was not injected: check your FXML file 'imageEditorTab.fxml'";
|
||||
assert imageEditorZoomGroup != null : "fx:id\"imageEditorZoomGroup\" was not injected: check your FXML file 'imageEditorTab.fxml'";
|
||||
assert imageEditorScrollAnchorPane != null : "fx:id\"imageEditorScrollAnchorPane\" was not injected: check your FXML file 'imageEditorTab.fxml'";
|
||||
assert zoomLabel != null : "fx:id=\"zoomLabel\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
|
||||
}
|
||||
|
||||
abstract public void rebuildImageSelector();
|
||||
|
@ -1,18 +1,22 @@
|
||||
package org.badvision.outlaweditor.ui.impl;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import org.badvision.outlaweditor.ui.EntitySelectorCell;
|
||||
import java.util.logging.Level;
|
||||
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.scene.control.ListView;
|
||||
import javafx.scene.control.cell.ComboBoxListCell;
|
||||
import javafx.util.StringConverter;
|
||||
import org.badvision.outlaweditor.Application;
|
||||
import org.badvision.outlaweditor.Editor;
|
||||
import org.badvision.outlaweditor.ImageEditor;
|
||||
import static org.badvision.outlaweditor.Application.currentPlatform;
|
||||
import static org.badvision.outlaweditor.ui.UIAction.confirm;
|
||||
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 org.badvision.outlaweditor.data.xml.Image;
|
||||
import org.badvision.outlaweditor.ui.ImageEditorTabController;
|
||||
@ -26,31 +30,27 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
|
||||
|
||||
public Image currentImage = null;
|
||||
public ImageEditor currentImageEditor = null;
|
||||
ChangeListener rebuildListener = (ObservableValue value, Object oldValue, Object newValue) -> rebuildImageSelector();
|
||||
|
||||
/**
|
||||
* Initializes the controller class.
|
||||
*/
|
||||
public void initialize() {
|
||||
super.initalize();
|
||||
imageSelector.setButtonCell(new ComboBoxListCell<Image>() {
|
||||
{
|
||||
super.setPrefWidth(125);
|
||||
imageSelector.setCellFactory((ListView<Image> param) -> new EntitySelectorCell<Image>(imageNameField, imageCategoryField) {
|
||||
@Override
|
||||
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
|
||||
public void updateItem(Image item, boolean empty) {
|
||||
textProperty().unbind();
|
||||
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) {
|
||||
public Image fromString(String string) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -109,10 +109,15 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateZoomLabel() {
|
||||
zoomLabel.setText(String.format("%1.1fx",currentImageEditor.getZoomScale()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void imageZoomIn(ActionEvent event) {
|
||||
if (currentImageEditor != null) {
|
||||
currentImageEditor.zoomIn();
|
||||
updateZoomLabel();
|
||||
updateScrollAreaWithScale(currentImageEditor.getZoomScale());
|
||||
}
|
||||
}
|
||||
@ -121,6 +126,7 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
|
||||
public void imageZoomOut(ActionEvent event) {
|
||||
if (currentImageEditor != null) {
|
||||
currentImageEditor.zoomOut();
|
||||
updateZoomLabel();
|
||||
updateScrollAreaWithScale(currentImageEditor.getZoomScale());
|
||||
}
|
||||
}
|
||||
@ -168,9 +174,13 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
|
||||
if (currentImage != null && currentImage.equals(i)) {
|
||||
return;
|
||||
}
|
||||
imageNameField.textProperty().removeListener(rebuildListener);
|
||||
imageCategoryField.textProperty().removeListener(rebuildListener);
|
||||
imageSelector.getSelectionModel().select(i);
|
||||
currentImage = i;
|
||||
EnumMap oldEditorState = null;
|
||||
if (currentImageEditor != null) {
|
||||
oldEditorState = currentImageEditor.getState();
|
||||
currentImageEditor.unregister();
|
||||
}
|
||||
if (i == null) {
|
||||
@ -193,7 +203,7 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
|
||||
imageNameField.setDisable(false);
|
||||
imageWidthField.setDisable(false);
|
||||
bind(imageNameField.textProperty(), stringProp(i, "name"));
|
||||
bind(imageCategoryField.textProperty(), categoryProp(i, "category"));
|
||||
bind(imageCategoryField.textProperty(), stringProp(i, "category"));
|
||||
} catch (NoSuchMethodException ex) {
|
||||
Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@ -205,8 +215,13 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
|
||||
currentImageEditor.setEntity(i);
|
||||
currentImageEditor.buildEditorUI(imageEditorScrollAnchorPane);
|
||||
currentImageEditor.buildPatternSelector(imagePatternMenu);
|
||||
imageEditorZoomGroup.setScaleX(1.0);
|
||||
imageEditorZoomGroup.setScaleY(1.0);
|
||||
// imageEditorZoomGroup.setScaleX(1.0);
|
||||
// imageEditorZoomGroup.setScaleY(1.0);
|
||||
imageNameField.textProperty().addListener(rebuildListener);
|
||||
imageCategoryField.textProperty().addListener(rebuildListener);
|
||||
if (oldEditorState != null) {
|
||||
currentImageEditor.setState(oldEditorState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,7 +233,14 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
|
||||
public void rebuildImageSelector() {
|
||||
Image i = getCurrentImage();
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ import static org.badvision.outlaweditor.data.PropertyHelper.stringProp;
|
||||
import org.badvision.outlaweditor.data.TileUtils;
|
||||
import org.badvision.outlaweditor.data.xml.Map;
|
||||
import org.badvision.outlaweditor.data.xml.Script;
|
||||
import org.badvision.outlaweditor.data.xml.Tile;
|
||||
import org.badvision.outlaweditor.ui.EntitySelectorCell;
|
||||
import org.badvision.outlaweditor.ui.MapEditorTabController;
|
||||
import org.badvision.outlaweditor.ui.ToolType;
|
||||
@ -267,7 +268,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
|
||||
public void finishUpdate(Map item) {
|
||||
}
|
||||
@ -278,12 +279,12 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
||||
@Override
|
||||
public void rebuildTileSelectors() {
|
||||
mapSelectTile.getItems().clear();
|
||||
Application.gameData.getTile().stream().map((t) -> {
|
||||
Application.gameData.getTile().stream().map((Tile t) -> {
|
||||
WritableImage img = TileUtils.getImage(t, currentPlatform);
|
||||
ImageView iv = new ImageView(img);
|
||||
MenuItem mapSelectItem = new MenuItem(t.getName(), iv);
|
||||
MenuItem mapSelectItem = new MenuItem(String.valueOf(t.getCategory())+"/"+String.valueOf(t.getName()), iv);
|
||||
mapSelectItem.setGraphic(new ImageView(TileUtils.getImage(t, currentPlatform)));
|
||||
mapSelectItem.setOnAction((ActionEvent event) -> {
|
||||
mapSelectItem.setOnAction((event) -> {
|
||||
if (getCurrentEditor() != null) {
|
||||
getCurrentEditor().setCurrentTile(t);
|
||||
}
|
||||
|
@ -2,20 +2,20 @@ package org.badvision.outlaweditor.ui.impl;
|
||||
|
||||
import org.badvision.outlaweditor.ui.EntitySelectorCell;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
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 javafx.util.StringConverter;
|
||||
import org.badvision.outlaweditor.Application;
|
||||
import org.badvision.outlaweditor.TileEditor;
|
||||
import static org.badvision.outlaweditor.ui.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;
|
||||
@ -31,6 +31,8 @@ import org.badvision.outlaweditor.ui.TileEditorTabController;
|
||||
*/
|
||||
public class TileEditorTabControllerImpl extends TileEditorTabController {
|
||||
|
||||
ChangeListener rebuildListener = (ObservableValue value, Object oldValue, Object newValue) -> rebuildTileSelectors();
|
||||
|
||||
@Override
|
||||
public void onCurrentTileSelected(ActionEvent event) {
|
||||
setCurrentTile(tileSelector.getSelectionModel().getSelectedItem());
|
||||
@ -48,7 +50,7 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
|
||||
t.setObstruction(getCurrentTile().isObstruction());
|
||||
t.setSprite(getCurrentTile().isSprite());
|
||||
t.setBlocker(getCurrentTile().isBlocker());
|
||||
t.getCategory().addAll(getCurrentTile().getCategory());
|
||||
t.setCategory(getCurrentTile().getCategory());
|
||||
getCurrentTile().getDisplayData().stream().map((d) -> {
|
||||
PlatformData p = new PlatformData();
|
||||
p.setHeight(d.getHeight());
|
||||
@ -90,7 +92,6 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
|
||||
|
||||
@Override
|
||||
public void tileBitMode(ActionEvent event) {
|
||||
ApplicationUIController mainController = ApplicationUIController.getController();
|
||||
if (getCurrentTileEditor() != null) {
|
||||
getCurrentTileEditor().setDrawMode(TileEditor.DrawMode.Toggle);
|
||||
}
|
||||
@ -98,7 +99,6 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
|
||||
|
||||
@Override
|
||||
public void tileDraw1BitMode(ActionEvent event) {
|
||||
ApplicationUIController mainController = ApplicationUIController.getController();
|
||||
if (getCurrentTileEditor() != null) {
|
||||
getCurrentTileEditor().setDrawMode(TileEditor.DrawMode.Pencil1px);
|
||||
}
|
||||
@ -106,7 +106,6 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
|
||||
|
||||
@Override
|
||||
public void tileDraw3BitMode(ActionEvent event) {
|
||||
ApplicationUIController mainController = ApplicationUIController.getController();
|
||||
if (getCurrentTileEditor() != null) {
|
||||
getCurrentTileEditor().setDrawMode(TileEditor.DrawMode.Pencil3px);
|
||||
}
|
||||
@ -114,7 +113,6 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
|
||||
|
||||
@Override
|
||||
public void tileShift(ActionEvent event) {
|
||||
ApplicationUIController mainController = ApplicationUIController.getController();
|
||||
if (getCurrentTileEditor() != null) {
|
||||
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 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((ListView<Tile> param) -> {
|
||||
return new EntitySelectorCell<Tile>(tileNameField) {
|
||||
return new EntitySelectorCell<Tile>(tileNameField, tileCategoryField) {
|
||||
@Override
|
||||
public void finishUpdate(Tile item) {
|
||||
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
|
||||
@ -176,6 +168,8 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
|
||||
|
||||
@Override
|
||||
public void setCurrentTile(Tile t) {
|
||||
tileNameField.textProperty().removeListener(rebuildListener);
|
||||
tileCategoryField.textProperty().removeListener(rebuildListener);
|
||||
tileSelector.getSelectionModel().select(t);
|
||||
if (t != null && t.equals(getCurrentTile())) {
|
||||
return;
|
||||
@ -188,6 +182,7 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
|
||||
bind(tileSpriteField.selectedProperty(), null);
|
||||
bind(tileBlockerField.selectedProperty(), null);
|
||||
bind(tileNameField.textProperty(), null);
|
||||
|
||||
tileIdField.setDisable(true);
|
||||
tileCategoryField.setDisable(true);
|
||||
tileObstructionField.setDisable(true);
|
||||
@ -213,7 +208,7 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
|
||||
tileBlockerField.setDisable(false);
|
||||
tileNameField.setDisable(false);
|
||||
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(tileSpriteField.selectedProperty(), boolProp(t, "sprite"));
|
||||
bind(tileBlockerField.selectedProperty(), boolProp(t, "blocker"));
|
||||
@ -221,6 +216,8 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
|
||||
TileEditor editor = Application.currentPlatform.tileEditor.newInstance();
|
||||
editor.setEntity(t);
|
||||
setCurrentTileEditor(editor);
|
||||
tileNameField.textProperty().addListener(rebuildListener);
|
||||
tileCategoryField.textProperty().addListener(rebuildListener);
|
||||
} catch (NoSuchMethodException ex) {
|
||||
Logger.getLogger(ApplicationUIController.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException | IllegalAccessException ex) {
|
||||
@ -233,7 +230,15 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
|
||||
@Override
|
||||
public void rebuildTileSelectors() {
|
||||
tileSelector.getItems().clear();
|
||||
tileSelector.getItems().addAll(Application.gameData.getTile());
|
||||
tileSelector.getSelectionModel().select(getCurrentTile());
|
||||
List<Tile> allTiles = Application.gameData.getTile();
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.effect.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import java.util.*?>
|
||||
<?import javafx.scene.*?>
|
||||
@ -13,7 +14,7 @@
|
||||
<ToolBar prefWidth="686.0">
|
||||
<items>
|
||||
<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="#onImageClonePressed" text="Clone" />
|
||||
<Button mnemonicParsing="false" onAction="#onImageExportPressed" text="Export" />
|
||||
@ -67,6 +68,11 @@
|
||||
</ScrollPane>
|
||||
<Button layoutX="433.0" layoutY="5.0" mnemonicParsing="false" onAction="#imageZoomIn" styleClass="zoomInButton" text="+" AnchorPane.rightAnchor="18.0" AnchorPane.topAnchor="5.0" />
|
||||
<Button layoutX="435.0" layoutY="37.0" mnemonicParsing="false" onAction="#imageZoomOut" prefHeight="23.999908447265625" styleClass="zoomOutButton" text="-" AnchorPane.rightAnchor="18.0" AnchorPane.topAnchor="37.0" />
|
||||
<Label fx:id="zoomLabel" alignment="CENTER" layoutX="428.0" layoutY="69.0" prefHeight="16.0" prefWidth="39.0" text="1x" textFill="WHITE" AnchorPane.rightAnchor="18.0" AnchorPane.topAnchor="69.0">
|
||||
<effect>
|
||||
<DropShadow blurType="ONE_PASS_BOX" color="#000240" height="12.0" radius="5.0" spread="0.5" width="10.0" />
|
||||
</effect>
|
||||
</Label>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
|
@ -4,10 +4,10 @@
|
||||
elementFormDefault="qualified" targetNamespace="outlaw" xmlns:tns="outlaw" attributeFormDefault="unqualified">
|
||||
<xs:complexType name="image">
|
||||
<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:sequence>
|
||||
<xs:attribute name="name" type="xs:NMTOKEN"/>
|
||||
<xs:attribute name="category" type="xs:string"/>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="tile">
|
||||
<xs:complexContent>
|
||||
@ -32,6 +32,7 @@
|
||||
<xs:sequence>
|
||||
<xs:element name="name" type="xs:string"/>
|
||||
<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="locationTrigger" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
@ -71,6 +72,7 @@
|
||||
<xs:attribute name="name" type="xs:string"/>
|
||||
<xs:attribute name="width" 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="startX" type="xs:int" default="0"/>
|
||||
<xs:attribute name="startY" type="xs:int" default="0"/>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<ToolBar prefWidth="686.0">
|
||||
<items>
|
||||
<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="#onTileExportPressed" text="Export" />
|
||||
<Button mnemonicParsing="false" onAction="#onTileClonePressed" prefWidth="64.9998779296875" text="Clone" />
|
||||
|
@ -8,7 +8,7 @@ The Apache license covers everything in here, including any sample game content
|
||||
Download Links
|
||||
--------------
|
||||
|
||||
- The most recent copy of Outlaw Editor (aka the Daily build) can be found here: https://www.dropbox.com/s/2bhoxqrqjjehmqb/OutlawEditor-jfx.jar
|
||||
- The most recent copy of Outlaw Editor (aka the Daily build) can be found here: https://www.dropbox.com/s/zrystud66myzlwa/OutlawEditor-jfx.jar?dl=0
|
||||
- Live builds of the Apple platform code (AKA the Apple // series game port) will soon be available
|
||||
- Download the 2014 KFest playable demo disk here: https://www.dropbox.com/s/j7pwpgweu65i4md/Lawless%20Legends%20-%20KFest%20playable%20demo%20-%20v0_50.dsk
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user