Bugfixes
This commit is contained in:
parent
70ff11da7f
commit
26dc8369a7
@ -210,8 +210,8 @@ public class MarioScreen extends Screen {
|
||||
for (int ix = 0; ix < width; ix++) {
|
||||
for (int iy = 0; iy < height; iy++) {
|
||||
final double distX = Math.abs(playerX - ix);
|
||||
final double distY = Math.abs(playerY - iy - 1.5d);
|
||||
if (distX * distX + distY * distY / 2d < 25d) {
|
||||
final double distY = Math.abs(playerY - iy - 1.2d);
|
||||
if (distX * distX + distY * distY / 2d < 270d) {
|
||||
final byte b = w.getBlockIdAt(ix, iy);
|
||||
if (b == 0) {
|
||||
if (blue != 1) {
|
||||
|
@ -377,6 +377,10 @@ public class BlockContainer implements TreeContainer, GraphicalElement {
|
||||
BlockContainer.initialized = true;
|
||||
}
|
||||
|
||||
public static boolean isInitialized() {
|
||||
return BlockContainer.initialized;
|
||||
}
|
||||
|
||||
public static BinaryFont getDefaultFont(final boolean small) {
|
||||
BlockContainer.checkInitialized();
|
||||
return BlockContainer.defFonts[small ? 1 : 0];
|
||||
|
@ -50,7 +50,7 @@ public class LoadingScreen extends Screen {
|
||||
ended = true;
|
||||
StaticVars.windowZoom.submit(previousZoomValue);
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getHUD().show();
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new MarioScreen());
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new MathInputScreen());
|
||||
}
|
||||
mustRefresh = true;
|
||||
}
|
||||
@ -58,7 +58,7 @@ public class LoadingScreen extends Screen {
|
||||
@Override
|
||||
public void render(RenderContext ctx) {
|
||||
DisplayOutputDevice display = d.display;
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().guiSkin.use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().guiSkin.use(display);
|
||||
ctx.getRenderer().glColor3i(255, 255, 255);
|
||||
ctx.getRenderer().glFillRect(ctx.getWidth() / 2f - 80, ctx.getHeight() / 2f - 64, 160, 48, 0, 32, 160, 48);
|
||||
ctx.getRenderer().glFillRect(ctx.getWidth() / 2f - 24, ctx.getHeight() / 2f - loadingTextTranslation, 48, 48, 160, 32, 48, 48);
|
||||
|
@ -45,6 +45,7 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
public class MathInputScreen extends Screen {
|
||||
|
||||
private static final BinaryFont fontBig = Utils.getFont(false);
|
||||
private final boolean isCloned;
|
||||
|
||||
public MathContext calc;
|
||||
public InputContext ic;
|
||||
@ -64,6 +65,7 @@ public class MathInputScreen extends Screen {
|
||||
public MathInputScreen() {
|
||||
super();
|
||||
historyBehavior = HistoryBehavior.NORMAL;
|
||||
isCloned = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,6 +83,7 @@ public class MathInputScreen extends Screen {
|
||||
this.mustRefresh = old.mustRefresh;
|
||||
this.result = new NormalOutputContainer(old.result);
|
||||
this.userInput = new NormalInputContainer(old.userInput, this.ic);
|
||||
this.isCloned = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -100,15 +103,19 @@ public class MathInputScreen extends Screen {
|
||||
public void graphicInitialized(ScreenContext ctx) throws InterruptedException {
|
||||
/* Fine caricamento */
|
||||
try {
|
||||
if (!BlockContainer.isInitialized()) {
|
||||
BlockContainer.initializeFonts(ctx.getGraphicEngine().loadFont("norm"), ctx.getGraphicEngine().loadFont("smal"));
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
WarpPI.getPlatform().exit(1);
|
||||
}
|
||||
|
||||
if (!isCloned) {
|
||||
userInput = new NormalInputContainer(ic);
|
||||
result = new NormalOutputContainer();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeRender(final ScreenContext ctx, final float dt) {
|
||||
|
@ -27,7 +27,7 @@ public class Timer {
|
||||
}
|
||||
});
|
||||
WarpPI.getPlatform().setThreadName(thread, "Timer");
|
||||
thread.setDaemon(true);
|
||||
WarpPI.getPlatform().setThreadDaemon(thread, true);
|
||||
thread.start();
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,25 @@
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>build-desktop-jar</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Maven Assembly Plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@ -81,14 +100,8 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
@ -5,6 +5,7 @@ import java.awt.event.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import it.cavallium.warppi.WarpPI;
|
||||
import it.cavallium.warppi.StaticVars;
|
||||
@ -118,9 +119,10 @@ public class SwingEngine implements GraphicEngine {
|
||||
|
||||
@Deprecated()
|
||||
public void refresh() {
|
||||
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())
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void repaint() {
|
||||
|
@ -1,34 +1,20 @@
|
||||
package it.cavallium.warppi.gui.graphicengine.impl.swing;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import it.cavallium.warppi.StaticVars;
|
||||
import it.cavallium.warppi.WarpPI;
|
||||
import it.cavallium.warppi.device.input.Keyboard;
|
||||
import it.cavallium.warppi.gui.graphicengine.RenderingLoop;
|
||||
import it.cavallium.warppi.util.EventSubmitter;
|
||||
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
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.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import it.cavallium.warppi.WarpPI;
|
||||
import it.cavallium.warppi.device.input.Keyboard;
|
||||
import it.cavallium.warppi.StaticVars;
|
||||
import it.cavallium.warppi.event.TouchEndEvent;
|
||||
import it.cavallium.warppi.event.TouchMoveEvent;
|
||||
import it.cavallium.warppi.event.TouchPoint;
|
||||
import it.cavallium.warppi.event.TouchStartEvent;
|
||||
import it.cavallium.warppi.gui.graphicengine.RenderingLoop;
|
||||
import it.cavallium.warppi.util.EventSubmitter;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
|
||||
public class SwingWindow extends JFrame {
|
||||
private static final long serialVersionUID = 2945898937634075491L;
|
||||
private final int defaultWidth;
|
||||
@ -124,7 +110,8 @@ public class SwingWindow extends JFrame {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentMoved(final ComponentEvent e) {}
|
||||
public void componentMoved(final ComponentEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentResized(final ComponentEvent e) {
|
||||
@ -232,11 +219,13 @@ public class SwingWindow extends JFrame {
|
||||
Keyboard.keyRaw(row, col, true);
|
||||
c.grabFocus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
Keyboard.keyRaw(row, col, false);
|
||||
c.grabFocus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
if (b.state == 2) {
|
||||
@ -247,6 +236,7 @@ public class SwingWindow extends JFrame {
|
||||
b.hover = false;
|
||||
b.repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
if (b.state == 2) {
|
||||
@ -257,6 +247,7 @@ public class SwingWindow extends JFrame {
|
||||
b.hover = true;
|
||||
b.repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
@ -173,7 +173,102 @@ class NEWTWindow implements GLEventListener {
|
||||
glWindow.addKeyListener(new KeyListener() {
|
||||
@Override
|
||||
public void keyPressed(final KeyEvent arg0) {
|
||||
Keyboard.debugKeyCode = arg0.getKeyCode();
|
||||
switch (arg0.getKeyCode()) {
|
||||
case KeyEvent.VK_ESCAPE:
|
||||
Keyboard.keyPressed(Key.POWEROFF);
|
||||
break;
|
||||
case KeyEvent.VK_D:
|
||||
Keyboard.keyPressed(Key.debug_DEG);
|
||||
break;
|
||||
case KeyEvent.VK_R:
|
||||
Keyboard.keyPressed(Key.debug_RAD);
|
||||
break;
|
||||
case KeyEvent.VK_G:
|
||||
Keyboard.keyPressed(Key.debug_GRA);
|
||||
break;
|
||||
case KeyEvent.VK_X:
|
||||
if (Keyboard.alpha)
|
||||
Keyboard.keyPressed(Key.LETTER_X);
|
||||
else
|
||||
Keyboard.keyPressed(Key.NONE);
|
||||
break;
|
||||
case KeyEvent.VK_P:
|
||||
if (Keyboard.alpha)
|
||||
Keyboard.keyPressed(Key.PI);
|
||||
else
|
||||
Keyboard.keyPressed(Key.NONE);
|
||||
break;
|
||||
case KeyEvent.VK_B:
|
||||
if (Keyboard.shift)
|
||||
Keyboard.keyPressed(Key.BRIGHTNESS_CYCLE_REVERSE);
|
||||
else if (!Keyboard.shift && !Keyboard.alpha)
|
||||
Keyboard.keyPressed(Key.BRIGHTNESS_CYCLE);
|
||||
else
|
||||
Keyboard.keyPressed(Key.ZOOM_MODE);
|
||||
break;
|
||||
case KeyEvent.VK_ENTER:
|
||||
if (!Keyboard.shift && !Keyboard.alpha)
|
||||
Keyboard.keyPressed(Key.SIMPLIFY);
|
||||
else
|
||||
Keyboard.keyPressed(Key.NONE);
|
||||
int row = 2;
|
||||
int col = 1;
|
||||
Keyboard.debugKeysDown[row - 1][col - 1] = true;
|
||||
break;
|
||||
case KeyEvent.VK_1:
|
||||
if (!Keyboard.shift && !Keyboard.alpha)
|
||||
Keyboard.keyPressed(Key.debug1);
|
||||
else
|
||||
Keyboard.keyPressed(Key.NONE);
|
||||
break;
|
||||
case KeyEvent.VK_2:
|
||||
if (!Keyboard.shift && !Keyboard.alpha)
|
||||
Keyboard.keyPressed(Key.debug2);
|
||||
else
|
||||
Keyboard.keyPressed(Key.NONE);
|
||||
break;
|
||||
case KeyEvent.VK_3:
|
||||
if (!Keyboard.shift && !Keyboard.alpha)
|
||||
Keyboard.keyPressed(Key.debug3);
|
||||
else
|
||||
Keyboard.keyPressed(Key.NONE);
|
||||
break;
|
||||
case KeyEvent.VK_4:
|
||||
if (!Keyboard.shift && !Keyboard.alpha)
|
||||
Keyboard.keyPressed(Key.debug4);
|
||||
else
|
||||
Keyboard.keyPressed(Key.NONE);
|
||||
break;
|
||||
case KeyEvent.VK_5:
|
||||
if (!Keyboard.shift && !Keyboard.alpha)
|
||||
Keyboard.keyPressed(Key.debug5);
|
||||
else
|
||||
Keyboard.keyPressed(Key.NONE);
|
||||
break;
|
||||
case 0x15:
|
||||
case KeyEvent.VK_SHIFT:
|
||||
Keyboard.keyPressed(Key.SHIFT);
|
||||
break;
|
||||
case KeyEvent.VK_CONTROL:
|
||||
Keyboard.keyPressed(Key.ALPHA);
|
||||
break;
|
||||
case KeyEvent.VK_M:
|
||||
Keyboard.keyPressed(Key.SURD_MODE);
|
||||
break;
|
||||
case KeyEvent.VK_LEFT:
|
||||
Keyboard.keyPressed(Key.LEFT);
|
||||
break;
|
||||
case KeyEvent.VK_RIGHT:
|
||||
Keyboard.keyPressed(Key.RIGHT);
|
||||
break;
|
||||
case KeyEvent.VK_UP:
|
||||
Keyboard.keyPressed(Key.UP);
|
||||
break;
|
||||
case KeyEvent.VK_DOWN:
|
||||
case (short) 12:
|
||||
Keyboard.keyPressed(Key.DOWN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -269,34 +364,17 @@ class NEWTWindow implements GLEventListener {
|
||||
Keyboard.keyPressed(Key.SURD_MODE);
|
||||
break;
|
||||
case KeyEvent.VK_LEFT:
|
||||
//LEFT
|
||||
row = 2;
|
||||
col = 3;
|
||||
Keyboard.debugKeysDown[row - 1][col - 1] = false;
|
||||
Keyboard.keyReleased(Key.LEFT);
|
||||
break;
|
||||
case KeyEvent.VK_RIGHT:
|
||||
//RIGHT
|
||||
row = 2;
|
||||
col = 5;
|
||||
Keyboard.debugKeysDown[row - 1][col - 1] = false;
|
||||
Keyboard.keyReleased(Key.RIGHT);
|
||||
break;
|
||||
case KeyEvent.VK_UP:
|
||||
//UP
|
||||
row = 1;
|
||||
col = 4;
|
||||
Keyboard.debugKeysDown[row - 1][col - 1] = false;
|
||||
Keyboard.keyReleased(Key.UP);
|
||||
break;
|
||||
case KeyEvent.VK_DOWN:
|
||||
//Down
|
||||
row = 3;
|
||||
col = 4;
|
||||
Keyboard.debugKeysDown[row - 1][col - 1] = false;
|
||||
break;
|
||||
case (short) 12:
|
||||
//Down
|
||||
row = 2;
|
||||
col = 4;
|
||||
Keyboard.debugKeysDown[row - 1][col - 1] = false;
|
||||
Keyboard.keyReleased(Key.DOWN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
11
pom.xml
11
pom.xml
@ -45,8 +45,19 @@
|
||||
<!-- <module>hardware</module> -->
|
||||
<module>desktop</module>
|
||||
<module>engine-jogl</module>
|
||||
</modules>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>generate-js</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>teavm</module>
|
||||
</modules>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
|
6
rules/rules.list
Normal file
6
rules/rules.list
Normal file
@ -0,0 +1,6 @@
|
||||
expand.rules
|
||||
exponent.rules
|
||||
fractions.rules
|
||||
number.rules
|
||||
undefined.rules
|
||||
variable.rules
|
@ -22,7 +22,7 @@
|
||||
<dependency>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-classlib</artifactId>
|
||||
<version>0.7.0-dev-916</version>
|
||||
<version>0.7.0-dev-859</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@ -81,7 +81,7 @@
|
||||
<plugin>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-maven-plugin</artifactId>
|
||||
<version>0.7.0-dev-916</version>
|
||||
<version>0.7.0-dev-859</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@ -91,10 +91,12 @@
|
||||
<configuration>
|
||||
<mainClass>it.cavallium.warppi.teavm.TeaVMBoot</mainClass>
|
||||
<mainPageIncluded>true</mainPageIncluded>
|
||||
<debugInformationGenerated>true</debugInformationGenerated>
|
||||
<debugInformationGenerated>false</debugInformationGenerated>
|
||||
<sourceMapsGenerated>true</sourceMapsGenerated>
|
||||
<sourceFilesCopied>true</sourceFilesCopied>
|
||||
<optimizationLevel>FULL</optimizationLevel>
|
||||
<minifying>true</minifying>
|
||||
<runtime>SEPARATE</runtime>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
@ -1,6 +1,7 @@
|
||||
package it.cavallium.warppi.gui.graphicengine.html;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import it.cavallium.warppi.util.EventSubmitter;
|
||||
import org.teavm.jso.JSBody;
|
||||
@ -28,7 +29,6 @@ import it.unimi.dsi.fastutil.objects.Object2IntArrayMap;
|
||||
public class HtmlEngine implements GraphicEngine {
|
||||
|
||||
private boolean initialized;
|
||||
public Semaphore exitSemaphore;
|
||||
private static final HTMLDocument document = Window.current().getDocument();
|
||||
private HTMLCanvasElement canvas;
|
||||
private CanvasRenderingContext2D g;
|
||||
@ -39,6 +39,7 @@ public class HtmlEngine implements GraphicEngine {
|
||||
private final int frameTime = (int) (1000d / 10d);
|
||||
private final EventSubmitter<Integer[]> onResize = EventSubmitter.create();
|
||||
private final EventSubmitter<Float> onZoom = EventSubmitter.create();
|
||||
private AtomicBoolean exitRequested = new AtomicBoolean();
|
||||
|
||||
@Override
|
||||
public int[] getSize() {
|
||||
@ -85,7 +86,6 @@ public class HtmlEngine implements GraphicEngine {
|
||||
|
||||
@Override
|
||||
public void create(final Runnable onInitialized) {
|
||||
exitSemaphore = WarpPI.getPlatform().newSemaphore(0);
|
||||
width = -1;
|
||||
height = -1;
|
||||
canvas = (HTMLCanvasElement) HtmlEngine.document.createElement("canvas");
|
||||
@ -253,7 +253,7 @@ public class HtmlEngine implements GraphicEngine {
|
||||
private void destroyEngine() {
|
||||
HtmlEngine.document.getBody().removeChild(canvas);
|
||||
initialized = false;
|
||||
exitSemaphore.release();
|
||||
exitRequested.set(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -313,11 +313,13 @@ public class HtmlEngine implements GraphicEngine {
|
||||
public void subscribeExit(Runnable subscriber) {
|
||||
var thr = new Thread(() -> {
|
||||
try {
|
||||
exitSemaphore.acquire();
|
||||
while(!exitRequested.get()) {
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
} catch (final InterruptedException e) {}
|
||||
subscriber.run();
|
||||
});
|
||||
thr.setDaemon(true);
|
||||
WarpPI.getPlatform().setThreadDaemon(thr, true);
|
||||
thr.start();
|
||||
}
|
||||
|
||||
|
@ -46,10 +46,14 @@ public class HtmlFont extends RFTFont {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitialized() {
|
||||
return super.isInitialized();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use(final DisplayOutputDevice d) {
|
||||
if (d.getGraphicEngine().getRenderer() instanceof HtmlRenderer)
|
||||
((HtmlRenderer) d.getGraphicEngine().getRenderer()).f = this;
|
||||
((HtmlEngine) d.getGraphicEngine()).getRenderer().f = this;
|
||||
}
|
||||
|
||||
}
|
@ -230,54 +230,4 @@ public class HtmlRenderer implements Renderer {
|
||||
public HtmlFont getCurrentFont() {
|
||||
return f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HtmlRenderer getBoundedInstance(int dx, int dy, int width, int height) {
|
||||
return new HtmlRenderer(e, g) {
|
||||
@Override
|
||||
public void glDrawLine(float x0, float y0, float x1, float y1) {
|
||||
super.glDrawLine(x0 + dx, y0 + dy, x1, y1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDrawCharCenter(int x, int y, char ch) {
|
||||
super.glDrawCharCenter(x + dx, y + dy, ch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDrawCharLeft(int x, int y, char ch) {
|
||||
super.glDrawCharLeft(x + dx, y + dy, ch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDrawCharRight(int x, int y, char ch) {
|
||||
super.glDrawCharRight(x + dx, y + dy, ch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glFillColor(float x0, float y0, float w1, float h1) {
|
||||
super.glFillColor(x0 + dx, y0 + dy, w1, h1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glFillRect(float x, float y, float width, float height, float uvX, float uvY, float uvWidth, float uvHeight) {
|
||||
super.glFillRect(x + dx, y + dy, width, height, uvX, uvY, uvWidth, uvHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDrawStringCenter(float x, float y, String text) {
|
||||
super.glDrawStringCenter(x + dx, y + dy, text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDrawStringLeft(float x, float y, String text) {
|
||||
super.glDrawStringLeft(x + dx, y + dy, text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDrawStringRight(float x, float y, String text) {
|
||||
super.glDrawStringRight(x + dx, y + dy, text);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package it.cavallium.warppi.gui.graphicengine.html;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.teavm.jso.browser.Window;
|
||||
@ -30,11 +31,9 @@ public class HtmlSkin implements Skin {
|
||||
|
||||
@Override
|
||||
public void use(final DisplayOutputDevice d) {
|
||||
if (d instanceof HtmlEngine) {
|
||||
if (!initd)
|
||||
initialize(d);
|
||||
((HtmlEngine) d).getRenderer().currentSkin = this;
|
||||
}
|
||||
((HtmlEngine) d.getGraphicEngine()).getRenderer().currentSkin = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -45,13 +44,13 @@ public class HtmlSkin implements Skin {
|
||||
@Override
|
||||
public void initialize(final DisplayOutputDevice d) {
|
||||
final HTMLDocument doc = Window.current().getDocument();
|
||||
Boolean[] done = new Boolean[]{false};
|
||||
AtomicBoolean done = new AtomicBoolean(false);
|
||||
imgEl = doc.createElement("img").cast();
|
||||
imgEl.addEventListener("load", (Event e) -> {
|
||||
done[0] = true;
|
||||
done.set(true);
|
||||
});
|
||||
imgEl.setSrc(url);
|
||||
while (!done[0]) {
|
||||
while (!done.get()) {
|
||||
try {Thread.sleep(15);} catch (Exception e) {}
|
||||
}
|
||||
skinSize = new int[] { imgEl.getNaturalWidth(), imgEl.getNaturalHeight() };
|
||||
|
@ -7,6 +7,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import it.cavallium.warppi.boot.StartupArguments;
|
||||
import it.cavallium.warppi.device.DeviceStateDevice;
|
||||
@ -15,6 +16,7 @@ import it.cavallium.warppi.device.display.NoDisplaysAvailableException;
|
||||
import it.cavallium.warppi.device.display.NullBacklightOutputDevice;
|
||||
import it.cavallium.warppi.device.input.KeyboardInputDevice;
|
||||
import it.cavallium.warppi.device.input.TouchInputDevice;
|
||||
import it.cavallium.warppi.event.TouchEvent;
|
||||
import it.cavallium.warppi.gui.graphicengine.html.HtmlDeviceState;
|
||||
import it.cavallium.warppi.gui.graphicengine.html.HtmlDisplayOutputDevice;
|
||||
import org.teavm.jso.browser.Window;
|
||||
@ -224,7 +226,41 @@ public class TeaVMPlatform implements Platform {
|
||||
if (displayOutputDevice instanceof HtmlDisplayOutputDevice) {
|
||||
//this.touchInputDevice = new HtmlTouchInputDevice((HtmlEngine) displayOutputDevice.getGraphicEngine());
|
||||
|
||||
this.keyboardInputDevice = null;
|
||||
//todo: implement
|
||||
this.touchInputDevice = new TouchInputDevice() {
|
||||
@Override
|
||||
public boolean getSwappedAxes() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getInvertedX() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getInvertedY() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void listenTouchEvents(Consumer<TouchEvent> touchEventListener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
//todo: implement
|
||||
this.keyboardInputDevice = new KeyboardInputDevice() {
|
||||
@Override
|
||||
public void initialize() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
this.deviceStateDevice = new HtmlDeviceState((HtmlEngine) displayOutputDevice.getGraphicEngine());
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class TeaVMStorageUtils implements StorageUtils {
|
||||
return new FileInputStream(targetFile);
|
||||
else
|
||||
TeaVMStorageUtils.resourcesCache.remove(path);
|
||||
final URL res = new URL(getBasePath() + path);
|
||||
final URL res = new URL(getBasePath() + (path.startsWith("/") ? path : "/" + path));
|
||||
final InputStream initialStream = res.openStream();
|
||||
final byte[] buffer = new byte[initialStream.available()];
|
||||
initialStream.read(buffer);
|
||||
|
Loading…
Reference in New Issue
Block a user