diff --git a/.gitmodules b/.gitmodules
index 612f980c..3e0b280b 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,6 +1,3 @@
-[submodule "Flow"]
- path = Flow
- url = https://github.com/Cavallium/Flow
[submodule "bigdecimal-math"]
path = bigdecimal-math
url = https://github.com/Cavallium/bigdecimal-math
diff --git a/Flow b/Flow
deleted file mode 160000
index 92db616e..00000000
--- a/Flow
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 92db616ef508f16fe30e8e37d17d7d7a18f56f4a
diff --git a/bigdecimal-math b/bigdecimal-math
index 40d89e53..da70aa7b 160000
--- a/bigdecimal-math
+++ b/bigdecimal-math
@@ -1 +1 @@
-Subproject commit 40d89e539223aaa9202326833a2c813bed3c6eef
+Subproject commit da70aa7ba3bcae0e2e76fde338c56696ff25ea96
diff --git a/core/pom.xml b/core/pom.xml
index 06afcbeb..3c3ec9db 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -6,7 +6,7 @@
it.cavallium
warppi
- 0.9.0a3
+ 0.10.0-alpha
warppi-core
@@ -14,20 +14,15 @@
WarpPI Calculator core project
-
- it.cavallium
- warppi-flow
- 1.0.1
-
it.cavallium
warppi-util
- 0.9.0a3
+ 0.10.0-alpha
it.cavallium
bigdecimal-math
- 0.9.0a3
+ 0.10.0-alpha
it.unimi.dsi
diff --git a/core/src/main/java/it/cavallium/warppi/Engine.java b/core/src/main/java/it/cavallium/warppi/Engine.java
index ef863750..5f86a812 100644
--- a/core/src/main/java/it/cavallium/warppi/Engine.java
+++ b/core/src/main/java/it/cavallium/warppi/Engine.java
@@ -8,20 +8,19 @@ import it.cavallium.warppi.device.HardwareDevice;
import it.cavallium.warppi.device.HardwareTouchDevice;
import it.cavallium.warppi.device.InputManager;
import it.cavallium.warppi.device.Keyboard;
-import it.cavallium.warppi.flow.BehaviorSubject;
-import it.cavallium.warppi.flow.Observable;
import it.cavallium.warppi.gui.DisplayManager;
import it.cavallium.warppi.gui.HUD;
import it.cavallium.warppi.gui.HardwareDisplay;
import it.cavallium.warppi.gui.screens.Screen;
import it.cavallium.warppi.util.ClassUtils;
+import it.cavallium.warppi.util.EventSubmitter;
public class Engine {
public static final Engine INSTANCE = new Engine();
private static Platform platform;
private static boolean running = false;
- private static BehaviorSubject loadPhase = BehaviorSubject.create();
- private final BehaviorSubject loaded = BehaviorSubject.create(false);
+ private static EventSubmitter loadPhase = new EventSubmitter<>();
+ private final EventSubmitter loaded = new EventSubmitter<>(false);
private HardwareDevice hardwareDevice;
private Engine() {}
@@ -43,8 +42,8 @@ public class Engine {
* @throws IOException
*/
public static void start(final Platform platform, final Screen screen, final HardwareDisplay disp,
- final HardwareTouchDevice touchdevice, final HUD hud, final StartupArguments args)
- throws InterruptedException, IOException {
+ final HardwareTouchDevice touchdevice, final HUD hud, final StartupArguments args)
+ throws InterruptedException, IOException {
if (Engine.running) {
throw new RuntimeException("Already running!");
} else {
@@ -54,8 +53,8 @@ public class Engine {
}
private void startInstance(final Platform platform, final Screen screen, final HardwareDisplay disp,
- final HardwareTouchDevice touchdevice, final HUD hud, final StartupArguments args)
- throws InterruptedException, IOException {
+ final HardwareTouchDevice touchdevice, final HUD hud, final StartupArguments args)
+ throws InterruptedException, IOException {
Engine.platform = platform;
platform.getConsoleUtils().out().println("WarpPI Calculator");
initializeEnvironment(args);
@@ -69,7 +68,7 @@ public class Engine {
final InputManager im = new InputManager(k, touchdevice);
hardwareDevice = new HardwareDevice(dm, im);
- hardwareDevice.setup(() -> Engine.loadPhase.onNext(new LoadingStatus()));
+ hardwareDevice.setup(() -> Engine.loadPhase.submit(new LoadingStatus()));
}
private void onShutdown() {
@@ -112,11 +111,11 @@ public class Engine {
Keyboard.stopKeyboard();
}
- public Observable isLoaded() {
+ public EventSubmitter isLoaded() {
return loaded;
}
- public Observable getLoadPhase() {
+ public EventSubmitter getLoadPhase() {
return Engine.loadPhase;
}
@@ -134,7 +133,7 @@ public class Engine {
}
public void done() {
- Engine.INSTANCE.loaded.onNext(true);
+ Engine.INSTANCE.loaded.submit(true);
Engine.INSTANCE.hardwareDevice.getDisplayManager().waitForExit();
Engine.INSTANCE.onShutdown();
}
diff --git a/core/src/main/java/it/cavallium/warppi/StaticVars.java b/core/src/main/java/it/cavallium/warppi/StaticVars.java
index 55a427d2..4295b11d 100644
--- a/core/src/main/java/it/cavallium/warppi/StaticVars.java
+++ b/core/src/main/java/it/cavallium/warppi/StaticVars.java
@@ -3,8 +3,7 @@ package it.cavallium.warppi;
import java.util.function.Function;
import it.cavallium.warppi.boot.StartupArguments;
-import it.cavallium.warppi.flow.BehaviorSubject;
-import it.cavallium.warppi.flow.Observable;
+import it.cavallium.warppi.util.EventSubmitter;
/*
* TODO: Move everything to Engine.Settings
@@ -15,7 +14,7 @@ public class StaticVars {
public static final int[] screenSize = new int[] { 480, 320 };
public static int outputLevel = 0;
public static boolean debugWindow2x = false;
- public static BehaviorSubject windowZoom = BehaviorSubject.create(2F);
+ public static EventSubmitter windowZoom = new EventSubmitter<>(2F);
public static Function windowZoomFunction = (val) -> {
if (StaticVars.debugWindow2x) {
return val + 1;
@@ -23,7 +22,7 @@ public class StaticVars {
return val;
}
};
- public static Observable windowZoom$ = StaticVars.windowZoom.map(StaticVars.windowZoomFunction);
+ public static EventSubmitter windowZoom$ = StaticVars.windowZoom.map(StaticVars.windowZoomFunction);
public static StartupArguments startupArguments;
private StaticVars() {
diff --git a/core/src/main/java/it/cavallium/warppi/device/Keyboard.java b/core/src/main/java/it/cavallium/warppi/device/Keyboard.java
index a949d5d1..0c54d416 100644
--- a/core/src/main/java/it/cavallium/warppi/device/Keyboard.java
+++ b/core/src/main/java/it/cavallium/warppi/device/Keyboard.java
@@ -941,7 +941,7 @@ public class Keyboard {
break;
case ZOOM_MODE:
final float newZoom = StaticVars.windowZoom.getLastValue() % 3 + 1;
- StaticVars.windowZoom.onNext(newZoom);
+ StaticVars.windowZoom.submit(newZoom);
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Keyboard", "Zoom: " + newZoom);
// StaticVars.windowZoom = ((StaticVars.windowZoom - 0.5f) % 2f) + 1f;
refresh = true;
diff --git a/core/src/main/java/it/cavallium/warppi/extra/tetris/TetrisScreen.java b/core/src/main/java/it/cavallium/warppi/extra/tetris/TetrisScreen.java
index 64e954d2..938775bc 100644
--- a/core/src/main/java/it/cavallium/warppi/extra/tetris/TetrisScreen.java
+++ b/core/src/main/java/it/cavallium/warppi/extra/tetris/TetrisScreen.java
@@ -43,7 +43,7 @@ public class TetrisScreen extends Screen {
@Override
public void initialized() {
- StaticVars.windowZoom.onNext(2f);
+ StaticVars.windowZoom.submit(2f);
}
@Override
diff --git a/core/src/main/java/it/cavallium/warppi/gui/DisplayManager.java b/core/src/main/java/it/cavallium/warppi/gui/DisplayManager.java
index 1efbabb6..502e90a6 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/DisplayManager.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/DisplayManager.java
@@ -10,8 +10,6 @@ import it.cavallium.warppi.Platform.ConsoleUtils;
import it.cavallium.warppi.Platform.Semaphore;
import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.device.Keyboard;
-import it.cavallium.warppi.flow.Observable;
-import it.cavallium.warppi.flow.Pair;
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer;
@@ -19,6 +17,7 @@ import it.cavallium.warppi.gui.graphicengine.RenderingLoop;
import it.cavallium.warppi.gui.graphicengine.Skin;
import it.cavallium.warppi.gui.graphicengine.impl.nogui.NoGuiEngine;
import it.cavallium.warppi.gui.screens.Screen;
+import it.cavallium.warppi.util.Timer;
import it.cavallium.warppi.util.Utils;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
@@ -459,34 +458,9 @@ public final class DisplayManager implements RenderingLoop {
Engine.getPlatform().exit(0);
}
- final Observable workTimer = Observable.interval(DisplayManager.tickDuration);
-
- final Observable onResizeObservable = engine.onResize();
- Observable> refreshObservable;
- if (onResizeObservable == null) {
- refreshObservable = workTimer.map((l) -> Pair.of(l, null));
- } else {
- refreshObservable = Observable.combineChanged(workTimer, engine.onResize());
- }
-
- refreshObservable.subscribe((pair) -> {
- double dt = 0;
- final long newtime = System.nanoTime();
- if (precTime == -1) {
- dt = DisplayManager.tickDuration;
- } else {
- dt = (newtime - precTime) / 1000d / 1000d;
- }
- precTime = newtime;
-
- if (pair.getRight() != null) {
- final Integer[] windowSize = pair.getRight();
- StaticVars.screenSize[0] = windowSize[0];
- StaticVars.screenSize[1] = windowSize[1];
- }
-
- screen.beforeRender((float) (dt / 1000d));
- });
+ var displayRefreshManager = new DisplayRefreshManager(this::onRefresh);
+ new Timer(DisplayManager.tickDuration, displayRefreshManager::onTick);
+ engine.onResize().subscribe(displayRefreshManager::onResize);
engine.start(getDrawable());
} catch (final Exception ex) {
@@ -495,6 +469,24 @@ public final class DisplayManager implements RenderingLoop {
}
}
+ private void onRefresh(Integer[] windowSize) {
+ double dt = 0;
+ final long newtime = System.nanoTime();
+ if (precTime == -1) {
+ dt = DisplayManager.tickDuration;
+ } else {
+ dt = (newtime - precTime) / 1000d / 1000d;
+ }
+ precTime = newtime;
+
+ if (windowSize != null) {
+ StaticVars.screenSize[0] = windowSize[0];
+ StaticVars.screenSize[1] = windowSize[1];
+ }
+
+ screen.beforeRender((float) (dt / 1000d));
+ }
+
public void changeBrightness(final float change) {
setBrightness(brightness + change);
}
diff --git a/core/src/main/java/it/cavallium/warppi/gui/DisplayRefreshManager.java b/core/src/main/java/it/cavallium/warppi/gui/DisplayRefreshManager.java
new file mode 100644
index 00000000..9103d41a
--- /dev/null
+++ b/core/src/main/java/it/cavallium/warppi/gui/DisplayRefreshManager.java
@@ -0,0 +1,33 @@
+package it.cavallium.warppi.gui;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Consumer;
+
+public class DisplayRefreshManager {
+ private final Consumer refreshConsumer;
+ private AtomicBoolean ticked = new AtomicBoolean(false);
+ private AtomicBoolean sizeSet = new AtomicBoolean(false);
+ private volatile Integer[] size;
+
+ public DisplayRefreshManager(Consumer refreshConsumer) {
+ this.refreshConsumer = refreshConsumer;
+ }
+
+ public void onTick() {
+ ticked.set(true);
+ refreshIfNeeded();
+ }
+
+ public void onResize(Integer[] newSize) {
+ size = newSize;
+ sizeSet.set(true);
+ refreshIfNeeded();
+ }
+
+ private void refreshIfNeeded() {
+ if (ticked.get() && sizeSet.get()) {
+ refreshConsumer.accept(size);
+ }
+ }
+}
diff --git a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/GraphicEngine.java b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/GraphicEngine.java
index 6ff150b0..350d499c 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/GraphicEngine.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/GraphicEngine.java
@@ -1,9 +1,10 @@
package it.cavallium.warppi.gui.graphicengine;
+import it.cavallium.warppi.util.EventSubscriber;
+
import java.io.IOException;
import java.util.List;
-
-import it.cavallium.warppi.flow.Observable;
+import java.util.function.Consumer;
public interface GraphicEngine {
@@ -23,7 +24,7 @@ public interface GraphicEngine {
void create(Runnable object);
- Observable onResize();
+ EventSubscriber onResize();
int getWidth();
diff --git a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/nogui/NoGuiEngine.java b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/nogui/NoGuiEngine.java
index cd8a9b20..5a59a0e6 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/nogui/NoGuiEngine.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/nogui/NoGuiEngine.java
@@ -4,12 +4,13 @@ import java.io.IOException;
import it.cavallium.warppi.Engine;
import it.cavallium.warppi.Platform.Semaphore;
-import it.cavallium.warppi.flow.Observable;
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.gui.graphicengine.RenderingLoop;
import it.cavallium.warppi.gui.graphicengine.Skin;
+import it.cavallium.warppi.util.EventSubmitter;
+import it.cavallium.warppi.util.EventSubscriber;
public class NoGuiEngine implements GraphicEngine {
@@ -44,7 +45,7 @@ public class NoGuiEngine implements GraphicEngine {
}
@Override
- public Observable onResize() {
+ public EventSubscriber onResize() {
return null;
}
diff --git a/core/src/main/java/it/cavallium/warppi/gui/screens/LoadingScreen.java b/core/src/main/java/it/cavallium/warppi/gui/screens/LoadingScreen.java
index db078d4e..d2a618c6 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/screens/LoadingScreen.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/screens/LoadingScreen.java
@@ -31,7 +31,7 @@ public class LoadingScreen extends Screen {
public void initialized() throws InterruptedException {
previousZoomValue = StaticVars.windowZoomFunction.apply(StaticVars.windowZoom.getLastValue());
Engine.INSTANCE.getHardwareDevice().getDisplayManager().getHUD().hide();
- StaticVars.windowZoom.onNext(1f);
+ StaticVars.windowZoom.submit(1f);
}
@Override
@@ -44,7 +44,7 @@ public class LoadingScreen extends Screen {
endLoading += dt;
if (!ended && loaded && (Engine.getPlatform().getSettings().isDebugEnabled() || endLoading >= 3.5f)) {
ended = true;
- StaticVars.windowZoom.onNext(previousZoomValue);
+ StaticVars.windowZoom.submit(previousZoomValue);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().getHUD().show();
Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new MathInputScreen());
}
diff --git a/core/src/main/java/it/cavallium/warppi/util/EventSubmitter.java b/core/src/main/java/it/cavallium/warppi/util/EventSubmitter.java
new file mode 100644
index 00000000..e7bfc96f
--- /dev/null
+++ b/core/src/main/java/it/cavallium/warppi/util/EventSubmitter.java
@@ -0,0 +1,64 @@
+package it.cavallium.warppi.util;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.function.Consumer;
+import java.util.function.Function;
+
+public class EventSubmitter implements EventSubscriber, Submitter {
+ private boolean initialized = false;
+ private T value;
+ private List> subscribers = new LinkedList<>();
+
+ public EventSubmitter() {
+ value = null;
+ }
+
+ public EventSubmitter(T defaultValue) {
+ this.value = defaultValue;
+ this.initialized = true;
+ }
+
+ public static EventSubmitter create() {
+ return new EventSubmitter<>();
+ }
+
+ public static EventSubmitter create(T value) {
+ return new EventSubmitter<>(value);
+ }
+
+ @Override
+ public T getLastValue() {
+ return value;
+ }
+
+ @Override
+ public void subscribe(Consumer action) {
+ T currentValue = value;
+ var newSubscribers = new LinkedList<>(subscribers);
+
+ if (initialized) {
+ action.accept(currentValue);
+ }
+ newSubscribers.add(action);
+
+ subscribers = newSubscribers;
+ }
+
+ @Override
+ public void submit(T value) {
+ this.value = value;
+ this.initialized = true;
+
+ for (Consumer subscriber : subscribers) {
+ subscriber.accept(value);
+ }
+ }
+
+ @Override
+ public EventSubmitter map(Function mapFunction) {
+ var eventSubmitter = new EventSubmitter();
+ map(eventSubmitter, mapFunction);
+ return eventSubmitter;
+ }
+}
diff --git a/core/src/main/java/it/cavallium/warppi/util/EventSubscriber.java b/core/src/main/java/it/cavallium/warppi/util/EventSubscriber.java
new file mode 100644
index 00000000..bbbf35b2
--- /dev/null
+++ b/core/src/main/java/it/cavallium/warppi/util/EventSubscriber.java
@@ -0,0 +1,31 @@
+package it.cavallium.warppi.util;
+
+import java.util.function.Consumer;
+import java.util.function.Function;
+
+public interface EventSubscriber {
+
+ /**
+ *
+ * @return Last value, or null
+ */
+ T getLastValue();
+
+ void subscribe(Consumer action);
+
+ default EventSubscriber map(Function mapFunction) {
+ var eventSubmitter = new EventSubmitter();
+ map(this, eventSubmitter, mapFunction);
+ return eventSubmitter;
+ }
+
+ default void map(EventSubmitter targetHandler, Function mapFunction) {
+ map(this, targetHandler, mapFunction);
+ }
+
+ static void map(EventSubscriber originalEventHandler, EventSubmitter mappedEventHandler, Function mapFunction) {
+ originalEventHandler.subscribe((value) -> {
+ mappedEventHandler.submit(mapFunction.apply(value));
+ });
+ }
+}
diff --git a/core/src/main/java/it/cavallium/warppi/util/Submitter.java b/core/src/main/java/it/cavallium/warppi/util/Submitter.java
new file mode 100644
index 00000000..387f32fa
--- /dev/null
+++ b/core/src/main/java/it/cavallium/warppi/util/Submitter.java
@@ -0,0 +1,5 @@
+package it.cavallium.warppi.util;
+
+public interface Submitter {
+ void submit(T value);
+}
diff --git a/core/src/main/java/it/cavallium/warppi/util/Timer.java b/core/src/main/java/it/cavallium/warppi/util/Timer.java
new file mode 100644
index 00000000..f0f4b5a7
--- /dev/null
+++ b/core/src/main/java/it/cavallium/warppi/util/Timer.java
@@ -0,0 +1,31 @@
+package it.cavallium.warppi.util;
+
+import it.cavallium.warppi.Engine;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+public class Timer {
+ public Timer(int intervalMillis, Runnable action) {
+ var thread = new Thread(() -> {
+ try {
+ AtomicLong lostTime = new AtomicLong();
+ while (!Thread.interrupted()) {
+ var time1 = System.currentTimeMillis();
+ action.run();
+ var time2 = System.currentTimeMillis();
+ var deltaTime = time2 - time1 + lostTime.get();
+ if (intervalMillis - deltaTime > 0) {
+ Thread.sleep(intervalMillis);
+ } else {
+ lostTime.set(deltaTime - intervalMillis);
+ }
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ });
+ Engine.getPlatform().setThreadName(thread, "Timer");
+ thread.setDaemon(true);
+ thread.start();
+ }
+}
diff --git a/desktop/pom.xml b/desktop/pom.xml
index ac174dbe..21a811b2 100644
--- a/desktop/pom.xml
+++ b/desktop/pom.xml
@@ -6,7 +6,7 @@
it.cavallium
warppi
- 0.9.0a3
+ 0.10.0-alpha
warppi-desktop
@@ -16,12 +16,12 @@
it.cavallium
warppi-core
- 0.9.0a3
+ 0.10.0-alpha
it.cavallium
warppi-engine-jogl
- 0.9.0a3
+ 0.10.0-alpha
org.fusesource.jansi
diff --git a/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingEngine.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingEngine.java
index 2af34820..7404258c 100644
--- a/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingEngine.java
+++ b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingEngine.java
@@ -7,11 +7,11 @@ import java.util.concurrent.Semaphore;
import it.cavallium.warppi.Engine;
import it.cavallium.warppi.StaticVars;
-import it.cavallium.warppi.flow.Observable;
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.RenderingLoop;
import it.cavallium.warppi.gui.graphicengine.Skin;
+import it.cavallium.warppi.util.EventSubmitter;
public class SwingEngine implements GraphicEngine {
@@ -62,7 +62,7 @@ public class SwingEngine implements GraphicEngine {
}
@Override
- public Observable onResize() {
+ public EventSubmitter onResize() {
return INSTANCE.onResize();
}
diff --git a/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingWindow.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingWindow.java
index 76cbd429..a185c561 100644
--- a/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingWindow.java
+++ b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingWindow.java
@@ -34,9 +34,8 @@ import it.cavallium.warppi.event.TouchEndEvent;
import it.cavallium.warppi.event.TouchMoveEvent;
import it.cavallium.warppi.event.TouchPoint;
import it.cavallium.warppi.event.TouchStartEvent;
-import it.cavallium.warppi.flow.BehaviorSubject;
-import it.cavallium.warppi.flow.Observable;
import it.cavallium.warppi.gui.graphicengine.RenderingLoop;
+import it.cavallium.warppi.util.EventSubmitter;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
public class SwingWindow extends JFrame {
@@ -45,8 +44,8 @@ public class SwingWindow extends JFrame {
private RenderingLoop renderingLoop;
private final SwingEngine display;
private int mult = 1;
- private final BehaviorSubject onResize;
- private final Observable onResize$;
+ private final EventSubmitter onResize;
+ private final EventSubmitter onResize$;
public JPanel buttonsPanel;
private SwingAdvancedButton[][] buttons;
private int BTN_SIZE;
@@ -82,8 +81,8 @@ public class SwingWindow extends JFrame {
setTitle("WarpPI Calculator by Andrea Cavalli (@Cavallium)");
- onResize = BehaviorSubject.create();
- onResize$ = onResize.doOnNext((newSize) -> {
+ onResize = EventSubmitter.create();
+ onResize$ = onResize.map((newSize) -> {
disp.r.size = new int[] { newSize[0], newSize[1] };
if (disp.r.size[0] <= 0)
disp.r.size[0] = 1;
@@ -91,6 +90,8 @@ public class SwingWindow extends JFrame {
disp.r.size[1] = 1;
SwingRenderer.canvas2d = new int[disp.r.size[0] * disp.r.size[1]];
disp.g = new BufferedImage(disp.r.size[0], disp.r.size[1], BufferedImage.TYPE_INT_RGB);
+
+ return newSize;
});
addComponentListener(new ComponentListener() {
@@ -104,7 +105,7 @@ public class SwingWindow extends JFrame {
@Override
public void componentResized(final ComponentEvent e) {
- onResize.onNext(new Integer[] { c.getWidth() / mult, c.getHeight() / mult });
+ onResize.submit(new Integer[] { c.getWidth() / mult, c.getHeight() / mult });
}
@Override
@@ -184,7 +185,7 @@ public class SwingWindow extends JFrame {
StaticVars.windowZoom$.subscribe((newZoomValue) -> {
if (newZoomValue != mult) {
mult = (int) newZoomValue.floatValue();
- onResize.onNext(new Integer[] { getWWidth(), getWHeight() });
+ onResize.submit(new Integer[] { getWWidth(), getWHeight() });
Engine.getPlatform().getConsoleUtils().out().println(3, "Engine", "CPU", "Zoom changed");
}
});
@@ -323,7 +324,7 @@ public class SwingWindow extends JFrame {
}
}
- public Observable onResize() {
+ public EventSubmitter onResize() {
return onResize$;
}
diff --git a/engine-jogl/pom.xml b/engine-jogl/pom.xml
index aeb6cab0..347f495a 100644
--- a/engine-jogl/pom.xml
+++ b/engine-jogl/pom.xml
@@ -6,7 +6,7 @@
it.cavallium
warppi
- 0.9.0a3
+ 0.10.0-alpha
warppi-engine-jogl
@@ -16,7 +16,7 @@
it.cavallium
warppi-core
- 0.9.0a3
+ 0.10.0-alpha
org.jogamp.jogl
diff --git a/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLEngine.java b/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLEngine.java
index 2b1dd570..f8336b47 100644
--- a/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLEngine.java
+++ b/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLEngine.java
@@ -13,11 +13,11 @@ import com.jogamp.opengl.util.texture.Texture;
import it.cavallium.warppi.Engine;
import it.cavallium.warppi.StaticVars;
-import it.cavallium.warppi.flow.Observable;
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.RenderingLoop;
import it.cavallium.warppi.gui.graphicengine.Skin;
+import it.cavallium.warppi.util.EventSubscriber;
public class JOGLEngine implements GraphicEngine {
@@ -85,7 +85,7 @@ public class JOGLEngine implements GraphicEngine {
}
@Override
- public Observable onResize() {
+ public EventSubscriber onResize() {
return wnd.onResizeEvent;
}
diff --git a/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/NEWTWindow.java b/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/NEWTWindow.java
index f574617e..f5e074b0 100644
--- a/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/NEWTWindow.java
+++ b/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/NEWTWindow.java
@@ -58,10 +58,8 @@ import it.cavallium.warppi.event.TouchEndEvent;
import it.cavallium.warppi.event.TouchMoveEvent;
import it.cavallium.warppi.event.TouchPoint;
import it.cavallium.warppi.event.TouchStartEvent;
-import it.cavallium.warppi.flow.BehaviorSubject;
-import it.cavallium.warppi.flow.SimpleSubject;
-import it.cavallium.warppi.flow.Subject;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
+import it.cavallium.warppi.util.EventSubmitter;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
/**
@@ -81,10 +79,10 @@ class NEWTWindow implements GLEventListener {
public volatile boolean refreshViewport;
public List touches = new ObjectArrayList<>();
- final BehaviorSubject onRealResize;
- final BehaviorSubject onResizeEvent = BehaviorSubject.create();
- private final BehaviorSubject onZoom = BehaviorSubject.create();
- private final Subject onGLContext = SimpleSubject.create();
+ final EventSubmitter onRealResize;
+ final EventSubmitter onResizeEvent = EventSubmitter.create();
+ private final EventSubmitter onZoom = EventSubmitter.create();
+ private final EventSubmitter onGLContext = EventSubmitter.create();
public NEWTWindow(final JOGLEngine disp) {
this.disp = disp;
@@ -93,18 +91,18 @@ class NEWTWindow implements GLEventListener {
disp.size[1] = StaticVars.screenSize[1];
realWindowSize = new int[] { StaticVars.screenSize[0], StaticVars.screenSize[1] };
windowZoom = StaticVars.windowZoomFunction.apply(StaticVars.windowZoom.getLastValue());
- onRealResize = BehaviorSubject.create(new Integer[] { (int) (StaticVars.screenSize[0] * windowZoom), (int) (StaticVars.screenSize[1] * windowZoom) });
+ onRealResize = EventSubmitter.create(new Integer[] { (int) (StaticVars.screenSize[0] * windowZoom), (int) (StaticVars.screenSize[1] * windowZoom) });
onRealResize.subscribe((realSize) -> {
realWindowSize[0] = realSize[0];
realWindowSize[1] = realSize[1];
disp.size[0] = realSize[0] / (int) windowZoom;
disp.size[1] = realSize[1] / (int) windowZoom;
- onResizeEvent.onNext(new Integer[] { disp.size[0], disp.size[1] });
+ onResizeEvent.submit(new Integer[] { disp.size[0], disp.size[1] });
refreshViewport = true;
});
StaticVars.windowZoom$.subscribe((zoom) -> {
- onZoom.onNext(zoom);
+ onZoom.submit(zoom);
});
onZoom.subscribe((z) -> {
if (windowZoom != 0) {
@@ -432,7 +430,7 @@ class NEWTWindow implements GLEventListener {
@Override
public void init(final GLAutoDrawable drawable) {
final GL2ES1 gl = drawable.getGL().getGL2ES1();
- onGLContext.onNext(gl);
+ onGLContext.submit(gl);
if (Engine.getPlatform().getSettings().isDebugEnabled())
//Vsync
@@ -472,14 +470,14 @@ class NEWTWindow implements GLEventListener {
@Override
public void reshape(final GLAutoDrawable glad, final int x, final int y, final int width, final int height) {
- onRealResize.onNext(new Integer[] { width, height });
+ onRealResize.submit(new Integer[] { width, height });
}
@Override
public void display(final GLAutoDrawable glad) {
final GL2ES1 gl = glad.getGL().getGL2ES1();
JOGLRenderer.gl = gl;
- onGLContext.onNext(gl);
+ onGLContext.submit(gl);
final boolean linear = windowZoom % (int) windowZoom != 0f;
if (refreshViewport) {
@@ -531,7 +529,7 @@ class NEWTWindow implements GLEventListener {
if (zoom == 0)
zoom = 1;
window.setSize(width * zoom, height * zoom);
- onRealResize.onNext(new Integer[] { width * zoom, height * zoom });
+ onRealResize.submit(new Integer[] { width * zoom, height * zoom });
}
@Override
diff --git a/hardware/pom.xml b/hardware/pom.xml
index 020f2e37..de2ce8b5 100644
--- a/hardware/pom.xml
+++ b/hardware/pom.xml
@@ -6,7 +6,7 @@
it.cavallium
warppi
- 0.9.0a3
+ 0.10.0-alpha
warppi-hardware
@@ -18,12 +18,12 @@
it.cavallium
warppi-core
- 0.9.0a3
+ 0.10.0-alpha
it.cavallium
warppi-engine-jogl
- 0.9.0a3
+ 0.10.0-alpha
com.pi4j
diff --git a/pom.xml b/pom.xml
index fc7486a7..64097df9 100755
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
it.cavallium
warppi
- 0.9.0a3
+ 0.10.0-alpha
pom
WarpPI Calculator
@@ -42,7 +42,6 @@
core
util
bigdecimal-math
- Flow
desktop
engine-jogl
diff --git a/teavm/pom.xml b/teavm/pom.xml
index 6aaf5c92..026b66db 100644
--- a/teavm/pom.xml
+++ b/teavm/pom.xml
@@ -6,7 +6,7 @@
it.cavallium
warppi
- 0.9.0a3
+ 0.10.0-alpha
warppi-teavm
jar
@@ -17,17 +17,12 @@
it.cavallium
warppi-core
- 0.9.0a3
-
-
- it.cavallium
- warppi-rules
- 0.9.0a3
+ 0.10.0-alpha
org.teavm
teavm-classlib
- 0.6.0-dev-682
+ 0.7.0-dev-916
provided
@@ -86,7 +81,7 @@
org.teavm
teavm-maven-plugin
- 0.6.0-dev-682
+ 0.7.0-dev-916
diff --git a/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlEngine.java b/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlEngine.java
index 10b18814..4dbc0217 100644
--- a/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlEngine.java
+++ b/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlEngine.java
@@ -2,6 +2,7 @@ package it.cavallium.warppi.gui.graphicengine.html;
import java.io.IOException;
+import it.cavallium.warppi.util.EventSubmitter;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSObject;
import org.teavm.jso.browser.Window;
@@ -20,8 +21,6 @@ import it.cavallium.warppi.Engine;
import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.Platform.Semaphore;
import it.cavallium.warppi.device.Keyboard;
-import it.cavallium.warppi.flow.BehaviorSubject;
-import it.cavallium.warppi.flow.Observable;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.RenderingLoop;
import it.unimi.dsi.fastutil.objects.Object2IntArrayMap;
@@ -38,8 +37,8 @@ public class HtmlEngine implements GraphicEngine {
private int width, height;
public int mult = 1;
private final int frameTime = (int) (1000d / 10d);
- private final BehaviorSubject onResize = BehaviorSubject.create();
- private final BehaviorSubject onZoom = BehaviorSubject.create();
+ private final EventSubmitter onResize = EventSubmitter.create();
+ private final EventSubmitter onZoom = EventSubmitter.create();
@Override
public int[] getSize() {
@@ -93,7 +92,7 @@ public class HtmlEngine implements GraphicEngine {
g = (CanvasRenderingContext2D) canvas.getContext("2d");
final HTMLInputElement keyInput = (HTMLInputElement) HtmlEngine.document.createElement("input");
StaticVars.windowZoom$.subscribe((zoom) -> {
- onZoom.onNext(zoom);
+ onZoom.submit(zoom);
});
onZoom.subscribe((windowZoom) -> {
if (windowZoom != 0) {
@@ -325,7 +324,7 @@ public class HtmlEngine implements GraphicEngine {
}
@Override
- public Observable onResize() {
+ public EventSubmitter onResize() {
return onResize;
}
diff --git a/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlSkin.java b/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlSkin.java
index 39090002..0f2297be 100644
--- a/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlSkin.java
+++ b/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlSkin.java
@@ -11,10 +11,6 @@ import org.teavm.jso.dom.html.HTMLImageElement;
import it.cavallium.warppi.Engine;
import it.cavallium.warppi.Platform.Semaphore;
-import it.cavallium.warppi.flow.BehaviorSubject;
-import it.cavallium.warppi.flow.SimpleSubject;
-import it.cavallium.warppi.flow.Subject;
-import it.cavallium.warppi.flow.ValueReference;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Skin;
@@ -49,13 +45,13 @@ public class HtmlSkin implements Skin {
@Override
public void initialize(final GraphicEngine d) {
final HTMLDocument doc = Window.current().getDocument();
- ValueReference done = new ValueReference(false);
+ Boolean[] done = new Boolean[]{false};
imgEl = doc.createElement("img").cast();
imgEl.addEventListener("load", (Event e) -> {
- done.value = true;
+ done[0] = true;
});
imgEl.setSrc(url);
- while (!done.value) {
+ while (!done[0]) {
try {Thread.sleep(15);} catch (Exception e) {}
}
skinSize = new int[] { imgEl.getNaturalWidth(), imgEl.getNaturalHeight() };
diff --git a/util/pom.xml b/util/pom.xml
index 42cdcab3..933ba64e 100644
--- a/util/pom.xml
+++ b/util/pom.xml
@@ -7,7 +7,7 @@
it.cavallium
warppi
- 0.9.0a3
+ 0.10.0-alpha
warppi-util