diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ImageEditor.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ImageEditor.java index 89dab96a..8d496239 100644 --- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ImageEditor.java +++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ImageEditor.java @@ -11,6 +11,8 @@ package org.badvision.outlaweditor; import java.util.EnumMap; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; import javafx.scene.control.Menu; import org.badvision.outlaweditor.data.xml.Image; import org.badvision.outlaweditor.data.xml.PlatformData; @@ -52,4 +54,9 @@ public abstract class ImageEditor extends Editor { } return null; } + + StringProperty cursorInfo = new SimpleStringProperty(); + public StringProperty cursorInfoProperty() { + return cursorInfo; + } } diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/MapEditor.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/MapEditor.java index c3dbacd6..f0773929 100644 --- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/MapEditor.java +++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/MapEditor.java @@ -18,6 +18,8 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; import javafx.application.Platform; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; import javafx.beans.value.ObservableValue; import javafx.event.EventHandler; import javafx.scene.Group; @@ -508,6 +510,12 @@ public class MapEditor extends Editor implements EventH } } } + + StringProperty cursorInfo = new SimpleStringProperty(); + public StringProperty cursorInfoProperty() { + return cursorInfo; + } + public static Rectangle selectRect = null; public double selectStartX = 0; public double selectStartY = 0; @@ -564,14 +572,15 @@ public class MapEditor extends Editor implements EventH @Override public void handle(MouseEvent t) { + int x = (int) (t.getX() / tileWidth) + posX; + int y = (int) (t.getY() / tileHeight) + posY; updateCursorAssistant(t); + cursorInfo.set("X="+x+" Y="+y); if (!t.isPrimaryButtonDown() && drawMode != DrawMode.FilledRect && t.getEventType() != MouseEvent.MOUSE_RELEASED) return; if (getCurrentTile() == null && drawMode != DrawMode.Eraser) { return; } t.consume(); - int x = (int) (t.getX() / tileWidth) + posX; - int y = (int) (t.getY() / tileHeight) + posY; boolean canSkip = false; if (getCurrentTile() == lastTile && x == lastX && y == lastY && drawMode == lastDrawMode) { canSkip = true; diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/apple/AppleImageEditor.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/apple/AppleImageEditor.java index 699e7f3d..e0736591 100644 --- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/apple/AppleImageEditor.java +++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/apple/AppleImageEditor.java @@ -75,6 +75,7 @@ public class AppleImageEditor extends ImageEditor implements EventHandler 3 || (pasteX + (xEnd-xStart)/7) < getWidth()) { + if ((xStart % 2) != pasteX % 2) { + if (pasteX == 0 || pasteX % 7 > 3 || (pasteX + (xEnd - xStart) / 7) < getWidth()) { pasteX++; } else { pasteX--; } } - System.out.println("Paste to "+pasteX+","+pasteY); + System.out.println("Paste to " + pasteX + "," + pasteY); for (int sourceY = yStart, targetY = pasteY; sourceY <= yEnd; sourceY++, targetY++) { if (targetY < 0 || targetY >= getHeight()) { continue; @@ -511,11 +519,11 @@ public class AppleImageEditor extends ImageEditor implements EventHandler= getWidth()) { + if (targetX < 0 || targetX / 7 >= getWidth()) { continue; } - int targetLoc = targetRow + targetX/7; - byte sourceByte = sourceData[sourceRow + sourceX/7]; + int targetLoc = targetRow + targetX / 7; + byte sourceByte = sourceData[sourceRow + sourceX / 7]; byte targetByte = targetData[targetLoc]; int targetBit = targetX % 7; int sourceBit = sourceX % 7; diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/ImageEditorTabController.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/ImageEditorTabController.java index b7336f39..6e5032c5 100644 --- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/ImageEditorTabController.java +++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/ImageEditorTabController.java @@ -10,6 +10,8 @@ package org.badvision.outlaweditor.ui; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.Group; @@ -50,6 +52,8 @@ public abstract class ImageEditorTabController { protected TextField imageWidthField; // Value injected by FXMLLoader @FXML protected Label zoomLabel; + @FXML + protected Label cursorInfo; @FXML public void initalize() { @@ -64,6 +68,7 @@ public abstract class ImageEditorTabController { 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'."; + assert cursorInfo != null : "fx:id=\"cursorInfo\" was not injected: check your FXML file 'imageEditorTab.fxml'."; } abstract public void rebuildImageSelector(); diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/MapEditorTabController.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/MapEditorTabController.java index 9aa2d390..9d197bb9 100644 --- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/MapEditorTabController.java +++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/MapEditorTabController.java @@ -15,6 +15,7 @@ import javafx.fxml.FXML; import javafx.scene.control.Button; import javafx.scene.control.CheckBox; import javafx.scene.control.ComboBox; +import javafx.scene.control.Label; import javafx.scene.control.ListView; import javafx.scene.control.Menu; import javafx.scene.control.TextField; @@ -65,6 +66,8 @@ public abstract class MapEditorTabController { protected CheckBox mapWrapAround; // Value injected by FXMLLoader @FXML protected Button scriptEraseTool; + @FXML + protected Label cursorInfo; @FXML abstract public void mapEraser(ActionEvent event); @@ -152,6 +155,7 @@ public abstract class MapEditorTabController { assert mapSelectTile != null : "fx:id=\"mapSelectTile\" was not injected: check your FXML file 'mapEditorTab.fxml'."; assert mapWidthField != null : "fx:id=\"mapWidthField\" was not injected: check your FXML file 'mapEditorTab.fxml'."; assert mapWrapAround != null : "fx:id=\"mapWrapAround\" was not injected: check your FXML file 'mapEditorTab.fxml'."; + assert cursorInfo != null : "fx:id=\"cursorInfo\" was not injected: check your FXML file 'imageEditorTab.fxml'."; } abstract public void rebuildTileSelectors(); diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/impl/ImageEditorTabControllerImpl.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/impl/ImageEditorTabControllerImpl.java index 3d37a66c..7e05511e 100644 --- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/impl/ImageEditorTabControllerImpl.java +++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/impl/ImageEditorTabControllerImpl.java @@ -11,10 +11,8 @@ 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; @@ -22,16 +20,16 @@ import javafx.scene.control.ListView; import javafx.util.StringConverter; import javax.xml.bind.JAXBException; import org.badvision.outlaweditor.Application; +import static org.badvision.outlaweditor.Application.currentPlatform; import org.badvision.outlaweditor.Editor; import org.badvision.outlaweditor.ImageEditor; -import static org.badvision.outlaweditor.Application.currentPlatform; import org.badvision.outlaweditor.TransferHelper; -import static org.badvision.outlaweditor.ui.UIAction.confirm; import static org.badvision.outlaweditor.data.PropertyHelper.bind; import static org.badvision.outlaweditor.data.PropertyHelper.stringProp; -import org.badvision.outlaweditor.data.xml.GameData; import org.badvision.outlaweditor.data.xml.Image; +import org.badvision.outlaweditor.ui.EntitySelectorCell; import org.badvision.outlaweditor.ui.ImageEditorTabController; +import static org.badvision.outlaweditor.ui.UIAction.confirm; /** * FXML Controller class @@ -205,6 +203,8 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController { if (currentImageEditor != null) { oldEditorState = currentImageEditor.getState(); currentImageEditor.unregister(); + cursorInfo.textProperty().unbind(); + cursorInfo.setText(""); } if (i == null) { bind(imageCategoryField.textProperty(), null); @@ -216,6 +216,8 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController { imageNameField.setDisable(true); imageWidthField.setDisable(true); currentImageEditor = null; + cursorInfo.textProperty().unbind(); + cursorInfo.setText(""); } else { if (i.getName() == null) { i.setName("Untitled"); @@ -246,6 +248,7 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController { currentImageEditor.setState(oldEditorState); } } + cursorInfo.textProperty().bind(currentImageEditor.cursorInfoProperty()); } private Image getCurrentImage() { diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/impl/MapEditorTabControllerImpl.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/impl/MapEditorTabControllerImpl.java index 8eb293c4..0dfdc121 100644 --- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/impl/MapEditorTabControllerImpl.java +++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/impl/MapEditorTabControllerImpl.java @@ -286,6 +286,8 @@ public class MapEditorTabControllerImpl extends MapEditorTabController { mapWidthField.setDisable(true); mapWrapAround.setDisable(true); setCurrentEditor(null); + cursorInfo.textProperty().unbind(); + cursorInfo.setText(""); } else { if (m.getScripts() != null) { DataUtilities.sortNamedEntities(m.getScripts().getScript()); @@ -321,6 +323,7 @@ public class MapEditorTabControllerImpl extends MapEditorTabController { if (currentTile != null) { e.setCurrentTile(currentTile); } + cursorInfo.textProperty().bind(e.cursorInfoProperty()); } redrawMapScripts(); } diff --git a/OutlawEditor/src/main/resources/imageEditorTab.fxml b/OutlawEditor/src/main/resources/imageEditorTab.fxml index ff3b9680..a611b457 100644 --- a/OutlawEditor/src/main/resources/imageEditorTab.fxml +++ b/OutlawEditor/src/main/resources/imageEditorTab.fxml @@ -7,14 +7,14 @@ - +