Fixed [^2] command and added GUI buttons to replace hardware ones on PCs
This commit is contained in:
parent
434ccb3a68
commit
ada6e552f6
@ -22,6 +22,7 @@ public class Engine {
|
||||
private static boolean running = false;
|
||||
private static BehaviorSubject<LoadingStatus> loadPhase = BehaviorSubject.create();
|
||||
private BehaviorSubject<Boolean> loaded = BehaviorSubject.create(false);
|
||||
private HardwareDevice hardwareDevice;
|
||||
|
||||
private Engine() {
|
||||
}
|
||||
@ -65,8 +66,8 @@ public class Engine {
|
||||
DisplayManager dm = new DisplayManager(disp, hud, screen, "WarpPI Calculator by Andrea Cavalli (@Cavallium)");
|
||||
Keyboard k = new Keyboard();
|
||||
InputManager im = new InputManager(k, touchdevice);
|
||||
HardwareDevice hardwareDevice = new HardwareDevice(dm, im);
|
||||
|
||||
hardwareDevice = new HardwareDevice(dm, im);
|
||||
|
||||
hardwareDevice.setup(() -> loadPhase.onNext(new LoadingStatus()));
|
||||
}
|
||||
|
||||
@ -113,6 +114,10 @@ public class Engine {
|
||||
return loadPhase;
|
||||
}
|
||||
|
||||
public HardwareDevice getHardwareDevice() {
|
||||
return hardwareDevice;
|
||||
}
|
||||
|
||||
public static Platform getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
@ -124,7 +129,7 @@ public class Engine {
|
||||
|
||||
public void done() {
|
||||
Engine.INSTANCE.loaded.onNext(true);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().waitForExit();
|
||||
Engine.INSTANCE.hardwareDevice.getDisplayManager().waitForExit();
|
||||
Engine.INSTANCE.onShutdown();
|
||||
}
|
||||
|
||||
|
@ -391,12 +391,12 @@ public class Utils {
|
||||
//
|
||||
// var.draw(x + wsegno, y + (hsegno - h1), null, null);
|
||||
//
|
||||
// HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawLine(x + 1, y + hsegno - 3, x + 1, y + hsegno - 3);
|
||||
// HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawLine(x + 2, y + hsegno - 2, x + 2, y + hsegno - 2);
|
||||
// HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawLine(x + 3, y + hsegno - 1, x + 3, y + hsegno - 1);
|
||||
// HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawLine(x + 3, y + (hsegno - 1) / 2 + 1, x + 3, y + hsegno - 1);
|
||||
// HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawLine(x + 4, y, x + 4, y + (hsegno - 1) / 2);
|
||||
// HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawLine(x + 4, y, x + 4 + 1 + w1 + 1, y);
|
||||
// Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawLine(x + 1, y + hsegno - 3, x + 1, y + hsegno - 3);
|
||||
// Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawLine(x + 2, y + hsegno - 2, x + 2, y + hsegno - 2);
|
||||
// Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawLine(x + 3, y + hsegno - 1, x + 3, y + hsegno - 1);
|
||||
// Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawLine(x + 3, y + (hsegno - 1) / 2 + 1, x + 3, y + hsegno - 1);
|
||||
// Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawLine(x + 4, y, x + 4, y + (hsegno - 1) / 2);
|
||||
// Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawLine(x + 4, y, x + 4 + 1 + w1 + 1, y);
|
||||
}
|
||||
|
||||
public static final int getFontHeight() {
|
||||
@ -408,7 +408,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static final BinaryFont getFont(boolean small, boolean zoomed) {
|
||||
return HardwareDevice.INSTANCE.getDisplayManager().fonts[getFontIndex(small, zoomed)];
|
||||
return Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[getFontIndex(small, zoomed)];
|
||||
}
|
||||
|
||||
public static final int getFontIndex(boolean small, boolean zoomed) {
|
||||
@ -434,15 +434,15 @@ public class Utils {
|
||||
public static final int getFontHeight(boolean small, boolean zoomed) {
|
||||
if (small) {
|
||||
if (zoomed) {
|
||||
return HardwareDevice.INSTANCE.getDisplayManager().glyphsHeight[3];
|
||||
return Engine.INSTANCE.getHardwareDevice().getDisplayManager().glyphsHeight[3];
|
||||
} else {
|
||||
return HardwareDevice.INSTANCE.getDisplayManager().glyphsHeight[1];
|
||||
return Engine.INSTANCE.getHardwareDevice().getDisplayManager().glyphsHeight[1];
|
||||
}
|
||||
} else {
|
||||
if (zoomed) {
|
||||
return HardwareDevice.INSTANCE.getDisplayManager().glyphsHeight[2];
|
||||
return Engine.INSTANCE.getHardwareDevice().getDisplayManager().glyphsHeight[2];
|
||||
} else {
|
||||
return HardwareDevice.INSTANCE.getDisplayManager().glyphsHeight[0];
|
||||
return Engine.INSTANCE.getHardwareDevice().getDisplayManager().glyphsHeight[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class Boot {
|
||||
|
||||
private static void loadCalculator(LoadingStatus loading) {
|
||||
try {
|
||||
HardwareDevice.INSTANCE.getDisplayManager().setBrightness(0.2f);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().setBrightness(0.2f);
|
||||
RulesManager.initialize();
|
||||
RulesManager.warmUp();
|
||||
loading.done();
|
||||
|
@ -4,12 +4,10 @@ import it.cavallium.warppi.Engine;
|
||||
import it.cavallium.warppi.gui.DisplayManager;
|
||||
|
||||
public class HardwareDevice {
|
||||
public static HardwareDevice INSTANCE;
|
||||
private final DisplayManager displayManager;
|
||||
private final InputManager inputManager;
|
||||
|
||||
public HardwareDevice(DisplayManager m, InputManager im) {
|
||||
INSTANCE = this;
|
||||
displayManager = m;
|
||||
inputManager = im;
|
||||
}
|
||||
|
@ -672,6 +672,81 @@ public class Keyboard {
|
||||
}
|
||||
}
|
||||
|
||||
static final String[][][] KeyLabelsMap = /* [ROW, COLUMN, (0:normal 1:shift 2:alpha)] */
|
||||
{ { /* ROW 0 */
|
||||
{ "⇪", "⇪", null }, /* 0,0 */
|
||||
{ "A", null, "A" }, /* 0,1 */
|
||||
{"", null, null }, /* 0,2 */
|
||||
{ "⇧", null, null }, /* 0,3 */
|
||||
{"", null, null }, /* 0,4 */
|
||||
{"", null, null }, /* 0,5 */
|
||||
{ "☼", "☼", null }, /* 0,6 */
|
||||
{"↩", null, null } /* 0,7 */
|
||||
}, { /* ROW 1 */
|
||||
{"", null, null }, /* 1,0 */
|
||||
{"", null, null }, /* 1,1 */
|
||||
{"⇦", null, null }, /* 1,2 */
|
||||
{"OK", null, null }, /* 1,3 */
|
||||
{"⇨", null, null }, /* 1,4 */
|
||||
{"↤", null, null }, /* 1,5 */
|
||||
{"↦", null, null }, /* 1,6 */
|
||||
{"", null, null } /* 1,7 */
|
||||
}, { /* ROW 2 */
|
||||
{"", null, null }, /* 2,0 */
|
||||
{"√", null, null }, /* 2,1 */
|
||||
{"", null, null }, /* 2,2 */
|
||||
{"⇩", null, null }, /* 2,3 */
|
||||
{"", null, null }, /* 2,4 */
|
||||
{"", null, null }, /* 2,5 */
|
||||
{"", null, null }, /* 2,6 */
|
||||
{"", null, null } /* 2,7 */
|
||||
}, { /* ROW 3 */
|
||||
{"", null, null }, /* 3,0 */
|
||||
{"", null, null }, /* 3,1 */
|
||||
{"^x", null, null }, /* 3,2 */
|
||||
{"^2", null, null }, /* 3,3 */
|
||||
{"", null, null }, /* 3,4 */
|
||||
{"", null, null }, /* 3,5 */
|
||||
{"", null, null }, /* 3,6 */
|
||||
{".", null, "y" } /* 3,7 */
|
||||
}, { /* ROW 4 */
|
||||
{"", null, null }, /* 4,0 */
|
||||
{"", null, null }, /* 4,1 */
|
||||
{"(", null, null }, /* 4,2 */
|
||||
{")", null, null }, /* 4,3 */
|
||||
{"", null, null }, /* 4,4 */
|
||||
{"S⇔D", null, null }, /* 4,5 */
|
||||
{"", null, null }, /* 4,6 */
|
||||
{"0", null, "x" } /* 4,7 */
|
||||
}, { /* ROW 5 */
|
||||
{"7", null, null }, /* 5,0 */
|
||||
{"8", null, null }, /* 5,1 */
|
||||
{"9", null, null }, /* 5,2 */
|
||||
{"⌫", null, null }, /* 5,3 */
|
||||
{"RESET", null, null }, /* 5,4 */
|
||||
{"", null, null }, /* 5,5 */
|
||||
{"", null, null }, /* 5,6 */
|
||||
{"", null, null } /* 5,7 */
|
||||
}, { /* ROW 6 */
|
||||
{"4", null, null }, /* 6,0 */
|
||||
{"5", null, null }, /* 6,1 */
|
||||
{"6", null, null }, /* 6,2 */
|
||||
{"/", null, null }, /* 6,3 */
|
||||
{"*", null, null }, /* 6,4 */
|
||||
{"", null, null }, /* 6,5 */
|
||||
{"", null, null }, /* 6,6 */
|
||||
{"", null, null } /* 6,7 */
|
||||
}, { /* ROW 7 */
|
||||
{"1", null, null }, /* 7,0 */
|
||||
{"2", null, null }, /* 7,1 */
|
||||
{"3", null, null }, /* 7,2 */
|
||||
{"+", null, null }, /* 7,3 */
|
||||
{"-", null, null }, /* 7,4 */
|
||||
{"", null, null }, /* 7,5 */
|
||||
{"", null, null }, /* 7,6 */
|
||||
{"", null, null } /* 7,7 */
|
||||
} };
|
||||
|
||||
static final Key[][][] keyMap = /* [ROW, COLUMN, (0:normal 1:shift 2:alpha)] */
|
||||
{ { /* ROW 0 */
|
||||
{ Key.SHIFT, Key.SHIFT, Key.SHIFT }, /* 0,0 */
|
||||
@ -746,6 +821,35 @@ public class Keyboard {
|
||||
{ Key.NONE, Key.NONE, Key.NONE }, /* 7,6 */
|
||||
{ Key.NONE, Key.NONE, Key.NONE } /* 7,7 */
|
||||
} };
|
||||
|
||||
public static String getKeyName(int row, int col) {
|
||||
return getKeyName(row, col, shift, alpha);
|
||||
}
|
||||
|
||||
public static String getKeyName(int row, int col, boolean shift, boolean alpha) {
|
||||
String[] keyValues = KeyLabelsMap[row][col];
|
||||
if (shift) {
|
||||
if (keyValues[1] != null) {
|
||||
return keyValues[1];
|
||||
}
|
||||
} else if (alpha) {
|
||||
if (keyValues[2] != null) {
|
||||
return keyValues[2];
|
||||
}
|
||||
}
|
||||
return keyValues[0];
|
||||
}
|
||||
|
||||
public static boolean hasKeyName(int row, int col) {
|
||||
String[] keyValues = KeyLabelsMap[row][col];
|
||||
if (shift) {
|
||||
return keyValues[1] != null;
|
||||
} else if (alpha) {
|
||||
return keyValues[2] != null;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void keyPressedRaw(int row, int col) {
|
||||
// KeyboardDebugScreen.keyX = row;
|
||||
@ -778,8 +882,8 @@ public class Keyboard {
|
||||
new GUIErrorMessage(ex);
|
||||
}
|
||||
}
|
||||
if (HardwareDevice.INSTANCE.getDisplayManager() != null) {
|
||||
final Screen scr = HardwareDevice.INSTANCE.getDisplayManager().getScreen();
|
||||
if (Engine.INSTANCE.getHardwareDevice().getDisplayManager() != null) {
|
||||
final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
|
||||
boolean refresh = false;
|
||||
boolean scrdone = false;
|
||||
try {
|
||||
@ -792,17 +896,17 @@ public class Keyboard {
|
||||
} else {
|
||||
switch (k) {
|
||||
case POWEROFF:
|
||||
HardwareDevice.INSTANCE.getDisplayManager().engine.destroy();
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.destroy();
|
||||
break;
|
||||
case NONE:
|
||||
break;
|
||||
case BRIGHTNESS_CYCLE:
|
||||
HardwareDevice.INSTANCE.getDisplayManager().cycleBrightness(false);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().cycleBrightness(false);
|
||||
refresh = true;
|
||||
break;
|
||||
case BRIGHTNESS_CYCLE_REVERSE:
|
||||
HardwareDevice.INSTANCE.getDisplayManager().setScreen(new MarioScreen()); //TODO: rimuovere: prova
|
||||
HardwareDevice.INSTANCE.getDisplayManager().cycleBrightness(true);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new MarioScreen()); //TODO: rimuovere: prova
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().cycleBrightness(true);
|
||||
refresh = true;
|
||||
break;
|
||||
case ZOOM_MODE:
|
||||
@ -812,11 +916,11 @@ public class Keyboard {
|
||||
// StaticVars.windowZoom = ((StaticVars.windowZoom - 0.5f) % 2f) + 1f;
|
||||
refresh = true;
|
||||
case HISTORY_BACK:
|
||||
HardwareDevice.INSTANCE.getDisplayManager().goBack();
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().goBack();
|
||||
refresh = true;
|
||||
break;
|
||||
case HISTORY_FORWARD:
|
||||
HardwareDevice.INSTANCE.getDisplayManager().goForward();
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().goForward();
|
||||
refresh = true;
|
||||
break;
|
||||
default:
|
||||
@ -859,8 +963,8 @@ public class Keyboard {
|
||||
done = additionalListener.onKeyReleased(new KeyReleasedEvent(k));
|
||||
}
|
||||
boolean refresh = false;
|
||||
if (HardwareDevice.INSTANCE.getDisplayManager() != null) {
|
||||
final Screen scr = HardwareDevice.INSTANCE.getDisplayManager().getScreen();
|
||||
if (Engine.INSTANCE.getHardwareDevice().getDisplayManager() != null) {
|
||||
final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
|
||||
if (scr != null && scr.initialized && scr.onKeyReleased(new KeyReleasedEvent(k))) {
|
||||
refresh = true;
|
||||
} else {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package it.cavallium.warppi.device;
|
||||
|
||||
import it.cavallium.warppi.Engine;
|
||||
import it.cavallium.warppi.event.TouchCancelEvent;
|
||||
import it.cavallium.warppi.event.TouchEndEvent;
|
||||
import it.cavallium.warppi.event.TouchMoveEvent;
|
||||
@ -19,7 +20,7 @@ public class PIHardwareTouchDevice implements HardwareTouchDevice {
|
||||
|
||||
@Override
|
||||
public boolean onTouchStart(TouchStartEvent e) {
|
||||
final Screen scr = HardwareDevice.INSTANCE.getDisplayManager().getScreen();
|
||||
final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
|
||||
boolean refresh = false;
|
||||
if (scr != null && scr.initialized && scr.onTouchStart(e)) {
|
||||
refresh = true;
|
||||
@ -27,14 +28,14 @@ public class PIHardwareTouchDevice implements HardwareTouchDevice {
|
||||
//Default behavior
|
||||
}
|
||||
if (refresh) {
|
||||
HardwareDevice.INSTANCE.getDisplayManager().forceRefresh = true;
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEnd(TouchEndEvent e) {
|
||||
final Screen scr = HardwareDevice.INSTANCE.getDisplayManager().getScreen();
|
||||
final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
|
||||
boolean refresh = false;
|
||||
if (scr != null && scr.initialized && scr.onTouchEnd(e)) {
|
||||
refresh = true;
|
||||
@ -42,14 +43,14 @@ public class PIHardwareTouchDevice implements HardwareTouchDevice {
|
||||
//Default behavior
|
||||
}
|
||||
if (refresh) {
|
||||
HardwareDevice.INSTANCE.getDisplayManager().forceRefresh = true;
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchCancel(TouchCancelEvent e) {
|
||||
final Screen scr = HardwareDevice.INSTANCE.getDisplayManager().getScreen();
|
||||
final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
|
||||
boolean refresh = false;
|
||||
if (scr != null && scr.initialized && scr.onTouchCancel(e)) {
|
||||
refresh = true;
|
||||
@ -57,14 +58,14 @@ public class PIHardwareTouchDevice implements HardwareTouchDevice {
|
||||
//Default behavior
|
||||
}
|
||||
if (refresh) {
|
||||
HardwareDevice.INSTANCE.getDisplayManager().forceRefresh = true;
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchMove(TouchMoveEvent e) {
|
||||
final Screen scr = HardwareDevice.INSTANCE.getDisplayManager().getScreen();
|
||||
final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
|
||||
boolean refresh = false;
|
||||
if (scr != null && scr.initialized && scr.onTouchMove(e)) {
|
||||
refresh = true;
|
||||
@ -72,7 +73,7 @@ public class PIHardwareTouchDevice implements HardwareTouchDevice {
|
||||
//Default behavior
|
||||
}
|
||||
if (refresh) {
|
||||
HardwareDevice.INSTANCE.getDisplayManager().forceRefresh = true;
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public class CalculatorHUD extends HUD {
|
||||
|
||||
int padding = 2;
|
||||
|
||||
final int brightness = (int) (Math.ceil(HardwareDevice.INSTANCE.getDisplayManager().getBrightness() * 9));
|
||||
final int brightness = (int) (Math.ceil(Engine.INSTANCE.getHardwareDevice().getDisplayManager().getBrightness() * 9));
|
||||
if (brightness <= 10) {
|
||||
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * brightness, 16 * 1, 16, 16);
|
||||
} else {
|
||||
@ -89,8 +89,8 @@ public class CalculatorHUD extends HUD {
|
||||
|
||||
padding += 18 + 6;
|
||||
|
||||
final boolean canGoBack = HardwareDevice.INSTANCE.getDisplayManager().canGoBack();
|
||||
final boolean canGoForward = HardwareDevice.INSTANCE.getDisplayManager().canGoForward();
|
||||
final boolean canGoBack = Engine.INSTANCE.getHardwareDevice().getDisplayManager().canGoBack();
|
||||
final boolean canGoForward = Engine.INSTANCE.getHardwareDevice().getDisplayManager().canGoForward();
|
||||
|
||||
if (StaticVars.haxMode) {
|
||||
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 18, 16 * 0, 16, 16);
|
||||
@ -112,15 +112,15 @@ public class CalculatorHUD extends HUD {
|
||||
//DRAW BOTTOM
|
||||
d.renderer.glDrawStringLeft(2, 90, d.displayDebugString);
|
||||
|
||||
Utils.getFont(true, false).use(HardwareDevice.INSTANCE.getDisplayManager().engine);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor4i(255, 0, 0, 40);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringLeft(1 + 1, StaticVars.screenSize[1] - 7 - 7 + 1, "WORK IN");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor4i(255, 0, 0, 80);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringLeft(1, StaticVars.screenSize[1] - 7 - 7, "WORK IN");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor4i(255, 0, 0, 40);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringLeft(1 + 1, StaticVars.screenSize[1] - 7 + 1, "PROGRESS.");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor4i(255, 0, 0, 80);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringLeft(1, StaticVars.screenSize[1] - 7, "PROGRESS.");
|
||||
Utils.getFont(true, false).use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4i(255, 0, 0, 40);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringLeft(1 + 1, StaticVars.screenSize[1] - 7 - 7 + 1, "WORK IN");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4i(255, 0, 0, 80);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringLeft(1, StaticVars.screenSize[1] - 7 - 7, "WORK IN");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4i(255, 0, 0, 40);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringLeft(1 + 1, StaticVars.screenSize[1] - 7 + 1, "PROGRESS.");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4i(255, 0, 0, 80);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringLeft(1, StaticVars.screenSize[1] - 7, "PROGRESS.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,6 +53,10 @@ public abstract class Block implements GraphicalElement {
|
||||
public int getLine() {
|
||||
return line;
|
||||
}
|
||||
|
||||
public int getCaretDeltaPositionAfterCreation() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public boolean isSmall() {
|
||||
return small;
|
||||
|
@ -0,0 +1,89 @@
|
||||
package it.cavallium.warppi.gui.expression.blocks;
|
||||
|
||||
import it.cavallium.warppi.Error;
|
||||
import it.cavallium.warppi.gui.expression.Caret;
|
||||
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
||||
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
||||
import it.cavallium.warppi.math.Function;
|
||||
import it.cavallium.warppi.math.MathContext;
|
||||
import it.cavallium.warppi.math.parser.features.FeaturePowerChar;
|
||||
import it.cavallium.warppi.math.parser.features.interfaces.Feature;
|
||||
|
||||
public class BlockPower2 extends Block {
|
||||
|
||||
private final BlockContainer containerExponent;
|
||||
|
||||
public BlockPower2() {
|
||||
containerExponent = new BlockContainer(true);
|
||||
containerExponent.addBlock(0, new BlockNumericChar('2'));
|
||||
recomputeDimensions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCaretDeltaPositionAfterCreation() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GraphicEngine ge, Renderer r, int x, int y, Caret caret) {
|
||||
BlockContainer.getDefaultFont(true).use(ge);
|
||||
r.glColor(BlockContainer.getDefaultColor());
|
||||
containerExponent.draw(ge, r, x, y, caret);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean putBlock(Caret caret, Block newBlock) {
|
||||
boolean added = false;
|
||||
added = added | containerExponent.putBlock(caret, newBlock);
|
||||
if (added) {
|
||||
recomputeDimensions();
|
||||
}
|
||||
return added;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delBlock(Caret caret) {
|
||||
boolean removed = false;
|
||||
removed = removed | containerExponent.delBlock(caret);
|
||||
if (removed) {
|
||||
recomputeDimensions();
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockReference<?> getBlock(Caret caret) {
|
||||
return containerExponent.getBlock(caret);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recomputeDimensions() {
|
||||
final int w2 = containerExponent.getWidth();
|
||||
final int h2 = containerExponent.getHeight();
|
||||
width = w2 + 1;
|
||||
height = h2 + BlockContainer.getDefaultCharHeight(small) - 3;
|
||||
line = h2 + BlockContainer.getDefaultCharHeight(small) / 2 - 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSmall(boolean small) {
|
||||
this.small = small;
|
||||
containerExponent.setSmall(true);
|
||||
recomputeDimensions();
|
||||
}
|
||||
|
||||
public BlockContainer getExponentContainer() {
|
||||
return containerExponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int computeCaretMaxBound() {
|
||||
return containerExponent.computeCaretMaxBound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Feature toFeature(MathContext context) throws Error {
|
||||
final Function exp = getExponentContainer().toFunction(context);
|
||||
return new FeaturePowerChar(exp);
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package it.cavallium.warppi.gui.expression.blocks;
|
||||
|
||||
import it.cavallium.warppi.Engine;
|
||||
import it.cavallium.warppi.Error;
|
||||
import it.cavallium.warppi.device.HardwareDevice;
|
||||
import it.cavallium.warppi.event.KeyPressedEvent;
|
||||
@ -222,7 +223,7 @@ public class BlockVariable extends Block {
|
||||
@Override
|
||||
public void draw(GraphicEngine ge, Renderer r, Caret caret) {
|
||||
r.glColor3f(1.0f, 1.0f, 1.0f);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().guiSkin.use(ge);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().guiSkin.use(ge);
|
||||
int popupX = location[0];
|
||||
int popupY = location[1];
|
||||
if (popupX < 0) {
|
||||
|
@ -65,7 +65,7 @@ public abstract class InputContainer implements GraphicalElement, InputLayout, S
|
||||
if (b != null) {
|
||||
caret.resetRemaining();
|
||||
if (root.putBlock(caret, b)) {
|
||||
caret.setPosition(caret.getPosition() + 1);
|
||||
caret.setPosition(caret.getPosition() + b.getCaretDeltaPositionAfterCreation());
|
||||
maxPosition = root.computeCaretMaxBound();
|
||||
root.recomputeDimensions();
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import it.cavallium.warppi.gui.expression.blocks.BlockLogarithm;
|
||||
import it.cavallium.warppi.gui.expression.blocks.BlockNumericChar;
|
||||
import it.cavallium.warppi.gui.expression.blocks.BlockParenthesis;
|
||||
import it.cavallium.warppi.gui.expression.blocks.BlockPower;
|
||||
import it.cavallium.warppi.gui.expression.blocks.BlockPower2;
|
||||
import it.cavallium.warppi.gui.expression.blocks.BlockReference;
|
||||
import it.cavallium.warppi.gui.expression.blocks.BlockSine;
|
||||
import it.cavallium.warppi.gui.expression.blocks.BlockSquareRoot;
|
||||
@ -51,8 +52,9 @@ public class NormalInputContainer extends InputContainer {
|
||||
case MathematicalSymbols.PARENTHESIS_CLOSE:
|
||||
return null;
|
||||
case MathematicalSymbols.POWER:
|
||||
case MathematicalSymbols.POWER_OF_TWO:
|
||||
return new BlockPower();
|
||||
case MathematicalSymbols.POWER_OF_TWO:
|
||||
return new BlockPower2();
|
||||
case MathematicalSymbols.MULTIPLICATION:
|
||||
case MathematicalSymbols.SUM:
|
||||
case MathematicalSymbols.SUM_SUBTRACTION:
|
||||
|
@ -1,5 +1,6 @@
|
||||
package it.cavallium.warppi.gui.screens;
|
||||
|
||||
import it.cavallium.warppi.Engine;
|
||||
import it.cavallium.warppi.StaticVars;
|
||||
import it.cavallium.warppi.Utils;
|
||||
import it.cavallium.warppi.device.HardwareDevice;
|
||||
@ -28,21 +29,21 @@ public class ChooseVariableValueScreen extends Screen {
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
Utils.getFont(false, true).use(HardwareDevice.INSTANCE.getDisplayManager().engine);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor4i(0, 0, 0, 64);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2 - 20, "WORK IN PROGRESS.");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 - 20 + 1, "WORK IN PROGRESS.");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2 - 20 + 1, "WORK IN PROGRESS.");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor3i(255, 0, 0);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 - 20, "WORK IN PROGRESS.");
|
||||
Utils.getFont(false, true).use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
Engine.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.");
|
||||
Engine.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.");
|
||||
Engine.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.");
|
||||
|
||||
Utils.getFont(false, false).use(HardwareDevice.INSTANCE.getDisplayManager().engine);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor4i(0, 0, 0, 64);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 + 1, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
|
||||
HardwareDevice.INSTANCE.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.");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor3i(255, 0, 0);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
|
||||
Utils.getFont(false, false).use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
Engine.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.");
|
||||
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.");
|
||||
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.");
|
||||
Engine.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.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,6 @@
|
||||
package it.cavallium.warppi.gui.screens;
|
||||
|
||||
import it.cavallium.warppi.Engine;
|
||||
import it.cavallium.warppi.StaticVars;
|
||||
import it.cavallium.warppi.device.HardwareDevice;
|
||||
import it.cavallium.warppi.event.KeyPressedEvent;
|
||||
@ -28,19 +29,19 @@ public class KeyboardDebugScreen extends Screen {
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
final Renderer renderer = HardwareDevice.INSTANCE.getDisplayManager().renderer;
|
||||
HardwareDevice.INSTANCE.getDisplayManager().fonts[2].use(HardwareDevice.INSTANCE.getDisplayManager().engine);
|
||||
final Renderer renderer = Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer;
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
renderer.glColor4f(0.75f, 0.0f, 0.0f, 1.0f);
|
||||
renderer.glDrawStringRight(StaticVars.screenSize[0] - 10, 30, "-" + keyevent.toUpperCase() + "-");
|
||||
if (keyevent != "NONE") {
|
||||
HardwareDevice.INSTANCE.getDisplayManager().fonts[2].use(HardwareDevice.INSTANCE.getDisplayManager().engine);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
renderer.glDrawStringLeft(10, 30, "Key position");
|
||||
renderer.glDrawStringLeft(10, 45, "X: " + keyX + ", Y:" + keyY);
|
||||
renderer.glDrawStringLeft(10, 65, "Key value");
|
||||
renderer.glDrawStringLeft(10, 80, key);
|
||||
}
|
||||
HardwareDevice.INSTANCE.getDisplayManager().fonts[3].use(HardwareDevice.INSTANCE.getDisplayManager().engine);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[3].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (log[i] != null) {
|
||||
@ -52,10 +53,10 @@ public class KeyboardDebugScreen extends Screen {
|
||||
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
renderer.glFillColor(-80 + 100 + 200, 90, 5, 5);
|
||||
renderer.glFillColor(-80 + 100, 100, 200, 70);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().fonts[2].use(HardwareDevice.INSTANCE.getDisplayManager().engine);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
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");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().fonts[3].use(HardwareDevice.INSTANCE.getDisplayManager().engine);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[3].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
renderer.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (pinsA[i] == 1) {
|
||||
@ -98,10 +99,10 @@ public class KeyboardDebugScreen extends Screen {
|
||||
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
renderer.glFillColor(150 + 90, 200, 5, 5);
|
||||
renderer.glFillColor(150 + 100, 100, 200, 70);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().fonts[2].use(HardwareDevice.INSTANCE.getDisplayManager().engine);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
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");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().fonts[3].use(HardwareDevice.INSTANCE.getDisplayManager().engine);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[3].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
renderer.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
for (int i = 15; i >= 8; i--) {
|
||||
if (pinsB[i] == 1) {
|
||||
|
@ -39,20 +39,20 @@ public class LoadingScreen extends Screen {
|
||||
endLoading += dt;
|
||||
if (loaded && (StaticVars.debugOn || endLoading >= 3.5f)) {
|
||||
StaticVars.windowZoom.onNext(previousZoomValue);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().setScreen(new MathInputScreen());
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new MathInputScreen());
|
||||
}
|
||||
mustRefresh = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
HardwareDevice.INSTANCE.getDisplayManager().guiSkin.use(HardwareDevice.INSTANCE.getDisplayManager().engine);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor3i(255, 255, 255);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] / 2f - 80, StaticVars.screenSize[1] / 2f - 64, 160, 48, 0, 32, 160, 48);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] / 2f - 24, StaticVars.screenSize[1] / 2f - loadingTextTranslation, 48, 48, 160, 32, 48, 48);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().guiSkin.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
Engine.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);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] / 2f - 24, StaticVars.screenSize[1] / 2f - loadingTextTranslation, 48, 48, 160, 32, 48, 48);
|
||||
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] - 224, StaticVars.screenSize[1] - 48, 224, 48, 0, 80, 224, 48);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] - 160 - 24 - 224, StaticVars.screenSize[1] - 48, 160, 48, 224, 80, 160, 48);
|
||||
Engine.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);
|
||||
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package it.cavallium.warppi.gui.screens;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import it.cavallium.warppi.Engine;
|
||||
import it.cavallium.warppi.StaticVars;
|
||||
import it.cavallium.warppi.device.HardwareDevice;
|
||||
import it.cavallium.warppi.device.Keyboard;
|
||||
@ -45,30 +46,30 @@ public class MarioScreen extends Screen {
|
||||
public void initialized() {
|
||||
try {
|
||||
if (skin == null) {
|
||||
skin = HardwareDevice.INSTANCE.getDisplayManager().engine.loadSkin("marioskin.png");
|
||||
skin = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("marioskin.png");
|
||||
}
|
||||
if (groundskin == null) {
|
||||
groundskin = HardwareDevice.INSTANCE.getDisplayManager().engine.loadSkin("marioground.png");
|
||||
groundskin = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("marioground.png");
|
||||
}
|
||||
if (gpuTest2 == null) {
|
||||
try {
|
||||
gpuTest2 = HardwareDevice.INSTANCE.getDisplayManager().engine.loadFont("gputest2");
|
||||
gpuTest2 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("gputest2");
|
||||
} catch (final Exception ex) {}
|
||||
}
|
||||
if (gpuTest1 == null) {
|
||||
try {
|
||||
gpuTest1 = HardwareDevice.INSTANCE.getDisplayManager().engine.loadFont("gputest12");
|
||||
gpuTest1 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("gputest12");
|
||||
gpuTest12 = true;
|
||||
} catch (final Exception ex) {
|
||||
gpuTest12 = false;
|
||||
try {
|
||||
gpuTest1 = HardwareDevice.INSTANCE.getDisplayManager().engine.loadFont("gputest1");
|
||||
gpuTest1 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("gputest1");
|
||||
} catch (final Exception ex2) {}
|
||||
}
|
||||
}
|
||||
if (gpuTest3 == null) {
|
||||
try {
|
||||
gpuTest3 = HardwareDevice.INSTANCE.getDisplayManager().engine.loadSkin("font_gputest3.png");
|
||||
gpuTest3 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("font_gputest3.png");
|
||||
} catch (final Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@ -105,24 +106,24 @@ public class MarioScreen extends Screen {
|
||||
gpuCharTestt1Elapsed -= 1.5;
|
||||
}
|
||||
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glClearColor(0xff000000);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glClearColor(0xff000000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
if (errored) {
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringLeft(0, 20, "ERROR");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringLeft(0, 20, "ERROR");
|
||||
} else {
|
||||
if (groundskin != null) {
|
||||
final double playerX = g.getPlayer().getX();
|
||||
final double playerY = g.getPlayer().getY();
|
||||
groundskin.use(HardwareDevice.INSTANCE.getDisplayManager().engine);
|
||||
groundskin.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
final MarioWorld w = g.getCurrentWorld();
|
||||
final int width = w.getWidth();
|
||||
final int height = w.getHeight();
|
||||
final float screenX = HardwareDevice.INSTANCE.getDisplayManager().engine.getWidth() / 2f - 8f;
|
||||
final float screenY = HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() / 2f - 8f;
|
||||
final float screenX = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getWidth() / 2f - 8f;
|
||||
final float screenY = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() / 2f - 8f;
|
||||
final float shiftX = -8 + 16 * (float) playerX;
|
||||
final float shiftY = -8 + 16 * (height - (float) playerY);
|
||||
int blue = -1;
|
||||
@ -135,59 +136,59 @@ public class MarioScreen extends Screen {
|
||||
if (b == 0) {
|
||||
if (blue != 1) {
|
||||
blue = 1;
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor(0xff9290ff);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xff9290ff);
|
||||
}
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glFillColor(screenX - shiftX + 16 * ix, screenY - shiftY + 16 * (height - iy), 16, 16);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillColor(screenX - shiftX + 16 * ix, screenY - shiftY + 16 * (height - iy), 16, 16);
|
||||
} else {
|
||||
if (blue != 0) {
|
||||
blue = 0;
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor(0xffffffff);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xffffffff);
|
||||
}
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glFillRect(screenX - shiftX + 16 * ix, screenY - shiftY + 16 * (height - iy), 16, 16, 0, 0, 16, 16);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(screenX - shiftX + 16 * ix, screenY - shiftY + 16 * (height - iy), 16, 16, 0, 0, 16, 16);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (blue != 0) {
|
||||
blue = 0;
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor(0xffffffff);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xffffffff);
|
||||
}
|
||||
|
||||
//DRAW MARIO
|
||||
skin.use(HardwareDevice.INSTANCE.getDisplayManager().engine);
|
||||
HardwareDevice.INSTANCE.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);
|
||||
skin.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
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);
|
||||
// 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
|
||||
if (gpuTest1 != null) {
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor3f(1, 1, 1);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glFillColor(HardwareDevice.INSTANCE.getDisplayManager().engine.getWidth() - (gpuTest12 ? 512 : 256), HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() / 2 - (gpuTest12 ? 256 : 128), gpuTest12 ? 512 : 256, gpuTest12 ? 512 : 256);
|
||||
gpuTest1.use(HardwareDevice.INSTANCE.getDisplayManager().engine);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor3f(0, 0, 0);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringRight(HardwareDevice.INSTANCE.getDisplayManager().engine.getWidth(), HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() / 2 - (gpuTest12 ? 256 : 128), gpuCharTest1[gpuCharTest1Num]);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3f(1, 1, 1);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillColor(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getWidth() - (gpuTest12 ? 512 : 256), Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() / 2 - (gpuTest12 ? 256 : 128), gpuTest12 ? 512 : 256, gpuTest12 ? 512 : 256);
|
||||
gpuTest1.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
Engine.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 - (gpuTest12 ? 256 : 128), gpuCharTest1[gpuCharTest1Num]);
|
||||
}
|
||||
if (gpuTest3 != null) {
|
||||
gpuTest3.use(HardwareDevice.INSTANCE.getDisplayManager().engine);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor4f(1, 1, 1, 0.7f);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glFillRect(0, StaticVars.screenSize[1] - 128, 224, 128, gpuTestNum * 224, 0, 224, 128);
|
||||
gpuTest3.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
Engine.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);
|
||||
}
|
||||
if (gpuTest2 != null) {
|
||||
gpuTest2.use(HardwareDevice.INSTANCE.getDisplayManager().engine);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor(0xFF000000);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "A");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor(0xFF800000);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "B");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor(0xFFeea28e);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "C");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor(0xFFee7255);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "D");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor(0xFFeac0b0);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "E");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor(0xFFf3d8ce);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "F");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor(0xFFffede7);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "G");
|
||||
gpuTest2.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFF000000);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "A");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFF800000);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "B");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFeea28e);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "C");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFee7255);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "D");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFeac0b0);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "E");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFf3d8ce);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "F");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFffede7);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "G");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class MathInputScreen extends Screen {
|
||||
calc = new MathContext();
|
||||
|
||||
try {
|
||||
BlockContainer.initializeFonts(HardwareDevice.INSTANCE.getDisplayManager().engine.loadFont("norm"), HardwareDevice.INSTANCE.getDisplayManager().engine.loadFont("smal"));
|
||||
BlockContainer.initializeFonts(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("norm"), Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("smal"));
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
Engine.getPlatform().exit(1);
|
||||
@ -86,10 +86,10 @@ public class MathInputScreen extends Screen {
|
||||
|
||||
@Override
|
||||
public void beforeRender(float dt) {
|
||||
if (HardwareDevice.INSTANCE.getDisplayManager().error == null) {
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glClearColor(0xFFc5c2af);
|
||||
if (Engine.INSTANCE.getHardwareDevice().getDisplayManager().error == null) {
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glClearColor(0xFFc5c2af);
|
||||
} else {
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glClearColor(0xFFDC3C32);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glClearColor(0xFFDC3C32);
|
||||
}
|
||||
if (userInput.beforeRender(dt)) {
|
||||
mustRefresh = true;
|
||||
@ -115,13 +115,13 @@ public class MathInputScreen extends Screen {
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
final Renderer renderer = HardwareDevice.INSTANCE.getDisplayManager().renderer;
|
||||
fontBig.use(HardwareDevice.INSTANCE.getDisplayManager().engine);
|
||||
final Renderer renderer = Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer;
|
||||
fontBig.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
final int textColor = 0xFF000000;
|
||||
final int padding = 4;
|
||||
renderer.glColor(textColor);
|
||||
|
||||
userInput.draw(HardwareDevice.INSTANCE.getDisplayManager().engine, renderer, padding, padding + 20);
|
||||
userInput.draw(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine, renderer, padding, padding + 20);
|
||||
|
||||
if (computingResult) {
|
||||
renderer.glColor3f(1, 1, 1);
|
||||
@ -130,22 +130,22 @@ public class MathInputScreen extends Screen {
|
||||
final int size = 32;
|
||||
final int posY = computingAnimationIndex % 2;
|
||||
final int posX = (computingAnimationIndex - posY) / 2;
|
||||
renderer.glFillRect(HardwareDevice.INSTANCE.getDisplayManager().engine.getWidth() - size - 4, HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() - size - 4, size, size, leftX + size * posX, leftY + size * posY, size, size);
|
||||
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);
|
||||
if (computingBreakTipVisible) {
|
||||
Utils.getFont(false).use(HardwareDevice.INSTANCE.getDisplayManager().engine);
|
||||
Utils.getFont(false).use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
renderer.glColor3f(0.75f, 0, 0);
|
||||
renderer.glDrawStringRight(HardwareDevice.INSTANCE.getDisplayManager().engine.getWidth() - 4 - size - 4, HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() - size / 2 - renderer.getCurrentFont().getCharacterHeight() / 2 - 4, "Press (=) to stop");
|
||||
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");
|
||||
}
|
||||
} else {
|
||||
if (!result.isContentEmpty()) {
|
||||
result.draw(HardwareDevice.INSTANCE.getDisplayManager().engine, renderer, HardwareDevice.INSTANCE.getDisplayManager().engine.getWidth() - result.getWidth() - 2, HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() - result.getHeight() - 2);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTopmost() {
|
||||
final Renderer renderer = HardwareDevice.INSTANCE.getDisplayManager().renderer;
|
||||
final Renderer renderer = Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer;
|
||||
renderer.glColor3f(1, 1, 1);
|
||||
final int pos = 2;
|
||||
final int spacersNumb = 1;
|
||||
@ -155,7 +155,7 @@ public class MathInputScreen extends Screen {
|
||||
} else {
|
||||
skinN = 21;
|
||||
}
|
||||
HardwareDevice.INSTANCE.getDisplayManager().guiSkin.use(HardwareDevice.INSTANCE.getDisplayManager().engine);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().guiSkin.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
renderer.glFillRect(2 + 18 * pos + 2 * spacersNumb, 2, 16, 16, 16 * skinN, 16 * 0, 16, 16);
|
||||
}
|
||||
|
||||
@ -199,10 +199,10 @@ public class MathInputScreen extends Screen {
|
||||
if (!step) {
|
||||
currentStep = 0;
|
||||
}
|
||||
if (HardwareDevice.INSTANCE.getDisplayManager().error != null) {
|
||||
if (Engine.INSTANCE.getHardwareDevice().getDisplayManager().error != null) {
|
||||
//TODO: make the error management a global API rather than being relegated to this screen.
|
||||
Engine.getPlatform().getConsoleUtils().out().println(1, "Resetting after error...");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().error = null;
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().error = null;
|
||||
calc.f = null;
|
||||
calc.f2 = null;
|
||||
calc.resultsCount = 0;
|
||||
@ -248,7 +248,7 @@ public class MathInputScreen extends Screen {
|
||||
}
|
||||
} catch (final Error e) {
|
||||
d.errorStackTrace = Engine.getPlatform().stacktraceToString(e);
|
||||
HardwareDevice.INSTANCE.getDisplayManager().error = e.id.toString();
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().error = e.id.toString();
|
||||
System.err.println(e.id);
|
||||
}
|
||||
computingResult = false;
|
||||
@ -386,9 +386,9 @@ public class MathInputScreen extends Screen {
|
||||
userInput.clear();
|
||||
result.clear();
|
||||
currentStep = 0;
|
||||
if (HardwareDevice.INSTANCE.getDisplayManager().error != null) {
|
||||
if (Engine.INSTANCE.getHardwareDevice().getDisplayManager().error != null) {
|
||||
Engine.getPlatform().getConsoleUtils().out().println(1, "Resetting after error...");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().error = null;
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().error = null;
|
||||
}
|
||||
return true;
|
||||
case SURD_MODE:
|
||||
@ -398,11 +398,11 @@ public class MathInputScreen extends Screen {
|
||||
Keyboard.keyPressed(Key.SIMPLIFY);
|
||||
return true;
|
||||
case debug1:
|
||||
HardwareDevice.INSTANCE.getDisplayManager().setScreen(new EmptyScreen());
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new EmptyScreen());
|
||||
return true;
|
||||
case HISTORY_BACK:
|
||||
// if (HardwareDevice.INSTANCE.getDisplayManager().canGoBack()) {
|
||||
// if (currentExpression != null && currentExpression.length() > 0 & HardwareDevice.INSTANCE.getDisplayManager().sessions[HardwareDevice.INSTANCE.getDisplayManager().currentSession + 1] instanceof MathInputScreen) {
|
||||
// if (Engine.INSTANCE.getHardwareDevice().getDisplayManager().canGoBack()) {
|
||||
// if (currentExpression != null && currentExpression.length() > 0 & Engine.INSTANCE.getHardwareDevice().getDisplayManager().sessions[Engine.INSTANCE.getHardwareDevice().getDisplayManager().currentSession + 1] instanceof MathInputScreen) {
|
||||
// newExpression = currentExpression;
|
||||
// try {
|
||||
// interpreta(true);
|
||||
@ -411,8 +411,8 @@ public class MathInputScreen extends Screen {
|
||||
// }
|
||||
return false;
|
||||
case HISTORY_FORWARD:
|
||||
// if (HardwareDevice.INSTANCE.getDisplayManager().canGoForward()) {
|
||||
// if (currentExpression != null && currentExpression.length() > 0 & HardwareDevice.INSTANCE.getDisplayManager().sessions[HardwareDevice.INSTANCE.getDisplayManager().currentSession - 1] instanceof MathInputScreen) {
|
||||
// if (Engine.INSTANCE.getHardwareDevice().getDisplayManager().canGoForward()) {
|
||||
// if (currentExpression != null && currentExpression.length() > 0 & Engine.INSTANCE.getHardwareDevice().getDisplayManager().sessions[Engine.INSTANCE.getHardwareDevice().getDisplayManager().currentSession - 1] instanceof MathInputScreen) {
|
||||
// newExpression = currentExpression;
|
||||
// try {
|
||||
// interpreta(true);
|
||||
@ -481,7 +481,7 @@ public class MathInputScreen extends Screen {
|
||||
final PrintWriter pw = new PrintWriter(sw);
|
||||
e.printStackTrace(pw);
|
||||
d.errorStackTrace = sw.toString().toUpperCase().replace("\t", " ").replace("\r", "").split("\n");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().error = e.id.toString();
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().error = e.id.toString();
|
||||
System.err.println(e.id);
|
||||
}
|
||||
return null;
|
||||
@ -498,7 +498,7 @@ public class MathInputScreen extends Screen {
|
||||
final ObjectArrayList<Function> partialResults = new ObjectArrayList<>();
|
||||
for (final Function f : calc.f2) {
|
||||
if (f instanceof Equation) {
|
||||
HardwareDevice.INSTANCE.getDisplayManager().setScreen(new SolveEquationScreen(this));
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new SolveEquationScreen(this));
|
||||
} else {
|
||||
results.add(f);
|
||||
for (final Function itm : results) {
|
||||
@ -538,7 +538,7 @@ public class MathInputScreen extends Screen {
|
||||
final PrintWriter pw = new PrintWriter(sw);
|
||||
e.printStackTrace(pw);
|
||||
d.errorStackTrace = sw.toString().toUpperCase().replace("\t", " ").replace("\r", "").split("\n");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().error = e.id.toString();
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().error = e.id.toString();
|
||||
System.err.println(e.id);
|
||||
}
|
||||
*/
|
||||
@ -551,7 +551,7 @@ public class MathInputScreen extends Screen {
|
||||
try {
|
||||
for (final Function f : calc.f) {
|
||||
if (f instanceof Equation) {
|
||||
HardwareDevice.INSTANCE.getDisplayManager().setScreen(new SolveEquationScreen(this));
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new SolveEquationScreen(this));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -580,7 +580,7 @@ public class MathInputScreen extends Screen {
|
||||
final PrintWriter pw = new PrintWriter(sw);
|
||||
e.printStackTrace(pw);
|
||||
d.errorStackTrace = sw.toString().toUpperCase().replace("\t", " ").replace("\r", "").split("\n");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().error = e.id.toString();
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().error = e.id.toString();
|
||||
System.err.println(e.id);
|
||||
}
|
||||
*/
|
||||
@ -594,9 +594,9 @@ public class MathInputScreen extends Screen {
|
||||
// if (!userInput.isEmpty()) {
|
||||
// final MathInputScreen cloned = clone();
|
||||
// cloned.userInput.setCaretPosition(cloned.userInput.getCaretMaxPosition()-1);
|
||||
// HardwareDevice.INSTANCE.getDisplayManager().replaceScreen(cloned);
|
||||
// Engine.INSTANCE.getHardwareDevice().getDisplayManager().replaceScreen(cloned);
|
||||
// initialized = false;
|
||||
// HardwareDevice.INSTANCE.getDisplayManager().setScreen(this);
|
||||
// Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(this);
|
||||
//
|
||||
// }
|
||||
}
|
||||
@ -638,9 +638,9 @@ public class MathInputScreen extends Screen {
|
||||
boolean cancelled = false;
|
||||
for (final Function f : knownVarsInFunctions) {
|
||||
final ChooseVariableValueScreen cvs = new ChooseVariableValueScreen(this, new VariableValue((Variable) f, new Number(calc, 0)));
|
||||
HardwareDevice.INSTANCE.getDisplayManager().setScreen(cvs);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(cvs);
|
||||
try {
|
||||
HardwareDevice.INSTANCE.getDisplayManager().screenChange.acquire();
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().screenChange.acquire();
|
||||
} catch (final InterruptedException e) {}
|
||||
if (cvs.resultNumberValue == null) {
|
||||
cancelled = true;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package it.cavallium.warppi.gui.screens;
|
||||
|
||||
import it.cavallium.warppi.Engine;
|
||||
import it.cavallium.warppi.StaticVars;
|
||||
import it.cavallium.warppi.device.HardwareDevice;
|
||||
import it.cavallium.warppi.event.KeyPressedEvent;
|
||||
@ -24,12 +25,12 @@ public class SolveForXScreen extends Screen {
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor4i(0, 0, 0, 64);
|
||||
HardwareDevice.INSTANCE.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.");
|
||||
HardwareDevice.INSTANCE.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.");
|
||||
HardwareDevice.INSTANCE.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.");
|
||||
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor3i(255, 0, 0);
|
||||
HardwareDevice.INSTANCE.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.");
|
||||
Engine.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.");
|
||||
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.");
|
||||
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.");
|
||||
Engine.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.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -47,11 +48,11 @@ public class SolveForXScreen extends Screen {
|
||||
switch (k.getKey()) {
|
||||
case LETTER_X:
|
||||
//TODO: far funzionare questa parte
|
||||
/*HardwareDevice.INSTANCE.getDisplayManager().goBack();
|
||||
/*Engine.INSTANCE.getHardwareDevice().getDisplayManager().goBack();
|
||||
try {
|
||||
es.calc.solveExpression('X');
|
||||
} catch (final Error e) {
|
||||
final Screen scr = HardwareDevice.INSTANCE.getDisplayManager().getScreen();
|
||||
final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
|
||||
if (scr instanceof MathInputScreen) {
|
||||
final MathInputScreen escr = (MathInputScreen) scr;
|
||||
escr.errorLevel = 1;
|
||||
|
@ -23,5 +23,10 @@
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
@ -1,3 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/main/resources=UTF-8
|
||||
encoding/<project>=UTF-8
|
||||
|
@ -14,6 +14,7 @@ import it.cavallium.warppi.CacheUtils;
|
||||
import it.cavallium.warppi.Engine;
|
||||
import it.cavallium.warppi.Error;
|
||||
import it.cavallium.warppi.deps.Platform;
|
||||
import it.cavallium.warppi.gui.DisplayManager;
|
||||
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
||||
import it.cavallium.warppi.gui.graphicengine.cpu.CPUEngine;
|
||||
import it.cavallium.warppi.gui.graphicengine.gpu.GPUEngine;
|
||||
@ -104,11 +105,18 @@ public class DesktopPlatform implements Platform {
|
||||
|
||||
@Override
|
||||
public void alphaChanged(boolean val) {
|
||||
|
||||
final GraphicEngine currentEngine = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine;
|
||||
if (currentEngine instanceof CPUEngine) {
|
||||
((CPUEngine) currentEngine).setAlphaChanged(val);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shiftChanged(boolean val) {
|
||||
final GraphicEngine currentEngine = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine;
|
||||
if (currentEngine instanceof CPUEngine) {
|
||||
((CPUEngine) currentEngine).setShiftChanged(val);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,6 +5,7 @@ import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
import it.cavallium.warppi.Engine;
|
||||
import it.cavallium.warppi.StaticVars;
|
||||
import it.cavallium.warppi.Utils;
|
||||
import it.cavallium.warppi.device.HardwareDevice;
|
||||
@ -71,12 +72,12 @@ public class CPUEngine implements GraphicEngine {
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return INSTANCE.getWidth() - StaticVars.screenPos[0];
|
||||
return INSTANCE.getWWidth() - StaticVars.screenPos[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return INSTANCE.getHeight() - StaticVars.screenPos[1];
|
||||
return INSTANCE.getWHeight() - StaticVars.screenPos[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -116,7 +117,7 @@ public class CPUEngine implements GraphicEngine {
|
||||
|
||||
@Deprecated()
|
||||
public void refresh() {
|
||||
if (HardwareDevice.INSTANCE.getDisplayManager().getScreen() == null || (HardwareDevice.INSTANCE.getDisplayManager().error != null && HardwareDevice.INSTANCE.getDisplayManager().error.length() > 0) || HardwareDevice.INSTANCE.getDisplayManager().getScreen() == null || HardwareDevice.INSTANCE.getDisplayManager().getScreen().mustBeRefreshed()) {
|
||||
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()) {
|
||||
INSTANCE.c.paintImmediately(0, 0, getWidth(), getHeight());
|
||||
}
|
||||
}
|
||||
@ -189,4 +190,12 @@ public class CPUEngine implements GraphicEngine {
|
||||
public boolean doesRefreshPauses() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setAlphaChanged(boolean val) {
|
||||
this.INSTANCE.setAlphaChanged(val);
|
||||
}
|
||||
|
||||
public void setShiftChanged(boolean val) {
|
||||
this.INSTANCE.setShiftChanged(val);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,109 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package it.cavallium.warppi.gui.graphicengine.cpu;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.swing.JButton;
|
||||
|
||||
public class JAdvancedButton extends JButton {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8445811316606975284L;
|
||||
public Image backgroundImage;
|
||||
public Dimension backgroundSize;
|
||||
public boolean drawColor = false;
|
||||
public boolean drawDefaultComponent = false;
|
||||
public int state;
|
||||
|
||||
public JAdvancedButton() {
|
||||
this.setOpaque(false);
|
||||
this.backgroundImage = null;
|
||||
this.backgroundSize = new Dimension(0, 0);
|
||||
}
|
||||
|
||||
public JAdvancedButton(final BufferedImage backgroundImage) throws IOException {
|
||||
this.setOpaque(false);
|
||||
this.backgroundImage = backgroundImage;
|
||||
if (backgroundImage != null) {
|
||||
this.backgroundSize = new Dimension(backgroundImage.getWidth(), backgroundImage.getHeight());
|
||||
}
|
||||
this.setMinimumSize(this.backgroundSize);
|
||||
this.setMaximumSize(this.backgroundSize);
|
||||
this.setPreferredSize(this.backgroundSize);
|
||||
this.setSize(this.backgroundSize);
|
||||
}
|
||||
|
||||
public JAdvancedButton(final BufferedImage backgroundImage, final Dimension backgroundSize) throws IOException {
|
||||
this.setOpaque(false);
|
||||
this.backgroundImage = backgroundImage;
|
||||
this.backgroundSize = backgroundSize;
|
||||
this.setMinimumSize(this.backgroundSize);
|
||||
this.setMaximumSize(this.backgroundSize);
|
||||
this.setPreferredSize(this.backgroundSize);
|
||||
this.setSize(this.backgroundSize);
|
||||
}
|
||||
|
||||
public void paintComponent(final Graphics g) {
|
||||
if (drawColor) {
|
||||
final Graphics2D g2d = (Graphics2D) g.create();
|
||||
final AlphaComposite acomp = AlphaComposite.getInstance(3, 1.0f);
|
||||
g2d.setComposite(acomp);
|
||||
g2d.setColor(getBackground());
|
||||
g2d.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
g2d.dispose();
|
||||
}
|
||||
if (this.backgroundImage != null) {
|
||||
final Graphics2D g2d = (Graphics2D) g.create();
|
||||
final AlphaComposite acomp = AlphaComposite.getInstance(3, 1.0f);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
|
||||
g2d.setComposite(acomp);
|
||||
g2d.drawImage(this.backgroundImage, 0, (int) this.backgroundSize.getHeight() * -state, (int) this.backgroundSize.getWidth(), (int) (this.backgroundSize.getHeight() * 3), null);
|
||||
g2d.setFont(g.getFont());
|
||||
g2d.setColor(super.getForeground());
|
||||
g2d.drawString(this.getText(), super.getWidth() / 2 - g.getFontMetrics().stringWidth(this.getText()) / 2, super.getHeight() / 2 + g.getFontMetrics().getHeight() / 4);
|
||||
g2d.dispose();
|
||||
}
|
||||
if (drawDefaultComponent) {
|
||||
super.paintComponent(g);
|
||||
}
|
||||
super.setBorderPainted(drawDefaultComponent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (canclick == false) {
|
||||
return false;
|
||||
}
|
||||
return super.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireActionPerformed(ActionEvent paramActionEvent)
|
||||
{
|
||||
if (this.getCanClick()) {
|
||||
super.fireActionPerformed(paramActionEvent);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCanClick(boolean can) {
|
||||
canclick = can;
|
||||
}
|
||||
|
||||
private boolean canclick = true;
|
||||
|
||||
public boolean getCanClick() {
|
||||
return canclick;
|
||||
}
|
||||
}
|
@ -1,11 +1,18 @@
|
||||
package it.cavallium.warppi.gui.graphicengine.cpu;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Point;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
@ -15,13 +22,18 @@ import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import it.cavallium.warppi.Engine;
|
||||
import it.cavallium.warppi.StaticVars;
|
||||
import it.cavallium.warppi.Utils;
|
||||
import it.cavallium.warppi.deps.Platform.PngUtils.PngReader;
|
||||
import it.cavallium.warppi.device.HardwareDevice;
|
||||
import it.cavallium.warppi.device.Keyboard;
|
||||
import it.cavallium.warppi.event.TouchEndEvent;
|
||||
@ -30,7 +42,9 @@ import it.cavallium.warppi.event.TouchPoint;
|
||||
import it.cavallium.warppi.event.TouchStartEvent;
|
||||
import it.cavallium.warppi.flow.BehaviorSubject;
|
||||
import it.cavallium.warppi.flow.Observable;
|
||||
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
||||
import it.cavallium.warppi.gui.graphicengine.RenderingLoop;
|
||||
import it.cavallium.warppi.gui.graphicengine.common.PngSkin;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
|
||||
public class SwingWindow extends JFrame {
|
||||
@ -41,12 +55,22 @@ public class SwingWindow extends JFrame {
|
||||
private int mult = 1;
|
||||
private BehaviorSubject<Integer[]> onResize;
|
||||
private Observable<Integer[]> onResize$;
|
||||
public JPanel buttonsPanel;
|
||||
private JAdvancedButton[][] buttons;
|
||||
private int BTN_SIZE;
|
||||
|
||||
public SwingWindow(CPUEngine disp) {
|
||||
display = disp;
|
||||
this.setLayout(new BorderLayout());
|
||||
this.setBackground(Color.BLACK);
|
||||
c = new CustomCanvas();
|
||||
c.setDoubleBuffered(false);
|
||||
this.add(c);
|
||||
this.add(c, BorderLayout.CENTER);
|
||||
try {
|
||||
setupButtonsPanel();
|
||||
} catch (IOException | URISyntaxException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
// this.setExtendedState(Frame.MAXIMIZED_BOTH);
|
||||
Toolkit.getDefaultToolkit().setDynamicLayout(false);
|
||||
// Transparent 16 x 16 pixel cursor image.
|
||||
@ -82,7 +106,7 @@ public class SwingWindow extends JFrame {
|
||||
addComponentListener(new ComponentListener() {
|
||||
@Override
|
||||
public void componentHidden(ComponentEvent e) {
|
||||
HardwareDevice.INSTANCE.getDisplayManager().engine.destroy();
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -100,7 +124,9 @@ public class SwingWindow extends JFrame {
|
||||
}
|
||||
}
|
||||
});
|
||||
addKeyListener(new KeyListener() {
|
||||
c.setFocusable(true);
|
||||
c.grabFocus();
|
||||
c.addKeyListener(new KeyListener() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent arg0) {
|
||||
Keyboard.debugKeyCode = arg0.getKeyCode();
|
||||
@ -117,7 +143,7 @@ public class SwingWindow extends JFrame {
|
||||
|
||||
}
|
||||
});
|
||||
addMouseMotionListener(new MouseMotionListener() {
|
||||
c.addMouseMotionListener(new MouseMotionListener() {
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
final Insets wp = SwingWindow.this.getInsets();
|
||||
@ -127,13 +153,13 @@ public class SwingWindow extends JFrame {
|
||||
touches.add(p);
|
||||
changedTouches.add(p);
|
||||
TouchMoveEvent tse = new TouchMoveEvent(changedTouches, touches);
|
||||
HardwareDevice.INSTANCE.getInputManager().getTouchDevice().onTouchMove(tse);
|
||||
Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchMove(tse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {}
|
||||
});
|
||||
addMouseListener(new MouseListener() {
|
||||
c.addMouseListener(new MouseListener() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {}
|
||||
|
||||
@ -146,7 +172,7 @@ public class SwingWindow extends JFrame {
|
||||
touches.add(p);
|
||||
changedTouches.add(p);
|
||||
TouchStartEvent tse = new TouchStartEvent(changedTouches, touches);
|
||||
HardwareDevice.INSTANCE.getInputManager().getTouchDevice().onTouchStart(tse);
|
||||
Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchStart(tse);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -157,7 +183,7 @@ public class SwingWindow extends JFrame {
|
||||
ObjectArrayList<TouchPoint> changedTouches = new ObjectArrayList<>();
|
||||
changedTouches.add(p);
|
||||
TouchEndEvent tse = new TouchEndEvent(changedTouches, touches);
|
||||
HardwareDevice.INSTANCE.getInputManager().getTouchDevice().onTouchEnd(tse);
|
||||
Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchEnd(tse);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -169,12 +195,126 @@ public class SwingWindow extends JFrame {
|
||||
StaticVars.windowZoom$.subscribe((newZoomValue) -> {
|
||||
if (newZoomValue != mult) {
|
||||
mult = (int) newZoomValue.floatValue();
|
||||
this.onResize.onNext(new Integer[] { getWidth(), getHeight() });
|
||||
this.onResize.onNext(new Integer[] { getWWidth(), getWHeight() });
|
||||
Engine.getPlatform().getConsoleUtils().out().println(3, "Engine", "CPU", "Zoom changed");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setupButtonsPanel() throws IOException, URISyntaxException {
|
||||
BTN_SIZE = 32;
|
||||
if (StaticVars.debugWindow2x) {
|
||||
BTN_SIZE *= 2;
|
||||
}
|
||||
|
||||
buttons = new JAdvancedButton[8][8];
|
||||
JPanel buttonsPanelContainer = new JPanel();
|
||||
buttonsPanelContainer.setLayout(new FlowLayout());
|
||||
buttonsPanelContainer.setBackground(Color.BLACK);
|
||||
this.add(buttonsPanelContainer, BorderLayout.PAGE_END);
|
||||
buttonsPanel = new JPanel();
|
||||
buttonsPanelContainer.add(buttonsPanel, BorderLayout.CENTER);
|
||||
buttonsPanel.setLayout(new GridLayout(9, 7));
|
||||
buttonsPanel.setBackground(Color.GRAY);
|
||||
buttonsPanel.setDoubleBuffered(false);
|
||||
buttonsPanel.setVisible(true);
|
||||
for (int row = 0; row < 5; row++) {
|
||||
for (int col = 0; col < 7; col++) {
|
||||
createBtn(row, col);
|
||||
}
|
||||
}
|
||||
for (int row = 5; row < 8; row++) {
|
||||
createBlankBox();
|
||||
for (int col = 0; col < 5; col++) {
|
||||
createBtn(row, col);
|
||||
}
|
||||
createBlankBox();
|
||||
}
|
||||
int b = 7;
|
||||
createBlankBox();
|
||||
for (int a = 4; a >= 0; a--) {
|
||||
createBtn(a, b);
|
||||
}
|
||||
createBlankBox();
|
||||
}
|
||||
|
||||
private void createBlankBox() {
|
||||
JPanel l = new JPanel();
|
||||
l.setPreferredSize(new Dimension((int)(BTN_SIZE * 1.5), BTN_SIZE));
|
||||
l.setBackground(Color.BLACK);
|
||||
buttonsPanel.add(l);
|
||||
}
|
||||
|
||||
private void createBtn(final int row, final int col) throws IOException, URISyntaxException {
|
||||
BufferedImage img = ImageIO.read(Engine.getPlatform().getStorageUtils().getResourceStream("/desktop-buttons.png"));
|
||||
final JAdvancedButton b = new JAdvancedButton(img, new Dimension((int)(BTN_SIZE * 1.5), BTN_SIZE));
|
||||
b.drawDefaultComponent = false;
|
||||
b.setText(Keyboard.getKeyName(row, col));
|
||||
b.setForeground(Color.BLACK);
|
||||
Font f = b.getFont();
|
||||
f = f.deriveFont(Font.BOLD, BTN_SIZE / 3);
|
||||
b.setFont(f);
|
||||
b.setBackground(new Color(200, 200, 200));
|
||||
b.setFocusable(true);
|
||||
b.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Keyboard.keyPressedRaw(row, col);
|
||||
Keyboard.keyReleasedRaw(row, col);
|
||||
c.grabFocus();
|
||||
}
|
||||
});
|
||||
buttons[row][col] = b;
|
||||
buttonsPanel.add(b);
|
||||
}
|
||||
|
||||
public void setAlphaChanged(boolean val) {
|
||||
for (int row = 0; row < buttons.length; row++) {
|
||||
for (int col = 0; col < buttons[0].length; col++) {
|
||||
JAdvancedButton btn = buttons[row][col];
|
||||
if (btn != null) {
|
||||
btn.setText(Keyboard.getKeyName(row, col));
|
||||
if (row == 0 && col == 1) {
|
||||
if (val) {
|
||||
btn.state = 2;
|
||||
} else {
|
||||
btn.state = 0;
|
||||
}
|
||||
}
|
||||
if (val && Keyboard.hasKeyName(row, col)) {
|
||||
btn.setForeground(Color.RED);
|
||||
} else {
|
||||
btn.setForeground(Color.BLACK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setShiftChanged(boolean val) {
|
||||
for (int row = 0; row < buttons.length; row++) {
|
||||
for (int col = 0; col < buttons[0].length; col++) {
|
||||
JAdvancedButton btn = buttons[row][col];
|
||||
if (btn != null) {
|
||||
btn.setText(Keyboard.getKeyName(row, col));
|
||||
if (row == 0 && col == 0) {
|
||||
if (val) {
|
||||
btn.state = 2;
|
||||
} else {
|
||||
btn.state = 0;
|
||||
}
|
||||
}
|
||||
if (val && Keyboard.hasKeyName(row, col)) {
|
||||
btn.setForeground(new Color(255, 120, 0));
|
||||
} else {
|
||||
btn.setForeground(Color.BLACK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Observable<Integer[]> onResize() {
|
||||
return onResize$;
|
||||
}
|
||||
@ -182,24 +322,19 @@ public class SwingWindow extends JFrame {
|
||||
@Override
|
||||
public void setSize(int width, int height) {
|
||||
c.setSize(new Dimension(width * mult, height * mult));
|
||||
c.setPreferredSize(new Dimension(width * mult, height * mult));
|
||||
super.getContentPane().setSize(new Dimension(width * mult, height * mult));
|
||||
super.getContentPane().setPreferredSize(new Dimension(width * mult, height * mult));
|
||||
c.setPreferredSize(new Dimension(width * mult, height * mult ));
|
||||
super.pack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getSize() {
|
||||
return new Dimension(getWidth(), getHeight());
|
||||
public Dimension getWSize() {
|
||||
return new Dimension(getWWidth(), getWHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
public int getWWidth() {
|
||||
return c.getWidth() / mult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
public int getWHeight() {
|
||||
return c.getHeight() / mult;
|
||||
}
|
||||
|
||||
@ -245,4 +380,6 @@ public class SwingWindow extends JFrame {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
BIN
desktop/src/main/resources/desktop-buttons.png
Normal file
BIN
desktop/src/main/resources/desktop-buttons.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 600 B |
BIN
desktop/src/main/resources/desktop-buttons.xcf
Normal file
BIN
desktop/src/main/resources/desktop-buttons.xcf
Normal file
Binary file not shown.
@ -50,6 +50,7 @@ import com.jogamp.opengl.fixedfunc.GLPointerFunc;
|
||||
import com.jogamp.opengl.util.Animator;
|
||||
import com.jogamp.opengl.util.texture.Texture;
|
||||
|
||||
import it.cavallium.warppi.Engine;
|
||||
import it.cavallium.warppi.StaticVars;
|
||||
import it.cavallium.warppi.device.HardwareDevice;
|
||||
import it.cavallium.warppi.device.Keyboard;
|
||||
@ -159,7 +160,7 @@ class NEWTWindow implements GLEventListener {
|
||||
|
||||
@Override
|
||||
public void windowDestroyed(WindowEvent e) {
|
||||
GraphicEngine engine = HardwareDevice.INSTANCE.getDisplayManager().engine;
|
||||
GraphicEngine engine = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine;
|
||||
if (engine.isInitialized()) {
|
||||
engine.destroy();
|
||||
}
|
||||
@ -347,14 +348,14 @@ class NEWTWindow implements GLEventListener {
|
||||
// float[] ps = e.getAllPressures();
|
||||
// short[] is = e.getAllPointerIDs();
|
||||
// for (int i = 0; i < e.getPointerCount(); i++) {
|
||||
// newPoints.add(HardwareDevice.INSTANCE.getInputManager().getTouchDevice().makePoint(is[i], xs[i], ys[i], disp.getWidth(), disp.getHeight(), 5, 5, ps[i], 0));
|
||||
// newPoints.add(Engine.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));
|
||||
// newPoints.remove(0);
|
||||
// touches = newPoints;
|
||||
// HardwareDevice.INSTANCE.getInputManager().getTouchDevice().onTouchStart(new TouchStartEvent(changedPoints, touches));
|
||||
// HardwareDevice.INSTANCE.getInputManager().getTouchDevice().onTouchEnd(new TouchEndEvent(changedPoints, touches));
|
||||
// Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchStart(new TouchStartEvent(changedPoints, touches));
|
||||
// Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchEnd(new TouchEndEvent(changedPoints, touches));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -380,11 +381,11 @@ class NEWTWindow implements GLEventListener {
|
||||
float[] ps = e.getAllPressures();
|
||||
short[] is = e.getAllPointerIDs();
|
||||
for (int i = 0; i < e.getPointerCount(); i++) {
|
||||
newPoints.add(HardwareDevice.INSTANCE.getInputManager().getTouchDevice().makePoint(is[i], xs[i], ys[i], disp.getWidth(), disp.getHeight(), 5, 5, ps[i], 0));
|
||||
newPoints.add(Engine.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));
|
||||
touches = newPoints;
|
||||
HardwareDevice.INSTANCE.getInputManager().getTouchDevice().onTouchStart(new TouchStartEvent(changedPoints, touches));
|
||||
Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchStart(new TouchStartEvent(changedPoints, touches));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -398,12 +399,12 @@ class NEWTWindow implements GLEventListener {
|
||||
float[] ps = e.getAllPressures();
|
||||
short[] is = e.getAllPointerIDs();
|
||||
for (int i = 0; i < e.getPointerCount(); i++) {
|
||||
newPoints.add(HardwareDevice.INSTANCE.getInputManager().getTouchDevice().makePoint(is[i], xs[i], ys[i], disp.getWidth(), disp.getHeight(), 5, 5, ps[i], 0));
|
||||
newPoints.add(Engine.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));
|
||||
newPoints.remove(0);
|
||||
touches = newPoints;
|
||||
HardwareDevice.INSTANCE.getInputManager().getTouchDevice().onTouchEnd(new TouchEndEvent(changedPoints, touches));
|
||||
Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchEnd(new TouchEndEvent(changedPoints, touches));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -424,7 +425,7 @@ class NEWTWindow implements GLEventListener {
|
||||
float[] ps = e.getAllPressures();
|
||||
short[] is = e.getAllPointerIDs();
|
||||
for (int i = 0; i < e.getPointerCount(); i++) {
|
||||
newPoints.add(HardwareDevice.INSTANCE.getInputManager().getTouchDevice().makePoint(is[i], xs[i], ys[i], disp.getWidth(), disp.getHeight(), 5, 5, ps[i], 0));
|
||||
newPoints.add(Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().makePoint(is[i], xs[i], ys[i], disp.getWidth(), disp.getHeight(), 5, 5, ps[i], 0));
|
||||
}
|
||||
newPoints.forEach((newp) -> {
|
||||
oldPoints.forEach((oldp) -> {
|
||||
@ -436,7 +437,7 @@ class NEWTWindow implements GLEventListener {
|
||||
});
|
||||
});
|
||||
touches = newPoints;
|
||||
HardwareDevice.INSTANCE.getInputManager().getTouchDevice().onTouchMove(new TouchMoveEvent(changedPoints, touches));
|
||||
Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchMove(new TouchMoveEvent(changedPoints, touches));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user