More appropriate class names

This commit is contained in:
Andrea Cavalli 2019-02-27 23:29:03 +01:00
parent c906c43b8b
commit ff7dd21788
75 changed files with 765 additions and 770 deletions

View File

@ -1,146 +0,0 @@
package it.cavallium.warppi;
import java.io.IOException;
import it.cavallium.warppi.Platform.ConsoleUtils;
import it.cavallium.warppi.boot.StartupArguments;
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;
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 HardwareDevice hardwareDevice;
private Engine() {}
/**
* Start an instance of the calculator.
*
* @param platform
* Platform implementation
* @param screen
* Default screen to show at startup
* @param disp
* Hardware display
* @param hud
* Head-up display
* @param args
* Startup arguments
* @throws InterruptedException
* @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 {
if (Engine.running) {
throw new RuntimeException("Already running!");
} else {
Engine.running = true;
Engine.INSTANCE.startInstance(platform, screen, disp, touchdevice, hud, args);
}
}
private void startInstance(final Platform platform, final Screen screen, final HardwareDisplay disp,
final HardwareTouchDevice touchdevice, final HUD hud, final StartupArguments args)
throws InterruptedException, IOException {
Engine.platform = platform;
platform.getConsoleUtils().out().println("WarpPI Calculator");
initializeEnvironment(args);
final Thread currentThread = Thread.currentThread();
currentThread.setPriority(Thread.MAX_PRIORITY);
Engine.getPlatform().setThreadName(currentThread, "Main thread");
final DisplayManager dm = new DisplayManager(disp, hud, screen, "WarpPI Calculator by Andrea Cavalli (@Cavallium)");
final Keyboard k = new Keyboard();
final InputManager im = new InputManager(k, touchdevice);
hardwareDevice = new HardwareDevice(dm, im);
hardwareDevice.setup(() -> Engine.loadPhase.onNext(new LoadingStatus()));
}
private void onShutdown() {
Engine.platform.getConsoleUtils().out().println(1, "Shutdown...");
beforeShutdown();
Engine.platform.getConsoleUtils().out().println(1, "");
Engine.platform.getConsoleUtils().out().println(1, "Closed.");
Engine.getPlatform().exit(0);
}
private void initializeEnvironment(final StartupArguments args) throws IOException {
ClassUtils.classLoader = this.getClass();
StaticVars.startupArguments = args;
StaticVars.debugWindow2x = args.isZoomed();
if (args.isVerboseLoggingEnabled() || args.isDebugEnabled()) {
StaticVars.outputLevel = ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE;
}
Engine.platform.getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, args);
checkDeviceType();
if (args.isRaspberryModeAllowed() == false) {
Engine.getPlatform().setRunningOnRaspberry(false);
}
if (Engine.getPlatform().isRunningOnRaspberry()) {
Engine.getPlatform().getGpio().wiringPiSetupPhys();
Engine.getPlatform().getGpio().pinMode(12, Engine.getPlatform().getGpio().valuePwmOutput());
} else {
StaticVars.screenPos = new int[] { 0, 0 };
if (Engine.getPlatform().isJavascript() == false) {
Engine.getPlatform().getSettings().setDebugEnabled(true);
}
}
}
private void checkDeviceType() {
// TODO Auto-generated method stub
}
public void beforeShutdown() {
Keyboard.stopKeyboard();
}
public Observable<Boolean> isLoaded() {
return loaded;
}
public Observable<LoadingStatus> getLoadPhase() {
return Engine.loadPhase;
}
public HardwareDevice getHardwareDevice() {
return hardwareDevice;
}
public static Platform getPlatform() {
return Engine.platform;
}
public static class LoadingStatus {
protected LoadingStatus() {
}
public void done() {
Engine.INSTANCE.loaded.onNext(true);
Engine.INSTANCE.hardwareDevice.getDisplayManager().waitForExit();
Engine.INSTANCE.onShutdown();
}
public void failed() {
Engine.INSTANCE.onShutdown();
}
}
}

View File

@ -9,7 +9,10 @@ import java.net.URL;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.device.display.BacklightOutputDevice;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.device.input.KeyboardInputDevice;
import it.cavallium.warppi.device.input.TouchInputDevice;
import it.cavallium.warppi.util.Error; import it.cavallium.warppi.util.Error;
public interface Platform { public interface Platform {
@ -52,9 +55,13 @@ public interface Platform {
URLClassLoader newURLClassLoader(URL[] urls); URLClassLoader newURLClassLoader(URL[] urls);
Map<String, GraphicEngine> getEnginesList(); TouchInputDevice getTouchInputDevice();
GraphicEngine getEngine(String string) throws NullPointerException; KeyboardInputDevice getKeyboardInputDevice();
DisplayOutputDevice getDisplayOutputDevice();
BacklightOutputDevice getBacklightOutputDevice();
void throwNewExceptionInInitializerError(String text); void throwNewExceptionInInitializerError(String text);

View File

@ -11,8 +11,6 @@ import it.cavallium.warppi.flow.Observable;
*/ */
public class StaticVars { public class StaticVars {
public static final boolean zoomed = true; public static final boolean zoomed = true;
public static int[] screenPos = new int[] { 0, 0 };
public static final int[] screenSize = new int[] { 480, 320 };
public static int outputLevel = 0; public static int outputLevel = 0;
public static boolean debugWindow2x = false; public static boolean debugWindow2x = false;
public static BehaviorSubject<Float> windowZoom = BehaviorSubject.create(2F); public static BehaviorSubject<Float> windowZoom = BehaviorSubject.create(2F);

View File

@ -0,0 +1,147 @@
package it.cavallium.warppi;
import java.io.IOException;
import it.cavallium.warppi.Platform.ConsoleUtils;
import it.cavallium.warppi.boot.StartupArguments;
import it.cavallium.warppi.device.Device;
import it.cavallium.warppi.device.display.BacklightOutputDevice;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.device.input.InputManager;
import it.cavallium.warppi.device.input.Keyboard;
import it.cavallium.warppi.device.input.KeyboardInputDevice;
import it.cavallium.warppi.device.input.TouchInputDevice;
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;
public class WarpPI {
public static final WarpPI INSTANCE = new WarpPI();
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 Device device;
private WarpPI() {}
/**
* Start an instance of the calculator.
*
* @param platform
* Platform implementation
* @param screen
* Default screen to show at startup
* @param hud
* Head-up display
* @param args
* Startup arguments
* @throws InterruptedException
* @throws IOException
*/
public static void start(final Platform platform, final Screen screen, final HUD hud, final StartupArguments args)
throws InterruptedException, IOException {
if (WarpPI.running) {
throw new RuntimeException("Already running!");
} else {
WarpPI.running = true;
WarpPI.INSTANCE.startEngine(platform, screen, hud, args);
}
}
private void startEngine(final Platform platform, final Screen screen,
final HUD hud, final StartupArguments args)
throws InterruptedException, IOException {
WarpPI.platform = platform;
platform.getConsoleUtils().out().println("WarpPI Calculator");
initializeEnvironment(args);
final Thread currentThread = Thread.currentThread();
currentThread.setPriority(Thread.MAX_PRIORITY);
WarpPI.getPlatform().setThreadName(currentThread, "Main thread");
final DisplayOutputDevice display = platform.getDisplayOutputDevice();
final BacklightOutputDevice backlight = platform.getBacklightOutputDevice();
final DisplayManager dm = new DisplayManager(display, backlight, hud, screen, "WarpPI Calculator by Andrea Cavalli (@Cavallium)");
final KeyboardInputDevice keyboard = platform.getKeyboardInputDevice();
final TouchInputDevice touchscreen = platform.getTouchInputDevice();
final InputManager im = new InputManager(keyboard, touchscreen);
device = new Device(dm, im);
device.setup(() -> WarpPI.loadPhase.onNext(new LoadingStatus()));
}
private void onShutdown() {
WarpPI.platform.getConsoleUtils().out().println(1, "Shutdown...");
beforeShutdown();
WarpPI.platform.getConsoleUtils().out().println(1, "");
WarpPI.platform.getConsoleUtils().out().println(1, "Closed.");
WarpPI.getPlatform().exit(0);
}
private void initializeEnvironment(final StartupArguments args) throws IOException {
ClassUtils.classLoader = this.getClass();
StaticVars.startupArguments = args;
StaticVars.debugWindow2x = args.isZoomed();
if (args.isVerboseLoggingEnabled() || args.isDebugEnabled()) {
StaticVars.outputLevel = ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE;
}
WarpPI.platform.getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, args);
checkDeviceType();
if (args.isRaspberryModeAllowed() == false) {
WarpPI.getPlatform().setRunningOnRaspberry(false);
}
if (WarpPI.getPlatform().isRunningOnRaspberry()) {
WarpPI.getPlatform().getGpio().wiringPiSetupPhys();
WarpPI.getPlatform().getGpio().pinMode(12, WarpPI.getPlatform().getGpio().valuePwmOutput());
} else {
if (WarpPI.getPlatform().isJavascript() == false) {
WarpPI.getPlatform().getSettings().setDebugEnabled(true);
}
}
}
private void checkDeviceType() {
// TODO Auto-generated method stub
}
public void beforeShutdown() {
Keyboard.stopKeyboard();
}
public Observable<Boolean> isLoaded() {
return loaded;
}
public Observable<LoadingStatus> getLoadPhase() {
return WarpPI.loadPhase;
}
public Device getHardwareDevice() {
return device;
}
public static Platform getPlatform() {
return WarpPI.platform;
}
public static class LoadingStatus {
protected LoadingStatus() {
}
public void done() {
WarpPI.INSTANCE.loaded.onNext(true);
WarpPI.INSTANCE.device.getDisplayManager().waitForExit();
WarpPI.INSTANCE.onShutdown();
}
public void failed() {
WarpPI.INSTANCE.onShutdown();
}
}
}

View File

@ -2,11 +2,11 @@ package it.cavallium.warppi.boot;
import java.util.Arrays; import java.util.Arrays;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Engine.LoadingStatus; import it.cavallium.warppi.WarpPI.LoadingStatus;
import it.cavallium.warppi.Platform; import it.cavallium.warppi.Platform;
import it.cavallium.warppi.device.PIHardwareDisplay; import it.cavallium.warppi.device.PIHardwareDisplay;
import it.cavallium.warppi.device.PIHardwareTouchDevice; import it.cavallium.warppi.device.input.PIHardwareTouchDevice;
import it.cavallium.warppi.gui.CalculatorHUD; import it.cavallium.warppi.gui.CalculatorHUD;
import it.cavallium.warppi.gui.screens.LoadingScreen; import it.cavallium.warppi.gui.screens.LoadingScreen;
import it.cavallium.warppi.math.rules.RulesManager; import it.cavallium.warppi.math.rules.RulesManager;
@ -15,13 +15,14 @@ import it.cavallium.warppi.util.Error;
public class Boot { public class Boot {
public static void boot(final Platform platform, final String[] args) throws Exception { public static void boot(final Platform platform, final String[] args) throws Exception {
Engine.start(platform, new LoadingScreen(), new PIHardwareDisplay(), new PIHardwareTouchDevice(false, false, false), new CalculatorHUD(), Boot.parseStartupArguments(args)); WarpPI.start(platform, new LoadingScreen(), new CalculatorHUD(), Boot.parseStartupArguments(args));
Engine.INSTANCE.getLoadPhase().subscribe(Boot::loadCalculator); WarpPI.INSTANCE.getLoadPhase().subscribe(Boot::loadCalculator);
} }
private static void loadCalculator(final LoadingStatus loading) { private static void loadCalculator(final LoadingStatus loading) {
try { try {
Engine.INSTANCE.getHardwareDevice().getDisplayManager().setBrightness(0.2f); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().setBrightness(0.2f);
//TODO: plugins system: PluginsManager.initialize();
RulesManager.initialize(); RulesManager.initialize();
RulesManager.warmUp(); RulesManager.warmUp();
loading.done(); loading.done();

View File

@ -8,7 +8,7 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.util.UUID; import java.util.UUID;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
public class CacheFile { public class CacheFile {
private String path; private String path;
@ -22,7 +22,7 @@ public class CacheFile {
path = UUID.randomUUID().toString() + ".ser"; path = UUID.randomUUID().toString() + ".ser";
} while (new File(path).exists()); } while (new File(path).exists());
try { try {
File.createTempFile(Engine.getPlatform().getSettings().getCalculatorNameLowercase(), ""); File.createTempFile(WarpPI.getPlatform().getSettings().getCalculatorNameLowercase(), "");
} catch (final IOException e) { } catch (final IOException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -1,13 +1,14 @@
package it.cavallium.warppi.device; package it.cavallium.warppi.device;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.device.input.InputManager;
import it.cavallium.warppi.gui.DisplayManager; import it.cavallium.warppi.gui.DisplayManager;
public class HardwareDevice { public class Device {
private final DisplayManager displayManager; private final DisplayManager displayManager;
private final InputManager inputManager; private final InputManager inputManager;
public HardwareDevice(final DisplayManager m, final InputManager im) { public Device(final DisplayManager m, final InputManager im) {
displayManager = m; displayManager = m;
inputManager = im; inputManager = im;
} }
@ -22,10 +23,9 @@ public class HardwareDevice {
public void setup(final Runnable r) { public void setup(final Runnable r) {
displayManager.initialize(); displayManager.initialize();
inputManager.getKeyboard().startKeyboard();
final Thread t = new Thread(r); final Thread t = new Thread(r);
Engine.getPlatform().setThreadDaemon(t, false); WarpPI.getPlatform().setThreadDaemon(t, false);
Engine.getPlatform().setThreadName(t, "Main thread (after setup)"); WarpPI.getPlatform().setThreadName(t, "Main thread (after setup)");
t.start(); t.start();
} }

View File

@ -1,20 +0,0 @@
package it.cavallium.warppi.device;
public class InputManager {
private final Keyboard keyboard;
private final HardwareTouchDevice touchDevice;
public InputManager(final Keyboard k, final HardwareTouchDevice t) {
keyboard = k;
touchDevice = t;
}
public Keyboard getKeyboard() {
return keyboard;
}
public HardwareTouchDevice getTouchDevice() {
return touchDevice;
}
}

View File

@ -1,24 +0,0 @@
package it.cavallium.warppi.device;
import it.cavallium.warppi.Engine;
import it.cavallium.warppi.gui.HardwareDisplay;
public class PIHardwareDisplay implements HardwareDisplay {
@Override
public void initialize() {}
@Override
public void shutdown() {}
@Override
public void setBrightness(final double value) {
if (Engine.getPlatform().isRunningOnRaspberry()) {
Engine.getPlatform().getGpio().pwmWrite(12, (int) Math.ceil(value * 1024f));
// SoftPwm.softPwmWrite(12, (int)(Math.ceil(brightness*10)));
} else {
Engine.getPlatform().getConsoleUtils().out().println(1, "Brightness: " + value);
}
}
}

View File

@ -1,6 +1,6 @@
package it.cavallium.warppi.device.chip; package it.cavallium.warppi.device.chip;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
public class ParallelToSerial { public class ParallelToSerial {
@ -18,16 +18,16 @@ public class ParallelToSerial {
public boolean[] read() { public boolean[] read() {
final boolean[] data = new boolean[8]; final boolean[] data = new boolean[8];
Engine.getPlatform().getGpio().digitalWrite(CLK_INH, Engine.getPlatform().getGpio().valueHigh()); WarpPI.getPlatform().getGpio().digitalWrite(CLK_INH, WarpPI.getPlatform().getGpio().valueHigh());
Engine.getPlatform().getGpio().digitalWrite(SH_LD, Engine.getPlatform().getGpio().valueLow()); WarpPI.getPlatform().getGpio().digitalWrite(SH_LD, WarpPI.getPlatform().getGpio().valueLow());
Engine.getPlatform().getGpio().delayMicroseconds(1); WarpPI.getPlatform().getGpio().delayMicroseconds(1);
Engine.getPlatform().getGpio().digitalWrite(SH_LD, Engine.getPlatform().getGpio().valueHigh()); WarpPI.getPlatform().getGpio().digitalWrite(SH_LD, WarpPI.getPlatform().getGpio().valueHigh());
Engine.getPlatform().getGpio().digitalWrite(CLK_INH, Engine.getPlatform().getGpio().valueLow()); WarpPI.getPlatform().getGpio().digitalWrite(CLK_INH, WarpPI.getPlatform().getGpio().valueLow());
for (int i = 7; i >= 0; i--) { for (int i = 7; i >= 0; i--) {
Engine.getPlatform().getGpio().digitalWrite(CLK, Engine.getPlatform().getGpio().valueHigh()); WarpPI.getPlatform().getGpio().digitalWrite(CLK, WarpPI.getPlatform().getGpio().valueHigh());
Engine.getPlatform().getGpio().digitalWrite(CLK, Engine.getPlatform().getGpio().valueLow()); WarpPI.getPlatform().getGpio().digitalWrite(CLK, WarpPI.getPlatform().getGpio().valueLow());
data[i] = Engine.getPlatform().getGpio().digitalRead(QH) == Engine.getPlatform().getGpio().valueHigh() ? true : false; data[i] = WarpPI.getPlatform().getGpio().digitalRead(QH) == WarpPI.getPlatform().getGpio().valueHigh() ? true : false;
} }
return data; return data;

View File

@ -1,6 +1,6 @@
package it.cavallium.warppi.device.chip; package it.cavallium.warppi.device.chip;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
public class SerialToParallel { public class SerialToParallel {
private final int RCK; //Storage register clock pin (latch pin) private final int RCK; //Storage register clock pin (latch pin)
@ -17,15 +17,15 @@ public class SerialToParallel {
if (data.length != 8) { if (data.length != 8) {
return; return;
} else { } else {
Engine.getPlatform().getGpio().digitalWrite(RCK, Engine.getPlatform().getGpio().valueLow()); WarpPI.getPlatform().getGpio().digitalWrite(RCK, WarpPI.getPlatform().getGpio().valueLow());
for (int i = 7; i >= 0; i--) { for (int i = 7; i >= 0; i--) {
Engine.getPlatform().getGpio().digitalWrite(SCK, Engine.getPlatform().getGpio().valueLow()); WarpPI.getPlatform().getGpio().digitalWrite(SCK, WarpPI.getPlatform().getGpio().valueLow());
Engine.getPlatform().getGpio().digitalWrite(SER, data[i]); WarpPI.getPlatform().getGpio().digitalWrite(SER, data[i]);
Engine.getPlatform().getGpio().digitalWrite(SCK, Engine.getPlatform().getGpio().valueHigh()); WarpPI.getPlatform().getGpio().digitalWrite(SCK, WarpPI.getPlatform().getGpio().valueHigh());
} }
Engine.getPlatform().getGpio().digitalWrite(RCK, Engine.getPlatform().getGpio().valueHigh()); WarpPI.getPlatform().getGpio().digitalWrite(RCK, WarpPI.getPlatform().getGpio().valueHigh());
} }
} }
} }

View File

@ -0,0 +1,16 @@
package it.cavallium.warppi.device.display;
public interface BacklightOutputDevice {
/**
* Set the brightness level
* @param value Value from 0.0 to 1.0
*/
void setBrightness(double value);
/**
* Turn on or off the backlight
* @param value true is ON, false is OFF
*/
void setPower(boolean value);
}

View File

@ -0,0 +1,8 @@
package it.cavallium.warppi.device.display;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
public interface DisplayOutputDevice {
public GraphicEngine getGraphicEngine();
public int[] getDisplaySize();
}

View File

@ -1,4 +1,4 @@
package it.cavallium.warppi.device.graphicengine; package it.cavallium.warppi.device.display;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -7,7 +7,7 @@ import java.net.URL;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.util.ClassUtils; import it.cavallium.warppi.util.ClassUtils;
import it.cavallium.warppi.util.Utils; import it.cavallium.warppi.util.Utils;
@ -32,7 +32,7 @@ public class RAWFont {
loadFont("/font_" + name + ".rft"); loadFont("/font_" + name + ".rft");
} catch (final IOException e) { } catch (final IOException e) {
e.printStackTrace(); e.printStackTrace();
Engine.getPlatform().exit(1); WarpPI.getPlatform().exit(1);
} }
chars32 = new int[(maxBound - minBound) * charIntCount]; chars32 = new int[(maxBound - minBound) * charIntCount];
for (int charIndex = 0; charIndex < maxBound - minBound; charIndex++) { for (int charIndex = 0; charIndex < maxBound - minBound; charIndex++) {
@ -110,7 +110,7 @@ public class RAWFont {
} catch (final Exception ex) { } catch (final Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
System.out.println(string); System.out.println(string);
Engine.getPlatform().exit(-1); WarpPI.getPlatform().exit(-1);
} }
} }
} else { } else {

View File

@ -0,0 +1,5 @@
package it.cavallium.warppi.device.input;
public interface HardwareKeyboardDevice {
}

View File

@ -0,0 +1,22 @@
package it.cavallium.warppi.device.input;
public class InputManager {
private final KeyboardInputDevice keyboard;
private final TouchInputDevice touchDevice;
public InputManager(KeyboardInputDevice keyboard, TouchInputDevice touchscreen) {
this.keyboard = keyboard;
this.touchDevice = touchscreen;
}
// TODO: manage the keyboard and the touchscreen here!
public KeyboardInputDevice getKeyboard() {
return keyboard;
}
public TouchInputDevice getTouchDevice() {
return touchDevice;
}
}

View File

@ -1,6 +1,6 @@
package it.cavallium.warppi.device; package it.cavallium.warppi.device.input;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform.ConsoleUtils; import it.cavallium.warppi.Platform.ConsoleUtils;
import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.device.chip.ParallelToSerial; import it.cavallium.warppi.device.chip.ParallelToSerial;
@ -40,7 +40,7 @@ public class Keyboard {
public synchronized void startKeyboard() { public synchronized void startKeyboard() {
final Thread kt = new Thread(() -> { final Thread kt = new Thread(() -> {
if (Engine.getPlatform().isRunningOnRaspberry() == false) { if (WarpPI.getPlatform().isRunningOnRaspberry() == false) {
try { try {
while (true) { while (true) {
if (Keyboard.debugKeyCode != -1) { if (Keyboard.debugKeyCode != -1) {
@ -55,19 +55,19 @@ public class Keyboard {
} }
} catch (final InterruptedException e) {} } catch (final InterruptedException e) {}
} else { } else {
Engine.getPlatform().getGpio().pinMode(Keyboard.CLK_INH_pin, Engine.getPlatform().getGpio().valueOutput()); WarpPI.getPlatform().getGpio().pinMode(Keyboard.CLK_INH_pin, WarpPI.getPlatform().getGpio().valueOutput());
Engine.getPlatform().getGpio().pinMode(Keyboard.RCK_pin, Engine.getPlatform().getGpio().valueOutput()); WarpPI.getPlatform().getGpio().pinMode(Keyboard.RCK_pin, WarpPI.getPlatform().getGpio().valueOutput());
Engine.getPlatform().getGpio().pinMode(Keyboard.SER_pin, Engine.getPlatform().getGpio().valueOutput()); WarpPI.getPlatform().getGpio().pinMode(Keyboard.SER_pin, WarpPI.getPlatform().getGpio().valueOutput());
Engine.getPlatform().getGpio().pinMode(Keyboard.SH_LD_pin, Engine.getPlatform().getGpio().valueOutput()); WarpPI.getPlatform().getGpio().pinMode(Keyboard.SH_LD_pin, WarpPI.getPlatform().getGpio().valueOutput());
Engine.getPlatform().getGpio().pinMode(Keyboard.SCK_and_CLK_pin, Engine.getPlatform().getGpio().valueOutput()); WarpPI.getPlatform().getGpio().pinMode(Keyboard.SCK_and_CLK_pin, WarpPI.getPlatform().getGpio().valueOutput());
Engine.getPlatform().getGpio().pinMode(Keyboard.QH_pin, Engine.getPlatform().getGpio().valueInput()); WarpPI.getPlatform().getGpio().pinMode(Keyboard.QH_pin, WarpPI.getPlatform().getGpio().valueInput());
Engine.getPlatform().getGpio().digitalWrite(Keyboard.CLK_INH_pin, false); WarpPI.getPlatform().getGpio().digitalWrite(Keyboard.CLK_INH_pin, false);
Engine.getPlatform().getGpio().digitalWrite(Keyboard.RCK_pin, false); WarpPI.getPlatform().getGpio().digitalWrite(Keyboard.RCK_pin, false);
Engine.getPlatform().getGpio().digitalWrite(Keyboard.SER_pin, false); WarpPI.getPlatform().getGpio().digitalWrite(Keyboard.SER_pin, false);
Engine.getPlatform().getGpio().digitalWrite(Keyboard.SH_LD_pin, false); WarpPI.getPlatform().getGpio().digitalWrite(Keyboard.SH_LD_pin, false);
Engine.getPlatform().getGpio().digitalWrite(Keyboard.SCK_and_CLK_pin, false); WarpPI.getPlatform().getGpio().digitalWrite(Keyboard.SCK_and_CLK_pin, false);
Engine.getPlatform().getGpio().digitalWrite(Keyboard.QH_pin, false); WarpPI.getPlatform().getGpio().digitalWrite(Keyboard.QH_pin, false);
final SerialToParallel chip1 = new SerialToParallel(Keyboard.RCK_pin, Keyboard.SCK_and_CLK_pin /*SCK*/, Keyboard.SER_pin); final SerialToParallel chip1 = new SerialToParallel(Keyboard.RCK_pin, Keyboard.SCK_and_CLK_pin /*SCK*/, Keyboard.SER_pin);
final ParallelToSerial chip2 = new ParallelToSerial(Keyboard.SH_LD_pin, Keyboard.CLK_INH_pin, Keyboard.QH_pin, Keyboard.SCK_and_CLK_pin/*CLK*/); final ParallelToSerial chip2 = new ParallelToSerial(Keyboard.SH_LD_pin, Keyboard.CLK_INH_pin, Keyboard.QH_pin, Keyboard.SCK_and_CLK_pin/*CLK*/);
@ -98,9 +98,9 @@ public class Keyboard {
} }
} }
}); });
Engine.getPlatform().setThreadName(kt, "Keyboard thread"); WarpPI.getPlatform().setThreadName(kt, "Keyboard thread");
kt.setPriority(Thread.NORM_PRIORITY + 1); kt.setPriority(Thread.NORM_PRIORITY + 1);
Engine.getPlatform().setThreadDaemon(kt); WarpPI.getPlatform().setThreadDaemon(kt);
kt.start(); kt.start();
} }
@ -290,7 +290,7 @@ public class Keyboard {
if (!Keyboard.shift && !Keyboard.alpha) { if (!Keyboard.shift && !Keyboard.alpha) {
debugKey(Key.NUM7, released); debugKey(Key.NUM7, released);
} else if (Keyboard.shift) { } else if (Keyboard.shift) {
if (Engine.getPlatform().isRunningOnRaspberry() == false) { if (WarpPI.getPlatform().isRunningOnRaspberry() == false) {
debugKey(Key.DIVIDE, released); debugKey(Key.DIVIDE, released);
} }
} }
@ -680,7 +680,7 @@ public class Keyboard {
*/ */
@Deprecated @Deprecated
public static boolean isKeyDown(final int row, final int col) { public static boolean isKeyDown(final int row, final int col) {
if (Engine.getPlatform().isRunningOnRaspberry()) { if (WarpPI.getPlatform().isRunningOnRaspberry()) {
return Keyboard.precedentStates[row - 1][col - 1]; return Keyboard.precedentStates[row - 1][col - 1];
} else { } else {
return Keyboard.debugKeysDown[row - 1][col - 1]; return Keyboard.debugKeysDown[row - 1][col - 1];
@ -892,13 +892,13 @@ public class Keyboard {
} }
public static void stopKeyboard() { public static void stopKeyboard() {
if (Engine.getPlatform().isRunningOnRaspberry()) { if (WarpPI.getPlatform().isRunningOnRaspberry()) {
Engine.getPlatform().getGpio().digitalWrite(33, false); WarpPI.getPlatform().getGpio().digitalWrite(33, false);
Engine.getPlatform().getGpio().digitalWrite(35, false); WarpPI.getPlatform().getGpio().digitalWrite(35, false);
Engine.getPlatform().getGpio().digitalWrite(36, false); WarpPI.getPlatform().getGpio().digitalWrite(36, false);
Engine.getPlatform().getGpio().digitalWrite(37, false); WarpPI.getPlatform().getGpio().digitalWrite(37, false);
Engine.getPlatform().getGpio().digitalWrite(38, false); WarpPI.getPlatform().getGpio().digitalWrite(38, false);
Engine.getPlatform().getGpio().digitalWrite(40, false); WarpPI.getPlatform().getGpio().digitalWrite(40, false);
} }
} }
@ -911,8 +911,8 @@ public class Keyboard {
new GUIErrorMessage(ex); new GUIErrorMessage(ex);
} }
} }
if (Engine.INSTANCE.getHardwareDevice().getDisplayManager() != null) { if (WarpPI.INSTANCE.getHardwareDevice().getDisplayManager() != null) {
final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen(); final Screen scr = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
boolean refresh = false; boolean refresh = false;
boolean scrdone = false; boolean scrdone = false;
try { try {
@ -925,38 +925,38 @@ public class Keyboard {
} else { } else {
switch (k) { switch (k) {
case POWEROFF: case POWEROFF:
Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.destroy(); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.destroy();
break; break;
case NONE: case NONE:
break; break;
case BRIGHTNESS_CYCLE: case BRIGHTNESS_CYCLE:
Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new TetrisScreen()); //TODO: rimuovere: prova WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new TetrisScreen()); //TODO: rimuovere: prova
Engine.INSTANCE.getHardwareDevice().getDisplayManager().cycleBrightness(false); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().cycleBrightness(false);
refresh = true; refresh = true;
break; break;
case BRIGHTNESS_CYCLE_REVERSE: case BRIGHTNESS_CYCLE_REVERSE:
Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new MarioScreen()); //TODO: rimuovere: prova WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new MarioScreen()); //TODO: rimuovere: prova
Engine.INSTANCE.getHardwareDevice().getDisplayManager().cycleBrightness(true); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().cycleBrightness(true);
refresh = true; refresh = true;
break; break;
case ZOOM_MODE: case ZOOM_MODE:
final float newZoom = StaticVars.windowZoom.getLastValue() % 3 + 1; final float newZoom = StaticVars.windowZoom.getLastValue() % 3 + 1;
StaticVars.windowZoom.onNext(newZoom); StaticVars.windowZoom.onNext(newZoom);
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Keyboard", "Zoom: " + newZoom); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Keyboard", "Zoom: " + newZoom);
// StaticVars.windowZoom = ((StaticVars.windowZoom - 0.5f) % 2f) + 1f; // StaticVars.windowZoom = ((StaticVars.windowZoom - 0.5f) % 2f) + 1f;
refresh = true; refresh = true;
break; break;
case HISTORY_BACK: case HISTORY_BACK:
Engine.INSTANCE.getHardwareDevice().getDisplayManager().goBack(); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().goBack();
refresh = true; refresh = true;
break; break;
case HISTORY_FORWARD: case HISTORY_FORWARD:
Engine.INSTANCE.getHardwareDevice().getDisplayManager().goForward(); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().goForward();
refresh = true; refresh = true;
break; break;
case BACK: case BACK:
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Closing current screen."); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Closing current screen.");
Engine.INSTANCE.getHardwareDevice().getDisplayManager().closeScreen(); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().closeScreen();
refresh = true; refresh = true;
break; break;
default: default:
@ -966,25 +966,25 @@ public class Keyboard {
switch (k) { switch (k) {
case SHIFT: case SHIFT:
if (Keyboard.alpha) { if (Keyboard.alpha) {
Engine.getPlatform().alphaChanged(Keyboard.alpha = false); WarpPI.getPlatform().alphaChanged(Keyboard.alpha = false);
} }
Engine.getPlatform().shiftChanged(Keyboard.shift = !Keyboard.shift); WarpPI.getPlatform().shiftChanged(Keyboard.shift = !Keyboard.shift);
refresh = true; refresh = true;
break; break;
case ALPHA: case ALPHA:
if (Keyboard.shift) { if (Keyboard.shift) {
Engine.getPlatform().shiftChanged(Keyboard.shift = false); WarpPI.getPlatform().shiftChanged(Keyboard.shift = false);
} }
Engine.getPlatform().alphaChanged(Keyboard.alpha = !Keyboard.alpha); WarpPI.getPlatform().alphaChanged(Keyboard.alpha = !Keyboard.alpha);
refresh = true; refresh = true;
break; break;
default: default:
if (k != Key.NONE) { if (k != Key.NONE) {
if (Keyboard.shift) { if (Keyboard.shift) {
Engine.getPlatform().shiftChanged(Keyboard.shift = false); WarpPI.getPlatform().shiftChanged(Keyboard.shift = false);
} }
if (Keyboard.alpha) { if (Keyboard.alpha) {
Engine.getPlatform().alphaChanged(Keyboard.alpha = false); WarpPI.getPlatform().alphaChanged(Keyboard.alpha = false);
} }
} }
break; break;
@ -993,7 +993,7 @@ public class Keyboard {
Keyboard.refreshRequest = true; Keyboard.refreshRequest = true;
} }
} else if (!done) { } else if (!done) {
Engine.getPlatform().getConsoleUtils().out().println(1, "Key " + k.toString() + " ignored."); WarpPI.getPlatform().getConsoleUtils().out().println(1, "Key " + k.toString() + " ignored.");
} }
} }
@ -1003,8 +1003,8 @@ public class Keyboard {
done = Keyboard.additionalListener.onKeyReleased(new KeyReleasedEvent(k)); done = Keyboard.additionalListener.onKeyReleased(new KeyReleasedEvent(k));
} }
boolean refresh = false; boolean refresh = false;
if (Engine.INSTANCE.getHardwareDevice().getDisplayManager() != null) { if (WarpPI.INSTANCE.getHardwareDevice().getDisplayManager() != null) {
final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen(); final Screen scr = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
if (scr != null && scr.initialized && scr.onKeyReleased(new KeyReleasedEvent(k))) { if (scr != null && scr.initialized && scr.onKeyReleased(new KeyReleasedEvent(k))) {
refresh = true; refresh = true;
} else { } else {
@ -1019,7 +1019,7 @@ public class Keyboard {
Keyboard.refreshRequest = true; Keyboard.refreshRequest = true;
} }
} else if (!done) { } else if (!done) {
Engine.getPlatform().getConsoleUtils().out().println(1, "Key " + k.toString() + " ignored."); WarpPI.getPlatform().getConsoleUtils().out().println(1, "Key " + k.toString() + " ignored.");
} }
} }

View File

@ -1,4 +1,4 @@
package it.cavallium.warppi.device; package it.cavallium.warppi.device.input;
public interface KeyboardAWTValues { public interface KeyboardAWTValues {

View File

@ -0,0 +1,5 @@
package it.cavallium.warppi.device.input;
public interface KeyboardInputDevice {
}

View File

@ -1,4 +1,4 @@
package it.cavallium.warppi.device; package it.cavallium.warppi.device.input;
public interface KeyboardJogampValues { public interface KeyboardJogampValues {

View File

@ -1,6 +1,6 @@
package it.cavallium.warppi.device; package it.cavallium.warppi.device.input;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.event.TouchCancelEvent; import it.cavallium.warppi.event.TouchCancelEvent;
import it.cavallium.warppi.event.TouchEndEvent; import it.cavallium.warppi.event.TouchEndEvent;
import it.cavallium.warppi.event.TouchMoveEvent; import it.cavallium.warppi.event.TouchMoveEvent;
@ -8,7 +8,7 @@ import it.cavallium.warppi.event.TouchPoint;
import it.cavallium.warppi.event.TouchStartEvent; import it.cavallium.warppi.event.TouchStartEvent;
import it.cavallium.warppi.gui.screens.Screen; import it.cavallium.warppi.gui.screens.Screen;
public class PIHardwareTouchDevice implements HardwareTouchDevice { public class PIHardwareTouchDevice implements TouchInputDevice {
private final boolean invertXY, invertX, invertY; private final boolean invertXY, invertX, invertY;
@ -20,7 +20,7 @@ public class PIHardwareTouchDevice implements HardwareTouchDevice {
@Override @Override
public boolean onTouchStart(final TouchStartEvent e) { public boolean onTouchStart(final TouchStartEvent e) {
final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen(); final Screen scr = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
boolean refresh = false; boolean refresh = false;
if (scr != null && scr.initialized && scr.onTouchStart(e)) { if (scr != null && scr.initialized && scr.onTouchStart(e)) {
refresh = true; refresh = true;
@ -28,14 +28,14 @@ public class PIHardwareTouchDevice implements HardwareTouchDevice {
//Default behavior //Default behavior
} }
if (refresh) { if (refresh) {
Engine.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true; WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true;
} }
return true; return true;
} }
@Override @Override
public boolean onTouchEnd(final TouchEndEvent e) { public boolean onTouchEnd(final TouchEndEvent e) {
final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen(); final Screen scr = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
boolean refresh = false; boolean refresh = false;
if (scr != null && scr.initialized && scr.onTouchEnd(e)) { if (scr != null && scr.initialized && scr.onTouchEnd(e)) {
refresh = true; refresh = true;
@ -43,14 +43,14 @@ public class PIHardwareTouchDevice implements HardwareTouchDevice {
//Default behavior //Default behavior
} }
if (refresh) { if (refresh) {
Engine.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true; WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true;
} }
return true; return true;
} }
@Override @Override
public boolean onTouchCancel(final TouchCancelEvent e) { public boolean onTouchCancel(final TouchCancelEvent e) {
final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen(); final Screen scr = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
boolean refresh = false; boolean refresh = false;
if (scr != null && scr.initialized && scr.onTouchCancel(e)) { if (scr != null && scr.initialized && scr.onTouchCancel(e)) {
refresh = true; refresh = true;
@ -58,14 +58,14 @@ public class PIHardwareTouchDevice implements HardwareTouchDevice {
//Default behavior //Default behavior
} }
if (refresh) { if (refresh) {
Engine.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true; WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true;
} }
return true; return true;
} }
@Override @Override
public boolean onTouchMove(final TouchMoveEvent e) { public boolean onTouchMove(final TouchMoveEvent e) {
final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen(); final Screen scr = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
boolean refresh = false; boolean refresh = false;
if (scr != null && scr.initialized && scr.onTouchMove(e)) { if (scr != null && scr.initialized && scr.onTouchMove(e)) {
refresh = true; refresh = true;
@ -73,7 +73,7 @@ public class PIHardwareTouchDevice implements HardwareTouchDevice {
//Default behavior //Default behavior
} }
if (refresh) { if (refresh) {
Engine.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true; WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true;
} }
return true; return true;
} }

View File

@ -1,9 +1,9 @@
package it.cavallium.warppi.device; package it.cavallium.warppi.device.input;
import it.cavallium.warppi.event.TouchEventListener; import it.cavallium.warppi.event.TouchEventListener;
import it.cavallium.warppi.event.TouchPoint; import it.cavallium.warppi.event.TouchPoint;
public interface HardwareTouchDevice extends TouchEventListener { public interface TouchInputDevice extends TouchEventListener {
boolean getInvertedXY(); boolean getInvertedXY();
boolean getInvertedX(); boolean getInvertedX();

View File

@ -2,10 +2,10 @@ package it.cavallium.warppi.extra.mario;
import java.io.IOException; import java.io.IOException;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.Platform.ConsoleUtils; import it.cavallium.warppi.Platform.ConsoleUtils;
import it.cavallium.warppi.device.Keyboard; import it.cavallium.warppi.device.input.Keyboard;
import it.cavallium.warppi.event.KeyPressedEvent; import it.cavallium.warppi.event.KeyPressedEvent;
import it.cavallium.warppi.event.KeyReleasedEvent; import it.cavallium.warppi.event.KeyReleasedEvent;
import it.cavallium.warppi.gui.HistoryBehavior; import it.cavallium.warppi.gui.HistoryBehavior;
@ -48,30 +48,30 @@ public class MarioScreen extends Screen {
public void graphicInitialized() { public void graphicInitialized() {
try { try {
if (MarioScreen.skin == null) { if (MarioScreen.skin == null) {
MarioScreen.skin = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("/marioskin.png"); MarioScreen.skin = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadSkin("/marioskin.png");
} }
if (MarioScreen.groundskin == null) { if (MarioScreen.groundskin == null) {
MarioScreen.groundskin = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("/marioground.png"); MarioScreen.groundskin = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadSkin("/marioground.png");
} }
if (MarioScreen.gpuTest2 == null) { if (MarioScreen.gpuTest2 == null) {
try { try {
MarioScreen.gpuTest2 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("N:\\gputest\\gputest2"); MarioScreen.gpuTest2 = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadFont("N:\\gputest\\gputest2");
} catch (final Exception ex) {} } catch (final Exception ex) {}
} }
if (MarioScreen.gpuTest1 == null) { if (MarioScreen.gpuTest1 == null) {
try { try {
MarioScreen.gpuTest1 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("N:\\gputest\\gputest12"); MarioScreen.gpuTest1 = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadFont("N:\\gputest\\gputest12");
MarioScreen.gpuTest12 = true; MarioScreen.gpuTest12 = true;
} catch (final Exception ex) { } catch (final Exception ex) {
MarioScreen.gpuTest12 = false; MarioScreen.gpuTest12 = false;
try { try {
MarioScreen.gpuTest1 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("N:\\gputest\\gputest1"); MarioScreen.gpuTest1 = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadFont("N:\\gputest\\gputest1");
} catch (final Exception ex2) {} } catch (final Exception ex2) {}
} }
} }
if (MarioScreen.gpuTest3 == null) { if (MarioScreen.gpuTest3 == null) {
try { try {
MarioScreen.gpuTest3 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("N:\\gputest\\font_gputest3.png"); MarioScreen.gpuTest3 = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadSkin("N:\\gputest\\font_gputest3.png");
} catch (final Exception ex) { } catch (final Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
@ -85,30 +85,30 @@ public class MarioScreen extends Screen {
public void initialized() { public void initialized() {
try { try {
if (MarioScreen.skin == null) { if (MarioScreen.skin == null) {
MarioScreen.skin = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("/marioskin.png"); MarioScreen.skin = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadSkin("/marioskin.png");
} }
if (MarioScreen.groundskin == null) { if (MarioScreen.groundskin == null) {
MarioScreen.groundskin = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("/marioground.png"); MarioScreen.groundskin = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadSkin("/marioground.png");
} }
if (MarioScreen.gpuTest2 == null) { if (MarioScreen.gpuTest2 == null) {
try { try {
MarioScreen.gpuTest2 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("N:\\gputest\\gputest2"); MarioScreen.gpuTest2 = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadFont("N:\\gputest\\gputest2");
} catch (final Exception ex) {} } catch (final Exception ex) {}
} }
if (MarioScreen.gpuTest1 == null) { if (MarioScreen.gpuTest1 == null) {
try { try {
MarioScreen.gpuTest1 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("N:\\gputest\\gputest12"); MarioScreen.gpuTest1 = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadFont("N:\\gputest\\gputest12");
MarioScreen.gpuTest12 = true; MarioScreen.gpuTest12 = true;
} catch (final Exception ex) { } catch (final Exception ex) {
MarioScreen.gpuTest12 = false; MarioScreen.gpuTest12 = false;
try { try {
MarioScreen.gpuTest1 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("N:\\gputest\\gputest1"); MarioScreen.gpuTest1 = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadFont("N:\\gputest\\gputest1");
} catch (final Exception ex2) {} } catch (final Exception ex2) {}
} }
} }
if (MarioScreen.gpuTest3 == null) { if (MarioScreen.gpuTest3 == null) {
try { try {
MarioScreen.gpuTest3 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("N:\\gputest\\font_gputest3.png"); MarioScreen.gpuTest3 = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadSkin("N:\\gputest\\font_gputest3.png");
} catch (final Exception ex) { } catch (final Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
@ -182,24 +182,24 @@ public class MarioScreen extends Screen {
gpuCharTestt1Elapsed -= 1.5; gpuCharTestt1Elapsed -= 1.5;
} }
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glClearColor(0xff000000); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glClearColor(0xff000000);
} }
} }
@Override @Override
public void render() { public void render() {
if (errored) { if (errored) {
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringLeft(0, 20, "ERROR"); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringLeft(0, 20, "ERROR");
} else { } else {
if (MarioScreen.groundskin != null) { if (MarioScreen.groundskin != null) {
final double playerX = g.getPlayer().getX(); final double playerX = g.getPlayer().getX();
final double playerY = g.getPlayer().getY(); final double playerY = g.getPlayer().getY();
MarioScreen.groundskin.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine); MarioScreen.groundskin.use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
final MarioWorld w = g.getCurrentWorld(); final MarioWorld w = g.getCurrentWorld();
final int width = w.getWidth(); final int width = w.getWidth();
final int height = w.getHeight(); final int height = w.getHeight();
final float screenX = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getWidth() / 2f - 8f; final float screenX = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getWidth() / 2f - 8f;
final float screenY = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() / 2f - 8f; final float screenY = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getHeight() / 2f - 8f;
final float shiftX = -8 + 16 * (float) playerX; final float shiftX = -8 + 16 * (float) playerX;
final float shiftY = -8 + 16 * (height - (float) playerY); final float shiftY = -8 + 16 * (height - (float) playerY);
int blue = -1; int blue = -1;
@ -212,59 +212,59 @@ public class MarioScreen extends Screen {
if (b == 0) { if (b == 0) {
if (blue != 1) { if (blue != 1) {
blue = 1; blue = 1;
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xff9290ff); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xff9290ff);
} }
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillColor(screenX - shiftX + 16 * ix, screenY - shiftY + 16 * (height - iy), 16, 16); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillColor(screenX - shiftX + 16 * ix, screenY - shiftY + 16 * (height - iy), 16, 16);
} else { } else {
if (blue != 0) { if (blue != 0) {
blue = 0; blue = 0;
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xffffffff); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xffffffff);
} }
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(screenX - shiftX + 16 * ix, screenY - shiftY + 16 * (height - iy), 16, 16, 0, 0, 16, 16); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(screenX - shiftX + 16 * ix, screenY - shiftY + 16 * (height - iy), 16, 16, 0, 0, 16, 16);
} }
} }
} }
} }
if (blue != 0) { if (blue != 0) {
blue = 0; blue = 0;
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xffffffff); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xffffffff);
} }
//DRAW MARIO //DRAW MARIO
MarioScreen.skin.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine); MarioScreen.skin.use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(screenX - (g.getPlayer().flipped ? 3 : 0), screenY, 35, 27, 35 * (g.getPlayer().marioSkinPos[0] + (g.getPlayer().flipped ? 2 : 1)), 27 * g.getPlayer().marioSkinPos[1], 35 * (g.getPlayer().flipped ? -1 : 1), 27); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(screenX - (g.getPlayer().flipped ? 3 : 0), screenY, 35, 27, 35 * (g.getPlayer().marioSkinPos[0] + (g.getPlayer().flipped ? 2 : 1)), 27 * g.getPlayer().marioSkinPos[1], 35 * (g.getPlayer().flipped ? -1 : 1), 27);
// PIDisplay.renderer.glDrawSkin(getPosX() - 18, 25 + getPosY(), 35 * (marioSkinPos[0] + (flipped ? 2 : 1)), 27 * marioSkinPos[1], 35 * (marioSkinPos[0] + (flipped ? 1 : 2)), 27 * (marioSkinPos[1] + 1), true); // PIDisplay.renderer.glDrawSkin(getPosX() - 18, 25 + getPosY(), 35 * (marioSkinPos[0] + (flipped ? 2 : 1)), 27 * marioSkinPos[1], 35 * (marioSkinPos[0] + (flipped ? 1 : 2)), 27 * (marioSkinPos[1] + 1), true);
} }
// GPU PERFORMANCE TEST // GPU PERFORMANCE TEST
if (MarioScreen.gpuTest1 != null) { if (MarioScreen.gpuTest1 != null) {
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3f(1, 1, 1); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3f(1, 1, 1);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillColor(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getWidth() - (MarioScreen.gpuTest12 ? 512 : 256), Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() / 2 - (MarioScreen.gpuTest12 ? 256 : 128), MarioScreen.gpuTest12 ? 512 : 256, MarioScreen.gpuTest12 ? 512 : 256); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillColor(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getWidth() - (MarioScreen.gpuTest12 ? 512 : 256), WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getHeight() / 2 - (MarioScreen.gpuTest12 ? 256 : 128), MarioScreen.gpuTest12 ? 512 : 256, MarioScreen.gpuTest12 ? 512 : 256);
MarioScreen.gpuTest1.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine); MarioScreen.gpuTest1.use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3f(0, 0, 0); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3f(0, 0, 0);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getWidth(), Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() / 2 - (MarioScreen.gpuTest12 ? 256 : 128), gpuCharTest1[gpuCharTest1Num]); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getWidth(), WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getHeight() / 2 - (MarioScreen.gpuTest12 ? 256 : 128), gpuCharTest1[gpuCharTest1Num]);
} }
if (MarioScreen.gpuTest3 != null) { if (MarioScreen.gpuTest3 != null) {
MarioScreen.gpuTest3.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine); MarioScreen.gpuTest3.use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4f(1, 1, 1, 0.7f); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4f(1, 1, 1, 0.7f);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(0, StaticVars.screenSize[1] - 128, 224, 128, gpuTestNum * 224, 0, 224, 128); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(0, StaticVars.screenSize[1] - 128, 224, 128, gpuTestNum * 224, 0, 224, 128);
} }
if (MarioScreen.gpuTest2 != null) { if (MarioScreen.gpuTest2 != null) {
MarioScreen.gpuTest2.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine); MarioScreen.gpuTest2.use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFF000000); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFF000000);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "A"); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "A");
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFF800000); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFF800000);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "B"); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "B");
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFeea28e); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFeea28e);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "C"); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "C");
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFee7255); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFee7255);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "D"); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "D");
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFeac0b0); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFeac0b0);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "E"); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "E");
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFf3d8ce); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFf3d8ce);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "F"); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "F");
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFffede7); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFffede7);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "G"); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "G");
} }
} }
} }

View File

@ -2,14 +2,14 @@ package it.cavallium.warppi.extra.tetris;
import java.io.IOException; import java.io.IOException;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.device.input.Keyboard;
import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.device.Keyboard;
import it.cavallium.warppi.event.KeyPressedEvent; import it.cavallium.warppi.event.KeyPressedEvent;
import it.cavallium.warppi.event.KeyReleasedEvent; import it.cavallium.warppi.event.KeyReleasedEvent;
import it.cavallium.warppi.gui.HistoryBehavior; import it.cavallium.warppi.gui.HistoryBehavior;
import it.cavallium.warppi.gui.graphicengine.BinaryFont; 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.Renderer;
import it.cavallium.warppi.gui.graphicengine.Skin; import it.cavallium.warppi.gui.graphicengine.Skin;
import it.cavallium.warppi.gui.screens.Screen; import it.cavallium.warppi.gui.screens.Screen;
@ -30,7 +30,7 @@ public class TetrisScreen extends Screen {
private ButtonInfo backPressed = new ButtonInfo(); private ButtonInfo backPressed = new ButtonInfo();
private GraphicEngine e; private DisplayOutputDevice e;
private Renderer r; private Renderer r;
@ -49,10 +49,10 @@ public class TetrisScreen extends Screen {
@Override @Override
public void graphicInitialized() { public void graphicInitialized() {
try { try {
e = d.engine; e = d.display;
r = d.renderer; r = d.renderer;
if (TetrisScreen.skin == null) { if (TetrisScreen.skin == null) {
TetrisScreen.skin = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("/tetrisskin.png"); TetrisScreen.skin = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadSkin("/tetrisskin.png");
} }
} catch (final IOException e) { } catch (final IOException e) {
e.printStackTrace(); e.printStackTrace();
@ -66,7 +66,7 @@ public class TetrisScreen extends Screen {
@Override @Override
public void beforeRender(final float dt) { public void beforeRender(final float dt) {
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glClearColor(0xff000000); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glClearColor(0xff000000);
g.update(dt, leftPressed, rightPressed, downPressed, upPressed, okPressed, backPressed); g.update(dt, leftPressed, rightPressed, downPressed, upPressed, okPressed, backPressed);
} }

View File

@ -1,9 +1,9 @@
package it.cavallium.warppi.gui; package it.cavallium.warppi.gui;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.device.input.Keyboard;
import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.device.Keyboard;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.gui.graphicengine.Skin; import it.cavallium.warppi.gui.graphicengine.Skin;
import it.cavallium.warppi.gui.screens.Screen; import it.cavallium.warppi.gui.screens.Screen;
@ -39,7 +39,7 @@ public class CalculatorHUD extends HUD {
@Override @Override
public void renderTopmostBackground() { public void renderTopmostBackground() {
final Renderer r = d.renderer; final Renderer r = d.renderer;
final GraphicEngine engine = d.engine; final DisplayOutputDevice engine = d.display;
r.glColor(0xFFc5c2af); r.glColor(0xFFc5c2af);
r.glFillColor(0, 0, engine.getWidth(), 20); r.glFillColor(0, 0, engine.getWidth(), 20);
@ -48,7 +48,7 @@ public class CalculatorHUD extends HUD {
@Override @Override
public void renderTopmost() { public void renderTopmost() {
final Renderer r = d.renderer; final Renderer r = d.renderer;
final GraphicEngine engine = d.engine; final DisplayOutputDevice engine = d.display;
final Skin guiSkin = d.guiSkin; final Skin guiSkin = d.guiSkin;
//DRAW TOP //DRAW TOP
@ -69,19 +69,19 @@ public class CalculatorHUD extends HUD {
int padding = 2; int padding = 2;
final int brightness = (int) Math.ceil(Engine.INSTANCE.getHardwareDevice().getDisplayManager().getBrightness() * 9); final int brightness = (int) Math.ceil(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getBrightness() * 9);
if (brightness <= 10) { if (brightness <= 10) {
r.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * brightness, 16 * 1, 16, 16); r.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * brightness, 16 * 1, 16, 16);
} else { } else {
Engine.getPlatform().getConsoleUtils().out().println(1, "Brightness error"); WarpPI.getPlatform().getConsoleUtils().out().println(1, "Brightness error");
} }
padding += 18 + 6; padding += 18 + 6;
final boolean canGoBack = Engine.INSTANCE.getHardwareDevice().getDisplayManager().canGoBack(); final boolean canGoBack = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().canGoBack();
final boolean canGoForward = Engine.INSTANCE.getHardwareDevice().getDisplayManager().canGoForward(); final boolean canGoForward = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().canGoForward();
if (Engine.getPlatform().getSettings().isDebugEnabled()) { if (WarpPI.getPlatform().getSettings().isDebugEnabled()) {
r.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 18, 16 * 0, 16, 16); r.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 18, 16 * 0, 16, 16);
padding += 18 + 6; padding += 18 + 6;
} }
@ -112,12 +112,12 @@ public class CalculatorHUD extends HUD {
r.glDrawStringLeft(1, StaticVars.screenSize[1] - 7, "PROGRESS."); r.glDrawStringLeft(1, StaticVars.screenSize[1] - 7, "PROGRESS.");
int currentDebugLine = 2; int currentDebugLine = 2;
if (Engine.getPlatform().getSettings().isDebugEnabled()) { if (WarpPI.getPlatform().getSettings().isDebugEnabled()) {
ObjectArrayList<Screen> allSessions = new ObjectArrayList<>(); ObjectArrayList<Screen> allSessions = new ObjectArrayList<>();
for (Screen session : Engine.INSTANCE.getHardwareDevice().getDisplayManager().sessions) { for (Screen session : WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().sessions) {
allSessions.add(0, session); allSessions.add(0, session);
} }
Screen curScreen = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen(); Screen curScreen = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
if (curScreen.historyBehavior == HistoryBehavior.DONT_KEEP_IN_HISTORY) { if (curScreen.historyBehavior == HistoryBehavior.DONT_KEEP_IN_HISTORY) {
allSessions.add(curScreen); allSessions.add(curScreen);
} }
@ -135,7 +135,7 @@ public class CalculatorHUD extends HUD {
r.glColor(0xFF990000); r.glColor(0xFF990000);
} }
r.glDrawStringLeft(0, StaticVars.screenSize[1] - ((currentDebugLine+1) * (r.getCurrentFont().getCharacterHeight()+1)), "[" + String.format("%1$03d", session.debugScreenID) + "] " + title.toUpperCase()); r.glDrawStringLeft(0, StaticVars.screenSize[1] - ((currentDebugLine+1) * (r.getCurrentFont().getCharacterHeight()+1)), "[" + String.format("%1$03d", session.debugScreenID) + "] " + title.toUpperCase());
if (session == Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen()) { if (session == WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen()) {
r.glColor(0xFF00CC00); r.glColor(0xFF00CC00);
} else { } else {
r.glColor(0xFF990000); r.glColor(0xFF990000);

View File

@ -5,11 +5,13 @@ import java.util.Arrays;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform.ConsoleUtils; import it.cavallium.warppi.Platform.ConsoleUtils;
import it.cavallium.warppi.Platform.Semaphore; import it.cavallium.warppi.Platform.Semaphore;
import it.cavallium.warppi.device.display.BacklightOutputDevice;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.device.input.Keyboard;
import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.device.Keyboard;
import it.cavallium.warppi.flow.Observable; import it.cavallium.warppi.flow.Observable;
import it.cavallium.warppi.flow.Pair; import it.cavallium.warppi.flow.Pair;
import it.cavallium.warppi.gui.graphicengine.BinaryFont; import it.cavallium.warppi.gui.graphicengine.BinaryFont;
@ -27,8 +29,9 @@ public final class DisplayManager implements RenderingLoop {
private float brightness; private float brightness;
public final GraphicEngine engine; public final DisplayOutputDevice display;
public final HardwareDisplay monitor; public final GraphicEngine graphicEngine;
public final BacklightOutputDevice backlight;
public final boolean supportsPauses; public final boolean supportsPauses;
public Renderer renderer; public Renderer renderer;
@ -51,15 +54,16 @@ public final class DisplayManager implements RenderingLoop {
*/ */
public boolean forceRefresh; public boolean forceRefresh;
public DisplayManager(final HardwareDisplay monitor, final HUD hud, final Screen screen, final String title) { public DisplayManager(final DisplayOutputDevice display, final BacklightOutputDevice backlight, final HUD hud, final Screen screen, final String title) {
this.monitor = monitor; this.display = display;
this.graphicEngine = display.getGraphicEngine();
this.backlight = backlight;
this.hud = hud; this.hud = hud;
initialTitle = title; initialTitle = title;
initialScreen = screen; initialScreen = screen;
screenChange = Engine.getPlatform().newSemaphore(); screenChange = WarpPI.getPlatform().newSemaphore();
engine = chooseGraphicEngine(); supportsPauses = graphicEngine.doesRefreshPauses();
supportsPauses = engine.doesRefreshPauses();
glyphsHeight = new int[] { 9, 6, 12, 9 }; glyphsHeight = new int[] { 9, 6, 12, 9 };
displayDebugString = ""; displayDebugString = "";
@ -67,8 +71,6 @@ public final class DisplayManager implements RenderingLoop {
} }
public void initialize() { public void initialize() {
monitor.initialize();
try { try {
hud.d = this; hud.d = this;
hud.create(); hud.create();
@ -77,18 +79,17 @@ public final class DisplayManager implements RenderingLoop {
} }
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
Engine.getPlatform().exit(0); WarpPI.getPlatform().exit(0);
} }
try { try {
engine.create(); graphicEngine.create();
renderer = engine.getRenderer(); renderer = graphicEngine.getRenderer();
engine.setTitle(initialTitle); graphicEngine.setTitle(initialTitle);
loop(); loop();
} catch (final Exception ex) { } catch (final Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
monitor.shutdown();
} }
/* /*
@ -111,54 +112,6 @@ public final class DisplayManager implements RenderingLoop {
* GL_UNSIGNED_BYTE, skin); } catch (IOException ex) { ex.printStackTrace(); } } * GL_UNSIGNED_BYTE, skin); } catch (IOException ex) { ex.printStackTrace(); } }
*/ */
private GraphicEngine chooseGraphicEngine() {
GraphicEngine d;
d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "framebuffer engine", null);
if (d != null && d.isSupported()) {
Engine.getPlatform().getConsoleUtils().out().println(1, "Using FB Graphic Engine");
return d;
}
d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "CPU engine", null);
if (d != null && d.isSupported()) {
Engine.getPlatform().getConsoleUtils().out().println(1, "Using CPU Graphic Engine");
return d;
}
d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "GPU engine", null);
if (d != null && d.isSupported()) {
Engine.getPlatform().getConsoleUtils().out().println(1, "Using GPU Graphic Engine");
return d;
}
d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "headless 24 bit engine", null);
if (d != null && d.isSupported()) {
System.err.println(
"Using Headless 24 bit Engine! This is a problem! No other graphic engines are available.");
return d;
}
d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "headless 256 colors engine", null);
if (d != null && d.isSupported()) {
System.err.println("Using Headless 256 Engine! This is a problem! No other graphic engines are available.");
return d;
}
d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "headless 8 colors engine", null);
if (d != null && d.isSupported()) {
System.err
.println("Using Headless basic Engine! This is a problem! No other graphic engines are available.");
return d;
}
d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "HTML5 engine", null);
if (d != null && d.isSupported()) {
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG,
"Using Html Graphic Engine");
return d;
}
d = new NoGuiEngine();
if (d != null && d.isSupported()) {
Engine.getPlatform().getConsoleUtils().out().println(1, "Using NoGui Graphic Engine");
return d;
}
throw new UnsupportedOperationException("No graphic engines available.");
}
public void closeScreen() { public void closeScreen() {
boolean isLastSession = sessions[1] == null; boolean isLastSession = sessions[1] == null;
if (!isLastSession) { if (!isLastSession) {
@ -250,7 +203,7 @@ public final class DisplayManager implements RenderingLoop {
screenChange.release(); screenChange.release();
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
Engine.getPlatform().exit(0); WarpPI.getPlatform().exit(0);
} }
} }
@ -276,7 +229,7 @@ public final class DisplayManager implements RenderingLoop {
screenChange.release(); screenChange.release();
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
Engine.getPlatform().exit(0); WarpPI.getPlatform().exit(0);
} }
} }
@ -354,25 +307,25 @@ public final class DisplayManager implements RenderingLoop {
} }
private void load_skin() throws IOException { private void load_skin() throws IOException {
guiSkin = engine.loadSkin("/skin.png"); guiSkin = graphicEngine.loadSkin("/skin.png");
} }
private void load_fonts() throws IOException { private void load_fonts() throws IOException {
fonts = new BinaryFont[7]; fonts = new BinaryFont[7];
fonts[0] = engine.loadFont("smal"); fonts[0] = graphicEngine.loadFont("smal");
fonts[1] = engine.loadFont("smallest"); fonts[1] = graphicEngine.loadFont("smallest");
fonts[2] = engine.loadFont("norm"); fonts[2] = graphicEngine.loadFont("norm");
fonts[3] = engine.loadFont("smal"); fonts[3] = graphicEngine.loadFont("smal");
// 4 // 4
// fonts[5] = engine.loadFont("square"); // fonts[5] = engine.loadFont("square");
} }
private void draw_init() { private void draw_init() {
if (engine.supportsFontRegistering()) { if (graphicEngine.supportsFontRegistering()) {
final List<BinaryFont> fontsIterator = engine.getRegisteredFonts(); final List<BinaryFont> fontsIterator = graphicEngine.getRegisteredFonts();
for (final BinaryFont f : fontsIterator) { for (final BinaryFont f : fontsIterator) {
if (!f.isInitialized()) { if (!f.isInitialized()) {
f.initialize(engine); f.initialize(display);
} }
} }
} }
@ -383,7 +336,7 @@ public final class DisplayManager implements RenderingLoop {
e.printStackTrace(); e.printStackTrace();
} }
} }
renderer.glClear(engine.getWidth(), engine.getHeight()); renderer.glClear(graphicEngine.getWidth(), graphicEngine.getHeight());
} }
private void draw_world() { private void draw_world() {
@ -391,13 +344,13 @@ public final class DisplayManager implements RenderingLoop {
if (error != null) { if (error != null) {
final BinaryFont fnt = Utils.getFont(false, false); final BinaryFont fnt = Utils.getFont(false, false);
if (fnt != null && fnt != engine.getRenderer().getCurrentFont()) { if (fnt != null && fnt != graphicEngine.getRenderer().getCurrentFont()) {
fnt.use(engine); fnt.use(display);
} }
renderer.glColor3i(129, 28, 22); renderer.glColor3i(129, 28, 22);
renderer.glDrawStringRight(StaticVars.screenSize[0] - 2, renderer.glDrawStringRight(StaticVars.screenSize[0] - 2,
StaticVars.screenSize[1] - (fnt.getCharacterHeight() + 2), StaticVars.screenSize[1] - (fnt.getCharacterHeight() + 2),
Engine.getPlatform().getSettings().getCalculatorNameUppercase() + " CALCULATOR"); WarpPI.getPlatform().getSettings().getCalculatorNameUppercase() + " CALCULATOR");
renderer.glColor3i(149, 32, 26); renderer.glColor3i(149, 32, 26);
renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, 22, error); renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, 22, error);
renderer.glColor3i(164, 34, 28); renderer.glColor3i(164, 34, 28);
@ -406,14 +359,14 @@ public final class DisplayManager implements RenderingLoop {
renderer.glDrawStringLeft(2, 22 + i, stackPart); renderer.glDrawStringLeft(2, 22 + i, stackPart);
i += 11; i += 11;
} }
if (fonts[0] != null && fonts[0] != engine.getRenderer().getCurrentFont()) { if (fonts[0] != null && fonts[0] != graphicEngine.getRenderer().getCurrentFont()) {
fonts[0].use(engine); fonts[0].use(display);
} }
renderer.glColor3i(129, 28, 22); renderer.glColor3i(129, 28, 22);
renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, 11, "UNEXPECTED EXCEPTION"); renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, 11, "UNEXPECTED EXCEPTION");
} else { } else {
if (fonts[0] != null && fonts[0] != engine.getRenderer().getCurrentFont()) { if (fonts[0] != null && fonts[0] != graphicEngine.getRenderer().getCurrentFont()) {
fonts[0].use(engine); fonts[0].use(display);
} }
if (hud.visible) if (hud.visible)
hud.renderBackground(); hud.renderBackground();
@ -456,17 +409,17 @@ public final class DisplayManager implements RenderingLoop {
} }
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
Engine.getPlatform().exit(0); WarpPI.getPlatform().exit(0);
} }
final Observable<Long> workTimer = Observable.interval(DisplayManager.tickDuration); final Observable<Long> workTimer = Observable.interval(DisplayManager.tickDuration);
final Observable<Integer[]> onResizeObservable = engine.onResize(); final Observable<Integer[]> onResizeObservable = graphicEngine.onResize();
Observable<Pair<Long, Integer[]>> refreshObservable; Observable<Pair<Long, Integer[]>> refreshObservable;
if (onResizeObservable == null) { if (onResizeObservable == null) {
refreshObservable = workTimer.map((l) -> Pair.of(l, null)); refreshObservable = workTimer.map((l) -> Pair.of(l, null));
} else { } else {
refreshObservable = Observable.combineChanged(workTimer, engine.onResize()); refreshObservable = Observable.combineChanged(workTimer, graphicEngine.onResize());
} }
refreshObservable.subscribe((pair) -> { refreshObservable.subscribe((pair) -> {
@ -488,7 +441,7 @@ public final class DisplayManager implements RenderingLoop {
screen.beforeRender((float) (dt / 1000d)); screen.beforeRender((float) (dt / 1000d));
}); });
engine.start(getDrawable()); graphicEngine.start(getDrawable());
} catch (final Exception ex) { } catch (final Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} finally { } finally {
@ -502,7 +455,7 @@ public final class DisplayManager implements RenderingLoop {
public void setBrightness(final float newval) { public void setBrightness(final float newval) {
if (newval >= 0 && newval <= 1) { if (newval >= 0 && newval <= 1) {
brightness = newval; brightness = newval;
monitor.setBrightness(brightness); backlight.setBrightness(brightness);
} }
} }
@ -539,6 +492,6 @@ public final class DisplayManager implements RenderingLoop {
} }
public void waitForExit() { public void waitForExit() {
engine.waitForExit(); graphicEngine.waitForExit();
} }
} }

View File

@ -1,6 +1,6 @@
package it.cavallium.warppi.gui; package it.cavallium.warppi.gui;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.util.Error; import it.cavallium.warppi.util.Error;
@ -20,7 +20,7 @@ public class GUIErrorMessage {
creationTime = System.currentTimeMillis(); creationTime = System.currentTimeMillis();
} }
public void draw(final GraphicEngine g, final Renderer r, final String msg) { public void draw(final DisplayOutputDevice g, final Renderer r, final String msg) {
final int scrW = g.getWidth(); final int scrW = g.getWidth();
final int scrH = g.getHeight(); final int scrH = g.getHeight();
final int width = 200; final int width = 200;

View File

@ -1,9 +0,0 @@
package it.cavallium.warppi.gui;
public interface HardwareDisplay {
void initialize();
void shutdown();
void setBrightness(double value);
}

View File

@ -2,11 +2,11 @@ package it.cavallium.warppi.gui.expression;
import java.util.Arrays; import java.util.Arrays;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.event.KeyboardEventListener; import it.cavallium.warppi.event.KeyboardEventListener;
import it.cavallium.warppi.gui.expression.blocks.Block; import it.cavallium.warppi.gui.expression.blocks.Block;
import it.cavallium.warppi.gui.expression.blocks.BlockVariable; import it.cavallium.warppi.gui.expression.blocks.BlockVariable;
import it.cavallium.warppi.gui.expression.blocks.TreeContainer; import it.cavallium.warppi.gui.expression.blocks.TreeContainer;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
public abstract class ExtraMenu<T extends Block> implements KeyboardEventListener { public abstract class ExtraMenu<T extends Block> implements KeyboardEventListener {
@ -32,7 +32,7 @@ public abstract class ExtraMenu<T extends Block> implements KeyboardEventListene
protected int height; protected int height;
protected int[] location; protected int[] location;
public abstract void draw(GraphicEngine ge, Renderer r, Caret caret); public abstract void draw(DisplayOutputDevice ge, Renderer r, Caret caret);
public abstract void open(); public abstract void open();

View File

@ -1,10 +1,10 @@
package it.cavallium.warppi.gui.expression.blocks; package it.cavallium.warppi.gui.expression.blocks;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.GraphicalElement; import it.cavallium.warppi.gui.GraphicalElement;
import it.cavallium.warppi.gui.expression.Caret; import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.ExtraMenu; import it.cavallium.warppi.gui.expression.ExtraMenu;
import it.cavallium.warppi.gui.expression.InputContext; import it.cavallium.warppi.gui.expression.InputContext;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.MathContext; import it.cavallium.warppi.math.MathContext;
import it.cavallium.warppi.math.parser.features.interfaces.Feature; import it.cavallium.warppi.math.parser.features.interfaces.Feature;
@ -45,7 +45,7 @@ public abstract class Block implements TreeBlock, GraphicalElement {
* Position relative to the window. * Position relative to the window.
* @param small * @param small
*/ */
public abstract void draw(GraphicEngine ge, Renderer r, int x, int y, Caret caret); public abstract void draw(DisplayOutputDevice ge, Renderer r, int x, int y, Caret caret);
public abstract boolean putBlock(Caret caret, Block newBlock); public abstract boolean putBlock(Caret caret, Block newBlock);

View File

@ -1,8 +1,8 @@
package it.cavallium.warppi.gui.expression.blocks; package it.cavallium.warppi.gui.expression.blocks;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.expression.Caret; import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.InputContext; import it.cavallium.warppi.gui.expression.InputContext;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.MathContext; import it.cavallium.warppi.math.MathContext;
import it.cavallium.warppi.math.parser.features.FeatureChar; import it.cavallium.warppi.math.parser.features.FeatureChar;
@ -29,7 +29,7 @@ public class BlockChar extends Block {
} }
@Override @Override
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) { public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
BlockContainer.getDefaultFont(small).use(ge); BlockContainer.getDefaultFont(small).use(ge);
r.glColor(BlockContainer.getDefaultColor()); r.glColor(BlockContainer.getDefaultColor());
r.glDrawCharLeft(x, y, ch); r.glDrawCharLeft(x, y, ch);

View File

@ -2,13 +2,13 @@ package it.cavallium.warppi.gui.expression.blocks;
import java.util.Arrays; import java.util.Arrays;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.GraphicalElement; import it.cavallium.warppi.gui.GraphicalElement;
import it.cavallium.warppi.gui.expression.Caret; import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.CaretState; import it.cavallium.warppi.gui.expression.CaretState;
import it.cavallium.warppi.gui.expression.InputContext; import it.cavallium.warppi.gui.expression.InputContext;
import it.cavallium.warppi.gui.graphicengine.BinaryFont; 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.Renderer;
import it.cavallium.warppi.math.Function; import it.cavallium.warppi.math.Function;
import it.cavallium.warppi.math.MathContext; import it.cavallium.warppi.math.MathContext;
@ -182,7 +182,7 @@ public class BlockContainer implements TreeContainer, GraphicalElement {
* @param caret * @param caret
* Position of the caret. * Position of the caret.
*/ */
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) { public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
int paddingX = 1; int paddingX = 1;
if (caret.getRemaining() == 0) { if (caret.getRemaining() == 0) {
@ -396,7 +396,7 @@ public class BlockContainer implements TreeContainer, GraphicalElement {
return BlockContainer.defFontSizes[b ? 3 : 1]; return BlockContainer.defFontSizes[b ? 3 : 1];
} }
public static void drawCaret(final GraphicEngine ge, final Renderer r, final Caret caret, final boolean small, public static void drawCaret(final DisplayOutputDevice ge, final Renderer r, final Caret caret, final boolean small,
final int x, final int y, final int height) { final int x, final int y, final int height) {
if (caret.getState() == CaretState.VISIBLE_ON) { if (caret.getState() == CaretState.VISIBLE_ON) {
r.glColor(BlockContainer.getDefaultColor()); r.glColor(BlockContainer.getDefaultColor());
@ -424,7 +424,7 @@ public class BlockContainer implements TreeContainer, GraphicalElement {
private static void checkInitialized() { private static void checkInitialized() {
if (!BlockContainer.initialized) { if (!BlockContainer.initialized) {
Engine.getPlatform().throwNewExceptionInInitializerError("Please initialize BlockContainer by running the method BlockContainer.initialize(...) first!"); WarpPI.getPlatform().throwNewExceptionInInitializerError("Please initialize BlockContainer by running the method BlockContainer.initialize(...) first!");
} }
} }

View File

@ -1,8 +1,8 @@
package it.cavallium.warppi.gui.expression.blocks; package it.cavallium.warppi.gui.expression.blocks;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.expression.Caret; import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.InputContext; import it.cavallium.warppi.gui.expression.InputContext;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.Function; import it.cavallium.warppi.math.Function;
import it.cavallium.warppi.math.MathContext; import it.cavallium.warppi.math.MathContext;
@ -38,7 +38,7 @@ public class BlockDivision extends Block {
} }
@Override @Override
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) { public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
BlockContainer.getDefaultFont(small).use(ge); BlockContainer.getDefaultFont(small).use(ge);
r.glColor(BlockContainer.getDefaultColor()); r.glColor(BlockContainer.getDefaultColor());
containerUp.draw(ge, r, x + 1 + paddingLeftUpper, y, caret); containerUp.draw(ge, r, x + 1 + paddingLeftUpper, y, caret);

View File

@ -1,8 +1,8 @@
package it.cavallium.warppi.gui.expression.blocks; package it.cavallium.warppi.gui.expression.blocks;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.expression.Caret; import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.InputContext; import it.cavallium.warppi.gui.expression.InputContext;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
public class BlockExponentialNotation extends BlockPower { public class BlockExponentialNotation extends BlockPower {
@ -25,7 +25,7 @@ public class BlockExponentialNotation extends BlockPower {
} }
@Override @Override
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) { public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
BlockContainer.getDefaultFont(small).use(ge); BlockContainer.getDefaultFont(small).use(ge);
r.glColor(BlockContainer.getDefaultColor()); r.glColor(BlockContainer.getDefaultColor());
r.glDrawStringLeft(x, y + height - bh, ""); r.glDrawStringLeft(x, y + height - bh, "");

View File

@ -1,8 +1,8 @@
package it.cavallium.warppi.gui.expression.blocks; package it.cavallium.warppi.gui.expression.blocks;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.expression.Caret; import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.InputContext; import it.cavallium.warppi.gui.expression.InputContext;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.Function; import it.cavallium.warppi.math.Function;
import it.cavallium.warppi.math.MathContext; import it.cavallium.warppi.math.MathContext;
@ -56,7 +56,7 @@ public class BlockLogarithm extends Block implements IParenthesis {
} }
@Override @Override
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) { public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
BlockContainer.getDefaultFont(small).use(ge); BlockContainer.getDefaultFont(small).use(ge);
r.glColor(BlockContainer.getDefaultColor()); r.glColor(BlockContainer.getDefaultColor());
if (prefix != null) { if (prefix != null) {

View File

@ -1,8 +1,8 @@
package it.cavallium.warppi.gui.expression.blocks; package it.cavallium.warppi.gui.expression.blocks;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.expression.Caret; import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.InputContext; import it.cavallium.warppi.gui.expression.InputContext;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.MathContext; import it.cavallium.warppi.math.MathContext;
import it.cavallium.warppi.math.parser.features.interfaces.Feature; import it.cavallium.warppi.math.parser.features.interfaces.Feature;
@ -52,7 +52,7 @@ public abstract class BlockParenthesisAbstract extends Block implements IParenth
} }
@Override @Override
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) { public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
BlockContainer.getDefaultFont(small).use(ge); BlockContainer.getDefaultFont(small).use(ge);
r.glColor(BlockContainer.getDefaultColor()); r.glColor(BlockContainer.getDefaultColor());
if (prefix != null) { if (prefix != null) {

View File

@ -1,8 +1,8 @@
package it.cavallium.warppi.gui.expression.blocks; package it.cavallium.warppi.gui.expression.blocks;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.expression.Caret; import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.InputContext; import it.cavallium.warppi.gui.expression.InputContext;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.Function; import it.cavallium.warppi.math.Function;
import it.cavallium.warppi.math.MathContext; import it.cavallium.warppi.math.MathContext;
@ -26,7 +26,7 @@ public class BlockPower extends Block {
} }
@Override @Override
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) { public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
BlockContainer.getDefaultFont(true).use(ge); BlockContainer.getDefaultFont(true).use(ge);
r.glColor(BlockContainer.getDefaultColor()); r.glColor(BlockContainer.getDefaultColor());
containerExponent.draw(ge, r, x, y, caret); containerExponent.draw(ge, r, x, y, caret);

View File

@ -1,8 +1,8 @@
package it.cavallium.warppi.gui.expression.blocks; package it.cavallium.warppi.gui.expression.blocks;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.expression.Caret; import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.InputContext; import it.cavallium.warppi.gui.expression.InputContext;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.Function; import it.cavallium.warppi.math.Function;
import it.cavallium.warppi.math.MathContext; import it.cavallium.warppi.math.MathContext;
@ -32,7 +32,7 @@ public class BlockPower2 extends Block {
} }
@Override @Override
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) { public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
BlockContainer.getDefaultFont(true).use(ge); BlockContainer.getDefaultFont(true).use(ge);
r.glColor(BlockContainer.getDefaultColor()); r.glColor(BlockContainer.getDefaultColor());
containerExponent.draw(ge, r, x, y, caret); containerExponent.draw(ge, r, x, y, caret);

View File

@ -1,8 +1,8 @@
package it.cavallium.warppi.gui.expression.blocks; package it.cavallium.warppi.gui.expression.blocks;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.expression.Caret; import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.InputContext; import it.cavallium.warppi.gui.expression.InputContext;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.Function; import it.cavallium.warppi.math.Function;
import it.cavallium.warppi.math.MathContext; import it.cavallium.warppi.math.MathContext;
@ -29,7 +29,7 @@ public class BlockSquareRoot extends Block {
} }
@Override @Override
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) { public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
BlockContainer.getDefaultFont(small).use(ge); BlockContainer.getDefaultFont(small).use(ge);
r.glColor(BlockContainer.getDefaultColor()); r.glColor(BlockContainer.getDefaultColor());
r.glDrawLine(x, y + height - 10 + 1, x, y + height - 10 + 2); // / r.glDrawLine(x, y + height - 10 + 1, x, y + height - 10 + 2); // /

View File

@ -1,8 +1,8 @@
package it.cavallium.warppi.gui.expression.blocks; package it.cavallium.warppi.gui.expression.blocks;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.expression.Caret; import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.InputContext; import it.cavallium.warppi.gui.expression.InputContext;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.MathContext; import it.cavallium.warppi.math.MathContext;
import it.cavallium.warppi.math.MathematicalSymbols; import it.cavallium.warppi.math.MathematicalSymbols;
@ -21,7 +21,7 @@ public class BlockUndefined extends Block {
} }
@Override @Override
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) { public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
BlockContainer.getDefaultFont(small).use(ge); BlockContainer.getDefaultFont(small).use(ge);
r.glColor(BlockContainer.getDefaultColor()); r.glColor(BlockContainer.getDefaultColor());
r.glDrawStringLeft(x, y, "UNDEFINED"); r.glDrawStringLeft(x, y, "UNDEFINED");

View File

@ -2,14 +2,14 @@ package it.cavallium.warppi.gui.expression.blocks;
import java.util.Arrays; import java.util.Arrays;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.event.KeyPressedEvent; import it.cavallium.warppi.event.KeyPressedEvent;
import it.cavallium.warppi.event.KeyReleasedEvent; import it.cavallium.warppi.event.KeyReleasedEvent;
import it.cavallium.warppi.gui.expression.Caret; import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.ExtraMenu; import it.cavallium.warppi.gui.expression.ExtraMenu;
import it.cavallium.warppi.gui.expression.InputContext; import it.cavallium.warppi.gui.expression.InputContext;
import it.cavallium.warppi.gui.graphicengine.BinaryFont; 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.Renderer;
import it.cavallium.warppi.math.MathContext; import it.cavallium.warppi.math.MathContext;
import it.cavallium.warppi.math.functions.Variable.V_TYPE; import it.cavallium.warppi.math.functions.Variable.V_TYPE;
@ -82,7 +82,7 @@ public class BlockVariable extends Block {
} }
@Override @Override
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) { public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
if (ic.variableTypeDirtyID != typeDirtyID) { if (ic.variableTypeDirtyID != typeDirtyID) {
retrieveValue(); retrieveValue();
} }
@ -238,9 +238,9 @@ public class BlockVariable extends Block {
} }
@Override @Override
public void draw(final GraphicEngine ge, final Renderer r, final Caret caret) { public void draw(final DisplayOutputDevice ge, final Renderer r, final Caret caret) {
r.glColor3f(1.0f, 1.0f, 1.0f); r.glColor3f(1.0f, 1.0f, 1.0f);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().guiSkin.use(ge); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().guiSkin.use(ge);
int popupX = location[0]; int popupX = location[0];
int popupY = location[1]; int popupY = location[1];
if (popupX < 0) { if (popupX < 0) {

View File

@ -1,5 +1,6 @@
package it.cavallium.warppi.gui.expression.containers; package it.cavallium.warppi.gui.expression.containers;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.event.KeyboardEventListener; import it.cavallium.warppi.event.KeyboardEventListener;
import it.cavallium.warppi.gui.GraphicalElement; import it.cavallium.warppi.gui.GraphicalElement;
import it.cavallium.warppi.gui.expression.Caret; import it.cavallium.warppi.gui.expression.Caret;
@ -10,7 +11,6 @@ import it.cavallium.warppi.gui.expression.blocks.Block;
import it.cavallium.warppi.gui.expression.blocks.BlockContainer; import it.cavallium.warppi.gui.expression.blocks.BlockContainer;
import it.cavallium.warppi.gui.expression.blocks.BlockReference; import it.cavallium.warppi.gui.expression.blocks.BlockReference;
import it.cavallium.warppi.gui.expression.layouts.InputLayout; import it.cavallium.warppi.gui.expression.layouts.InputLayout;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.Function; import it.cavallium.warppi.math.Function;
import it.cavallium.warppi.math.MathContext; import it.cavallium.warppi.math.MathContext;
@ -211,7 +211,7 @@ public abstract class InputContainer implements GraphicalElement, InputLayout {
* @param y * @param y
* Position relative to the window. * Position relative to the window.
*/ */
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y) { public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y) {
caret.resetRemaining(); caret.resetRemaining();
root.draw(ge, r, x, y, caret); root.draw(ge, r, x, y, caret);
if (extra != null) { if (extra != null) {

View File

@ -1,12 +1,12 @@
package it.cavallium.warppi.gui.expression.containers; package it.cavallium.warppi.gui.expression.containers;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.GraphicalElement; import it.cavallium.warppi.gui.GraphicalElement;
import it.cavallium.warppi.gui.expression.Caret; import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.CaretState; import it.cavallium.warppi.gui.expression.CaretState;
import it.cavallium.warppi.gui.expression.blocks.Block; import it.cavallium.warppi.gui.expression.blocks.Block;
import it.cavallium.warppi.gui.expression.blocks.BlockContainer; import it.cavallium.warppi.gui.expression.blocks.BlockContainer;
import it.cavallium.warppi.gui.expression.layouts.OutputLayout; import it.cavallium.warppi.gui.expression.layouts.OutputLayout;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectArrayList;
@ -119,7 +119,7 @@ public abstract class OutputContainer implements GraphicalElement, OutputLayout
* @param y * @param y
* Position relative to the window. * Position relative to the window.
*/ */
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y) { public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y) {
int offset = 0; int offset = 0;
for (final BlockContainer root : roots) { for (final BlockContainer root : roots) {
root.draw(ge, r, x, y + offset, caret); root.draw(ge, r, x, y + offset, caret);

View File

@ -3,26 +3,29 @@ package it.cavallium.warppi.gui.graphicengine;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.flow.Observable; import it.cavallium.warppi.flow.Observable;
public interface GraphicEngine { public interface GraphicEngine {
int[] getSize(); int[] getSize();
boolean isSupported();
boolean isInitialized(); boolean isInitialized();
void setTitle(String title); void setTitle(String title);
void setResizable(boolean r); void setResizable(boolean r);
void setDisplayMode(final int ww, final int wh); void setDisplayMode(int ww, int wh);
void create(Runnable object);
default void create() { default void create() {
create(null); create(null);
}; };
void create(Runnable object);
Observable<Integer[]> onResize(); Observable<Integer[]> onResize();
int getWidth(); int getWidth();
@ -45,8 +48,6 @@ public interface GraphicEngine {
void waitForExit(); void waitForExit();
boolean isSupported();
boolean doesRefreshPauses(); boolean doesRefreshPauses();
default boolean supportsFontRegistering() { default boolean supportsFontRegistering() {

View File

@ -3,15 +3,17 @@ package it.cavallium.warppi.gui.graphicengine;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
public interface Skin { public interface Skin {
void load(String file) throws IOException, URISyntaxException; void load(String file) throws IOException, URISyntaxException;
void initialize(GraphicEngine d); void initialize(DisplayOutputDevice d);
boolean isInitialized(); boolean isInitialized();
void use(GraphicEngine d); void use(DisplayOutputDevice d);
/** /**
* May not be available before initialization * May not be available before initialization

View File

@ -3,9 +3,9 @@ package it.cavallium.warppi.gui.graphicengine.impl.common;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform.ImageUtils.ImageReader; import it.cavallium.warppi.Platform.ImageUtils.ImageReader;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.Skin; import it.cavallium.warppi.gui.graphicengine.Skin;
public abstract class PngSkin implements Skin { public abstract class PngSkin implements Skin {
@ -25,7 +25,7 @@ public abstract class PngSkin implements Skin {
if (!file.startsWith("/")) { if (!file.startsWith("/")) {
file = "/" + file; file = "/" + file;
} }
final ImageReader r = Engine.getPlatform().getImageUtils().load(Engine.getPlatform().getStorageUtils().getResourceStream(file)); final ImageReader r = WarpPI.getPlatform().getImageUtils().load(WarpPI.getPlatform().getStorageUtils().getResourceStream(file));
if (r == null) { if (r == null) {
skinData = new int[0]; skinData = new int[0];
skinSize = new int[] { 0, 0 }; skinSize = new int[] { 0, 0 };
@ -37,7 +37,7 @@ public abstract class PngSkin implements Skin {
} }
@Override @Override
public void initialize(final GraphicEngine d) { public void initialize(final DisplayOutputDevice d) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }

View File

@ -8,10 +8,10 @@ import java.util.LinkedList;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform.ConsoleUtils; import it.cavallium.warppi.Platform.ConsoleUtils;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.BinaryFont; import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.util.Utils; import it.cavallium.warppi.util.Utils;
public abstract class RFTFont implements BinaryFont { public abstract class RFTFont implements BinaryFont {
@ -62,7 +62,7 @@ public abstract class RFTFont implements BinaryFont {
} }
private void load(final String path, final boolean onlyRaw) throws IOException { private void load(final String path, final boolean onlyRaw) throws IOException {
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN + 1, "Loading font " + path); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN + 1, "Loading font " + path);
loadFont(path); loadFont(path);
if (!onlyRaw) { if (!onlyRaw) {
chars32 = new int[intervalsTotalSize * charIntCount]; chars32 = new int[intervalsTotalSize * charIntCount];
@ -94,14 +94,14 @@ public abstract class RFTFont implements BinaryFont {
} }
} }
Engine.getPlatform().gc(); WarpPI.getPlatform().gc();
} }
private void loadFont(String string) throws IOException { private void loadFont(String string) throws IOException {
if (!string.startsWith("/")) { if (!string.startsWith("/")) {
string = "/" + string; string = "/" + string;
} }
InputStream res = Engine.getPlatform().getStorageUtils().getResourceStream(string); InputStream res = WarpPI.getPlatform().getStorageUtils().getResourceStream(string);
final int[] file = Utils.realBytes(Utils.convertStreamToByteArray(res, res.available())); final int[] file = Utils.realBytes(Utils.convertStreamToByteArray(res, res.available()));
final int filelength = file.length; final int filelength = file.length;
if (filelength >= 16) { if (filelength >= 16) {
@ -140,7 +140,7 @@ public abstract class RFTFont implements BinaryFont {
} catch (final Exception ex) { } catch (final Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
System.out.println(string); System.out.println(string);
Engine.getPlatform().exit(-1); WarpPI.getPlatform().exit(-1);
} }
} }
} else { } else {
@ -266,7 +266,7 @@ public abstract class RFTFont implements BinaryFont {
} }
@Override @Override
public void initialize(final GraphicEngine d) {} public void initialize(final DisplayOutputDevice d) {}
@Override @Override
public int getStringWidth(final String text) { public int getStringWidth(final String text) {
@ -314,7 +314,7 @@ public abstract class RFTFont implements BinaryFont {
} }
@Override @Override
public void use(final GraphicEngine d) { public void use(final DisplayOutputDevice d) {
} }

View File

@ -2,8 +2,9 @@ package it.cavallium.warppi.gui.graphicengine.impl.nogui;
import java.io.IOException; import java.io.IOException;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform.Semaphore; import it.cavallium.warppi.Platform.Semaphore;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.flow.Observable; import it.cavallium.warppi.flow.Observable;
import it.cavallium.warppi.gui.graphicengine.BinaryFont; import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
@ -14,7 +15,7 @@ import it.cavallium.warppi.gui.graphicengine.Skin;
public class NoGuiEngine implements GraphicEngine { public class NoGuiEngine implements GraphicEngine {
private boolean initialized; private boolean initialized;
public Semaphore exitSemaphore = Engine.getPlatform().newSemaphore(0); public Semaphore exitSemaphore = WarpPI.getPlatform().newSemaphore(0);
@Override @Override
public int[] getSize() { public int[] getSize() {
@ -147,7 +148,7 @@ public class NoGuiEngine implements GraphicEngine {
public BinaryFont loadFont(final String fontName) throws IOException { public BinaryFont loadFont(final String fontName) throws IOException {
return new BinaryFont() { return new BinaryFont() {
@Override @Override
public void use(final GraphicEngine d) {} public void use(final DisplayOutputDevice d) {}
@Override @Override
public void load(final String file) throws IOException {} public void load(final String file) throws IOException {}
@ -158,7 +159,7 @@ public class NoGuiEngine implements GraphicEngine {
} }
@Override @Override
public void initialize(final GraphicEngine d) {} public void initialize(final DisplayOutputDevice d) {}
@Override @Override
public int getStringWidth(final String text) { public int getStringWidth(final String text) {
@ -193,7 +194,7 @@ public class NoGuiEngine implements GraphicEngine {
public BinaryFont loadFont(final String path, final String fontName) throws IOException { public BinaryFont loadFont(final String path, final String fontName) throws IOException {
return new BinaryFont() { return new BinaryFont() {
@Override @Override
public void use(final GraphicEngine d) {} public void use(final DisplayOutputDevice d) {}
@Override @Override
public void load(final String file) throws IOException {} public void load(final String file) throws IOException {}
@ -204,7 +205,7 @@ public class NoGuiEngine implements GraphicEngine {
} }
@Override @Override
public void initialize(final GraphicEngine d) {} public void initialize(final DisplayOutputDevice d) {}
@Override @Override
public int getStringWidth(final String text) { public int getStringWidth(final String text) {
@ -239,7 +240,7 @@ public class NoGuiEngine implements GraphicEngine {
public Skin loadSkin(final String file) throws IOException { public Skin loadSkin(final String file) throws IOException {
return new Skin() { return new Skin() {
@Override @Override
public void use(final GraphicEngine d) {} public void use(final DisplayOutputDevice d) {}
@Override @Override
public void load(final String file) throws IOException {} public void load(final String file) throws IOException {}
@ -250,7 +251,7 @@ public class NoGuiEngine implements GraphicEngine {
} }
@Override @Override
public void initialize(final GraphicEngine d) {} public void initialize(final DisplayOutputDevice d) {}
@Override @Override
public int getSkinWidth() { public int getSkinWidth() {

View File

@ -1,6 +1,6 @@
package it.cavallium.warppi.gui.screens; package it.cavallium.warppi.gui.screens;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.event.KeyPressedEvent; import it.cavallium.warppi.event.KeyPressedEvent;
import it.cavallium.warppi.gui.HistoryBehavior; import it.cavallium.warppi.gui.HistoryBehavior;
@ -32,21 +32,21 @@ public class ChooseVariableValueScreen extends Screen {
@Override @Override
public void render() { public void render() {
Utils.getFont(false, true).use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine); Utils.getFont(false, true).use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4i(0, 0, 0, 64); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4i(0, 0, 0, 64);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2 - 20, "WORK IN PROGRESS."); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2 - 20, "WORK IN PROGRESS.");
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 - 20 + 1, "WORK IN PROGRESS."); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 - 20 + 1, "WORK IN PROGRESS.");
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2 - 20 + 1, "WORK IN PROGRESS."); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2 - 20 + 1, "WORK IN PROGRESS.");
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3i(255, 0, 0); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3i(255, 0, 0);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 - 20, "WORK IN PROGRESS."); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 - 20, "WORK IN PROGRESS.");
Utils.getFont(false, false).use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine); Utils.getFont(false, false).use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4i(0, 0, 0, 64); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4i(0, 0, 0, 64);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE."); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 + 1, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE."); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 + 1, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2 + 1, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE."); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2 + 1, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3i(255, 0, 0); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3i(255, 0, 0);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE."); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
} }
@Override @Override

View File

@ -1,6 +1,6 @@
package it.cavallium.warppi.gui.screens; package it.cavallium.warppi.gui.screens;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.event.KeyPressedEvent; import it.cavallium.warppi.event.KeyPressedEvent;
import it.cavallium.warppi.event.KeyReleasedEvent; import it.cavallium.warppi.event.KeyReleasedEvent;
@ -32,19 +32,19 @@ public class KeyboardDebugScreen extends Screen {
@Override @Override
public void render() { public void render() {
final Renderer renderer = Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer; final Renderer renderer = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer;
Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
renderer.glColor4f(0.75f, 0.0f, 0.0f, 1.0f); renderer.glColor4f(0.75f, 0.0f, 0.0f, 1.0f);
renderer.glDrawStringRight(StaticVars.screenSize[0] - 10, 30, "-" + keyevent.toUpperCase() + "-"); renderer.glDrawStringRight(StaticVars.screenSize[0] - 10, 30, "-" + keyevent.toUpperCase() + "-");
if (keyevent != "NONE") { if (keyevent != "NONE") {
Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f); renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
renderer.glDrawStringLeft(10, 30, "Key position"); renderer.glDrawStringLeft(10, 30, "Key position");
renderer.glDrawStringLeft(10, 45, "X: " + KeyboardDebugScreen.keyX + ", Y:" + KeyboardDebugScreen.keyY); renderer.glDrawStringLeft(10, 45, "X: " + KeyboardDebugScreen.keyX + ", Y:" + KeyboardDebugScreen.keyY);
renderer.glDrawStringLeft(10, 65, "Key value"); renderer.glDrawStringLeft(10, 65, "Key value");
renderer.glDrawStringLeft(10, 80, key); renderer.glDrawStringLeft(10, 80, key);
} }
Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[3].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().fonts[3].use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f); renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
if (KeyboardDebugScreen.log[i] != null) { if (KeyboardDebugScreen.log[i] != null) {
@ -56,10 +56,10 @@ public class KeyboardDebugScreen extends Screen {
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f); renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
renderer.glFillColor(-80 + 100 + 200, 90, 5, 5); renderer.glFillColor(-80 + 100 + 200, 90, 5, 5);
renderer.glFillColor(-80 + 100, 100, 200, 70); renderer.glFillColor(-80 + 100, 100, 200, 70);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
renderer.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); renderer.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
renderer.glDrawStringCenter(-80 + 100 + 200 / 2, 100 + 70 / 2 - renderer.getCurrentFont().getCharacterHeight() / 2, "FROM SERIAL"); renderer.glDrawStringCenter(-80 + 100 + 200 / 2, 100 + 70 / 2 - renderer.getCurrentFont().getCharacterHeight() / 2, "FROM SERIAL");
Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[3].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().fonts[3].use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
renderer.glColor4f(0.0f, 0.0f, 1.0f, 1.0f); renderer.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
if (KeyboardDebugScreen.pinsA[i] == 1) { if (KeyboardDebugScreen.pinsA[i] == 1) {
@ -102,10 +102,10 @@ public class KeyboardDebugScreen extends Screen {
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f); renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
renderer.glFillColor(150 + 90, 200, 5, 5); renderer.glFillColor(150 + 90, 200, 5, 5);
renderer.glFillColor(150 + 100, 100, 200, 70); renderer.glFillColor(150 + 100, 100, 200, 70);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
renderer.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); renderer.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
renderer.glDrawStringCenter(150 + 100 + 200 / 2, 100 + 70 / 2 - renderer.getCurrentFont().getCharacterHeight() / 2, "TO SERIAL"); renderer.glDrawStringCenter(150 + 100 + 200 / 2, 100 + 70 / 2 - renderer.getCurrentFont().getCharacterHeight() / 2, "TO SERIAL");
Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[3].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().fonts[3].use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
renderer.glColor4f(0.0f, 0.0f, 1.0f, 1.0f); renderer.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
for (int i = 15; i >= 8; i--) { for (int i = 15; i >= 8; i--) {
if (KeyboardDebugScreen.pinsB[i] == 1) { if (KeyboardDebugScreen.pinsB[i] == 1) {

View File

@ -1,6 +1,6 @@
package it.cavallium.warppi.gui.screens; package it.cavallium.warppi.gui.screens;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.gui.GraphicUtils; import it.cavallium.warppi.gui.GraphicUtils;
import it.cavallium.warppi.gui.HistoryBehavior; import it.cavallium.warppi.gui.HistoryBehavior;
@ -21,7 +21,7 @@ public class LoadingScreen extends Screen {
@Override @Override
public void created() throws InterruptedException { public void created() throws InterruptedException {
Engine.INSTANCE.isLoaded().subscribe((loaded) -> { WarpPI.INSTANCE.isLoaded().subscribe((loaded) -> {
this.loaded = loaded; this.loaded = loaded;
}); });
endLoading = 0; endLoading = 0;
@ -30,7 +30,7 @@ public class LoadingScreen extends Screen {
@Override @Override
public void initialized() throws InterruptedException { public void initialized() throws InterruptedException {
previousZoomValue = StaticVars.windowZoomFunction.apply(StaticVars.windowZoom.getLastValue()); previousZoomValue = StaticVars.windowZoomFunction.apply(StaticVars.windowZoom.getLastValue());
Engine.INSTANCE.getHardwareDevice().getDisplayManager().getHUD().hide(); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getHUD().hide();
StaticVars.windowZoom.onNext(1f); StaticVars.windowZoom.onNext(1f);
} }
@ -42,24 +42,24 @@ public class LoadingScreen extends Screen {
loadingTextTranslation = GraphicUtils.sinDeg(endLoading * 90f) * 10f; loadingTextTranslation = GraphicUtils.sinDeg(endLoading * 90f) * 10f;
endLoading += dt; endLoading += dt;
if (!ended && loaded && (Engine.getPlatform().getSettings().isDebugEnabled() || endLoading >= 3.5f)) { if (!ended && loaded && (WarpPI.getPlatform().getSettings().isDebugEnabled() || endLoading >= 3.5f)) {
ended = true; ended = true;
StaticVars.windowZoom.onNext(previousZoomValue); StaticVars.windowZoom.onNext(previousZoomValue);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().getHUD().show(); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getHUD().show();
Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new MathInputScreen()); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new MathInputScreen());
} }
mustRefresh = true; mustRefresh = true;
} }
@Override @Override
public void render() { public void render() {
Engine.INSTANCE.getHardwareDevice().getDisplayManager().guiSkin.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().guiSkin.use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3i(255, 255, 255); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3i(255, 255, 255);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] / 2f - 80, StaticVars.screenSize[1] / 2f - 64, 160, 48, 0, 32, 160, 48); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] / 2f - 80, StaticVars.screenSize[1] / 2f - 64, 160, 48, 0, 32, 160, 48);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] / 2f - 24, StaticVars.screenSize[1] / 2f - loadingTextTranslation, 48, 48, 160, 32, 48, 48); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] / 2f - 24, StaticVars.screenSize[1] / 2f - loadingTextTranslation, 48, 48, 160, 32, 48, 48);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] - 224, StaticVars.screenSize[1] - 48, 224, 48, 0, 80, 224, 48); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] - 224, StaticVars.screenSize[1] - 48, 224, 48, 0, 80, 224, 48);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] - 160 - 24 - 224, StaticVars.screenSize[1] - 48, 160, 48, 224, 80, 160, 48); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] - 160 - 24 - 224, StaticVars.screenSize[1] - 48, 160, 48, 224, 80, 160, 48);
} }

View File

@ -5,9 +5,9 @@ import java.util.HashMap;
import org.apache.commons.lang3.SerializationUtils; import org.apache.commons.lang3.SerializationUtils;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform.ConsoleUtils; import it.cavallium.warppi.Platform.ConsoleUtils;
import it.cavallium.warppi.device.Keyboard; import it.cavallium.warppi.device.input.Keyboard;
import it.cavallium.warppi.event.Key; import it.cavallium.warppi.event.Key;
import it.cavallium.warppi.event.KeyPressedEvent; import it.cavallium.warppi.event.KeyPressedEvent;
import it.cavallium.warppi.event.KeyReleasedEvent; import it.cavallium.warppi.event.KeyReleasedEvent;
@ -88,10 +88,10 @@ public class MathInputScreen extends Screen {
calc = new MathContext(); calc = new MathContext();
try { try {
BlockContainer.initializeFonts(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("norm"), Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("smal")); BlockContainer.initializeFonts(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadFont("norm"), WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadFont("smal"));
} catch (final IOException e) { } catch (final IOException e) {
e.printStackTrace(); e.printStackTrace();
Engine.getPlatform().exit(1); WarpPI.getPlatform().exit(1);
} }
userInput = new NormalInputContainer(ic); userInput = new NormalInputContainer(ic);
@ -112,10 +112,10 @@ public class MathInputScreen extends Screen {
@Override @Override
public void beforeRender(final float dt) { public void beforeRender(final float dt) {
if (Engine.INSTANCE.getHardwareDevice().getDisplayManager().error == null) { if (WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().error == null) {
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glClearColor(0xFFc5c2af); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glClearColor(0xFFc5c2af);
} else { } else {
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glClearColor(0xFFDC3C32); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glClearColor(0xFFDC3C32);
} }
if (userInput.beforeRender(dt)) { if (userInput.beforeRender(dt)) {
mustRefresh = true; mustRefresh = true;
@ -141,13 +141,13 @@ public class MathInputScreen extends Screen {
@Override @Override
public void render() { public void render() {
final Renderer renderer = Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer; final Renderer renderer = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer;
MathInputScreen.fontBig.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine); MathInputScreen.fontBig.use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
final int textColor = 0xFF000000; final int textColor = 0xFF000000;
final int padding = 4; final int padding = 4;
renderer.glColor(textColor); renderer.glColor(textColor);
userInput.draw(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine, renderer, padding, padding + 20); userInput.draw(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display, renderer, padding, padding + 20);
if (computingResult) { if (computingResult) {
renderer.glColor3f(1, 1, 1); renderer.glColor3f(1, 1, 1);
@ -156,20 +156,20 @@ public class MathInputScreen extends Screen {
final int size = 32; final int size = 32;
final int posY = computingAnimationIndex % 2; final int posY = computingAnimationIndex % 2;
final int posX = (computingAnimationIndex - posY) / 2; final int posX = (computingAnimationIndex - posY) / 2;
renderer.glFillRect(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getWidth() - size - 4, Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - size - 4, size, size, leftX + size * posX, leftY + size * posY, size, size); renderer.glFillRect(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getWidth() - size - 4, WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getHeight() - size - 4, size, size, leftX + size * posX, leftY + size * posY, size, size);
if (computingBreakTipVisible) { if (computingBreakTipVisible) {
Utils.getFont(false).use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine); Utils.getFont(false).use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
renderer.glColor3f(0.75f, 0, 0); renderer.glColor3f(0.75f, 0, 0);
renderer.glDrawStringRight(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getWidth() - 4 - size - 4, Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - size / 2 - renderer.getCurrentFont().getCharacterHeight() / 2 - 4, "Press (=) to stop"); renderer.glDrawStringRight(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getWidth() - 4 - size - 4, WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getHeight() - size / 2 - renderer.getCurrentFont().getCharacterHeight() / 2 - 4, "Press (=) to stop");
} }
} else if (!result.isContentEmpty()) { } else if (!result.isContentEmpty()) {
result.draw(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine, renderer, Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getWidth() - result.getWidth() - 2, Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - result.getHeight() - 2); result.draw(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display, renderer, WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getWidth() - result.getWidth() - 2, WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getHeight() - result.getHeight() - 2);
} }
} }
@Override @Override
public void renderTopmost() { public void renderTopmost() {
final Renderer renderer = Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer; final Renderer renderer = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer;
renderer.glColor3f(1, 1, 1); renderer.glColor3f(1, 1, 1);
final int pos = 2; final int pos = 2;
final int spacersNumb = 1; final int spacersNumb = 1;
@ -179,7 +179,7 @@ public class MathInputScreen extends Screen {
} else { } else {
skinN = 21; skinN = 21;
} }
Engine.INSTANCE.getHardwareDevice().getDisplayManager().guiSkin.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().guiSkin.use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
renderer.glFillRect(2 + 18 * pos + 2 * spacersNumb, 2, 16, 16, 16 * skinN, 16 * 0, 16, 16); renderer.glFillRect(2 + 18 * pos + 2 * spacersNumb, 2, 16, 16, 16 * skinN, 16 * 0, 16, 16);
} }
@ -195,7 +195,7 @@ public class MathInputScreen extends Screen {
@Override @Override
public boolean onKeyPressed(final KeyPressedEvent k) { public boolean onKeyPressed(final KeyPressedEvent k) {
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "MathInputScreen", "Pressed key " + k.getKey().toString()); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "MathInputScreen", "Pressed key " + k.getKey().toString());
try { try {
switch (k.getKey()) { switch (k.getKey()) {
case OK: case OK:
@ -347,9 +347,9 @@ public class MathInputScreen extends Screen {
userInput.clear(); userInput.clear();
result.clear(); result.clear();
currentStep = 0; currentStep = 0;
if (Engine.INSTANCE.getHardwareDevice().getDisplayManager().error != null) { if (WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().error != null) {
Engine.getPlatform().getConsoleUtils().out().println(1, "Resetting after error..."); WarpPI.getPlatform().getConsoleUtils().out().println(1, "Resetting after error...");
Engine.INSTANCE.getHardwareDevice().getDisplayManager().error = null; WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().error = null;
} }
return true; return true;
case SURD_MODE: case SURD_MODE:
@ -361,7 +361,7 @@ public class MathInputScreen extends Screen {
} }
return true; return true;
case debug1: case debug1:
Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new EmptyScreen()); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new EmptyScreen());
return true; return true;
case HISTORY_BACK: case HISTORY_BACK:
// if (Engine.INSTANCE.getHardwareDevice().getDisplayManager().canGoBack()) { // if (Engine.INSTANCE.getHardwareDevice().getDisplayManager().canGoBack()) {
@ -428,7 +428,7 @@ public class MathInputScreen extends Screen {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void swapInputScreen() { private void swapInputScreen() {
MathInputScreen mis = new MathInputScreen(this); MathInputScreen mis = new MathInputScreen(this);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(mis); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(mis);
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ -517,10 +517,10 @@ public class MathInputScreen extends Screen {
if (!step) { if (!step) {
currentStep = 0; currentStep = 0;
} }
if (Engine.INSTANCE.getHardwareDevice().getDisplayManager().error != null) { if (WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().error != null) {
//TODO: make the error management a global API rather than being relegated to this screen. //TODO: make the error management a global API rather than being relegated to this screen.
Engine.getPlatform().getConsoleUtils().out().println(1, "Resetting after error..."); WarpPI.getPlatform().getConsoleUtils().out().println(1, "Resetting after error...");
Engine.INSTANCE.getHardwareDevice().getDisplayManager().error = null; WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().error = null;
calc.f = null; calc.f = null;
calc.f2 = null; calc.f2 = null;
calc.resultsCount = 0; calc.resultsCount = 0;
@ -540,13 +540,13 @@ public class MathInputScreen extends Screen {
calc.f2.clear(); calc.f2.clear();
} }
calc.f.add(expr); calc.f.add(expr);
Engine.getPlatform().getConsoleUtils().out().println(2, "INPUT: " + expr); WarpPI.getPlatform().getConsoleUtils().out().println(2, "INPUT: " + expr);
final MathSolver ms = new MathSolver(expr); final MathSolver ms = new MathSolver(expr);
final ObjectArrayList<ObjectArrayList<Function>> resultSteps = ms.solveAllSteps(); final ObjectArrayList<ObjectArrayList<Function>> resultSteps = ms.solveAllSteps();
resultSteps.add(0, Utils.newArrayList(expr)); resultSteps.add(0, Utils.newArrayList(expr));
final ObjectArrayList<Function> resultExpressions = resultSteps.get(resultSteps.size() - 1); final ObjectArrayList<Function> resultExpressions = resultSteps.get(resultSteps.size() - 1);
for (final Function rr : resultExpressions) { for (final Function rr : resultExpressions) {
Engine.getPlatform().getConsoleUtils().out().println(0, "RESULT: " + rr.toString()); WarpPI.getPlatform().getConsoleUtils().out().println(0, "RESULT: " + rr.toString());
} }
final ObjectArrayList<ObjectArrayList<Block>> resultBlocks = MathParser.parseOutput(calc, resultExpressions); final ObjectArrayList<ObjectArrayList<Block>> resultBlocks = MathParser.parseOutput(calc, resultExpressions);
result.setContentAsMultipleGroups(resultBlocks); result.setContentAsMultipleGroups(resultBlocks);
@ -559,22 +559,22 @@ public class MathInputScreen extends Screen {
} }
} }
} catch (final InterruptedException ex) { } catch (final InterruptedException ex) {
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Computing thread stopped."); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Computing thread stopped.");
} catch (final Exception ex) { } catch (final Exception ex) {
if (Engine.getPlatform().getSettings().isDebugEnabled()) { if (WarpPI.getPlatform().getSettings().isDebugEnabled()) {
ex.printStackTrace(); ex.printStackTrace();
} }
throw new Error(Errors.SYNTAX_ERROR); throw new Error(Errors.SYNTAX_ERROR);
} }
} catch (final Error e) { } catch (final Error e) {
d.errorStackTrace = Engine.getPlatform().stacktraceToString(e); d.errorStackTrace = WarpPI.getPlatform().stacktraceToString(e);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().error = e.id.toString(); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().error = e.id.toString();
System.err.println(e.id); System.err.println(e.id);
} }
computingResult = false; computingResult = false;
}); });
Engine.getPlatform().setThreadName(computingThread, "Computing Thread"); WarpPI.getPlatform().setThreadName(computingThread, "Computing Thread");
Engine.getPlatform().setThreadDaemon(computingThread); WarpPI.getPlatform().setThreadDaemon(computingThread);
computingThread.setPriority(Thread.NORM_PRIORITY + 3); computingThread.setPriority(Thread.NORM_PRIORITY + 3);
computingThread.start(); computingThread.start();
return true; return true;
@ -638,9 +638,9 @@ public class MathInputScreen extends Screen {
boolean cancelled = false; boolean cancelled = false;
for (final Function f : knownVarsInFunctions) { for (final Function f : knownVarsInFunctions) {
final ChooseVariableValueScreen cvs = new ChooseVariableValueScreen(this, new VariableValue((Variable) f, new Number(calc, 0))); final ChooseVariableValueScreen cvs = new ChooseVariableValueScreen(this, new VariableValue((Variable) f, new Number(calc, 0)));
Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(cvs); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(cvs);
try { try {
Engine.INSTANCE.getHardwareDevice().getDisplayManager().screenChange.acquire(); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().screenChange.acquire();
} catch (final InterruptedException e) {} } catch (final InterruptedException e) {}
if (cvs.resultNumberValue == null) { if (cvs.resultNumberValue == null) {
cancelled = true; cancelled = true;
@ -661,9 +661,9 @@ public class MathInputScreen extends Screen {
} }
} }
}); });
Engine.getPlatform().setThreadName(ct, "Variables user-input queue thread"); WarpPI.getPlatform().setThreadName(ct, "Variables user-input queue thread");
ct.setPriority(Thread.MIN_PRIORITY); ct.setPriority(Thread.MIN_PRIORITY);
Engine.getPlatform().setThreadDaemon(ct); WarpPI.getPlatform().setThreadDaemon(ct);
ct.start(); ct.start();
} }

View File

@ -1,6 +1,6 @@
package it.cavallium.warppi.gui.screens; package it.cavallium.warppi.gui.screens;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.event.KeyPressedEvent; import it.cavallium.warppi.event.KeyPressedEvent;
import it.cavallium.warppi.gui.HistoryBehavior; import it.cavallium.warppi.gui.HistoryBehavior;
@ -28,12 +28,12 @@ public class SolveForXScreen extends Screen {
@Override @Override
public void render() { public void render() {
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4i(0, 0, 0, 64); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4i(0, 0, 0, 64);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 4, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE."); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 4, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 4 + 1, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE."); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 4 + 1, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 4 + 1, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE."); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 4 + 1, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3i(255, 0, 0); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3i(255, 0, 0);
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 4, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE."); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 4, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
} }
@Override @Override

View File

@ -1,6 +1,6 @@
package it.cavallium.warppi.math.parser; package it.cavallium.warppi.math.parser;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform.ConsoleUtils; import it.cavallium.warppi.Platform.ConsoleUtils;
import it.cavallium.warppi.gui.expression.blocks.Block; import it.cavallium.warppi.gui.expression.blocks.Block;
import it.cavallium.warppi.gui.expression.containers.InputContainer; import it.cavallium.warppi.gui.expression.containers.InputContainer;
@ -83,17 +83,17 @@ public class MathParser {
boolean lastLoopDidSomething; boolean lastLoopDidSomething;
Function lastElement; Function lastElement;
if (Engine.getPlatform().getSettings().isDebugEnabled()) { if (WarpPI.getPlatform().getSettings().isDebugEnabled()) {
Engine.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "\tStatus: "); WarpPI.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "\tStatus: ");
for (final Function f : functionsList) { for (final Function f : functionsList) {
Engine.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, f.toString()); WarpPI.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, f.toString());
} }
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE);
} }
for (final MathParserStep step : steps) { for (final MathParserStep step : steps) {
if (Engine.getPlatform().getSettings().isDebugEnabled()) { if (WarpPI.getPlatform().getSettings().isDebugEnabled()) {
Engine.getPlatform().getConsoleUtils().out().println(2, "Stack fixing step \"" + step.getStepName() + "\""); WarpPI.getPlatform().getConsoleUtils().out().println(2, "Stack fixing step \"" + step.getStepName() + "\"");
} }
final int stepQty = step.requiresReversedIteration() ? -1 : 1, final int stepQty = step.requiresReversedIteration() ? -1 : 1,
initialIndex = step.requiresReversedIteration() ? functionsList.size() - 1 : 0; initialIndex = step.requiresReversedIteration() ? functionsList.size() - 1 : 0;
@ -114,12 +114,12 @@ public class MathParser {
} }
} while (lastLoopDidSomething); } while (lastLoopDidSomething);
if (Engine.getPlatform().getSettings().isDebugEnabled()) { if (WarpPI.getPlatform().getSettings().isDebugEnabled()) {
Engine.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "\tStatus: "); WarpPI.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "\tStatus: ");
for (final Function f : functionsList) { for (final Function f : functionsList) {
Engine.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, f.toString()); WarpPI.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, f.toString());
} }
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE);
} }
} }

View File

@ -11,7 +11,7 @@ import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform.ConsoleUtils; import it.cavallium.warppi.Platform.ConsoleUtils;
import it.cavallium.warppi.Platform.StorageUtils; import it.cavallium.warppi.Platform.StorageUtils;
import it.cavallium.warppi.Platform.URLClassLoader; import it.cavallium.warppi.Platform.URLClassLoader;
@ -33,7 +33,7 @@ public class RulesManager {
@SuppressWarnings({ "unchecked" }) @SuppressWarnings({ "unchecked" })
public static void initialize() { public static void initialize() {
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Loading the rules"); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Loading the rules");
RulesManager.rules = new ObjectArrayList[RuleType.values().length]; RulesManager.rules = new ObjectArrayList[RuleType.values().length];
for (final RuleType val : RuleType.values()) { for (final RuleType val : RuleType.values()) {
RulesManager.rules[val.ordinal()] = new ObjectArrayList<>(); RulesManager.rules[val.ordinal()] = new ObjectArrayList<>();
@ -42,25 +42,25 @@ public class RulesManager {
boolean compiledSomething = false; boolean compiledSomething = false;
InputStream defaultRulesList; InputStream defaultRulesList;
try { try {
defaultRulesList = Engine.getPlatform().getStorageUtils().getResourceStream("/default-rules.lst"); defaultRulesList = WarpPI.getPlatform().getStorageUtils().getResourceStream("/default-rules.lst");
} catch (final IOException ex) { } catch (final IOException ex) {
throw new FileNotFoundException("default-rules.lst not found!"); throw new FileNotFoundException("default-rules.lst not found!");
} }
final List<String> ruleLines = new ArrayList<>(); final List<String> ruleLines = new ArrayList<>();
final File rulesPath = Engine.getPlatform().getStorageUtils().get("rules/"); final File rulesPath = WarpPI.getPlatform().getStorageUtils().get("rules/");
if (rulesPath.exists()) { if (rulesPath.exists()) {
for (final File f : Engine.getPlatform().getStorageUtils().walk(rulesPath)) { for (final File f : WarpPI.getPlatform().getStorageUtils().walk(rulesPath)) {
if (f.toString().endsWith(".java")) { if (f.toString().endsWith(".java")) {
String path = Engine.getPlatform().getStorageUtils().relativize(rulesPath, f).toString(); String path = WarpPI.getPlatform().getStorageUtils().relativize(rulesPath, f).toString();
path = path.substring(0, path.length() - ".java".length()); path = path.substring(0, path.length() - ".java".length());
ruleLines.add(path); ruleLines.add(path);
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Found external rule: " + f.getAbsolutePath()); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Found external rule: " + f.getAbsolutePath());
} }
} }
} }
ruleLines.addAll(Engine.getPlatform().getStorageUtils().readAllLines(defaultRulesList)); ruleLines.addAll(WarpPI.getPlatform().getStorageUtils().readAllLines(defaultRulesList));
final File tDir = Engine.getPlatform().getStorageUtils().resolve(Engine.getPlatform().getStorageUtils().get(System.getProperty("java.io.tmpdir"), "WarpPi-Calculator"), "rules-rt"); final File tDir = WarpPI.getPlatform().getStorageUtils().resolve(WarpPI.getPlatform().getStorageUtils().get(System.getProperty("java.io.tmpdir"), "WarpPi-Calculator"), "rules-rt");
// try { // try {
// final Path defaultResource = Utils.getResource("/math-rules-cache.zip"); // final Path defaultResource = Utils.getResource("/math-rules-cache.zip");
// } // }
@ -68,15 +68,15 @@ public class RulesManager {
File cacheFilePath = null; File cacheFilePath = null;
cacheFilePath = new File("math-rules-cache.zip"); cacheFilePath = new File("math-rules-cache.zip");
boolean cacheFileExists = false; boolean cacheFileExists = false;
if (Engine.getPlatform().isJavascript()) { if (WarpPI.getPlatform().isJavascript()) {
Engine.getPlatform().loadPlatformRules(); WarpPI.getPlatform().loadPlatformRules();
} else { } else {
if (cacheFilePath.exists()) { if (cacheFilePath.exists()) {
cacheFileExists = true; cacheFileExists = true;
cacheFileStream = new FileInputStream(cacheFilePath); cacheFileStream = new FileInputStream(cacheFilePath);
} else { } else {
try { try {
cacheFileStream = Engine.getPlatform().getStorageUtils().getResourceStream("/math-rules-cache.zip");//Paths.get(Utils.getJarDirectory().toString()).resolve("math-rules-cache.zip").toAbsolutePath( cacheFileStream = WarpPI.getPlatform().getStorageUtils().getResourceStream("/math-rules-cache.zip");//Paths.get(Utils.getJarDirectory().toString()).resolve("math-rules-cache.zip").toAbsolutePath(
org.apache.commons.io.FileUtils.copyInputStreamToFile(cacheFileStream, cacheFilePath); org.apache.commons.io.FileUtils.copyInputStreamToFile(cacheFileStream, cacheFilePath);
cacheFileExists = true; cacheFileExists = true;
} catch (final IOException ex) { //File does not exists. } catch (final IOException ex) { //File does not exists.
@ -88,7 +88,7 @@ public class RulesManager {
if (tDir.exists()) { if (tDir.exists()) {
tDir.delete(); tDir.delete();
} }
Engine.getPlatform().unzip(cacheFilePath.toString(), tDir.getParent().toString(), ""); WarpPI.getPlatform().unzip(cacheFilePath.toString(), tDir.getParent().toString(), "");
useCache = !StaticVars.startupArguments.isUncached(); useCache = !StaticVars.startupArguments.isUncached();
} catch (final Exception ex) { } catch (final Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
@ -100,28 +100,28 @@ public class RulesManager {
final String[] ruleDetails = rulesLine.split(",", 1); final String[] ruleDetails = rulesLine.split(",", 1);
final String ruleName = ruleDetails[0]; final String ruleName = ruleDetails[0];
final String ruleNameEscaped = ruleName.replace(".", "_"); final String ruleNameEscaped = ruleName.replace(".", "_");
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", "Evaluating /rules/" + ruleNameEscaped + ".java"); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", "Evaluating /rules/" + ruleNameEscaped + ".java");
final String pathWithoutExtension = "/rules/" + ruleNameEscaped; final String pathWithoutExtension = "/rules/" + ruleNameEscaped;
final String scriptFile = pathWithoutExtension + ".java"; final String scriptFile = pathWithoutExtension + ".java";
final InputStream resourcePath = Engine.getPlatform().getStorageUtils().getResourceStream(scriptFile); final InputStream resourcePath = WarpPI.getPlatform().getStorageUtils().getResourceStream(scriptFile);
if (resourcePath == null) { if (resourcePath == null) {
System.err.println(new FileNotFoundException("/rules/" + ruleName + ".java not found!")); System.err.println(new FileNotFoundException("/rules/" + ruleName + ".java not found!"));
} else { } else {
Rule r = null; Rule r = null;
if (useCache) { if (useCache) {
try { try {
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", ruleName, "Trying to load cached rule"); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", ruleName, "Trying to load cached rule");
r = RulesManager.loadClassRuleFromSourceFile(scriptFile, tDir); r = RulesManager.loadClassRuleFromSourceFile(scriptFile, tDir);
if (r != null) { if (r != null) {
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", ruleName, "Loaded cached rule"); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", ruleName, "Loaded cached rule");
} }
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", ruleName, "Can't load the rule " + ruleNameEscaped + "!"); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", ruleName, "Can't load the rule " + ruleNameEscaped + "!");
} }
} }
if (r == null || !useCache) { if (r == null || !useCache) {
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", ruleName, "This rule is not cached. Compiling"); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", ruleName, "This rule is not cached. Compiling");
try { try {
r = RulesManager.compileJavaRule(scriptFile, tDir); r = RulesManager.compileJavaRule(scriptFile, tDir);
compiledSomething = true; compiledSomething = true;
@ -137,27 +137,27 @@ public class RulesManager {
} }
} }
} }
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Loaded all the rules successfully"); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Loaded all the rules successfully");
if (!Engine.getPlatform().isJavascript() && compiledSomething) { if (!WarpPI.getPlatform().isJavascript() && compiledSomething) {
if (cacheFileExists || cacheFilePath.exists()) { if (cacheFileExists || cacheFilePath.exists()) {
cacheFilePath.delete(); cacheFilePath.delete();
} }
Engine.getPlatform().zip(tDir.toString(), cacheFilePath.toString(), ""); WarpPI.getPlatform().zip(tDir.toString(), cacheFilePath.toString(), "");
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Cached the compiled rules"); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Cached the compiled rules");
} }
if (cacheFileStream != null) { if (cacheFileStream != null) {
cacheFileStream.close(); cacheFileStream.close();
} }
} catch (URISyntaxException | IOException e) { } catch (URISyntaxException | IOException e) {
e.printStackTrace(); e.printStackTrace();
Engine.getPlatform().exit(1); WarpPI.getPlatform().exit(1);
} }
} }
public static Rule compileJavaRule(final String scriptFile, final File tDir) throws IOException, URISyntaxException, public static Rule compileJavaRule(final String scriptFile, final File tDir) throws IOException, URISyntaxException,
InstantiationException, IllegalAccessException, ClassNotFoundException { InstantiationException, IllegalAccessException, ClassNotFoundException {
final InputStream resource = Engine.getPlatform().getStorageUtils().getResourceStream(scriptFile); final InputStream resource = WarpPI.getPlatform().getStorageUtils().getResourceStream(scriptFile);
final String text = Engine.getPlatform().getStorageUtils().read(resource); final String text = WarpPI.getPlatform().getStorageUtils().read(resource);
final String[] textArray = text.split("\\n", 6); final String[] textArray = text.split("\\n", 6);
if (textArray[3].contains("PATH=")) { if (textArray[3].contains("PATH=")) {
final String javaClassDeclaration = textArray[3].substring(6); final String javaClassDeclaration = textArray[3].substring(6);
@ -166,19 +166,19 @@ public class RulesManager {
final String javaClassNameAndPath = new StringBuilder("it.cavallium.warppi.math.rules.").append(javaClassDeclaration).toString(); final String javaClassNameAndPath = new StringBuilder("it.cavallium.warppi.math.rules.").append(javaClassDeclaration).toString();
extIndex = javaClassNameAndPath.lastIndexOf('.'); extIndex = javaClassNameAndPath.lastIndexOf('.');
final String javaCode = new StringBuilder("package ").append(javaClassNameAndPath.substring(0, extIndex >= 0 ? extIndex : javaClassNameAndPath.length())).append(";\n").append(textArray[5]).toString(); final String javaCode = new StringBuilder("package ").append(javaClassNameAndPath.substring(0, extIndex >= 0 ? extIndex : javaClassNameAndPath.length())).append(";\n").append(textArray[5]).toString();
final File tDirPath = Engine.getPlatform().getStorageUtils().getParent(Engine.getPlatform().getStorageUtils().resolve(tDir, javaClassNameAndPath.replace('.', File.separatorChar))); final File tDirPath = WarpPI.getPlatform().getStorageUtils().getParent(WarpPI.getPlatform().getStorageUtils().resolve(tDir, javaClassNameAndPath.replace('.', File.separatorChar)));
final File tFileJava = Engine.getPlatform().getStorageUtils().resolve(tDirPath, javaClassNameOnly + ".java"); final File tFileJava = WarpPI.getPlatform().getStorageUtils().resolve(tDirPath, javaClassNameOnly + ".java");
final File tFileClass = Engine.getPlatform().getStorageUtils().resolve(tDirPath, javaClassNameOnly + ".class"); final File tFileClass = WarpPI.getPlatform().getStorageUtils().resolve(tDirPath, javaClassNameOnly + ".class");
if (!tDirPath.exists()) { if (!tDirPath.exists()) {
Engine.getPlatform().getStorageUtils().createDirectories(tDirPath); WarpPI.getPlatform().getStorageUtils().createDirectories(tDirPath);
} }
if (tFileJava.exists()) { if (tFileJava.exists()) {
tFileJava.delete(); tFileJava.delete();
} }
Engine.getPlatform().getStorageUtils(); WarpPI.getPlatform().getStorageUtils();
Engine.getPlatform().getStorageUtils(); WarpPI.getPlatform().getStorageUtils();
Engine.getPlatform().getStorageUtils().write(tFileJava, javaCode.getBytes("UTF-8"), StorageUtils.OpenOptionWrite, StorageUtils.OpenOptionCreate); WarpPI.getPlatform().getStorageUtils().write(tFileJava, javaCode.getBytes("UTF-8"), StorageUtils.OpenOptionWrite, StorageUtils.OpenOptionCreate);
final boolean compiled = Engine.getPlatform().compile(new String[] { "-nowarn", "-1.8", "-proc:none", tFileJava.toString() }, new PrintWriter(System.out), new PrintWriter(System.err)); final boolean compiled = WarpPI.getPlatform().compile(new String[] { "-nowarn", "-1.8", "-proc:none", tFileJava.toString() }, new PrintWriter(System.out), new PrintWriter(System.err));
if (StaticVars.startupArguments.isUncached()) { if (StaticVars.startupArguments.isUncached()) {
tFileJava.deleteOnExit(); tFileJava.deleteOnExit();
} else { } else {
@ -197,12 +197,12 @@ public class RulesManager {
public static Rule loadClassRuleFromSourceFile(final String scriptFile, final File tDir) throws IOException, public static Rule loadClassRuleFromSourceFile(final String scriptFile, final File tDir) throws IOException,
URISyntaxException, InstantiationException, IllegalAccessException, ClassNotFoundException { URISyntaxException, InstantiationException, IllegalAccessException, ClassNotFoundException {
final InputStream resource = Engine.getPlatform().getStorageUtils().getResourceStream(scriptFile); final InputStream resource = WarpPI.getPlatform().getStorageUtils().getResourceStream(scriptFile);
final String text = Engine.getPlatform().getStorageUtils().read(resource); final String text = WarpPI.getPlatform().getStorageUtils().read(resource);
final String[] textArray = text.split("\\n", 6); final String[] textArray = text.split("\\n", 6);
if (textArray[3].contains("PATH=")) { if (textArray[3].contains("PATH=")) {
final String javaClassName = textArray[3].substring(6); final String javaClassName = textArray[3].substring(6);
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "RulesManager", "Rule java class name: " + javaClassName); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "RulesManager", "Rule java class name: " + javaClassName);
final String javaClassNameAndPath = new StringBuilder("it.cavallium.warppi.math.rules.").append(javaClassName).toString(); final String javaClassNameAndPath = new StringBuilder("it.cavallium.warppi.math.rules.").append(javaClassName).toString();
try { try {
return RulesManager.loadClassRuleDirectly(javaClassNameAndPath, tDir); return RulesManager.loadClassRuleDirectly(javaClassNameAndPath, tDir);
@ -217,7 +217,7 @@ public class RulesManager {
public static Rule loadClassRuleDirectly(final String javaClassNameAndPath, final File tDir) throws IOException, public static Rule loadClassRuleDirectly(final String javaClassNameAndPath, final File tDir) throws IOException,
URISyntaxException, InstantiationException, IllegalAccessException, ClassNotFoundException { URISyntaxException, InstantiationException, IllegalAccessException, ClassNotFoundException {
final URLClassLoader cl = Engine.getPlatform().newURLClassLoader(new URL[] { tDir.toURI().toURL() }); final URLClassLoader cl = WarpPI.getPlatform().newURLClassLoader(new URL[] { tDir.toURI().toURL() });
final Class<?> aClass = cl.loadClass(javaClassNameAndPath); final Class<?> aClass = cl.loadClass(javaClassNameAndPath);
cl.close(); cl.close();
return (Rule) aClass.newInstance(); return (Rule) aClass.newInstance();
@ -259,6 +259,6 @@ public class RulesManager {
public static void addRule(final Rule rule) { public static void addRule(final Rule rule) {
RulesManager.rules[rule.getRuleType().ordinal()].add(rule); RulesManager.rules[rule.getRuleType().ordinal()].add(rule);
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", rule.getRuleName(), "Loaded as " + rule.getRuleType() + " rule"); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", rule.getRuleName(), "Loaded as " + rule.getRuleType() + " rule");
} }
} }

View File

@ -4,7 +4,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform.ConsoleUtils; import it.cavallium.warppi.Platform.ConsoleUtils;
import it.cavallium.warppi.math.Function; import it.cavallium.warppi.math.Function;
import it.cavallium.warppi.math.rules.Rule; import it.cavallium.warppi.math.rules.Rule;
@ -40,7 +40,7 @@ public class MathSolver {
public ObjectArrayList<ObjectArrayList<Function>> solveAllSteps() throws InterruptedException, Error { public ObjectArrayList<ObjectArrayList<Function>> solveAllSteps() throws InterruptedException, Error {
final ObjectArrayList<ObjectArrayList<Function>> steps = new ObjectArrayList<>(); final ObjectArrayList<ObjectArrayList<Function>> steps = new ObjectArrayList<>();
ObjectArrayList<Function> lastFnc = null, currFnc = new ObjectArrayList<>(); ObjectArrayList<Function> lastFnc = null, currFnc = new ObjectArrayList<>();
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Solving all steps. Input: " + initialFunction.toString()); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Solving all steps. Input: " + initialFunction.toString());
currFnc.add(initialFunction); currFnc.add(initialFunction);
long stepNumber = 0; long stepNumber = 0;
int initStepState = 0, endStepState = 0; int initStepState = 0, endStepState = 0;
@ -66,11 +66,11 @@ public class MathSolver {
} }
lastFnc = currFnc; lastFnc = currFnc;
initStepState = stepState.get(); initStepState = stepState.get();
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Starting step " + stepStates[initStepState] + ". Input: " + currFnc); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Starting step " + stepStates[initStepState] + ". Input: " + currFnc);
final ObjectArrayList<Function> stepResult = solveStep(lastFnc, stepState); final ObjectArrayList<Function> stepResult = solveStep(lastFnc, stepState);
if (stepResult != null) { if (stepResult != null) {
for (final Function result : stepResult) { for (final Function result : stepResult) {
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, result.toString()); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, result.toString());
} }
currFnc = stepResult; currFnc = stepResult;
steps.add(currFnc); steps.add(currFnc);
@ -78,22 +78,22 @@ public class MathSolver {
endStepState = stepState.get(); endStepState = stepState.get();
stepNumber++; stepNumber++;
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Step result: " + stepResult); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Step result: " + stepResult);
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Step result details: Consecutive steps that did nothing: " + consecutiveNullSteps + ", this step did " + stepStateRepetitions + " simplifications."); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Step result details: Consecutive steps that did nothing: " + consecutiveNullSteps + ", this step did " + stepStateRepetitions + " simplifications.");
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Next step state: " + stepStates[endStepState]); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Next step state: " + stepStates[endStepState]);
if (Engine.getPlatform().getSettings().isDebugEnabled()) { if (WarpPI.getPlatform().getSettings().isDebugEnabled()) {
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, currFnc + " is " + (checkEquals(currFnc, lastFunctions[0][endStepState]) ? "" : "not ") + "equals to [0]:" + lastFunctions[0][endStepState]); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, currFnc + " is " + (checkEquals(currFnc, lastFunctions[0][endStepState]) ? "" : "not ") + "equals to [0]:" + lastFunctions[0][endStepState]);
} }
if (Engine.getPlatform().getSettings().isDebugEnabled()) { if (WarpPI.getPlatform().getSettings().isDebugEnabled()) {
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, currFnc + " is " + (checkEquals(currFnc, lastFunctions[1][endStepState]) ? "" : "not ") + "equals to [1]:" + lastFunctions[1][endStepState]); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, currFnc + " is " + (checkEquals(currFnc, lastFunctions[1][endStepState]) ? "" : "not ") + "equals to [1]:" + lastFunctions[1][endStepState]);
} }
} while (consecutiveNullSteps < stepStates.length && !checkEquals(currFnc, lastFunctions[0][endStepState]) && !checkEquals(currFnc, lastFunctions[1][endStepState])); } while (consecutiveNullSteps < stepStates.length && !checkEquals(currFnc, lastFunctions[0][endStepState]) && !checkEquals(currFnc, lastFunctions[1][endStepState]));
if (consecutiveNullSteps >= stepStates.length) { if (consecutiveNullSteps >= stepStates.length) {
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + consecutiveNullSteps + " >= " + stepStates.length); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + consecutiveNullSteps + " >= " + stepStates.length);
} else if (checkEquals(currFnc, lastFunctions[0][endStepState])) { } else if (checkEquals(currFnc, lastFunctions[0][endStepState])) {
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + currFnc + " is equals to [0]:" + lastFunctions[0][endStepState]); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + currFnc + " is equals to [0]:" + lastFunctions[0][endStepState]);
} else { } else {
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + currFnc + " is equals to [1]:" + lastFunctions[1][endStepState]); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + currFnc + " is equals to [1]:" + lastFunctions[1][endStepState]);
} }
return steps; return steps;
} }
@ -244,7 +244,7 @@ public class MathSolver {
if (appliedRules.isEmpty()) { if (appliedRules.isEmpty()) {
results = null; results = null;
} }
if (Engine.getPlatform().getConsoleUtils().getOutputLevel() >= ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN & results != null && !appliedRules.isEmpty()) { if (WarpPI.getPlatform().getConsoleUtils().getOutputLevel() >= ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN & results != null && !appliedRules.isEmpty()) {
final StringBuilder rulesStr = new StringBuilder(); final StringBuilder rulesStr = new StringBuilder();
for (final Rule r : appliedRules) { for (final Rule r : appliedRules) {
rulesStr.append(r.getRuleName()); rulesStr.append(r.getRuleName());
@ -253,7 +253,7 @@ public class MathSolver {
if (rulesStr.length() > 0) { if (rulesStr.length() > 0) {
rulesStr.setLength(rulesStr.length() - 1); rulesStr.setLength(rulesStr.length() - 1);
} }
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", currentAcceptedRules.toString(), "Applied rules: " + rulesStr); WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", currentAcceptedRules.toString(), "Applied rules: " + rulesStr);
} }
return results; return results;
} }

View File

@ -15,7 +15,7 @@ import java.util.Map;
import org.nevec.rjm.BigDecimalMath; import org.nevec.rjm.BigDecimalMath;
import org.nevec.rjm.Rational; import org.nevec.rjm.Rational;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.gui.graphicengine.BinaryFont; import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.math.Function; import it.cavallium.warppi.math.Function;
@ -399,7 +399,7 @@ public class Utils {
} }
public static final BinaryFont getFont(final boolean small, final boolean zoomed) { public static final BinaryFont getFont(final boolean small, final boolean zoomed) {
return Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[Utils.getFontIndex(small, zoomed)]; return WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().fonts[Utils.getFontIndex(small, zoomed)];
} }
public static final int getFontIndex(final boolean small, final boolean zoomed) { public static final int getFontIndex(final boolean small, final boolean zoomed) {
@ -423,14 +423,14 @@ public class Utils {
public static final int getFontHeight(final boolean small, final boolean zoomed) { public static final int getFontHeight(final boolean small, final boolean zoomed) {
if (small) { if (small) {
if (zoomed) { if (zoomed) {
return Engine.INSTANCE.getHardwareDevice().getDisplayManager().glyphsHeight[3]; return WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().glyphsHeight[3];
} else { } else {
return Engine.INSTANCE.getHardwareDevice().getDisplayManager().glyphsHeight[1]; return WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().glyphsHeight[1];
} }
} else if (zoomed) { } else if (zoomed) {
return Engine.INSTANCE.getHardwareDevice().getDisplayManager().glyphsHeight[2]; return WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().glyphsHeight[2];
} else { } else {
return Engine.INSTANCE.getHardwareDevice().getDisplayManager().glyphsHeight[0]; return WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().glyphsHeight[0];
} }
} }
@ -567,7 +567,7 @@ public class Utils {
} }
public static boolean isWindows() { public static boolean isWindows() {
return Engine.getPlatform().getOsName().indexOf("win") >= 0; return WarpPI.getPlatform().getOsName().indexOf("win") >= 0;
} }
public static <T> ObjectArrayList<T> newArrayList(final T o) { public static <T> ObjectArrayList<T> newArrayList(final T o) {
@ -578,7 +578,7 @@ public class Utils {
public static InputStream getResourceStreamSafe(final String string) throws IOException, URISyntaxException { public static InputStream getResourceStreamSafe(final String string) throws IOException, URISyntaxException {
try { try {
return Engine.getPlatform().getStorageUtils().getResourceStream(string); return WarpPI.getPlatform().getStorageUtils().getResourceStream(string);
} catch (final Exception ex) { } catch (final Exception ex) {
return null; return null;
} }

View File

@ -8,7 +8,7 @@ import java.io.InputStream;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import ar.com.hjg.pngj.ImageLineInt; import ar.com.hjg.pngj.ImageLineInt;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform.ImageUtils.ImageReader; import it.cavallium.warppi.Platform.ImageUtils.ImageReader;
public class DesktopImageReader implements ImageReader { public class DesktopImageReader implements ImageReader {

View File

@ -6,11 +6,17 @@ import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.net.URL; import java.net.URL;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.device.display.BacklightOutputDevice;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.device.input.KeyboardInputDevice;
import it.cavallium.warppi.device.input.TouchInputDevice;
import it.cavallium.warppi.Platform; import it.cavallium.warppi.Platform;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.impl.jogl.JOGLEngine; import it.cavallium.warppi.gui.graphicengine.impl.jogl.JOGLEngine;
@ -28,7 +34,6 @@ public class DesktopPlatform implements Platform {
private final DesktopStorageUtils su; private final DesktopStorageUtils su;
private final ImageUtils pu; private final ImageUtils pu;
private final String on; private final String on;
private final Map<String, GraphicEngine> el;
private final DesktopSettings settings; private final DesktopSettings settings;
private Boolean runningOnRaspberryOverride = null; private Boolean runningOnRaspberryOverride = null;
@ -38,9 +43,6 @@ public class DesktopPlatform implements Platform {
su = new DesktopStorageUtils(); su = new DesktopStorageUtils();
pu = new DesktopImageUtils(); pu = new DesktopImageUtils();
on = System.getProperty("os.name").toLowerCase(); on = System.getProperty("os.name").toLowerCase();
el = new HashMap<>();
el.put("CPU engine", new SwingEngine());
el.put("GPU engine", new JOGLEngine());
settings = new DesktopSettings(); settings = new DesktopSettings();
} }
@ -106,14 +108,14 @@ public class DesktopPlatform implements Platform {
@Override @Override
public void alphaChanged(final boolean val) { public void alphaChanged(final boolean val) {
final GraphicEngine currentEngine = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine; final DisplayOutputDevice currentEngine = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display;
if (currentEngine instanceof SwingEngine) if (currentEngine instanceof SwingEngine)
((SwingEngine) currentEngine).setAlphaChanged(val); ((SwingEngine) currentEngine).setAlphaChanged(val);
} }
@Override @Override
public void shiftChanged(final boolean val) { public void shiftChanged(final boolean val) {
final GraphicEngine currentEngine = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine; final DisplayOutputDevice currentEngine = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display;
if (currentEngine instanceof SwingEngine) if (currentEngine instanceof SwingEngine)
((SwingEngine) currentEngine).setShiftChanged(val); ((SwingEngine) currentEngine).setShiftChanged(val);
} }
@ -133,16 +135,6 @@ public class DesktopPlatform implements Platform {
return new DesktopURLClassLoader(urls); return new DesktopURLClassLoader(urls);
} }
@Override
public Map<String, GraphicEngine> getEnginesList() {
return el;
}
@Override
public GraphicEngine getEngine(final String string) throws NullPointerException {
return el.get(string);
}
@Override @Override
public void throwNewExceptionInInitializerError(final String text) { public void throwNewExceptionInInitializerError(final String text) {
throw new ExceptionInInitializerError(); throw new ExceptionInInitializerError();
@ -219,9 +211,9 @@ public class DesktopPlatform implements Platform {
public boolean isRunningOnRaspberry() { public boolean isRunningOnRaspberry() {
if (runningOnRaspberryOverride != null) return runningOnRaspberryOverride; if (runningOnRaspberryOverride != null) return runningOnRaspberryOverride;
return CacheUtils.get("isRunningOnRaspberry", 24 * 60 * 60 * 1000, () -> { return CacheUtils.get("isRunningOnRaspberry", 24 * 60 * 60 * 1000, () -> {
if (Engine.getPlatform().isJavascript()) if (WarpPI.getPlatform().isJavascript())
return false; return false;
if (Engine.getPlatform().getOsName().equals("Linux")) if (WarpPI.getPlatform().getOsName().equals("Linux"))
try { try {
final File osRelease = new File("/etc", "os-release"); final File osRelease = new File("/etc", "os-release");
return FileUtils.readLines(osRelease, "UTF-8").stream().map(String::toLowerCase).anyMatch(line -> line.contains("raspbian") && line.contains("name")); return FileUtils.readLines(osRelease, "UTF-8").stream().map(String::toLowerCase).anyMatch(line -> line.contains("raspbian") && line.contains("name"));
@ -233,4 +225,30 @@ public class DesktopPlatform implements Platform {
}); });
} }
@Override
public TouchInputDevice getTouchInputDevice() {
// TODO Auto-generated method stub
return null;
}
@Override
public KeyboardInputDevice getKeyboardInputDevice() {
// TODO Auto-generated method stub
return null;
}
@Override
public DisplayOutputDevice getDisplayOutputDevice() {
return displayOutput
new SwingEngine();
new JOGLEngine();
List<DisplayOutputDevice> availableDevices = new LinkedList<>();
}
@Override
public BacklightOutputDevice getBacklightOutputDevice() {
// TODO Auto-generated method stub
return null;
}
} }

View File

@ -5,7 +5,7 @@ import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.Semaphore; import java.util.concurrent.Semaphore;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.flow.Observable; import it.cavallium.warppi.flow.Observable;
import it.cavallium.warppi.gui.graphicengine.BinaryFont; import it.cavallium.warppi.gui.graphicengine.BinaryFont;
@ -53,7 +53,7 @@ public class SwingEngine implements GraphicEngine {
initialized = false; initialized = false;
exitSemaphore = new Semaphore(0); exitSemaphore = new Semaphore(0);
INSTANCE = new SwingWindow(this); INSTANCE = new SwingWindow(this);
setResizable(Engine.getPlatform().getSettings().isDebugEnabled()); setResizable(WarpPI.getPlatform().getSettings().isDebugEnabled());
setDisplayMode((int) (StaticVars.screenSize[0] / StaticVars.windowZoom.getLastValue()), (int) (StaticVars.screenSize[1] / StaticVars.windowZoom.getLastValue())); setDisplayMode((int) (StaticVars.screenSize[0] / StaticVars.windowZoom.getLastValue()), (int) (StaticVars.screenSize[1] / StaticVars.windowZoom.getLastValue()));
INSTANCE.setVisible(true); INSTANCE.setVisible(true);
initialized = true; initialized = true;
@ -112,7 +112,7 @@ public class SwingEngine implements GraphicEngine {
@Deprecated() @Deprecated()
public void refresh() { public void refresh() {
if (Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen() == null || Engine.INSTANCE.getHardwareDevice().getDisplayManager().error != null && Engine.INSTANCE.getHardwareDevice().getDisplayManager().error.length() > 0 || Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen() == null || Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen().mustBeRefreshed()) if (WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen() == null || WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().error != null && WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().error.length() > 0 || WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen() == null || WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen().mustBeRefreshed())
INSTANCE.c.paintImmediately(0, 0, getWidth(), getHeight()); INSTANCE.c.paintImmediately(0, 0, getWidth(), getHeight());
} }

View File

@ -2,7 +2,7 @@ package it.cavallium.warppi.gui.graphicengine.impl.swing;
import java.io.IOException; import java.io.IOException;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.impl.common.RFTFont; import it.cavallium.warppi.gui.graphicengine.impl.common.RFTFont;
public class SwingFont extends RFTFont { public class SwingFont extends RFTFont {
@ -16,7 +16,7 @@ public class SwingFont extends RFTFont {
} }
@Override @Override
public void use(final GraphicEngine d) { public void use(final DisplayOutputDevice d) {
if (d.getRenderer() instanceof SwingRenderer) if (d.getRenderer() instanceof SwingRenderer)
((SwingRenderer) d.getRenderer()).currentFont = this; ((SwingRenderer) d.getRenderer()).currentFont = this;
} }

View File

@ -2,7 +2,7 @@ package it.cavallium.warppi.gui.graphicengine.impl.swing;
import java.io.IOException; import java.io.IOException;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.impl.common.PngSkin; import it.cavallium.warppi.gui.graphicengine.impl.common.PngSkin;
public class SwingSkin extends PngSkin { public class SwingSkin extends PngSkin {
@ -12,7 +12,7 @@ public class SwingSkin extends PngSkin {
} }
@Override @Override
public void use(final GraphicEngine d) { public void use(final DisplayOutputDevice d) {
if (d.getRenderer() instanceof SwingRenderer) if (d.getRenderer() instanceof SwingRenderer)
((SwingRenderer) d.getRenderer()).currentSkin = this; ((SwingRenderer) d.getRenderer()).currentSkin = this;
} }

View File

@ -27,9 +27,9 @@ import javax.imageio.ImageIO;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.device.input.Keyboard;
import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.device.Keyboard;
import it.cavallium.warppi.event.TouchEndEvent; import it.cavallium.warppi.event.TouchEndEvent;
import it.cavallium.warppi.event.TouchMoveEvent; import it.cavallium.warppi.event.TouchMoveEvent;
import it.cavallium.warppi.event.TouchPoint; import it.cavallium.warppi.event.TouchPoint;
@ -70,7 +70,7 @@ public class SwingWindow extends JFrame {
mult = StaticVars.windowZoomFunction.apply(StaticVars.windowZoom.getLastValue()).intValue(); mult = StaticVars.windowZoomFunction.apply(StaticVars.windowZoom.getLastValue()).intValue();
if (!Engine.getPlatform().getSettings().isDebugEnabled()) { if (!WarpPI.getPlatform().getSettings().isDebugEnabled()) {
// Create a new blank cursor. // Create a new blank cursor.
final Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor"); final Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor");
@ -96,7 +96,7 @@ public class SwingWindow extends JFrame {
addComponentListener(new ComponentListener() { addComponentListener(new ComponentListener() {
@Override @Override
public void componentHidden(final ComponentEvent e) { public void componentHidden(final ComponentEvent e) {
Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.destroy(); WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.destroy();
} }
@Override @Override
@ -109,7 +109,7 @@ public class SwingWindow extends JFrame {
@Override @Override
public void componentShown(final ComponentEvent e) { public void componentShown(final ComponentEvent e) {
if (Engine.getPlatform().getSettings().isDebugEnabled()) if (WarpPI.getPlatform().getSettings().isDebugEnabled())
SwingWindow.this.centerWindow(); SwingWindow.this.centerWindow();
} }
}); });
@ -142,7 +142,7 @@ public class SwingWindow extends JFrame {
touches.add(p); touches.add(p);
changedTouches.add(p); changedTouches.add(p);
final TouchMoveEvent tse = new TouchMoveEvent(changedTouches, touches); final TouchMoveEvent tse = new TouchMoveEvent(changedTouches, touches);
Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchMove(tse); WarpPI.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchMove(tse);
} }
@Override @Override
@ -161,7 +161,7 @@ public class SwingWindow extends JFrame {
touches.add(p); touches.add(p);
changedTouches.add(p); changedTouches.add(p);
final TouchStartEvent tse = new TouchStartEvent(changedTouches, touches); final TouchStartEvent tse = new TouchStartEvent(changedTouches, touches);
Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchStart(tse); WarpPI.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchStart(tse);
} }
@Override @Override
@ -172,7 +172,7 @@ public class SwingWindow extends JFrame {
final ObjectArrayList<TouchPoint> changedTouches = new ObjectArrayList<>(); final ObjectArrayList<TouchPoint> changedTouches = new ObjectArrayList<>();
changedTouches.add(p); changedTouches.add(p);
final TouchEndEvent tse = new TouchEndEvent(changedTouches, touches); final TouchEndEvent tse = new TouchEndEvent(changedTouches, touches);
Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchEnd(tse); WarpPI.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchEnd(tse);
} }
@Override @Override
@ -185,7 +185,7 @@ public class SwingWindow extends JFrame {
if (newZoomValue != mult) { if (newZoomValue != mult) {
mult = (int) newZoomValue.floatValue(); mult = (int) newZoomValue.floatValue();
onResize.onNext(new Integer[] { getWWidth(), getWHeight() }); onResize.onNext(new Integer[] { getWWidth(), getWHeight() });
Engine.getPlatform().getConsoleUtils().out().println(3, "Engine", "CPU", "Zoom changed"); WarpPI.getPlatform().getConsoleUtils().out().println(3, "Engine", "CPU", "Zoom changed");
} }
}); });
} }
@ -234,7 +234,7 @@ public class SwingWindow extends JFrame {
} }
private void createBtn(final int row, final int col) throws IOException, URISyntaxException { private void createBtn(final int row, final int col) throws IOException, URISyntaxException {
final BufferedImage img = ImageIO.read(Engine.getPlatform().getStorageUtils().getResourceStream("/desktop-buttons.png")); final BufferedImage img = ImageIO.read(WarpPI.getPlatform().getStorageUtils().getResourceStream("/desktop-buttons.png"));
final SwingAdvancedButton b = new SwingAdvancedButton(img, new Dimension((int) (BTN_SIZE * 1.5), BTN_SIZE)); final SwingAdvancedButton b = new SwingAdvancedButton(img, new Dimension((int) (BTN_SIZE * 1.5), BTN_SIZE));
b.drawDefaultComponent = false; b.drawDefaultComponent = false;
b.setText(Keyboard.getKeyName(row, col)); b.setText(Keyboard.getKeyName(row, col));

View File

@ -11,7 +11,7 @@ import java.util.concurrent.Semaphore;
import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.Texture;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.flow.Observable; import it.cavallium.warppi.flow.Observable;
import it.cavallium.warppi.gui.graphicengine.BinaryFont; import it.cavallium.warppi.gui.graphicengine.BinaryFont;
@ -79,7 +79,7 @@ public class JOGLEngine implements GraphicEngine {
wnd = new NEWTWindow(this); wnd = new NEWTWindow(this);
wnd.create(); wnd.create();
setDisplayMode(StaticVars.screenSize[0], StaticVars.screenSize[1]); setDisplayMode(StaticVars.screenSize[0], StaticVars.screenSize[1]);
setResizable(Engine.getPlatform().getSettings().isDebugEnabled()); setResizable(WarpPI.getPlatform().getSettings().isDebugEnabled());
initialized = true; initialized = true;
wnd.onInitialized = onInitialized; wnd.onInitialized = onInitialized;
} }

View File

@ -12,9 +12,9 @@ import ar.com.hjg.pngj.ImageInfo;
import ar.com.hjg.pngj.ImageLineHelper; import ar.com.hjg.pngj.ImageLineHelper;
import ar.com.hjg.pngj.ImageLineInt; import ar.com.hjg.pngj.ImageLineInt;
import ar.com.hjg.pngj.PngWriter; import ar.com.hjg.pngj.PngWriter;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.BinaryFont; import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.impl.common.RFTFont; import it.cavallium.warppi.gui.graphicengine.impl.common.RFTFont;
public class JOGLFont implements BinaryFont { public class JOGLFont implements BinaryFont {
@ -35,11 +35,11 @@ public class JOGLFont implements BinaryFont {
private boolean initialized = false; private boolean initialized = false;
private File tmpFont; private File tmpFont;
JOGLFont(final GraphicEngine g, final String name) throws IOException { JOGLFont(final DisplayOutputDevice g, final String name) throws IOException {
this(g, null, name); this(g, null, name);
} }
public JOGLFont(final GraphicEngine g, final String path, final String name) throws IOException { public JOGLFont(final DisplayOutputDevice g, final String path, final String name) throws IOException {
load(path, name); load(path, name);
((JOGLEngine) g).registerFont(this); ((JOGLEngine) g).registerFont(this);
} }
@ -63,10 +63,10 @@ public class JOGLFont implements BinaryFont {
intervalsTotalSize = font.intervalsTotalSize; intervalsTotalSize = font.intervalsTotalSize;
boolean[][] rawchars = font.rawchars; boolean[][] rawchars = font.rawchars;
font = null; font = null;
Engine.getPlatform().gc(); WarpPI.getPlatform().gc();
pregenTexture(rawchars); pregenTexture(rawchars);
rawchars = null; rawchars = null;
Engine.getPlatform().gc(); WarpPI.getPlatform().gc();
} }
public int[] getCharIndexes(final String txt) { public int[] getCharIndexes(final String txt) {
@ -154,7 +154,7 @@ public class JOGLFont implements BinaryFont {
} }
chars = null; chars = null;
png.end(); png.end();
Engine.getPlatform().gc(); WarpPI.getPlatform().gc();
try { try {
memoryWidth = w; memoryWidth = w;
@ -164,7 +164,7 @@ public class JOGLFont implements BinaryFont {
textureH = h; textureH = h;
outputStream.flush(); outputStream.flush();
outputStream.close(); outputStream.close();
Engine.getPlatform().gc(); WarpPI.getPlatform().gc();
tmpFont = f; tmpFont = f;
} catch (GLException | IOException e) { } catch (GLException | IOException e) {
e.printStackTrace(); e.printStackTrace();
@ -185,14 +185,14 @@ public class JOGLFont implements BinaryFont {
} }
@Override @Override
public void initialize(final GraphicEngine d) { public void initialize(final DisplayOutputDevice d) {
genTexture(); genTexture();
tmpFont = null; tmpFont = null;
initialized = true; initialized = true;
} }
@Override @Override
public void use(final GraphicEngine d) { public void use(final DisplayOutputDevice d) {
if (!initialized) if (!initialized)
initialize(d); initialize(d);
final JOGLRenderer r = (JOGLRenderer) d.getRenderer(); final JOGLRenderer r = (JOGLRenderer) d.getRenderer();

View File

@ -17,7 +17,7 @@ import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureData; import com.jogamp.opengl.util.texture.TextureData;
import com.jogamp.opengl.util.texture.TextureIO; import com.jogamp.opengl.util.texture.TextureIO;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.gui.graphicengine.BinaryFont; import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
@ -272,7 +272,7 @@ public class JOGLRenderer implements Renderer {
final int imgW = img.getWidth(); final int imgW = img.getWidth();
final int imgH = img.getHeight(); final int imgH = img.getHeight();
img = null; img = null;
Engine.getPlatform().gc(); WarpPI.getPlatform().gc();
return new OpenedTextureData(imgW, imgH, f, isResource); return new OpenedTextureData(imgW, imgH, f, isResource);
} }
@ -301,7 +301,7 @@ public class JOGLRenderer implements Renderer {
final Texture tex = TextureIO.newTexture(f, false); final Texture tex = TextureIO.newTexture(f, false);
if (deleteOnExit && f.exists()) if (deleteOnExit && f.exists())
try { try {
if (Engine.getPlatform().getSettings().isDebugEnabled()) if (WarpPI.getPlatform().getSettings().isDebugEnabled())
throw new IOException("Delete on exit!"); throw new IOException("Delete on exit!");
f.delete(); f.delete();
} catch (final Exception ex) { } catch (final Exception ex) {

View File

@ -8,8 +8,8 @@ import java.nio.file.Paths;
import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLException;
import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.Texture;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.Skin; import it.cavallium.warppi.gui.graphicengine.Skin;
import it.cavallium.warppi.gui.graphicengine.impl.jogl.JOGLRenderer.OpenedTextureData; import it.cavallium.warppi.gui.graphicengine.impl.jogl.JOGLRenderer.OpenedTextureData;
@ -23,21 +23,21 @@ public class JOGLSkin implements Skin {
private boolean initialized = false; private boolean initialized = false;
private boolean isResource; private boolean isResource;
JOGLSkin(final GraphicEngine d, final String file) throws IOException { JOGLSkin(final DisplayOutputDevice d, final String file) throws IOException {
load(file); load(file);
} }
@Override @Override
public void load(final String file) throws IOException { public void load(final String file) throws IOException {
final boolean isResource = !Files.exists(Paths.get(file)); final boolean isResource = !Files.exists(Paths.get(file));
if (isResource && Engine.getPlatform().getStorageUtils().getResourceStream(file) == null) if (isResource && WarpPI.getPlatform().getStorageUtils().getResourceStream(file) == null)
throw new IOException("File '" + file + "' not found!"); throw new IOException("File '" + file + "' not found!");
texturePath = file; texturePath = file;
this.isResource = isResource; this.isResource = isResource;
} }
@Override @Override
public void initialize(final GraphicEngine d) { public void initialize(final DisplayOutputDevice d) {
try { try {
final OpenedTextureData i = JOGLRenderer.openTexture(texturePath, isResource); final OpenedTextureData i = JOGLRenderer.openTexture(texturePath, isResource);
t = JOGLRenderer.importTexture(i.f, i.deleteOnExit); t = JOGLRenderer.importTexture(i.f, i.deleteOnExit);
@ -52,7 +52,7 @@ public class JOGLSkin implements Skin {
} }
@Override @Override
public void use(final GraphicEngine d) { public void use(final DisplayOutputDevice d) {
if (!initialized) if (!initialized)
initialize(d); initialize(d);
final JOGLRenderer r = (JOGLRenderer) d.getRenderer(); final JOGLRenderer r = (JOGLRenderer) d.getRenderer();

View File

@ -50,9 +50,10 @@ import com.jogamp.opengl.fixedfunc.GLPointerFunc;
import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.Texture;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.device.input.Keyboard;
import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.device.Keyboard;
import it.cavallium.warppi.event.Key; import it.cavallium.warppi.event.Key;
import it.cavallium.warppi.event.TouchEndEvent; import it.cavallium.warppi.event.TouchEndEvent;
import it.cavallium.warppi.event.TouchMoveEvent; import it.cavallium.warppi.event.TouchMoveEvent;
@ -61,7 +62,6 @@ import it.cavallium.warppi.event.TouchStartEvent;
import it.cavallium.warppi.flow.BehaviorSubject; import it.cavallium.warppi.flow.BehaviorSubject;
import it.cavallium.warppi.flow.SimpleSubject; import it.cavallium.warppi.flow.SimpleSubject;
import it.cavallium.warppi.flow.Subject; import it.cavallium.warppi.flow.Subject;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectArrayList;
/** /**
@ -125,7 +125,7 @@ class NEWTWindow implements GLEventListener {
System.err.println("Le OpenGL non sono presenti su questo computer!"); System.err.println("Le OpenGL non sono presenti su questo computer!");
return; return;
} }
if (Engine.getPlatform().getSettings().isDebugEnabled()) if (WarpPI.getPlatform().getSettings().isDebugEnabled())
System.setProperty("jnlp.newt.window.icons", "res/icons/calculator-016.png res/icons/calculator-018.png res/icons/calculator-256.png"); System.setProperty("jnlp.newt.window.icons", "res/icons/calculator-016.png res/icons/calculator-018.png res/icons/calculator-256.png");
final GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2ES1)); final GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2ES1));
System.out.println("Loaded OpenGL"); System.out.println("Loaded OpenGL");
@ -150,7 +150,7 @@ class NEWTWindow implements GLEventListener {
@Override @Override
public void windowDestroyed(final WindowEvent e) { public void windowDestroyed(final WindowEvent e) {
final GraphicEngine engine = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine; final DisplayOutputDevice engine = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display;
if (engine.isInitialized()) if (engine.isInitialized())
engine.destroy(); engine.destroy();
} }
@ -361,10 +361,10 @@ class NEWTWindow implements GLEventListener {
final float[] ps = e.getAllPressures(); final float[] ps = e.getAllPressures();
final short[] is = e.getAllPointerIDs(); final short[] is = e.getAllPointerIDs();
for (int i = 0; i < e.getPointerCount(); i++) for (int i = 0; i < e.getPointerCount(); i++)
newPoints.add(Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().makePoint(is[i], xs[i], ys[i], disp.getWidth(), disp.getHeight(), 5, 5, ps[i], 0)); newPoints.add(WarpPI.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().makePoint(is[i], xs[i], ys[i], disp.getWidth(), disp.getHeight(), 5, 5, ps[i], 0));
changedPoints.add(newPoints.get(0)); changedPoints.add(newPoints.get(0));
touches = newPoints; touches = newPoints;
Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchStart(new TouchStartEvent(changedPoints, touches)); WarpPI.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchStart(new TouchStartEvent(changedPoints, touches));
} }
@Override @Override
@ -378,11 +378,11 @@ class NEWTWindow implements GLEventListener {
final float[] ps = e.getAllPressures(); final float[] ps = e.getAllPressures();
final short[] is = e.getAllPointerIDs(); final short[] is = e.getAllPointerIDs();
for (int i = 0; i < e.getPointerCount(); i++) for (int i = 0; i < e.getPointerCount(); i++)
newPoints.add(Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().makePoint(is[i], xs[i], ys[i], disp.getWidth(), disp.getHeight(), 5, 5, ps[i], 0)); newPoints.add(WarpPI.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().makePoint(is[i], xs[i], ys[i], disp.getWidth(), disp.getHeight(), 5, 5, ps[i], 0));
changedPoints.add(newPoints.get(0)); changedPoints.add(newPoints.get(0));
newPoints.remove(0); newPoints.remove(0);
touches = newPoints; touches = newPoints;
Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchEnd(new TouchEndEvent(changedPoints, touches)); WarpPI.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchEnd(new TouchEndEvent(changedPoints, touches));
} }
@Override @Override
@ -403,7 +403,7 @@ class NEWTWindow implements GLEventListener {
final float[] ps = e.getAllPressures(); final float[] ps = e.getAllPressures();
final short[] is = e.getAllPointerIDs(); final short[] is = e.getAllPointerIDs();
for (int i = 0; i < e.getPointerCount(); i++) for (int i = 0; i < e.getPointerCount(); i++)
newPoints.add(Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().makePoint(is[i], xs[i], ys[i], disp.getWidth(), disp.getHeight(), 5, 5, ps[i], 0)); newPoints.add(WarpPI.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().makePoint(is[i], xs[i], ys[i], disp.getWidth(), disp.getHeight(), 5, 5, ps[i], 0));
newPoints.forEach((newp) -> { newPoints.forEach((newp) -> {
oldPoints.forEach((oldp) -> { oldPoints.forEach((oldp) -> {
if (newp.getID() == oldp.getID()) if (newp.getID() == oldp.getID())
@ -412,7 +412,7 @@ class NEWTWindow implements GLEventListener {
}); });
}); });
touches = newPoints; touches = newPoints;
Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchMove(new TouchMoveEvent(changedPoints, touches)); WarpPI.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchMove(new TouchMoveEvent(changedPoints, touches));
} }
} }
@ -434,7 +434,7 @@ class NEWTWindow implements GLEventListener {
final GL2ES1 gl = drawable.getGL().getGL2ES1(); final GL2ES1 gl = drawable.getGL().getGL2ES1();
onGLContext.onNext(gl); onGLContext.onNext(gl);
if (Engine.getPlatform().getSettings().isDebugEnabled()) if (WarpPI.getPlatform().getSettings().isDebugEnabled())
//Vsync //Vsync
gl.setSwapInterval(1); gl.setSwapInterval(1);
else else

View File

@ -2,7 +2,7 @@ package it.cavallium.warppi.gui.graphicengine.impl.framebuffer;
import java.io.IOException; import java.io.IOException;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.impl.common.RFTFont; import it.cavallium.warppi.gui.graphicengine.impl.common.RFTFont;
public class FBFont extends RFTFont { public class FBFont extends RFTFont {
@ -16,7 +16,7 @@ public class FBFont extends RFTFont {
} }
@Override @Override
public void use(final GraphicEngine d) { public void use(final DisplayOutputDevice d) {
@SuppressWarnings("unused") @SuppressWarnings("unused")
final FBEngine dfb = (FBEngine) d; final FBEngine dfb = (FBEngine) d;
// TODO: implement // TODO: implement

View File

@ -2,7 +2,7 @@ package it.cavallium.warppi.gui.graphicengine.impl.framebuffer;
import java.io.IOException; import java.io.IOException;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.impl.common.PngSkin; import it.cavallium.warppi.gui.graphicengine.impl.common.PngSkin;
public class FBSkin extends PngSkin { public class FBSkin extends PngSkin {
@ -12,7 +12,7 @@ public class FBSkin extends PngSkin {
} }
@Override @Override
public void use(final GraphicEngine d) { public void use(final DisplayOutputDevice d) {
@SuppressWarnings("unused") @SuppressWarnings("unused")
final FBEngine dfb = (FBEngine) d; final FBEngine dfb = (FBEngine) d;
// TODO: implement // TODO: implement

View File

@ -8,6 +8,8 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import it.cavallium.warppi.Platform; import it.cavallium.warppi.Platform;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.device.input.KeyboardInputDevice;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.impl.framebuffer.FBEngine; import it.cavallium.warppi.gui.graphicengine.impl.framebuffer.FBEngine;
import it.cavallium.warppi.gui.graphicengine.impl.jogl.JOGLEngine; import it.cavallium.warppi.gui.graphicengine.impl.jogl.JOGLEngine;
@ -20,6 +22,7 @@ public class HardwarePlatform implements Platform {
private final HardwareConsoleUtils cu; private final HardwareConsoleUtils cu;
private final HardwareGpio gi; private final HardwareGpio gi;
private final HardwareKeyboard hk;
private final HardwareStorageUtils su; private final HardwareStorageUtils su;
private final ImageUtils pu; private final ImageUtils pu;
private final String on; private final String on;
@ -30,6 +33,7 @@ public class HardwarePlatform implements Platform {
public HardwarePlatform() { public HardwarePlatform() {
cu = new HardwareConsoleUtils(); cu = new HardwareConsoleUtils();
gi = new HardwareGpio(); gi = new HardwareGpio();
hk = new HardwareKeyboard();
su = new HardwareStorageUtils(); su = new HardwareStorageUtils();
pu = new HardwareImageUtils(); pu = new HardwareImageUtils();
on = System.getProperty("os.name").toLowerCase(); on = System.getProperty("os.name").toLowerCase();
@ -49,6 +53,11 @@ public class HardwarePlatform implements Platform {
return gi; return gi;
} }
@Override
public KeyboardInputDevice getHardwareKeyboard() {
return gi;
}
@Override @Override
public StorageUtils getStorageUtils() { public StorageUtils getStorageUtils() {
return su; return su;
@ -123,12 +132,12 @@ public class HardwarePlatform implements Platform {
} }
@Override @Override
public Map<String, GraphicEngine> getEnginesList() { public Map<String, GraphicEngine> getGraphicEnginesList() {
return el; return el;
} }
@Override @Override
public GraphicEngine getEngine(final String string) throws NullPointerException { public DisplayOutputDevice getGraphicEngine(final String string) throws NullPointerException {
return el.get(string); return el.get(string);
} }

View File

@ -16,10 +16,10 @@ import org.teavm.jso.dom.html.HTMLElement;
import org.teavm.jso.dom.html.HTMLInputElement; import org.teavm.jso.dom.html.HTMLInputElement;
import org.teavm.jso.dom.xml.NodeList; import org.teavm.jso.dom.xml.NodeList;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.Platform.Semaphore; import it.cavallium.warppi.Platform.Semaphore;
import it.cavallium.warppi.device.Keyboard; import it.cavallium.warppi.device.input.Keyboard;
import it.cavallium.warppi.flow.BehaviorSubject; import it.cavallium.warppi.flow.BehaviorSubject;
import it.cavallium.warppi.flow.Observable; import it.cavallium.warppi.flow.Observable;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
@ -86,7 +86,7 @@ public class HtmlEngine implements GraphicEngine {
@Override @Override
public void create(final Runnable onInitialized) { public void create(final Runnable onInitialized) {
exitSemaphore = Engine.getPlatform().newSemaphore(0); exitSemaphore = WarpPI.getPlatform().newSemaphore(0);
width = -1; width = -1;
height = -1; height = -1;
canvas = (HTMLCanvasElement) HtmlEngine.document.createElement("canvas"); canvas = (HTMLCanvasElement) HtmlEngine.document.createElement("canvas");
@ -277,8 +277,8 @@ public class HtmlEngine implements GraphicEngine {
e.printStackTrace(); e.printStackTrace();
} }
}); });
Engine.getPlatform().setThreadName(th, "Canvas rendering thread"); WarpPI.getPlatform().setThreadName(th, "Canvas rendering thread");
Engine.getPlatform().setThreadDaemon(th); WarpPI.getPlatform().setThreadDaemon(th);
th.start(); th.start();
} }
@ -316,7 +316,7 @@ public class HtmlEngine implements GraphicEngine {
@Override @Override
public boolean isSupported() { public boolean isSupported() {
return Engine.getPlatform().isJavascript(); return WarpPI.getPlatform().isJavascript();
} }
@Override @Override

View File

@ -7,7 +7,7 @@ import org.teavm.jso.canvas.CanvasRenderingContext2D;
import org.teavm.jso.dom.html.HTMLCanvasElement; import org.teavm.jso.dom.html.HTMLCanvasElement;
import org.teavm.jso.dom.html.HTMLDocument; import org.teavm.jso.dom.html.HTMLDocument;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.impl.common.RFTFont; import it.cavallium.warppi.gui.graphicengine.impl.common.RFTFont;
public class HtmlFont extends RFTFont { public class HtmlFont extends RFTFont {
@ -47,7 +47,7 @@ public class HtmlFont extends RFTFont {
} }
@Override @Override
public void use(final GraphicEngine d) { public void use(final DisplayOutputDevice d) {
if (d.getRenderer() instanceof HtmlRenderer) if (d.getRenderer() instanceof HtmlRenderer)
((HtmlRenderer) d.getRenderer()).f = this; ((HtmlRenderer) d.getRenderer()).f = this;
} }

View File

@ -9,13 +9,13 @@ import org.teavm.jso.dom.events.Event;
import org.teavm.jso.dom.html.HTMLDocument; import org.teavm.jso.dom.html.HTMLDocument;
import org.teavm.jso.dom.html.HTMLImageElement; import org.teavm.jso.dom.html.HTMLImageElement;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform.Semaphore; import it.cavallium.warppi.Platform.Semaphore;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.flow.BehaviorSubject; import it.cavallium.warppi.flow.BehaviorSubject;
import it.cavallium.warppi.flow.SimpleSubject; import it.cavallium.warppi.flow.SimpleSubject;
import it.cavallium.warppi.flow.Subject; import it.cavallium.warppi.flow.Subject;
import it.cavallium.warppi.flow.ValueReference; import it.cavallium.warppi.flow.ValueReference;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Skin; import it.cavallium.warppi.gui.graphicengine.Skin;
public class HtmlSkin implements Skin { public class HtmlSkin implements Skin {
@ -33,7 +33,7 @@ public class HtmlSkin implements Skin {
} }
@Override @Override
public void use(final GraphicEngine d) { public void use(final DisplayOutputDevice d) {
if (d instanceof HtmlEngine) { if (d instanceof HtmlEngine) {
if (!initd) if (!initd)
initialize(d); initialize(d);
@ -43,11 +43,11 @@ public class HtmlSkin implements Skin {
@Override @Override
public void load(String file) throws IOException { public void load(String file) throws IOException {
url = Engine.getPlatform().getStorageUtils().getBasePath() + (!file.startsWith("/") ? "/" : "") + file; url = WarpPI.getPlatform().getStorageUtils().getBasePath() + (!file.startsWith("/") ? "/" : "") + file;
} }
@Override @Override
public void initialize(final GraphicEngine d) { public void initialize(final DisplayOutputDevice d) {
final HTMLDocument doc = Window.current().getDocument(); final HTMLDocument doc = Window.current().getDocument();
ValueReference<Boolean> done = new ValueReference<Boolean>(false); ValueReference<Boolean> done = new ValueReference<Boolean>(false);
imgEl = doc.createElement("img").cast(); imgEl = doc.createElement("img").cast();

View File

@ -9,6 +9,7 @@ import org.teavm.jso.browser.Window;
import org.teavm.jso.dom.html.HTMLDocument; import org.teavm.jso.dom.html.HTMLDocument;
import it.cavallium.warppi.Platform; import it.cavallium.warppi.Platform;
import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.html.HtmlEngine; import it.cavallium.warppi.gui.graphicengine.html.HtmlEngine;
import it.cavallium.warppi.math.rules.RulesManager; import it.cavallium.warppi.math.rules.RulesManager;
@ -122,12 +123,12 @@ public class TeaVMPlatform implements Platform {
} }
@Override @Override
public Map<String, GraphicEngine> getEnginesList() { public Map<String, GraphicEngine> getGraphicEnginesList() {
return el; return el;
} }
@Override @Override
public GraphicEngine getEngine(final String string) throws NullPointerException { public DisplayOutputDevice getGraphicEngine(final String string) throws NullPointerException {
return el.get(string); return el.get(string);
} }