From e43ddccb56af8be9a7aba48c73a876e0ff977b37 Mon Sep 17 00:00:00 2001 From: Brendan Robert Date: Wed, 30 Nov 2022 09:33:59 -0600 Subject: [PATCH] Fixed script editor funky UI issues --- .../outlaweditor/spelling/SpellChecker.java | 3 +- .../ui/MythosScriptEditorController.java | 1 + .../mythos/mythos-editor/html/editor.html | 7 +- .../Apple/tools/AppPackaging/update_builds.sh | 12 ++ Platform/Apple/tools/jace/.idea/.gitignore | 8 ++ .../tools/jace/.idea/azure/azureSettings.xml | 6 + Platform/Apple/tools/jace/.idea/compiler.xml | 13 ++ Platform/Apple/tools/jace/.idea/encodings.xml | 7 ++ .../tools/jace/.idea/jarRepositories.xml | 25 ++++ Platform/Apple/tools/jace/.idea/misc.xml | 12 ++ .../tools/jace/.idea/runConfigurations.xml | 10 ++ Platform/Apple/tools/jace/.idea/vcs.xml | 6 + Platform/Apple/tools/jace/lawlesslegends.iml | 23 ---- .../java/jace/lawless/FPSMonitorDevice.java | 115 ++++++++++++++++++ 14 files changed, 222 insertions(+), 26 deletions(-) create mode 100644 Platform/Apple/tools/AppPackaging/update_builds.sh create mode 100644 Platform/Apple/tools/jace/.idea/.gitignore create mode 100644 Platform/Apple/tools/jace/.idea/azure/azureSettings.xml create mode 100644 Platform/Apple/tools/jace/.idea/compiler.xml create mode 100644 Platform/Apple/tools/jace/.idea/encodings.xml create mode 100644 Platform/Apple/tools/jace/.idea/jarRepositories.xml create mode 100644 Platform/Apple/tools/jace/.idea/misc.xml create mode 100644 Platform/Apple/tools/jace/.idea/runConfigurations.xml create mode 100644 Platform/Apple/tools/jace/.idea/vcs.xml delete mode 100644 Platform/Apple/tools/jace/lawlesslegends.iml create mode 100644 Platform/Apple/tools/jace/src/main/java/jace/lawless/FPSMonitorDevice.java 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 e7ed70d3..620aabc8 100644 --- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/spelling/SpellChecker.java +++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/spelling/SpellChecker.java @@ -14,6 +14,7 @@ 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; @@ -73,7 +74,7 @@ public class SpellChecker { } private Set getSuggestions(String word) { - TreeSet suggestions = new TreeSet<>(); + Set suggestions = Collections.synchronizedSet(new TreeSet<>()); if (word == null || word.isEmpty()) { return suggestions; } 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 7e44fd0a..8726cd3f 100644 --- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/MythosScriptEditorController.java +++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/MythosScriptEditorController.java @@ -111,6 +111,7 @@ public class MythosScriptEditorController mythos = (JSObject) editorView.getEngine().executeScript("Mythos"); mythos.setMember("editor", editor); editorView.getEngine().executeScript(loadScript); + editorView.getEngine().executeScript("window.dispatchEvent(new Event('resize'));"); } }); diff --git a/OutlawEditor/src/main/resources/mythos/mythos-editor/html/editor.html b/OutlawEditor/src/main/resources/mythos/mythos-editor/html/editor.html index e8c3e5d5..cdd04812 100644 --- a/OutlawEditor/src/main/resources/mythos/mythos-editor/html/editor.html +++ b/OutlawEditor/src/main/resources/mythos/mythos-editor/html/editor.html @@ -28,16 +28,19 @@ html, body { height: 100%; margin: 0; + overflow: hidden; } #blocklyArea { min-height: 100%; - width: 100%; + width: 100%; height: 100%; + overflow: hidden; } #blocklyDiv { height: 700px; - width: 996px; + width: 990px; + overflow: hidden; } diff --git a/Platform/Apple/tools/AppPackaging/update_builds.sh b/Platform/Apple/tools/AppPackaging/update_builds.sh new file mode 100644 index 00000000..3bd31861 --- /dev/null +++ b/Platform/Apple/tools/AppPackaging/update_builds.sh @@ -0,0 +1,12 @@ +mkdir -p /tmp/ll/Lawless\ Legends +cd /tmp/ll +cp /Users/brobert/Dropbox/Lawless\ Legends/Lawless\ Legends\ Manual\ v5\ 20210217.txt . +cp /Users/brobert/Documents/code/lawless-legends/Platform/Apple/tools/jace/target/*jar ./Lawless\ Legends +zip -rv /Users/brobert/Dropbox/Lawless\ Legends/Lawless\ Legends-win64.zip . +rm -rf ./Lawless\ Legends + +mkdir -p /tmp/ll/Lawless\ Legends.app/Contents/Resources +cp /Users/brobert/Documents/code/lawless-legends/Platform/Apple/tools/jace/target/*jar ./Lawless\ Legends.app/Contents/Resources +zip -rv /Users/brobert/Dropbox/Lawless\ Legends/Lawless\ Legends-osx.zip . +cd ~ +rm -rf /tmp/ll diff --git a/Platform/Apple/tools/jace/.idea/.gitignore b/Platform/Apple/tools/jace/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/Platform/Apple/tools/jace/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/Platform/Apple/tools/jace/.idea/azure/azureSettings.xml b/Platform/Apple/tools/jace/.idea/azure/azureSettings.xml new file mode 100644 index 00000000..448ab9e8 --- /dev/null +++ b/Platform/Apple/tools/jace/.idea/azure/azureSettings.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/Platform/Apple/tools/jace/.idea/compiler.xml b/Platform/Apple/tools/jace/.idea/compiler.xml new file mode 100644 index 00000000..0134e91b --- /dev/null +++ b/Platform/Apple/tools/jace/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Platform/Apple/tools/jace/.idea/encodings.xml b/Platform/Apple/tools/jace/.idea/encodings.xml new file mode 100644 index 00000000..aa00ffab --- /dev/null +++ b/Platform/Apple/tools/jace/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Platform/Apple/tools/jace/.idea/jarRepositories.xml b/Platform/Apple/tools/jace/.idea/jarRepositories.xml new file mode 100644 index 00000000..8ed179ad --- /dev/null +++ b/Platform/Apple/tools/jace/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Platform/Apple/tools/jace/.idea/misc.xml b/Platform/Apple/tools/jace/.idea/misc.xml new file mode 100644 index 00000000..d5cd6143 --- /dev/null +++ b/Platform/Apple/tools/jace/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/Platform/Apple/tools/jace/.idea/runConfigurations.xml b/Platform/Apple/tools/jace/.idea/runConfigurations.xml new file mode 100644 index 00000000..797acea5 --- /dev/null +++ b/Platform/Apple/tools/jace/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/Platform/Apple/tools/jace/.idea/vcs.xml b/Platform/Apple/tools/jace/.idea/vcs.xml new file mode 100644 index 00000000..4fce1d86 --- /dev/null +++ b/Platform/Apple/tools/jace/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Platform/Apple/tools/jace/lawlesslegends.iml b/Platform/Apple/tools/jace/lawlesslegends.iml deleted file mode 100644 index 1f4a2c9c..00000000 --- a/Platform/Apple/tools/jace/lawlesslegends.iml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Platform/Apple/tools/jace/src/main/java/jace/lawless/FPSMonitorDevice.java b/Platform/Apple/tools/jace/src/main/java/jace/lawless/FPSMonitorDevice.java new file mode 100644 index 00000000..c7e17f81 --- /dev/null +++ b/Platform/Apple/tools/jace/src/main/java/jace/lawless/FPSMonitorDevice.java @@ -0,0 +1,115 @@ +package jace.lawless; + +import jace.LawlessLegends; +import jace.apple2e.Apple2e; +import jace.apple2e.SoftSwitches; +import jace.core.Computer; +import jace.core.Device; +import jace.core.Motherboard; +import javafx.application.Platform; +import javafx.geometry.Insets; +import javafx.scene.control.Label; +import javafx.scene.effect.DropShadow; +import javafx.scene.layout.Background; +import javafx.scene.layout.BackgroundFill; +import javafx.scene.layout.CornerRadii; +import javafx.scene.layout.Region; +import javafx.scene.paint.Color; + +/** + * Simple device that displays speed and fps stats + */ +public class FPSMonitorDevice extends Device { + public static final long UPDATE_CHECK_FREQUENCY = 1000; + Apple2e computer; + Label cpuSpeedIcon; + Label fpsIcon; + + long checkCounter = 0; + long tickCounter = 0; + int frameCounter = 0; + long lastUpdate = 0; + long UPDATE_INTERVAL = 1000/2; + boolean lastVBLState = false; + + public FPSMonitorDevice(Computer c) { + super(c); + computer = (Apple2e) c; + } + + @Override + protected String getDeviceName() { + return "FPS Monitor"; + } + + @Override + public void tick() { + tickCounter += Math.min(Motherboard.cpuPerClock, 1); + boolean vblState = SoftSwitches.VBL.getSwitch().getState(); + if (!vblState && lastVBLState) { + frameCounter++; + } + lastVBLState = vblState; + if (--checkCounter <= UPDATE_CHECK_FREQUENCY) { + updateIcon(); + checkCounter = UPDATE_CHECK_FREQUENCY; + } + } + + Label initLabel(Label l) { + l.setTextFill(Color.WHITE); + l.setEffect(new DropShadow(2.0, Color.BLACK)); + l.setBackground(new Background(new BackgroundFill(Color.rgb(0, 0, 0, 0.8), new CornerRadii(5.0), new Insets(-5.0)))); + l.setMinWidth(64.0); + l.setMaxWidth(Region.USE_PREF_SIZE); + return l; + } + + void updateIcon() { + long now = System.currentTimeMillis(); + long ellapsed = now - lastUpdate; + if (ellapsed < UPDATE_INTERVAL) { + return; + } + + if (cpuSpeedIcon == null) { + cpuSpeedIcon = initLabel(new Label()); + fpsIcon = initLabel(new Label()); + } + LawlessLegends.getApplication().controller.addIndicator(cpuSpeedIcon,1000); + LawlessLegends.getApplication().controller.addIndicator(fpsIcon,1000); + double secondsEllapsed = ((double) ellapsed) / 1000.0; + double speed = ((double) tickCounter) / secondsEllapsed / 1000000.0; + double fps = ((double) frameCounter)/secondsEllapsed; + String mhzStr = String.format("%1.1fmhz", speed); + String fpsStr = String.format("%1.1ffps", fps); +// System.out.println(mhzStr+";"+fpsStr); + Platform.runLater(()->{ + cpuSpeedIcon.setText(mhzStr); + fpsIcon.setText(fpsStr); + }); + // Reset counters + lastUpdate = now; + tickCounter = 0; + frameCounter = 0; + } + + @Override + public String getShortName() { + return "fps"; + } + + @Override + public void reconfigure() { + tickCounter = 0; + frameCounter = 0; + } + + @Override + public void detach() { + if (cpuSpeedIcon != null) { + LawlessLegends.getApplication().controller.removeIndicator(cpuSpeedIcon); + LawlessLegends.getApplication().controller.removeIndicator(fpsIcon); + } + } +}