Removed old libraries
This commit is contained in:
parent
8e11197368
commit
da387d1165
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -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
|
||||
|
1
Flow
1
Flow
@ -1 +0,0 @@
|
||||
Subproject commit 92db616ef508f16fe30e8e37d17d7d7a18f56f4a
|
@ -1 +1 @@
|
||||
Subproject commit 40d89e539223aaa9202326833a2c813bed3c6eef
|
||||
Subproject commit da70aa7ba3bcae0e2e76fde338c56696ff25ea96
|
11
core/pom.xml
11
core/pom.xml
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>it.cavallium</groupId>
|
||||
<artifactId>warppi</artifactId>
|
||||
<version>0.9.0a3</version>
|
||||
<version>0.10.0-alpha</version>
|
||||
</parent>
|
||||
<artifactId>warppi-core</artifactId>
|
||||
|
||||
@ -14,20 +14,15 @@
|
||||
<description>WarpPI Calculator core project</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>it.cavallium</groupId>
|
||||
<artifactId>warppi-flow</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>it.cavallium</groupId>
|
||||
<artifactId>warppi-util</artifactId>
|
||||
<version>0.9.0a3</version>
|
||||
<version>0.10.0-alpha</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>it.cavallium</groupId>
|
||||
<artifactId>bigdecimal-math</artifactId>
|
||||
<version>0.9.0a3</version>
|
||||
<version>0.10.0-alpha</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>it.unimi.dsi</groupId>
|
||||
|
@ -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<LoadingStatus> loadPhase = BehaviorSubject.create();
|
||||
private final BehaviorSubject<Boolean> loaded = BehaviorSubject.create(false);
|
||||
private static EventSubmitter<LoadingStatus> loadPhase = new EventSubmitter<>();
|
||||
private final EventSubmitter<Boolean> 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<Boolean> isLoaded() {
|
||||
public EventSubmitter<Boolean> isLoaded() {
|
||||
return loaded;
|
||||
}
|
||||
|
||||
public Observable<LoadingStatus> getLoadPhase() {
|
||||
public EventSubmitter<LoadingStatus> 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();
|
||||
}
|
||||
|
@ -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<Float> windowZoom = BehaviorSubject.create(2F);
|
||||
public static EventSubmitter<Float> windowZoom = new EventSubmitter<>(2F);
|
||||
public static Function<Float, Float> windowZoomFunction = (val) -> {
|
||||
if (StaticVars.debugWindow2x) {
|
||||
return val + 1;
|
||||
@ -23,7 +22,7 @@ public class StaticVars {
|
||||
return val;
|
||||
}
|
||||
};
|
||||
public static Observable<Float> windowZoom$ = StaticVars.windowZoom.map(StaticVars.windowZoomFunction);
|
||||
public static EventSubmitter<Float> windowZoom$ = StaticVars.windowZoom.map(StaticVars.windowZoomFunction);
|
||||
public static StartupArguments startupArguments;
|
||||
|
||||
private StaticVars() {
|
||||
|
@ -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;
|
||||
|
@ -43,7 +43,7 @@ public class TetrisScreen extends Screen {
|
||||
|
||||
@Override
|
||||
public void initialized() {
|
||||
StaticVars.windowZoom.onNext(2f);
|
||||
StaticVars.windowZoom.submit(2f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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<Long> workTimer = Observable.interval(DisplayManager.tickDuration);
|
||||
|
||||
final Observable<Integer[]> onResizeObservable = engine.onResize();
|
||||
Observable<Pair<Long, Integer[]>> 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);
|
||||
}
|
||||
|
@ -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<Integer[]> refreshConsumer;
|
||||
private AtomicBoolean ticked = new AtomicBoolean(false);
|
||||
private AtomicBoolean sizeSet = new AtomicBoolean(false);
|
||||
private volatile Integer[] size;
|
||||
|
||||
public DisplayRefreshManager(Consumer<Integer[]> 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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<Integer[]> onResize();
|
||||
EventSubscriber<Integer[]> onResize();
|
||||
|
||||
int getWidth();
|
||||
|
||||
|
@ -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<Integer[]> onResize() {
|
||||
public EventSubscriber<Integer[]> onResize() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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<T> implements EventSubscriber<T>, Submitter<T> {
|
||||
private boolean initialized = false;
|
||||
private T value;
|
||||
private List<Consumer<T>> subscribers = new LinkedList<>();
|
||||
|
||||
public EventSubmitter() {
|
||||
value = null;
|
||||
}
|
||||
|
||||
public EventSubmitter(T defaultValue) {
|
||||
this.value = defaultValue;
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
public static <T> EventSubmitter<T> create() {
|
||||
return new EventSubmitter<>();
|
||||
}
|
||||
|
||||
public static <T> EventSubmitter<T> create(T value) {
|
||||
return new EventSubmitter<>(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getLastValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribe(Consumer<T> 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<T> subscriber : subscribers) {
|
||||
subscriber.accept(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <U> EventSubmitter<U> map(Function<T, U> mapFunction) {
|
||||
var eventSubmitter = new EventSubmitter<U>();
|
||||
map(eventSubmitter, mapFunction);
|
||||
return eventSubmitter;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package it.cavallium.warppi.util;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public interface EventSubscriber<T> {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Last value, or null
|
||||
*/
|
||||
T getLastValue();
|
||||
|
||||
void subscribe(Consumer<T> action);
|
||||
|
||||
default <U> EventSubscriber<U> map(Function<T, U> mapFunction) {
|
||||
var eventSubmitter = new EventSubmitter<U>();
|
||||
map(this, eventSubmitter, mapFunction);
|
||||
return eventSubmitter;
|
||||
}
|
||||
|
||||
default <U> void map(EventSubmitter<U> targetHandler, Function<T, U> mapFunction) {
|
||||
map(this, targetHandler, mapFunction);
|
||||
}
|
||||
|
||||
static <T, U> void map(EventSubscriber<T> originalEventHandler, EventSubmitter<U> mappedEventHandler, Function<T, U> mapFunction) {
|
||||
originalEventHandler.subscribe((value) -> {
|
||||
mappedEventHandler.submit(mapFunction.apply(value));
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package it.cavallium.warppi.util;
|
||||
|
||||
public interface Submitter<T> {
|
||||
void submit(T value);
|
||||
}
|
31
core/src/main/java/it/cavallium/warppi/util/Timer.java
Normal file
31
core/src/main/java/it/cavallium/warppi/util/Timer.java
Normal file
@ -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();
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>it.cavallium</groupId>
|
||||
<artifactId>warppi</artifactId>
|
||||
<version>0.9.0a3</version>
|
||||
<version>0.10.0-alpha</version>
|
||||
</parent>
|
||||
<artifactId>warppi-desktop</artifactId>
|
||||
|
||||
@ -16,12 +16,12 @@
|
||||
<dependency>
|
||||
<groupId>it.cavallium</groupId>
|
||||
<artifactId>warppi-core</artifactId>
|
||||
<version>0.9.0a3</version>
|
||||
<version>0.10.0-alpha</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>it.cavallium</groupId>
|
||||
<artifactId>warppi-engine-jogl</artifactId>
|
||||
<version>0.9.0a3</version>
|
||||
<version>0.10.0-alpha</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.fusesource.jansi</groupId>
|
||||
|
@ -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<Integer[]> onResize() {
|
||||
public EventSubmitter<Integer[]> onResize() {
|
||||
return INSTANCE.onResize();
|
||||
}
|
||||
|
||||
|
@ -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<Integer[]> onResize;
|
||||
private final Observable<Integer[]> onResize$;
|
||||
private final EventSubmitter<Integer[]> onResize;
|
||||
private final EventSubmitter<Integer[]> 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<Integer[]> onResize() {
|
||||
public EventSubmitter<Integer[]> onResize() {
|
||||
return onResize$;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>it.cavallium</groupId>
|
||||
<artifactId>warppi</artifactId>
|
||||
<version>0.9.0a3</version>
|
||||
<version>0.10.0-alpha</version>
|
||||
</parent>
|
||||
<artifactId>warppi-engine-jogl</artifactId>
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
<dependency>
|
||||
<groupId>it.cavallium</groupId>
|
||||
<artifactId>warppi-core</artifactId>
|
||||
<version>0.9.0a3</version>
|
||||
<version>0.10.0-alpha</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jogamp.jogl</groupId>
|
||||
|
@ -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<Integer[]> onResize() {
|
||||
public EventSubscriber<Integer[]> onResize() {
|
||||
return wnd.onResizeEvent;
|
||||
}
|
||||
|
||||
|
@ -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<TouchPoint> touches = new ObjectArrayList<>();
|
||||
|
||||
final BehaviorSubject<Integer[]> onRealResize;
|
||||
final BehaviorSubject<Integer[]> onResizeEvent = BehaviorSubject.create();
|
||||
private final BehaviorSubject<Float> onZoom = BehaviorSubject.create();
|
||||
private final Subject<GL2ES1> onGLContext = SimpleSubject.create();
|
||||
final EventSubmitter<Integer[]> onRealResize;
|
||||
final EventSubmitter<Integer[]> onResizeEvent = EventSubmitter.create();
|
||||
private final EventSubmitter<Float> onZoom = EventSubmitter.create();
|
||||
private final EventSubmitter<GL2ES1> 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
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>it.cavallium</groupId>
|
||||
<artifactId>warppi</artifactId>
|
||||
<version>0.9.0a3</version>
|
||||
<version>0.10.0-alpha</version>
|
||||
</parent>
|
||||
<artifactId>warppi-hardware</artifactId>
|
||||
|
||||
@ -18,12 +18,12 @@
|
||||
<dependency>
|
||||
<groupId>it.cavallium</groupId>
|
||||
<artifactId>warppi-core</artifactId>
|
||||
<version>0.9.0a3</version>
|
||||
<version>0.10.0-alpha</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>it.cavallium</groupId>
|
||||
<artifactId>warppi-engine-jogl</artifactId>
|
||||
<version>0.9.0a3</version>
|
||||
<version>0.10.0-alpha</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pi4j</groupId>
|
||||
|
3
pom.xml
3
pom.xml
@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>it.cavallium</groupId>
|
||||
<artifactId>warppi</artifactId>
|
||||
<version>0.9.0a3</version>
|
||||
<version>0.10.0-alpha</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>WarpPI Calculator</name>
|
||||
@ -42,7 +42,6 @@
|
||||
<module>core</module>
|
||||
<module>util</module>
|
||||
<module>bigdecimal-math</module>
|
||||
<module>Flow</module>
|
||||
<!-- <module>hardware</module> -->
|
||||
<module>desktop</module>
|
||||
<module>engine-jogl</module>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>it.cavallium</groupId>
|
||||
<artifactId>warppi</artifactId>
|
||||
<version>0.9.0a3</version>
|
||||
<version>0.10.0-alpha</version>
|
||||
</parent>
|
||||
<artifactId>warppi-teavm</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
@ -17,17 +17,12 @@
|
||||
<dependency>
|
||||
<groupId>it.cavallium</groupId>
|
||||
<artifactId>warppi-core</artifactId>
|
||||
<version>0.9.0a3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>it.cavallium</groupId>
|
||||
<artifactId>warppi-rules</artifactId>
|
||||
<version>0.9.0a3</version>
|
||||
<version>0.10.0-alpha</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-classlib</artifactId>
|
||||
<version>0.6.0-dev-682</version>
|
||||
<version>0.7.0-dev-916</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@ -86,7 +81,7 @@
|
||||
<plugin>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-maven-plugin</artifactId>
|
||||
<version>0.6.0-dev-682</version>
|
||||
<version>0.7.0-dev-916</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
@ -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<Integer[]> onResize = BehaviorSubject.create();
|
||||
private final BehaviorSubject<Float> onZoom = BehaviorSubject.create();
|
||||
private final EventSubmitter<Integer[]> onResize = EventSubmitter.create();
|
||||
private final EventSubmitter<Float> 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<Integer[]> onResize() {
|
||||
public EventSubmitter<Integer[]> onResize() {
|
||||
return onResize;
|
||||
}
|
||||
|
||||
|
@ -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<Boolean> done = new ValueReference<Boolean>(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() };
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>it.cavallium</groupId>
|
||||
<artifactId>warppi</artifactId>
|
||||
<version>0.9.0a3</version>
|
||||
<version>0.10.0-alpha</version>
|
||||
</parent>
|
||||
<artifactId>warppi-util</artifactId>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user