diff --git a/.gitignore b/.gitignore
index ec5693fa..1cd19134 100644
--- a/.gitignore
+++ b/.gitignore
@@ -64,7 +64,15 @@ error_stack.txt
# Hey, don't include the commercial game data you ninny!
/Platform/Apple/tools/jace/src/main/resources/jace/data/game.2mg
+Platform/Apple/tools/PackPartitions/game*
+Platform/Apple/tools/PackPartitions/font*
+Platform/Apple/tools/PackPartitions/pack_report.txt
+Platform/Apple/tools/PackPartitions/world.xml
# Ignore NetBeans project files
Platform/Apple/tools/jace/nb-configuration.xml
Platform/Apple/tools/jace/nbactions.xml
+
+# Ignore temporary pom files
+Platform/Apple/tools/jace/runPom.xml
+Platform/Apple/tools/jace/*.log
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 00000000..9bd06c2e
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,4 @@
+{
+ "java.configuration.updateBuildConfiguration": "automatic",
+ "java.debug.settings.onBuildFailureProceed": true
+}
\ No newline at end of file
diff --git a/OutlawEditor/.java-version b/OutlawEditor/.java-version
index 62593409..2f32724e 100644
--- a/OutlawEditor/.java-version
+++ b/OutlawEditor/.java-version
@@ -1 +1 @@
-1.8
+graalvm64-17.0.6
diff --git a/OutlawEditor/OutlawPluginExample/pom.xml b/OutlawEditor/OutlawPluginExample/pom.xml
deleted file mode 100644
index f1c459c0..00000000
--- a/OutlawEditor/OutlawPluginExample/pom.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-
- 4.0.0
-
- org.badvision
- OutlawPluginExample
- 0.1
- bundle
-
- Outlaw Plugin Example
-
-
- UTF-8
- 1.8
- 1.8
-
-
-
-
-
- org.apache.felix
- maven-bundle-plugin
- 3.0.1
- true
-
-
- org.badvision.outlaw.plugin.example
- org.badvision.outlaw.plugin.example.Activator
- *
-
-
-
-
- org.apache.felix
- maven-scr-plugin
- 1.22.0
-
-
- generate-scr-scrdescriptor
-
- scr
-
-
-
- 8-Bit Bunch
-
-
-
-
-
-
-
-
-
-
- org.badvision
- OutlawEditor
- 1.0-SNAPSHOT
-
-
- org.apache.felix
- org.apache.felix.scr.annotations
- 1.10.0
-
-
- org.apache.felix
- org.apache.felix.main
- 5.4.0
-
-
-
diff --git a/OutlawEditor/OutlawPluginExample/src/main/java/org/badvision/outlaw/plugin/example/Activator.java b/OutlawEditor/OutlawPluginExample/src/main/java/org/badvision/outlaw/plugin/example/Activator.java
deleted file mode 100644
index ba30b341..00000000
--- a/OutlawEditor/OutlawPluginExample/src/main/java/org/badvision/outlaw/plugin/example/Activator.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.badvision.outlaw.plugin.example;
-
-import org.badvision.outlaweditor.api.ApplicationState;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-/**
- * This is an example activator class, provided to demonstrate basic bundle lifecycle events.
- * Since we're using declarative servies (Felix SCR), all the messy bits of service registration
- * and reference passing are managed for us. Otherwise we'd be doing that here. Fortunately,
- * we don't have to do all that.
- *
- * Still, this is a useful mechanism if you have some one-time setup or shutdown concerns that apply
- * to your whole bundle, such as reading configuration data from a file or whatever.
- *
- * @author blurry
- */
-public class Activator implements BundleActivator {
- @Override
- public void start(BundleContext bc) throws Exception {
- System.out.println("Hello, plugin!");
- checkReferences();
- }
-
- @Override
- public void stop(BundleContext bc) throws Exception {
- System.out.println("Goodbye, plugin!");
- }
-
- private void checkReferences() {
- // Note that our activator is not a component, so we can't use the @Reference
- // annotation to inject app automatically. ApplicationState has a convenience
- // method to get around this in just such events, but it's a hack.
- // Ultimately it's not a good idea to rely on this too much as it follows
- // some bad practices behind the scene that leave unclosed references, etc.
- // I'll have to come up with a safer way to inject dependencies without
- // causing housekeeping issues for OSGi.
- ApplicationState app = ApplicationState.getInstance();
- if (app == null) {
- System.out.println("App is null?!?!");
- } else if (app.getCurrentPlatform() == null) {
- System.out.println("Current platform is null?");
- } else {
- System.out.println("Current platform is " + app.getCurrentPlatform());
- }
- }
-}
diff --git a/OutlawEditor/OutlawPluginExample/src/main/java/org/badvision/outlaw/plugin/example/ExamplePlugin.java b/OutlawEditor/OutlawPluginExample/src/main/java/org/badvision/outlaw/plugin/example/ExamplePlugin.java
deleted file mode 100644
index dee8e2f5..00000000
--- a/OutlawEditor/OutlawPluginExample/src/main/java/org/badvision/outlaw/plugin/example/ExamplePlugin.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.badvision.outlaw.plugin.example;
-
-import javafx.event.ActionEvent;
-import javax.xml.bind.JAXB;
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.Service;
-import org.badvision.outlaweditor.api.ApplicationState;
-import org.badvision.outlaweditor.api.MenuAction;
-import org.badvision.outlaweditor.ui.UIAction;
-import org.osgi.framework.BundleContext;
-
-/**
- * This registers a simple plugin that does nothing more than print a message to
- * the console when executed. However, this plugin also demonstrates how to
- * inject dependencies to more useful features, specifically the
- * ApplicationState which in turn provides all game data, etc.
- *
- * @author blurry
- */
-@Component(immediate = true)
-@Service(MenuAction.class)
-public class ExamplePlugin implements MenuAction {
-
- // Note: Because ApplicationState is already a defined service, this will automatically be bound.
- // Hence, it is not necessary to worry about passing it it.
- @Reference
- ApplicationState app;
-
- // This is called when our plugin is starting
- @Activate
- public void activate() throws Exception {
- System.out.println("Hello, menu!");
- checkReferences();
- }
-
- // This is called when our plugin is stopping
- @Deactivate
- public void stop(BundleContext bc) throws Exception {
- System.out.println("Goodbye, menu!");
- }
-
- // This identifies the menu item label
- @Override
- public String getName() {
- return "Example action";
- }
-
- // This method is called when the user selects the menu item
- @Override
- public void handle(ActionEvent event) {
- System.out.println("Clicked!");
- JAXB.marshal(ApplicationState.getInstance().getGameData(), System.out);
- checkReferences();
- UIAction.confirm("Did you mean to click that?",
- () -> UIAction.alert("Well isn't that special?"),
- () -> UIAction.alert("You should be more careful next time then."));
- }
-
- private void checkReferences() {
-// app = ApplicationState.getInstance();
- if (app == null) {
- System.out.println("App is null?!?!");
- } else if (app.getCurrentPlatform() == null) {
- System.out.println("Current platform is null?");
- } else {
- System.out.println("Current platform is " + app.getCurrentPlatform());
- }
- }
-}
diff --git a/OutlawEditor/pom.xml b/OutlawEditor/pom.xml
index 81fc9d10..1f5e7734 100644
--- a/OutlawEditor/pom.xml
+++ b/OutlawEditor/pom.xml
@@ -5,11 +5,13 @@
OutlawEditor
OutlawEditor
jar
- 2.0-SNAPSHOT
+ 3.0
UTF-8
org.badvision.outlaweditor.Application
apache20
+ 21-ea+31
+ 5.2.3
@@ -20,110 +22,82 @@
OutlawEditor
- org.apache.felix
- maven-scr-plugin
- 1.26.4
-
-
- generate-scr-scrdescriptor
-
- scr
-
-
-
- 8-Bit Bunch
-
-
-
-
+ com.gluonhq
+ gluonfx-maven-plugin
+ 1.0.24
+
+ ${mainClass}
+
+
+
+
+
+
+
- org.apache.felix
- maven-bundle-plugin
- 5.1.2
- true
+ org.openjfx
+ javafx-maven-plugin
+ 0.0.8
-
- org.badvision.outlaweditor,org.badvision.outlaweditor.ui.impl,org.badvision.outlaweditor.ui.apple
- org.badvision.outlaweditor.api,org.badvision.outlaweditor.data.xml,org.badvision.outlaweditor.data,org.badvision.outlaweditor.ui
-
+ ${mainClass}
+
+
+
+
+
+
org.apache.maven.plugins
- maven-dependency-plugin
- 3.1.2
+ maven-compiler-plugin
+
+ 17
+ 17
+
+ 3.13.0
+
+
+ org.codehaus.mojo
+ jaxb2-maven-plugin
+ 3.2.0
- unpack-dependencies
- prepare-package
+ xjc
- unpack-dependencies
+ xjc
-
- META-INF/*.SF,META-INF/*.DSA,META-INF/*.RSA
- system
- junit,org.mockito,org.hamcrest
- ${project.build.directory}/classes
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
-
-
- ${mainClass}
-
-
+ src/main/resources/jaxb
+ org.badvision.outlaweditor.data.xml
- 3.2.0
org.apache.maven.plugins
- maven-compiler-plugin
-
- 1.8
- 1.8
-
+ maven-dependency-plugin
3.8.1
-
-
- org.jvnet.jaxb2.maven2
- maven-jaxb2-plugin
- 0.14.0
+ copy-dependencies
+ package
- generate
+ copy-dependencies
-
- jaxb/OutlawSchema/*.xsd
-
- ${project.build.directory}/generated-sources/xjc/META-INF/jaxb-OutlawSchema.episode
- org.badvision.outlaweditor.data.xml
-
- -Xcopyable
- -Xmergeable
-
-
-
- org.jvnet.jaxb2_commons
- jaxb2-basics
- 0.12.0
-
-
+ ${project.build.directory}/lib
+ false
+ false
+ true
+ compile
- jaxb-generate-OutlawSchema
-
junit
@@ -133,44 +107,34 @@
jar
- org.jvnet.jaxb2_commons
- jaxb2-basics
- 0.12.0
-
-
- org.apache.felix
- org.apache.felix.framework
- 5.6.10
-
-
- org.apache.felix
- org.apache.felix.main
- 5.6.10
+ jakarta.xml.bind
+ jakarta.xml.bind-api
+ 4.0.2
- org.apache.felix
- org.apache.felix.scr.annotations
- 1.12.0
+ org.glassfish.jaxb
+ jaxb-runtime
+ 4.0.5
- org.apache.felix
- org.apache.felix.scr
- 2.1.26
+ org.controlsfx
+ controlsfx
+ 11.2.1
- org.apache.poi
- poi
- 5.0.0
+ org.openjfx
+ javafx-controls
+ ${javafx.version}
- org.apache.poi
- poi-ooxml
- 5.0.0
+ org.openjfx
+ javafx-web
+ ${javafx.version}
- org.controlsfx
- controlsfx
- 8.40.18
+ org.openjfx
+ javafx-fxml
+ ${javafx.version}
\ No newline at end of file
diff --git a/OutlawEditor/src/main/java/module-info.java b/OutlawEditor/src/main/java/module-info.java
new file mode 100644
index 00000000..6d801b1a
--- /dev/null
+++ b/OutlawEditor/src/main/java/module-info.java
@@ -0,0 +1,23 @@
+module outlaweditor {
+ requires javafx.controls;
+ requires javafx.graphics;
+ requires javafx.web;
+ requires javafx.media;
+ requires javafx.fxml;
+ requires java.logging;
+ requires java.desktop;
+ requires java.scripting;
+ requires java.xml;
+ requires jdk.jsobject;
+ requires jakarta.xml.bind;
+ requires org.glassfish.jaxb.runtime;
+
+ requires org.controlsfx.controls;
+ // requires org.apache.poi.ooxml;
+
+ opens org.badvision.outlaweditor to javafx.graphics, javafx.fxml, javafx.web, org.apache.poi.ooxml;
+ opens org.badvision.outlaweditor.ui to javafx.fxml;
+ opens org.badvision.outlaweditor.ui.impl to javafx.fxml;
+ opens org.badvision.outlaweditor.data to jakarta.xml.bind;
+ opens org.badvision.outlaweditor.data.xml to javafx.base, jakarta.xml.bind, javafx.web;
+}
\ No newline at end of file
diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/Application.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/Application.java
index 35800f0e..066fae0b 100644
--- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/Application.java
+++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/Application.java
@@ -10,54 +10,59 @@
package org.badvision.outlaweditor;
import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+
+import org.badvision.outlaweditor.api.ApplicationState;
+import org.badvision.outlaweditor.api.Platform;
+import org.badvision.outlaweditor.data.xml.GameData;
+import org.badvision.outlaweditor.ui.ApplicationUIController;
+
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
-import org.apache.felix.framework.Felix;
-import org.apache.felix.framework.util.FelixConstants;
-import org.apache.felix.main.AutoProcessor;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Service;
-import org.apache.felix.scr.impl.Activator;
-import org.badvision.outlaweditor.api.ApplicationState;
-import org.badvision.outlaweditor.api.MenuAction;
-import org.badvision.outlaweditor.api.Platform;
-import org.badvision.outlaweditor.data.xml.GameData;
-import org.badvision.outlaweditor.ui.ApplicationUIController;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.launch.Framework;
-import org.osgi.util.tracker.ServiceTracker;
+// import org.apache.felix.scr.annotations.Component;
+// import org.apache.felix.scr.annotations.Service;
+// import org.apache.felix.scr.impl.Activator;
+// import org.badvision.outlaweditor.api.ApplicationState;
+// import org.badvision.outlaweditor.api.MenuAction;
+// import org.badvision.outlaweditor.api.Platform;
+// import org.badvision.outlaweditor.data.xml.GameData;
+// import org.badvision.outlaweditor.ui.ApplicationUIController;
+// import org.apache.felix.framework.Felix;
+// import org.apache.felix.framework.util.FelixConstants;
+// import org.apache.felix.main.AutoProcessor;
+// import org.osgi.framework.BundleActivator;
+// import org.osgi.framework.BundleContext;
+// import org.osgi.framework.BundleException;
+// import org.osgi.framework.launch.Framework;
+// import org.osgi.util.tracker.ServiceTracker;
/**
*
* @author brobert
*/
-@Component
-@Service(org.badvision.outlaweditor.api.ApplicationState.class)
-public class Application extends javafx.application.Application implements ApplicationState, BundleActivator {
+// @Component
+// @Service(org.badvision.outlaweditor.api.ApplicationState.class)
+public class Application extends javafx.application.Application implements ApplicationState/*, BundleActivator*/ {
- public static Framework felix;
+ // public static Framework felix;
private GameData gameData = new GameData();
private Platform currentPlatform = Platform.AppleII;
private ApplicationUIController controller;
private Stage primaryStage;
public static void shutdown() {
+ /*
try {
felix.stop();
felix.waitForStop(0L);
} catch (BundleException | InterruptedException ex) {
Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex);
}
+ */
}
+ public static ApplicationState applicationStateSingleton;
@Override
public GameData getGameData() {
@@ -96,16 +101,17 @@ public Stage getPrimaryStage() {
@Override
public void start(Stage primaryStage) {
+ applicationStateSingleton = this;
this.primaryStage = primaryStage;
javafx.application.Platform.setImplicitExit(true);
-
+/*
try {
startPluginContainer();
} catch (Exception ex) {
Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex);
throw new RuntimeException(ex);
}
-
+*/
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/ApplicationUI.fxml"));
fxmlLoader.setResources(null);
try {
@@ -135,6 +141,7 @@ public static void main(String[] args) {
launch(args);
}
+/*
ServiceTracker tracker;
private void startPluginContainer() throws BundleException, Exception {
Map config = new HashMap<>();
@@ -175,4 +182,5 @@ public void start(BundleContext bc) throws Exception {
@Override
public void stop(BundleContext bc) throws Exception {
}
+*/
}
diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/Editor.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/Editor.java
index e0a6bad9..dda36c6a 100644
--- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/Editor.java
+++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/Editor.java
@@ -13,12 +13,13 @@
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javafx.scene.layout.Pane;
-import javax.xml.bind.JAXBException;
+
import org.badvision.outlaweditor.data.DataObserver;
import org.badvision.outlaweditor.data.DataProducer;
import org.badvision.outlaweditor.data.xml.Script;
-import org.jvnet.jaxb2_commons.lang.CopyTo2;
+
+import jakarta.xml.bind.JAXBException;
+import javafx.scene.layout.Pane;
/**
* Extremely generic editor abstraction -- useful for uniform edit features
@@ -107,13 +108,15 @@ protected void trackState() {
public void undo() {
if (!undoStates.isEmpty()) {
- CopyTo2 undoState = (CopyTo2) undoStates.removeFirst();
- undoState.copyTo(getEntity());
+ T undoState = undoStates.removeFirst();
+ copyEntityFrom(undoState);
onEntityUpdated();
redraw();
}
}
+ public abstract void copyEntityFrom(T copyFrom);
+
protected void onEntityUpdated() {
}
diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/GlobalEditor.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/GlobalEditor.java
index ccb4145f..60f55828 100644
--- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/GlobalEditor.java
+++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/GlobalEditor.java
@@ -99,5 +99,9 @@ private GameData getGameData() {
public void copyData() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
-
+
+ @Override
+ public void copyEntityFrom(Global src) {
+ throw new UnsupportedOperationException("Not supported."); //To change body of generated methods, choose Tools | Templates.
+ }
}
diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ImageEditor.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ImageEditor.java
index 09f48fd3..83bf6602 100644
--- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ImageEditor.java
+++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ImageEditor.java
@@ -79,4 +79,14 @@ public void registerPatternSelectorModal(Pane pane, PatternSelectModal modal) {
public void showSelectorModal() {
patternSelectModal.showPatternSelectModal(targetPane);
}
+
+ @Override
+ public void copyEntityFrom(Image src) {
+ Image dest = getEntity();
+ dest.setCategory(src.getCategory());
+ dest.setComment(src.getComment());
+ dest.setName(src.getName());
+ dest.getDisplayData().clear();
+ dest.getDisplayData().addAll(src.getDisplayData());
+ }
}
diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/MapEditor.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/MapEditor.java
index fe6531c0..83f32aff 100644
--- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/MapEditor.java
+++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/MapEditor.java
@@ -17,6 +17,18 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
+
+import org.badvision.outlaweditor.api.ApplicationState;
+import org.badvision.outlaweditor.data.TileMap;
+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.Scripts;
+import org.badvision.outlaweditor.data.xml.Tile;
+import org.badvision.outlaweditor.ui.TileSelectModal;
+import org.badvision.outlaweditor.ui.ToolType;
+
+import jakarta.xml.bind.JAXBException;
import javafx.application.Platform;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
@@ -42,16 +54,6 @@
import javafx.scene.paint.Paint;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
-import javax.xml.bind.JAXBException;
-import org.badvision.outlaweditor.api.ApplicationState;
-import org.badvision.outlaweditor.data.TileMap;
-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.Scripts;
-import org.badvision.outlaweditor.data.xml.Tile;
-import org.badvision.outlaweditor.ui.TileSelectModal;
-import org.badvision.outlaweditor.ui.ToolType;
/**
*
@@ -101,7 +103,7 @@ public void setDrawMode(DrawMode drawMode) {
this.drawMode = drawMode;
switch (drawMode) {
case TileEraser:
- ImageCursor cursor = new ImageCursor(new Image("images/eraser.png"));
+ ImageCursor cursor = new ImageCursor(new Image(MapEditor.class.getResourceAsStream("/images/eraser.png")));
drawCanvas.setCursor(cursor);
break;
case Select:
@@ -815,4 +817,21 @@ public void handle(MouseEvent t) {
}
}
+
+ @Override
+ public void copyEntityFrom(Map src) {
+ Map dest = getEntity();
+ dest.setCategory(src.getCategory());
+ dest.setDisplay3D(src.isDisplay3D());
+ dest.setHeight(src.getHeight());
+ dest.setName(src.getName());
+ dest.setOrder(src.getOrder());
+ dest.setScripts(src.getScripts());
+ dest.setStartX(src.getStartX());
+ dest.setStartY(src.getStartY());
+ dest.setVariables(src.getVariables());
+ dest.setWidth(src.getWidth());
+ dest.getChunk().clear();
+ dest.getChunk().addAll(src.getChunk());
+ }
}
diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/MythosEditor.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/MythosEditor.java
index 281d0cc3..8812d430 100644
--- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/MythosEditor.java
+++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/MythosEditor.java
@@ -13,9 +13,7 @@
import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
import java.util.logging.Level;
@@ -23,19 +21,12 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import javafx.fxml.FXMLLoader;
-import javafx.scene.Scene;
-import javafx.scene.layout.AnchorPane;
-import javafx.stage.Stage;
-import javafx.stage.WindowEvent;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
+
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+
import org.badvision.outlaweditor.api.ApplicationState;
import static org.badvision.outlaweditor.data.DataUtilities.extract;
import static org.badvision.outlaweditor.data.DataUtilities.extractFirst;
@@ -56,6 +47,16 @@
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
+import jakarta.xml.bind.JAXBContext;
+import jakarta.xml.bind.JAXBElement;
+import jakarta.xml.bind.JAXBException;
+import jakarta.xml.bind.Unmarshaller;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Scene;
+import javafx.scene.layout.AnchorPane;
+import javafx.stage.Stage;
+import javafx.stage.WindowEvent;
+
/**
* Mythos Scripting Editor
*
@@ -80,9 +81,6 @@ public MythosEditor(Script theScript, Scope theScope) {
public void show() {
primaryStage = new Stage();
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/MythosScriptEditor.fxml"));
- Map properties = new HashMap<>();
- properties.put(MythosScriptEditorController.ONLOAD_SCRIPT, generateLoadScript());
- fxmlLoader.setResources(MythosScriptEditorController.createResourceBundle(properties));
try {
AnchorPane node = (AnchorPane) fxmlLoader.load();
controller = fxmlLoader.getController();
diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/SheetEditor.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/SheetEditor.java
index 4b4779ad..9786ad41 100644
--- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/SheetEditor.java
+++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/SheetEditor.java
@@ -14,13 +14,14 @@
package org.badvision.outlaweditor;
import java.io.IOException;
+
+import org.badvision.outlaweditor.data.xml.Sheet;
+import org.badvision.outlaweditor.ui.impl.SheetEditorControllerImpl;
+
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
-import javafx.stage.WindowEvent;
-import org.badvision.outlaweditor.data.xml.Sheet;
-import org.badvision.outlaweditor.ui.impl.SheetEditorControllerImpl;
/**
* Edit a spreadsheet of information
@@ -38,6 +39,16 @@ public Sheet getSheet() {
return sheet;
}
+ public boolean isShowing() {
+ return primaryStage != null && primaryStage.isShowing();
+ }
+
+ public void toFront() {
+ if (isShowing()) {
+ primaryStage.toFront();
+ }
+ }
+
public void show() {
primaryStage = new Stage();
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/SheetEditor.fxml"));
diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/TileEditor.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/TileEditor.java
index d1eceefe..54358d46 100644
--- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/TileEditor.java
+++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/TileEditor.java
@@ -10,20 +10,11 @@
package org.badvision.outlaweditor;
-/**
- *
- * @author brobert
- */
-import javafx.event.EventHandler;
-import javafx.scene.control.Menu;
-import javafx.scene.input.KeyCode;
-import javafx.scene.input.KeyEvent;
-import javafx.scene.layout.FlowPane;
-import javafx.scene.layout.Pane;
-import org.badvision.outlaweditor.api.ApplicationState;
import org.badvision.outlaweditor.data.xml.Tile;
import org.badvision.outlaweditor.ui.PatternSelectModal;
-import org.badvision.outlaweditor.ui.TileSelectModal;
+
+import javafx.scene.control.Menu;
+import javafx.scene.layout.Pane;
public abstract class TileEditor extends Editor {
abstract public void buildPatternSelector(Menu tilePatternMenu);
@@ -45,4 +36,19 @@ public void registerPatternSelectorModal(Pane pane, PatternSelectModal modal) {
public void showSelectorModal() {
patternSelectModal.showPatternSelectModal(targetPane);
}
+
+ @Override
+ public void copyEntityFrom(Tile src) {
+ Tile dest = getEntity();
+ dest.setBlocker(src.isBlocker());
+ dest.setCategory(src.getCategory());
+ dest.setComment(src.getComment());
+ dest.setId(src.getId());
+ dest.setName(src.getName());
+ dest.setObstruction(src.isObstruction());
+ dest.setSprite(src.isSprite());
+ dest.getDisplayData().clear();
+ dest.getDisplayData().addAll(src.getDisplayData());
+ }
+
}
diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/TransferHelper.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/TransferHelper.java
index c5ceaf91..4740d888 100644
--- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/TransferHelper.java
+++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/TransferHelper.java
@@ -12,7 +12,16 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
-import javafx.scene.ImageCursor;
+
+import javax.xml.namespace.QName;
+
+import org.badvision.outlaweditor.ui.ToolType;
+
+import jakarta.xml.bind.JAXBContext;
+import jakarta.xml.bind.JAXBElement;
+import jakarta.xml.bind.JAXBException;
+import jakarta.xml.bind.Marshaller;
+import jakarta.xml.bind.util.JAXBSource;
import javafx.scene.Node;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.DataFormat;
@@ -20,14 +29,6 @@
import javafx.scene.input.Dragboard;
import javafx.scene.input.MouseEvent;
import javafx.scene.input.TransferMode;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.util.JAXBSource;
-import javax.xml.namespace.QName;
-import org.badvision.outlaweditor.data.xml.Script;
-import org.badvision.outlaweditor.ui.ToolType;
/**
* Simplify management of drag/drop operations
diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/api/ApplicationState.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/api/ApplicationState.java
index 0537b88a..383918d7 100644
--- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/api/ApplicationState.java
+++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/api/ApplicationState.java
@@ -15,12 +15,12 @@
*/
package org.badvision.outlaweditor.api;
-import javafx.stage.Stage;
-import org.badvision.outlaweditor.Application;
import org.badvision.outlaweditor.data.xml.GameData;
import org.badvision.outlaweditor.ui.ApplicationUIController;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
+
+import javafx.stage.Stage;
+// import org.osgi.framework.BundleContext;
+// import org.osgi.framework.FrameworkUtil;
/**
*
@@ -40,7 +40,7 @@ public interface ApplicationState {
public ApplicationUIController getController();
public Stage getPrimaryStage();
-
+ /*
static public BundleContext getBundleContext() {
if (Application.felix != null) {
return Application.felix.getBundleContext();
@@ -53,5 +53,9 @@ public static ApplicationState getInstance() {
BundleContext bc = getBundleContext();
return bc.getService(bc.getServiceReference(ApplicationState.class));
}
+ */
+ public static ApplicationState getInstance() {
+ return org.badvision.outlaweditor.Application.applicationStateSingleton;
+ }
}
diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/api/Platform.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/api/Platform.java
index a3dc142e..06fe52c6 100644
--- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/api/Platform.java
+++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/api/Platform.java
@@ -43,7 +43,7 @@ public enum Platform {
public int maxImageWidth;
public int maxImageHeight;
- Platform(Class ed, Class imged, TileRenderer ren, ImageRenderer img, int w, int h, int maxW, int maxH) {
+ Platform(Class extends TileEditor> ed, Class extends ImageEditor> imged, TileRenderer ren, ImageRenderer img, int w, int h, int maxW, int maxH) {
tileEditor = ed;
imageEditor = imged;
tileRenderer = ren;
diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/data/DataUtilities.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/data/DataUtilities.java
index 08990bf3..7bb51543 100644
--- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/data/DataUtilities.java
+++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/data/DataUtilities.java
@@ -34,12 +34,6 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.xml.namespace.QName;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.badvision.outlaweditor.api.ApplicationState;
import org.badvision.outlaweditor.data.xml.Block;
import org.badvision.outlaweditor.data.xml.Field;
@@ -266,12 +260,8 @@ public static List> readFromFile(File file) {
if (file.getName().toLowerCase().endsWith("txt")
|| file.getName().toLowerCase().endsWith("tsv")) {
return readTextFile(file);
- } else if (file.getName().toLowerCase().endsWith("xls")) {
- return readLegacyExcel(file);
- } else if (file.getName().toLowerCase().endsWith("xlsx")) {
- return readExcel(file);
- }
- } catch (IOException | InvalidFormatException ex) {
+ }
+ } catch (IOException ex) {
Logger.getLogger(DataUtilities.class.getName()).log(Level.SEVERE, null, ex);
}
UIAction.alert("Couldn't figure out how to import file " + file.getName());
@@ -283,42 +273,6 @@ public static List> readTextFile(File file) throws FileNotFoundExce
return reader.lines().map(line -> Arrays.asList(line.split("\\t"))).collect(Collectors.toList());
}
- public static List> readLegacyExcel(File file) throws FileNotFoundException, IOException {
- return readSheet(new HSSFWorkbook(new FileInputStream(file)));
- }
-
- public static List> readExcel(File file) throws FileNotFoundException, IOException, InvalidFormatException {
- return readSheet(new XSSFWorkbook(file));
- }
-
- public static List> readSheet(Workbook workbook) {
- Sheet sheet = workbook.getSheetAt(0);
- List> data = new ArrayList<>();
- sheet.forEach(row -> {
- List rowData = new ArrayList<>();
- row.forEach(cell -> {
- String col = getStringValueFromCell(cell);
- rowData.add(col);
- });
- data.add(rowData);
- });
- return data;
- }
-
- public static String getStringValueFromCell(Cell cell) {
- switch (cell.getCellType()) {
- case BOOLEAN:
- return Boolean.toString(cell.getBooleanCellValue());
- case BLANK:
- return null;
- case NUMERIC:
- return Double.toString(cell.getNumericCellValue());
- case STRING:
- return cell.getStringCellValue();
- default:
- return "???";
- }
- }
public static String hexDump(byte[] data) {
StringBuilder dump = new StringBuilder();
diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/data/PropertyHelper.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/data/PropertyHelper.java
index 2a68e35a..d194c970 100644
--- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/data/PropertyHelper.java
+++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/data/PropertyHelper.java
@@ -27,15 +27,15 @@
public class PropertyHelper {
public static JavaBeanIntegerProperty intProp(Object t, String fieldName) throws NoSuchMethodException {
- return new JavaBeanIntegerPropertyBuilder().bean(t).name(fieldName).build();
+ return JavaBeanIntegerPropertyBuilder.create().bean(t).name(fieldName).build();
}
public static JavaBeanBooleanProperty boolProp(Object t, String fieldName) throws NoSuchMethodException {
- return new JavaBeanBooleanPropertyBuilder().bean(t).name(fieldName).build();
+ return JavaBeanBooleanPropertyBuilder.create().bean(t).name(fieldName).build();
}
public static JavaBeanStringProperty stringProp(Object t, String fieldName) throws NoSuchMethodException {
- return new JavaBeanStringPropertyBuilder().bean(t).name(fieldName).build();
+ return JavaBeanStringPropertyBuilder.create().bean(t).name(fieldName).build();
}
private static final Map boundProperties = new HashMap<>();
diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/data/TileMap.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/data/TileMap.java
index 604fd883..9d16fb2e 100644
--- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/data/TileMap.java
+++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/data/TileMap.java
@@ -17,11 +17,7 @@
import java.util.List;
import java.util.Optional;
import java.util.Set;
-import javafx.scene.control.Alert;
-import javafx.scene.image.WritableImage;
-import javafx.scene.paint.Color;
-import javax.xml.bind.JAXBElement;
-import org.badvision.outlaweditor.Application;
+
import org.badvision.outlaweditor.api.ApplicationState;
import org.badvision.outlaweditor.api.Platform;
import org.badvision.outlaweditor.data.xml.Map;
@@ -33,6 +29,11 @@
import org.badvision.outlaweditor.data.xml.Tile;
import org.badvision.outlaweditor.ui.UIAction;
+import jakarta.xml.bind.JAXBElement;
+import javafx.scene.control.Alert;
+import javafx.scene.image.WritableImage;
+import javafx.scene.paint.Color;
+
/**
*
* @author brobert
diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/spelling/SpellChecker.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/spelling/SpellChecker.java
index 620aabc8..3ca8ceff 100644
--- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/spelling/SpellChecker.java
+++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/spelling/SpellChecker.java
@@ -10,17 +10,14 @@
package org.badvision.outlaweditor.spelling;
import java.io.BufferedReader;
-import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.TreeSet;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+
import org.badvision.outlaweditor.data.DataUtilities;
/**
@@ -54,22 +51,18 @@ public SpellResponse check(String value) {
private static void loadDictionary() {
if (dictionary == null) {
- URL dictionaryPath = SpellChecker.class.getResource("/mythos/dictionary.txt");
- try {
- BufferedReader content = new BufferedReader(new InputStreamReader((InputStream) dictionaryPath.getContent()));
- dictionary = new HashMap<>();
- content.lines().forEach((String word)-> {
- String lower = word.toLowerCase();
- Set words = dictionary.get(lower.charAt(0));
- if (words == null) {
- words = new LinkedHashSet<>();
- dictionary.put(lower.charAt(0), words);
- }
- words.add(word);
- });
- } catch (IOException ex) {
- Logger.getLogger(SpellChecker.class.getName()).log(Level.SEVERE, null, ex);
- }
+ InputStream dictionaryStream = SpellChecker.class.getResourceAsStream("/mythos/dictionary.txt");
+ BufferedReader content = new BufferedReader(new InputStreamReader(dictionaryStream));
+ dictionary = new HashMap<>();
+ content.lines().forEach((String word)-> {
+ String lower = word.toLowerCase();
+ Set words = dictionary.get(lower.charAt(0));
+ if (words == null) {
+ words = new LinkedHashSet<>();
+ dictionary.put(lower.charAt(0), words);
+ }
+ words.add(word);
+ });
}
}
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 6e5032c5..f9be9ade 100644
--- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/ImageEditorTabController.java
+++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/ImageEditorTabController.java
@@ -10,8 +10,6 @@
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;
diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/ModalEditor.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/ModalEditor.java
index d7129475..da7bf76e 100644
--- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/ModalEditor.java
+++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/ModalEditor.java
@@ -10,7 +10,8 @@
package org.badvision.outlaweditor.ui;
-import com.sun.glass.ui.Application;
+import static org.badvision.outlaweditor.data.DataUtilities.uppercaseFirst;
+
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
@@ -23,6 +24,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;
+
import javafx.application.Platform;
import javafx.beans.property.adapter.JavaBeanStringPropertyBuilder;
import javafx.beans.value.ObservableValue;
@@ -43,13 +45,13 @@
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.util.Callback;
-import static org.badvision.outlaweditor.data.DataUtilities.uppercaseFirst;
/**
*
* @author blurry
*/
public class ModalEditor {
+ Dialog dialog;
public static interface EditControl {
@@ -61,7 +63,6 @@ public static interface EditControl {
}
public static class TextControl implements EditControl {
-
TextField control = new TextField();
@Override
@@ -98,7 +99,7 @@ public TableControl(Map, TableCell>> co
TableColumn col = new TableColumn<>(uppercaseFirst(colName));
col.setCellValueFactory((TableColumn.CellDataFeatures param) -> {
try {
- return (ObservableValue) new JavaBeanStringPropertyBuilder().bean(param.getValue()).name(colName).build();
+ return (ObservableValue) JavaBeanStringPropertyBuilder.create().bean(param.getValue()).name(colName).build();
} catch (NoSuchMethodException ex) {
Logger.getLogger(ModalEditor.class.getName()).log(Level.SEVERE, null, ex);
throw new RuntimeException(ex);
@@ -116,7 +117,7 @@ public TableControl(Map, TableCell>> co
addButton.setOnAction((event) -> {
try {
rows.add(rowType.newInstance());
- Application.invokeLater(() -> {
+ Platform.runLater(() -> {
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
@@ -172,7 +173,7 @@ public PropertyDescriptor getPropertyDescriptor(PropertyDescriptor[] descriptors
public Optional editObject(T sourceObject, Map obj, Class clazz, String title, String header) throws IntrospectionException {
BeanInfo info = Introspector.getBeanInfo(clazz);
- Dialog dialog = new Dialog();
+ dialog = new Dialog();
dialog.setTitle(title);
dialog.setHeaderText(header);
@@ -210,8 +211,7 @@ public Optional editObject(T sourceObject, Map obj,
descriptor.getWriteMethod().invoke(sourceObject, control.getValue());
} else {
Object val = descriptor.getReadMethod().invoke(sourceObject);
- if (val instanceof List) {
- List sourceList = (List) val;
+ if (val instanceof List sourceList) {
sourceList.clear();
sourceList.addAll((Collection) control.getValue());
}
@@ -227,4 +227,14 @@ public Optional editObject(T sourceObject, Map obj,
return dialog.showAndWait();
}
+
+ public boolean isOpen() {
+ return dialog != null && dialog.isShowing();
+ }
+
+ public void close() {
+ if (isOpen()) {
+ dialog.close();
+ }
+ }
}
diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/MythosScriptEditorController.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/MythosScriptEditorController.java
index 8726cd3f..862ce501 100644
--- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/MythosScriptEditorController.java
+++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/MythosScriptEditorController.java
@@ -10,10 +10,10 @@
package org.badvision.outlaweditor.ui;
import java.net.URL;
-import java.util.ListResourceBundle;
-import java.util.Map;
import java.util.ResourceBundle;
-import java.util.Set;
+
+import org.badvision.outlaweditor.MythosEditor;
+
import javafx.application.Platform;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Worker.State;
@@ -25,13 +25,11 @@
import javafx.scene.web.WebView;
import javafx.stage.Stage;
import netscape.javascript.JSObject;
-import org.badvision.outlaweditor.MythosEditor;
public class MythosScriptEditorController
implements Initializable {
public static final String MYTHOS_EDITOR = "/mythos/mythos-editor/html/editor.html";
- public static final String ONLOAD_SCRIPT = "onloadScript";
// This is tied to the Mythos object defined in mythos_uncompressed
JSObject mythos;
@@ -60,6 +58,26 @@ public class MythosScriptEditorController
public void setEditor(MythosEditor editor) {
this.editor = editor;
+ final String loadScript = editor.generateLoadScript();
+ if (loadScript != null) {
+ editorView.getEngine().getLoadWorker().stateProperty().addListener(
+ (value, old, newState) -> {
+ if (newState == State.SUCCEEDED) {
+ mythos = (JSObject) editorView.getEngine().executeScript("Mythos");
+ mythos.setMember("editor", editor);
+ editorView.getEngine().executeScript(loadScript);
+ editorView.getEngine().executeScript("window.dispatchEvent(new Event('resize'));");
+ }
+ });
+
+ editorView.getEngine().setPromptHandler((PromptData prompt) -> {
+ return UIAction.getText(prompt.getMessage(), prompt.getDefaultValue());
+ });
+ }
+
+ //TODO: Verify the path conversion works in Win7 with a jar file
+ // Affected by https://bugs.openjdk.java.net/browse/JDK-8136466
+ editorView.getEngine().load(getClass().getResource(MYTHOS_EDITOR).toExternalForm());
}
// Handler for MenuItem[fx:id="menuItemAbortChanges"] onAction
@@ -92,6 +110,11 @@ public void onRedoSelected(ActionEvent event) {
public void onUndoSelected(ActionEvent event) {
// handle the event here
}
+ /**
+ *
+ * @param fxmlFileLocation
+ * @param resources
+ */
@Override // This method is called by the FXMLLoader when initialization is complete
public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
@@ -103,23 +126,6 @@ public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
assert menuItemRedo != null : "fx:id=\"menuItemRedo\" was not injected: check your FXML file 'MythosScriptEditor.fxml'.";
assert menuItemUndo != null : "fx:id=\"menuItemUndo\" was not injected: check your FXML file 'MythosScriptEditor.fxml'.";
- final String loadScript = resources.getString(ONLOAD_SCRIPT);
- if (loadScript != null) {
- editorView.getEngine().getLoadWorker().stateProperty().addListener(
- (value, old, newState) -> {
- if (newState == State.SUCCEEDED) {
- mythos = (JSObject) editorView.getEngine().executeScript("Mythos");
- mythos.setMember("editor", editor);
- editorView.getEngine().executeScript(loadScript);
- editorView.getEngine().executeScript("window.dispatchEvent(new Event('resize'));");
- }
- });
-
- editorView.getEngine().setPromptHandler((PromptData prompt) -> {
- return UIAction.getText(prompt.getMessage(), prompt.getDefaultValue());
- });
- }
-
// JavaFX8 has a bug where stage maximize events do not trigger resize events to webview components
Platform.runLater(() -> {
Stage stage = (Stage) editorView.getScene().getWindow();
@@ -129,26 +135,6 @@ public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
});
}
});
-
- //TODO: Verify the path conversion works in Win7 with a jar file
- // Affected by https://bugs.openjdk.java.net/browse/JDK-8136466
- editorView.getEngine().load(getClass().getResource(MYTHOS_EDITOR).toExternalForm());
- }
-
- public static ResourceBundle createResourceBundle(final Map input) {
- return new ListResourceBundle() {
- @Override
- protected Object[][] getContents() {
- Object[][] output = new Object[input.size()][2];
- Set keys = input.keySet();
- int i = 0;
- for (String key : keys) {
- output[i] = new Object[]{key, input.get(key)};
- i++;
- }
- return output;
- }
- };
}
public String getScriptXml() {
diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/SheetEditorController.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/SheetEditorController.java
index 58f57da3..d0b716ca 100644
--- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/SheetEditorController.java
+++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/SheetEditorController.java
@@ -15,12 +15,14 @@
import java.net.URL;
import java.util.ResourceBundle;
+
+import org.controlsfx.control.spreadsheet.SpreadsheetColumn;
+import org.controlsfx.control.spreadsheet.SpreadsheetView;
+
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TextField;
-import org.controlsfx.control.spreadsheet.SpreadsheetColumn;
-import org.controlsfx.control.spreadsheet.SpreadsheetView;
/**
*
diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/ToolType.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/ToolType.java
index 08774c9d..4f7eb944 100644
--- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/ToolType.java
+++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/ToolType.java
@@ -11,14 +11,15 @@
package org.badvision.outlaweditor.ui;
import java.util.Optional;
+
import javafx.scene.image.Image;
public enum ToolType {
- ERASER("images/eraser.png"), FILL(null), SELECT(null), MOVE(null), DRAW(null);
+ ERASER("/images/eraser.png"), FILL(null), SELECT(null), MOVE(null), DRAW(null);
ToolType(String iconPath) {
if (iconPath != null) {
- icon = Optional.of(new Image(iconPath));
+ icon = Optional.of(new Image(ToolType.class.getResourceAsStream(iconPath)));
} else {
icon = Optional.empty();
}
diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/UIAction.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/UIAction.java
index e09e3c65..f3848a41 100644
--- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/UIAction.java
+++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/UIAction.java
@@ -19,6 +19,26 @@
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
+
+import org.badvision.outlaweditor.Application;
+import org.badvision.outlaweditor.FileUtils;
+import org.badvision.outlaweditor.MythosEditor;
+import org.badvision.outlaweditor.SheetEditor;
+import org.badvision.outlaweditor.api.ApplicationState;
+import org.badvision.outlaweditor.apple.ImageDitherEngine;
+import org.badvision.outlaweditor.data.DataUtilities;
+import org.badvision.outlaweditor.data.TilesetUtils;
+import org.badvision.outlaweditor.data.xml.GameData;
+import org.badvision.outlaweditor.data.xml.Global;
+import org.badvision.outlaweditor.data.xml.Scope;
+import org.badvision.outlaweditor.data.xml.Script;
+import org.badvision.outlaweditor.data.xml.Sheet;
+import org.badvision.outlaweditor.data.xml.UserType;
+import org.badvision.outlaweditor.data.xml.Variable;
+import org.badvision.outlaweditor.data.xml.Variables;
+import org.badvision.outlaweditor.ui.impl.ImageConversionWizardController;
+
+import jakarta.xml.bind.JAXB;
import javafx.animation.FadeTransition;
import javafx.application.Platform;
import javafx.event.ActionEvent;
@@ -41,32 +61,14 @@
import javafx.scene.image.ImageView;
import javafx.scene.image.WritableImage;
import javafx.scene.layout.AnchorPane;
-import javafx.scene.layout.HBoxBuilder;
-import javafx.scene.layout.VBoxBuilder;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.util.Callback;
import javafx.util.Duration;
import javafx.util.converter.DefaultStringConverter;
-import javax.xml.bind.JAXB;
-import org.badvision.outlaweditor.Application;
-import org.badvision.outlaweditor.FileUtils;
-import org.badvision.outlaweditor.MythosEditor;
-import org.badvision.outlaweditor.SheetEditor;
-import org.badvision.outlaweditor.api.ApplicationState;
-import org.badvision.outlaweditor.apple.ImageDitherEngine;
-import org.badvision.outlaweditor.data.DataUtilities;
-import org.badvision.outlaweditor.data.TilesetUtils;
-import org.badvision.outlaweditor.data.xml.GameData;
-import org.badvision.outlaweditor.data.xml.Global;
-import org.badvision.outlaweditor.data.xml.Scope;
-import org.badvision.outlaweditor.data.xml.Script;
-import org.badvision.outlaweditor.data.xml.Sheet;
-import org.badvision.outlaweditor.data.xml.UserType;
-import org.badvision.outlaweditor.data.xml.Variable;
-import org.badvision.outlaweditor.data.xml.Variables;
-import org.badvision.outlaweditor.ui.impl.ImageConversionWizardController;
/**
*
@@ -142,6 +144,8 @@ public static void actionPerformed(MAIN_ACTIONS action) throws IOException {
JAXB.marshal(ApplicationState.getInstance().getGameData(), currentSaveFile);
}
break;
+ default:
+ break;
}
}
@@ -184,7 +188,7 @@ public static void quitWithoutConfirming() {
public static WritableImage getBadImage(int width, int height) {
if (badImage == null) {
- badImage = new Image("images/icon_brokenLink.png");
+ badImage = new Image(UIAction.class.getResourceAsStream("/images/icon_brokenLink.png"));
}
WritableImage img = new WritableImage(width, height);
img.getPixelWriter().setPixels(0, 0, (int) badImage.getWidth(), (int) badImage.getHeight(), badImage.getPixelReader(), 0, 0);
@@ -214,7 +218,10 @@ public static void alert(String message) {
public static void choose(String message, Choice... choices) {
final Stage dialogStage = new Stage();
- HBoxBuilder options = HBoxBuilder.create().alignment(Pos.CENTER).spacing(10.0).padding(new Insets(5));
+ HBox hbox = new HBox();
+ hbox.setAlignment(Pos.CENTER);
+ hbox.setSpacing(10.0);
+ hbox.setPadding(new Insets(5));
List