mirror of
https://github.com/Eaglercraft-Archive/Eaglercraftx-1.8.8-src.git
synced 2025-06-28 10:58:15 -05:00
Update #40 - FPS boost and fixed IndexOutOfBoundsException
This commit is contained in:
@ -117,7 +117,7 @@ public class PlatformApplication {
|
||||
@JSBody(params = { "cb" }, script = "if(!navigator.clipboard) { cb(prompt(\"Please enter the text to paste:\") || \"\"); } else if (!navigator.clipboard.readText) cb(\"\"); else navigator.clipboard.readText().then(function(s) { cb(s); }, function(s) { cb(\"\"); });")
|
||||
private static native void getClipboard1(StupidFunctionResolveString cb);
|
||||
|
||||
@JSBody(params = { "str" }, script = "if(navigator.clipboard) clipboard.writeText(str);")
|
||||
@JSBody(params = { "str" }, script = "if(navigator.clipboard) navigator.clipboard.writeText(str);")
|
||||
private static native void setClipboard0(String str);
|
||||
|
||||
public static void setLocalStorage(String name, byte[] data) {
|
||||
|
@ -119,6 +119,7 @@ public class PlatformAudio {
|
||||
public void restart() {
|
||||
if(isEnded) {
|
||||
isEnded = false;
|
||||
isPaused = false;
|
||||
AudioBufferSourceNode src = audioctx.createBufferSource();
|
||||
resource.cacheHit = PlatformRuntime.steadyTimeMillis();
|
||||
src.setBuffer(resource.buffer);
|
||||
@ -302,13 +303,11 @@ public class PlatformAudio {
|
||||
}
|
||||
gameRecGain = audioctx.createGain();
|
||||
gameRecGain.getGain().setValue(gameVol);
|
||||
synchronized(activeSounds) {
|
||||
for(BrowserAudioHandle handle : activeSounds) {
|
||||
if(handle.panner != null) {
|
||||
handle.panner.connect(gameRecGain);
|
||||
}else {
|
||||
handle.gain.connect(gameRecGain);
|
||||
}
|
||||
for(BrowserAudioHandle handle : activeSounds) {
|
||||
if(handle.panner != null) {
|
||||
handle.panner.connect(gameRecGain);
|
||||
}else {
|
||||
handle.gain.connect(gameRecGain);
|
||||
}
|
||||
}
|
||||
PlatformVoiceClient.addRecordingDest(gameRecGain);
|
||||
@ -341,16 +340,14 @@ public class PlatformAudio {
|
||||
gameRecGain.disconnect();
|
||||
}catch(Throwable t) {
|
||||
}
|
||||
synchronized(activeSounds) {
|
||||
for(BrowserAudioHandle handle : activeSounds) {
|
||||
try {
|
||||
if(handle.panner != null) {
|
||||
handle.panner.disconnect(gameRecGain);
|
||||
}else {
|
||||
handle.gain.disconnect(gameRecGain);
|
||||
}
|
||||
}catch(Throwable t) {
|
||||
for(BrowserAudioHandle handle : activeSounds) {
|
||||
try {
|
||||
if(handle.panner != null) {
|
||||
handle.panner.disconnect(gameRecGain);
|
||||
}else {
|
||||
handle.gain.disconnect(gameRecGain);
|
||||
}
|
||||
}catch(Throwable t) {
|
||||
}
|
||||
}
|
||||
PlatformVoiceClient.removeRecordingDest(gameRecGain);
|
||||
@ -361,18 +358,13 @@ public class PlatformAudio {
|
||||
}
|
||||
|
||||
public static IAudioResource loadAudioData(String filename, boolean holdInCache) {
|
||||
BrowserAudioResource buffer;
|
||||
synchronized(soundCache) {
|
||||
buffer = soundCache.get(filename);
|
||||
}
|
||||
BrowserAudioResource buffer = soundCache.get(filename);
|
||||
if(buffer == null) {
|
||||
byte[] file = PlatformAssets.getResourceBytes(filename);
|
||||
if(file == null) return null;
|
||||
buffer = new BrowserAudioResource(decodeAudioData(file, filename));
|
||||
if(holdInCache) {
|
||||
synchronized(soundCache) {
|
||||
soundCache.put(filename, buffer);
|
||||
}
|
||||
soundCache.put(filename, buffer);
|
||||
}
|
||||
}
|
||||
if(buffer.buffer != null) {
|
||||
@ -383,23 +375,14 @@ public class PlatformAudio {
|
||||
}
|
||||
}
|
||||
|
||||
public static interface IAudioCacheLoader {
|
||||
byte[] loadFile(String filename);
|
||||
}
|
||||
|
||||
public static IAudioResource loadAudioDataNew(String filename, boolean holdInCache, IAudioCacheLoader loader) {
|
||||
BrowserAudioResource buffer;
|
||||
synchronized(soundCache) {
|
||||
buffer = soundCache.get(filename);
|
||||
}
|
||||
BrowserAudioResource buffer = soundCache.get(filename);
|
||||
if(buffer == null) {
|
||||
byte[] file = loader.loadFile(filename);
|
||||
if(file == null) return null;
|
||||
buffer = new BrowserAudioResource(decodeAudioData(file, filename));
|
||||
if(holdInCache) {
|
||||
synchronized(soundCache) {
|
||||
soundCache.put(filename, buffer);
|
||||
}
|
||||
soundCache.put(filename, buffer);
|
||||
}
|
||||
}
|
||||
if(buffer.buffer != null) {
|
||||
@ -457,35 +440,27 @@ public class PlatformAudio {
|
||||
long millis = PlatformRuntime.steadyTimeMillis();
|
||||
if(millis - cacheFreeTimer > 30000l) {
|
||||
cacheFreeTimer = millis;
|
||||
synchronized(soundCache) {
|
||||
Iterator<BrowserAudioResource> itr = soundCache.values().iterator();
|
||||
while(itr.hasNext()) {
|
||||
if(millis - itr.next().cacheHit > 600000l) { // 10 minutes
|
||||
itr.remove();
|
||||
}
|
||||
Iterator<BrowserAudioResource> itr = soundCache.values().iterator();
|
||||
while(itr.hasNext()) {
|
||||
if(millis - itr.next().cacheHit > 600000l) { // 10 minutes
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(millis - activeFreeTimer > 700l) {
|
||||
activeFreeTimer = millis;
|
||||
synchronized(activeSounds) {
|
||||
Iterator<BrowserAudioHandle> itr = activeSounds.iterator();
|
||||
while(itr.hasNext()) {
|
||||
if(itr.next().shouldFree()) {
|
||||
itr.remove();
|
||||
}
|
||||
Iterator<BrowserAudioHandle> itr = activeSounds.iterator();
|
||||
while(itr.hasNext()) {
|
||||
if(itr.next().shouldFree()) {
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void flushAudioCache() {
|
||||
synchronized(soundCache) {
|
||||
soundCache.clear();
|
||||
}
|
||||
synchronized(activeSounds) {
|
||||
activeSounds.clear();
|
||||
}
|
||||
soundCache.clear();
|
||||
activeSounds.clear();
|
||||
}
|
||||
|
||||
public static boolean available() {
|
||||
@ -529,9 +504,7 @@ public class PlatformAudio {
|
||||
src.start();
|
||||
|
||||
BrowserAudioHandle ret = new BrowserAudioHandle(internalTrack, src, panner, gain, pitch);
|
||||
synchronized(activeSounds) {
|
||||
activeSounds.add(ret);
|
||||
}
|
||||
activeSounds.add(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -557,9 +530,7 @@ public class PlatformAudio {
|
||||
src.start();
|
||||
|
||||
BrowserAudioHandle ret = new BrowserAudioHandle(internalTrack, src, null, gain, pitch);
|
||||
synchronized(activeSounds) {
|
||||
activeSounds.add(ret);
|
||||
}
|
||||
activeSounds.add(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -574,7 +545,7 @@ public class PlatformAudio {
|
||||
}
|
||||
|
||||
static void destroy() {
|
||||
soundCache.clear();
|
||||
flushAudioCache();
|
||||
if(audioctx != null) {
|
||||
audioctx.close();
|
||||
audioctx = null;
|
||||
|
@ -37,6 +37,7 @@ import org.teavm.jso.gamepad.Gamepad;
|
||||
import org.teavm.jso.gamepad.GamepadButton;
|
||||
import org.teavm.jso.gamepad.GamepadEvent;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.Display;
|
||||
import net.lax1dude.eaglercraft.v1_8.EagUtils;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.teavm.ClientMain;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.teavm.EarlyLoadScreen;
|
||||
@ -883,6 +884,12 @@ public class PlatformInput {
|
||||
static native double getDevicePixelRatio(Window win);
|
||||
|
||||
public static void update() {
|
||||
update(0);
|
||||
}
|
||||
|
||||
private static final long[] syncTimer = new long[1];
|
||||
|
||||
public static void update(int fpsLimit) {
|
||||
double r = getDevicePixelRatio(win);
|
||||
if(r < 0.01) r = 1.0;
|
||||
windowDPI = (float)r;
|
||||
@ -934,12 +941,21 @@ public class PlatformInput {
|
||||
PlatformScreenRecord.captureFrameHook();
|
||||
if(getVisibilityState(win.getDocument())) {
|
||||
if(vsyncSupport && vsync) {
|
||||
syncTimer[0] = 0l;
|
||||
asyncRequestAnimationFrame();
|
||||
}else {
|
||||
PlatformRuntime.swapDelayTeaVM();
|
||||
if(fpsLimit <= 0) {
|
||||
syncTimer[0] = 0l;
|
||||
PlatformRuntime.swapDelayTeaVM();
|
||||
}else {
|
||||
if(!Display.sync(fpsLimit, syncTimer)) {
|
||||
PlatformRuntime.swapDelayTeaVM();
|
||||
}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
EagUtils.sleep(50l);
|
||||
syncTimer[0] = 0l;
|
||||
EagUtils.sleep(50);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1177,6 +1193,10 @@ public class PlatformInput {
|
||||
enableRepeatEvents = b;
|
||||
}
|
||||
|
||||
public static boolean keyboardAreKeysLocked() {
|
||||
return lockKeys;
|
||||
}
|
||||
|
||||
public static boolean mouseNext() {
|
||||
currentEvent = null;
|
||||
synchronized(mouseEvents) {
|
||||
@ -1262,7 +1282,7 @@ public class PlatformInput {
|
||||
}
|
||||
|
||||
public static boolean mouseIsButtonDown(int i) {
|
||||
return buttonStates[i];
|
||||
return (i < 0 || i >= buttonStates.length) ? false : buttonStates[i];
|
||||
}
|
||||
|
||||
public static int mouseGetDWheel() {
|
||||
@ -1553,7 +1573,7 @@ public class PlatformInput {
|
||||
EarlyLoadScreen.paintEnable(PlatformOpenGL.checkVAOCapable(), allowBootMenu);
|
||||
|
||||
while(mouseEvents.isEmpty() && keyEvents.isEmpty() && touchEvents.isEmpty()) {
|
||||
EagUtils.sleep(100l);
|
||||
EagUtils.sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1720,13 +1740,13 @@ public class PlatformInput {
|
||||
}
|
||||
|
||||
@JSBody(params = { "doc" }, script = "doc.exitFullscreen();")
|
||||
private static native void exitFullscreen(HTMLDocument doc);
|
||||
private static native void exitFullscreen(HTMLDocument doc);
|
||||
|
||||
@JSBody(params = { "doc" }, script = "doc.webkitExitFullscreen();")
|
||||
private static native void webkitExitFullscreen(HTMLDocument doc);
|
||||
private static native void webkitExitFullscreen(HTMLDocument doc);
|
||||
|
||||
@JSBody(params = { "doc" }, script = "doc.mozCancelFullscreen();")
|
||||
private static native void mozCancelFullscreen(HTMLDocument doc);
|
||||
private static native void mozCancelFullscreen(HTMLDocument doc);
|
||||
|
||||
public static void showCursor(EnumCursorType cursor) {
|
||||
switch(cursor) {
|
||||
@ -1843,20 +1863,13 @@ public class PlatformInput {
|
||||
return ret != null ? ret.intValue() : -1;
|
||||
};
|
||||
|
||||
public static void touchBufferFlush() {
|
||||
pointerLockSupported = 0;
|
||||
pointerLockFlag = true;
|
||||
currentTouchState = null;
|
||||
touchEvents.clear();
|
||||
}
|
||||
|
||||
// Note: this can't be called from the main loop, don't try
|
||||
private static void touchOpenDeviceKeyboard() {
|
||||
if(!touchIsDeviceKeyboardOpenMAYBE()) {
|
||||
if(touchKeyboardField != null) {
|
||||
touchKeyboardField.blur();
|
||||
touchKeyboardField.setValue("");
|
||||
EagUtils.sleep(10l);
|
||||
EagUtils.sleep(10);
|
||||
if(touchKeyboardForm != null) {
|
||||
touchKeyboardForm.removeChild(touchKeyboardField);
|
||||
}else {
|
||||
@ -2127,7 +2140,7 @@ public class PlatformInput {
|
||||
touchKeyboardField.blur();
|
||||
touchKeyboardField.setValue("");
|
||||
if(sync) {
|
||||
EagUtils.sleep(10l);
|
||||
EagUtils.sleep(10);
|
||||
if(touchKeyboardForm != null) {
|
||||
touchKeyboardForm.removeChild(touchKeyboardField);
|
||||
}else {
|
||||
|
@ -469,10 +469,10 @@ public class PlatformOpenGL {
|
||||
data == null ? null : EaglerArrayBufferAllocator.getDataView8Unsigned(data));
|
||||
}
|
||||
|
||||
public static final void _wglTexImage2D(int target, int level, int internalFormat, int width,
|
||||
public static final void _wglTexImage2Df32(int target, int level, int internalFormat, int width,
|
||||
int height, int border, int format, int type, FloatBuffer data) {
|
||||
ctx.texImage2D(target, level, internalFormat, width, height, border, format, type,
|
||||
data == null ? null : EaglerArrayBufferAllocator.getDataView8Unsigned(data));
|
||||
data == null ? null : EaglerArrayBufferAllocator.getDataView32F(data));
|
||||
}
|
||||
|
||||
public static final void _wglTexSubImage2D(int target, int level, int xoffset, int yoffset,
|
||||
@ -493,10 +493,10 @@ public class PlatformOpenGL {
|
||||
data == null ? null : EaglerArrayBufferAllocator.getDataView8Unsigned(data));
|
||||
}
|
||||
|
||||
public static final void _wglTexSubImage2D(int target, int level, int xoffset, int yoffset,
|
||||
public static final void _wglTexSubImage2Df32(int target, int level, int xoffset, int yoffset,
|
||||
int width, int height, int format, int type, FloatBuffer data) {
|
||||
ctx.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type,
|
||||
data == null ? null : EaglerArrayBufferAllocator.getDataView8Unsigned(data));
|
||||
data == null ? null : EaglerArrayBufferAllocator.getDataView32F(data));
|
||||
}
|
||||
|
||||
public static final void _wglCopyTexSubImage2D(int target, int level, int xoffset, int yoffset,
|
||||
@ -517,19 +517,19 @@ public class PlatformOpenGL {
|
||||
}
|
||||
|
||||
public static final void _wglShaderSource(IShaderGL obj, String source) {
|
||||
ctx.shaderSource(obj == null ? null : ((OpenGLObjects.ShaderGL)obj).ptr, source);
|
||||
ctx.shaderSource(((OpenGLObjects.ShaderGL)obj).ptr, source);
|
||||
}
|
||||
|
||||
public static final void _wglCompileShader(IShaderGL obj) {
|
||||
ctx.compileShader(obj == null ? null : ((OpenGLObjects.ShaderGL)obj).ptr);
|
||||
ctx.compileShader(((OpenGLObjects.ShaderGL)obj).ptr);
|
||||
}
|
||||
|
||||
public static final int _wglGetShaderi(IShaderGL obj, int param) {
|
||||
return ctx.getShaderParameteri(obj == null ? null : ((OpenGLObjects.ShaderGL)obj).ptr, param);
|
||||
return ctx.getShaderParameteri(((OpenGLObjects.ShaderGL)obj).ptr, param);
|
||||
}
|
||||
|
||||
public static final String _wglGetShaderInfoLog(IShaderGL obj) {
|
||||
return ctx.getShaderInfoLog(obj == null ? null : ((OpenGLObjects.ShaderGL)obj).ptr);
|
||||
return ctx.getShaderInfoLog(((OpenGLObjects.ShaderGL)obj).ptr);
|
||||
}
|
||||
|
||||
public static final void _wglUseProgram(IProgramGL obj) {
|
||||
@ -537,33 +537,31 @@ public class PlatformOpenGL {
|
||||
}
|
||||
|
||||
public static final void _wglAttachShader(IProgramGL obj, IShaderGL shader) {
|
||||
ctx.attachShader(obj == null ? null : ((OpenGLObjects.ProgramGL)obj).ptr,
|
||||
shader == null ? null : ((OpenGLObjects.ShaderGL)shader).ptr);
|
||||
ctx.attachShader(((OpenGLObjects.ProgramGL)obj).ptr, ((OpenGLObjects.ShaderGL)shader).ptr);
|
||||
}
|
||||
|
||||
public static final void _wglDetachShader(IProgramGL obj, IShaderGL shader) {
|
||||
ctx.detachShader(obj == null ? null : ((OpenGLObjects.ProgramGL)obj).ptr,
|
||||
shader == null ? null : ((OpenGLObjects.ShaderGL)shader).ptr);
|
||||
ctx.detachShader(((OpenGLObjects.ProgramGL)obj).ptr, ((OpenGLObjects.ShaderGL)shader).ptr);
|
||||
}
|
||||
|
||||
public static final void _wglLinkProgram(IProgramGL obj) {
|
||||
ctx.linkProgram(obj == null ? null : ((OpenGLObjects.ProgramGL)obj).ptr);
|
||||
ctx.linkProgram(((OpenGLObjects.ProgramGL)obj).ptr);
|
||||
}
|
||||
|
||||
public static final int _wglGetProgrami(IProgramGL obj, int param) {
|
||||
return ctx.getProgramParameteri(obj == null ? null : ((OpenGLObjects.ProgramGL)obj).ptr, param);
|
||||
return ctx.getProgramParameteri(((OpenGLObjects.ProgramGL)obj).ptr, param);
|
||||
}
|
||||
|
||||
public static final String _wglGetProgramInfoLog(IProgramGL obj) {
|
||||
return ctx.getProgramInfoLog(obj == null ? null : ((OpenGLObjects.ProgramGL)obj).ptr);
|
||||
return ctx.getProgramInfoLog(((OpenGLObjects.ProgramGL)obj).ptr);
|
||||
}
|
||||
|
||||
public static final void _wglBindAttribLocation(IProgramGL obj, int index, String name) {
|
||||
ctx.bindAttribLocation(obj == null ? null : ((OpenGLObjects.ProgramGL)obj).ptr, index, name);
|
||||
ctx.bindAttribLocation(((OpenGLObjects.ProgramGL)obj).ptr, index, name);
|
||||
}
|
||||
|
||||
public static final int _wglGetAttribLocation(IProgramGL obj, String name) {
|
||||
return ctx.getAttribLocation(obj == null ? null : ((OpenGLObjects.ProgramGL)obj).ptr, name);
|
||||
return ctx.getAttribLocation(((OpenGLObjects.ProgramGL)obj).ptr, name);
|
||||
}
|
||||
|
||||
public static final void _wglDrawArrays(int mode, int first, int count) {
|
||||
@ -571,13 +569,13 @@ public class PlatformOpenGL {
|
||||
//checkErr("_wglDrawArrays(" + mode + ", " + first + ", " + count + ");");
|
||||
}
|
||||
|
||||
public static final void _wglDrawArraysInstanced(int mode, int first, int count, int instanced) {
|
||||
public static final void _wglDrawArraysInstanced(int mode, int first, int count, int instances) {
|
||||
switch(instancingImpl) {
|
||||
case INSTANCE_IMPL_CORE:
|
||||
ctx.drawArraysInstanced(mode, first, count, instanced);
|
||||
ctx.drawArraysInstanced(mode, first, count, instances);
|
||||
break;
|
||||
case INSTANCE_IMPL_ANGLE:
|
||||
ANGLEInstancedArrays.drawArraysInstancedANGLE(mode, first, count, instanced);
|
||||
ANGLEInstancedArrays.drawArraysInstancedANGLE(mode, first, count, instances);
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException();
|
||||
@ -590,13 +588,13 @@ public class PlatformOpenGL {
|
||||
//checkErr("_wglDrawElements(" + mode + ", " + count + ", " + type + ", " + offset + ");");
|
||||
}
|
||||
|
||||
public static final void _wglDrawElementsInstanced(int mode, int count, int type, int offset, int instanced) {
|
||||
public static final void _wglDrawElementsInstanced(int mode, int count, int type, int offset, int instances) {
|
||||
switch(instancingImpl) {
|
||||
case INSTANCE_IMPL_CORE:
|
||||
ctx.drawElementsInstanced(mode, count, type, offset, instanced);
|
||||
ctx.drawElementsInstanced(mode, count, type, offset, instances);
|
||||
break;
|
||||
case INSTANCE_IMPL_ANGLE:
|
||||
ANGLEInstancedArrays.drawElementsInstancedANGLE(mode, count, type, offset, instanced);
|
||||
ANGLEInstancedArrays.drawElementsInstancedANGLE(mode, count, type, offset, instances);
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException();
|
||||
@ -708,13 +706,11 @@ public class PlatformOpenGL {
|
||||
|
||||
public static final void _wglFramebufferTexture2D(int target, int attachment, int texTarget,
|
||||
ITextureGL texture, int level) {
|
||||
ctx.framebufferTexture2D(target, attachment, texTarget,
|
||||
texture == null ? null : ((OpenGLObjects.TextureGL)texture).ptr, level);
|
||||
ctx.framebufferTexture2D(target, attachment, texTarget, ((OpenGLObjects.TextureGL)texture).ptr, level);
|
||||
}
|
||||
|
||||
public static final void _wglFramebufferTextureLayer(int target, int attachment, ITextureGL texture, int level, int layer) {
|
||||
ctx.framebufferTextureLayer(target, attachment,
|
||||
texture == null ? null : ((OpenGLObjects.TextureGL) texture).ptr, level, layer);
|
||||
ctx.framebufferTextureLayer(target, attachment, ((OpenGLObjects.TextureGL) texture).ptr, level, layer);
|
||||
}
|
||||
|
||||
public static final void _wglBlitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1,
|
||||
|
@ -12,7 +12,6 @@ import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
|
||||
import net.lax1dude.eaglercraft.v1_8.EagUtils;
|
||||
import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID;
|
||||
import net.lax1dude.eaglercraft.v1_8.EaglercraftVersion;
|
||||
import net.lax1dude.eaglercraft.v1_8.Filesystem;
|
||||
@ -37,6 +36,8 @@ import org.teavm.jso.dom.xml.Node;
|
||||
import org.teavm.jso.dom.xml.NodeList;
|
||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||
import org.teavm.jso.webgl.WebGLFramebuffer;
|
||||
import org.teavm.platform.Platform;
|
||||
import org.teavm.platform.PlatformRunnable;
|
||||
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Iterators;
|
||||
@ -172,11 +173,12 @@ public class PlatformRuntime {
|
||||
logger.info("Creating main game canvas");
|
||||
|
||||
root = doc.getElementById(ClientMain.configRootElementId);
|
||||
root.getClassList().add("_eaglercraftX_root_element");
|
||||
if(root == null) {
|
||||
throw new RuntimeInitializationFailureException("Root element \"" + ClientMain.configRootElementId + "\" was not found in this document!");
|
||||
}
|
||||
|
||||
root.getClassList().add("_eaglercraftX_root_element");
|
||||
|
||||
Node nodeler;
|
||||
while((nodeler = root.getLastChild()) != null && TeaVMUtils.isTruthy(nodeler)) {
|
||||
root.removeChild(nodeler);
|
||||
@ -748,7 +750,7 @@ public class PlatformRuntime {
|
||||
if(!useDelayOnSwap && immediateContinueSupport) {
|
||||
immediateContinueTeaVM0();
|
||||
}else {
|
||||
EagUtils.sleep(0l);
|
||||
sleep(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -756,7 +758,7 @@ public class PlatformRuntime {
|
||||
if(immediateContinueSupport) {
|
||||
immediateContinueTeaVM0();
|
||||
}else {
|
||||
EagUtils.sleep(0l);
|
||||
sleep(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -890,7 +892,7 @@ public class PlatformRuntime {
|
||||
immediateContinueChannel = null;
|
||||
return IMMEDIATE_CONT_FAILED_NOT_ASYNC;
|
||||
}
|
||||
EagUtils.sleep(10l);
|
||||
sleep(10);
|
||||
currentMsgChannelContinueHack = null;
|
||||
if(!checkMe[0]) {
|
||||
if(immediateContinueChannel != null) {
|
||||
@ -945,7 +947,7 @@ public class PlatformRuntime {
|
||||
currentLegacyContinueHack = null;
|
||||
return IMMEDIATE_CONT_FAILED_NOT_ASYNC;
|
||||
}
|
||||
EagUtils.sleep(10l);
|
||||
sleep(10);
|
||||
currentLegacyContinueHack = null;
|
||||
if(!checkMe[0]) {
|
||||
return IMMEDIATE_CONT_FAILED_NOT_CONT;
|
||||
@ -1103,6 +1105,24 @@ public class PlatformRuntime {
|
||||
return (long)(steadyTimeMillis0(steadyTimeFunc) * 1000000.0);
|
||||
}
|
||||
|
||||
@Async
|
||||
public static native void sleep(int millis);
|
||||
|
||||
private static void sleep(int millis, final AsyncCallback<Void> callback) {
|
||||
Platform.schedule(new DumbSleepHandler(callback), millis);
|
||||
}
|
||||
|
||||
private static class DumbSleepHandler implements PlatformRunnable {
|
||||
private final AsyncCallback<Void> callback;
|
||||
private DumbSleepHandler(AsyncCallback<Void> callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
callback.complete(null);
|
||||
}
|
||||
}
|
||||
|
||||
static void checkBootMenu() {
|
||||
while(PlatformInput.keyboardNext()) {
|
||||
if(PlatformInput.keyboardGetEventKeyState()) {
|
||||
|
@ -2,6 +2,7 @@ package net.lax1dude.eaglercraft.v1_8.internal;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@ -49,7 +50,7 @@ public class PlatformScreenRecord {
|
||||
static Window win;
|
||||
static HTMLCanvasElement canvas;
|
||||
static boolean support;
|
||||
static final Set<EnumScreenRecordingCodec> supportedCodecs = new HashSet<>();
|
||||
static final Set<EnumScreenRecordingCodec> supportedCodecs = EnumSet.noneOf(EnumScreenRecordingCodec.class);
|
||||
static float currentGameVolume = 1.0f;
|
||||
static float currentMicVolume = 0.0f;
|
||||
static MediaStream recStream = null;
|
||||
|
@ -218,7 +218,7 @@ public class ClientMain {
|
||||
systemOut.println("ClientMain: [INFO] launching eaglercraftx main thread");
|
||||
|
||||
try {
|
||||
Main.appMain(new String[0]);
|
||||
Main.appMain();
|
||||
}catch(Throwable t) {
|
||||
systemErr.println("ClientMain: [ERROR] unhandled exception caused main thread to exit");
|
||||
EagRuntime.debugPrintStackTraceToSTDERR(t);
|
||||
|
@ -199,7 +199,7 @@ public class EarlyLoadScreen {
|
||||
_wglDisableVertexAttribArray(0);
|
||||
|
||||
PlatformInput.update();
|
||||
EagUtils.sleep(50l); // allow webgl to flush
|
||||
EagUtils.sleep(50); // allow webgl to flush
|
||||
|
||||
_wglUseProgram(null);
|
||||
_wglBindBuffer(GL_ARRAY_BUFFER, null);
|
||||
@ -266,7 +266,7 @@ public class EarlyLoadScreen {
|
||||
_wglDisableVertexAttribArray(0);
|
||||
|
||||
PlatformInput.update();
|
||||
EagUtils.sleep(50l); // allow webgl to flush
|
||||
EagUtils.sleep(50); // allow webgl to flush
|
||||
|
||||
_wglUseProgram(null);
|
||||
_wglBindBuffer(GL_ARRAY_BUFFER, null);
|
||||
@ -351,7 +351,7 @@ public class EarlyLoadScreen {
|
||||
}
|
||||
|
||||
PlatformInput.update();
|
||||
EagUtils.sleep(50l); // allow webgl to flush
|
||||
EagUtils.sleep(50); // allow webgl to flush
|
||||
|
||||
_wglUseProgram(null);
|
||||
if(!(vaos && softVAOs)) {
|
||||
|
@ -90,8 +90,8 @@ public class JOrbisAudioBufferDecoder {
|
||||
logger.warn("[{}]: Number of channels in header does not match the stream", errorString);
|
||||
}
|
||||
if(ch == -1 || len == 0) {
|
||||
logger.warn("[{}]: Empty file", errorString);
|
||||
return ctx.createBuffer(ch, 0, dec.jorbisInfo.rate);
|
||||
logger.error("[{}]: Empty file", errorString);
|
||||
return null;
|
||||
}
|
||||
switch(loadVia) {
|
||||
case LOAD_VIA_AUDIOBUFFER: {
|
||||
|
@ -47,6 +47,7 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter, IBootMenu
|
||||
private String worldsDB = "worlds";
|
||||
private String resourcePacksDB = "resourcePacks";
|
||||
private JSONObject integratedServerOpts;
|
||||
private boolean checkGLErrors = false;
|
||||
private boolean checkShaderGLErrors = false;
|
||||
private boolean demoMode = EaglercraftVersion.forceDemoMode;
|
||||
private boolean isAllowUpdateSvc = EaglercraftVersion.enableUpdateService;
|
||||
@ -97,6 +98,7 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter, IBootMenu
|
||||
serverToJoin = eaglercraftXOpts.getJoinServer(null);
|
||||
worldsDB = eaglercraftXOpts.getWorldsDB("worlds");
|
||||
resourcePacksDB = eaglercraftXOpts.getResourcePacksDB("resourcePacks");
|
||||
checkGLErrors = eaglercraftXOpts.getCheckGLErrors(false);
|
||||
checkShaderGLErrors = eaglercraftXOpts.getCheckShaderGLErrors(false);
|
||||
demoMode = EaglercraftVersion.forceDemoMode || eaglercraftXOpts.getDemoMode(false);
|
||||
isAllowUpdateSvc = EaglercraftVersion.enableUpdateService && !demoMode && eaglercraftXOpts.getAllowUpdateSvc(true);
|
||||
@ -224,6 +226,7 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter, IBootMenu
|
||||
serverToJoin = eaglercraftOpts.optString("joinServer", null);
|
||||
worldsDB = eaglercraftOpts.optString("worldsDB", "worlds");
|
||||
resourcePacksDB = eaglercraftOpts.optString("resourcePacksDB", "resourcePacks");
|
||||
checkGLErrors = eaglercraftOpts.optBoolean("checkGLErrors", false);
|
||||
checkShaderGLErrors = eaglercraftOpts.optBoolean("checkShaderGLErrors", false);
|
||||
if(EaglercraftVersion.forceDemoMode) {
|
||||
eaglercraftOpts.put("demoMode", true);
|
||||
@ -361,6 +364,11 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter, IBootMenu
|
||||
return relays;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCheckGLErrors() {
|
||||
return checkGLErrors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCheckShaderGLErrors() {
|
||||
return checkShaderGLErrors;
|
||||
@ -553,6 +561,7 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter, IBootMenu
|
||||
jsonObject.put("joinServer", serverToJoin);
|
||||
jsonObject.put("worldsDB", worldsDB);
|
||||
jsonObject.put("resourcePacksDB", resourcePacksDB);
|
||||
jsonObject.put("checkGLErrors", checkGLErrors);
|
||||
jsonObject.put("checkShaderGLErrors", checkShaderGLErrors);
|
||||
jsonObject.put("demoMode", demoMode);
|
||||
jsonObject.put("allowUpdateSvc", isAllowUpdateSvc);
|
||||
|
@ -139,7 +139,7 @@ public class TeaVMUpdateThread implements Runnable {
|
||||
if(b == null) {
|
||||
updateProg.progressBar = 1.0f;
|
||||
updateProg.statusString3 = "FAILED!";
|
||||
EagUtils.sleep(300l);
|
||||
EagUtils.sleep(300);
|
||||
updateProg.progressBar = -1.0f;
|
||||
updateProg.statusString3 = null;
|
||||
continue;
|
||||
@ -155,7 +155,7 @@ public class TeaVMUpdateThread implements Runnable {
|
||||
}
|
||||
updateProg.statusString2 = "Signature Invalid!";
|
||||
logger.error("File signature is invalid: {}", url);
|
||||
EagUtils.sleep(1000l);
|
||||
EagUtils.sleep(1000);
|
||||
}
|
||||
|
||||
updateProg.progressBar = -1.0f;
|
||||
|
@ -1,10 +1,8 @@
|
||||
package net.lax1dude.eaglercraft.v1_8.internal.teavm;
|
||||
|
||||
import org.teavm.jso.JSBody;
|
||||
import org.teavm.jso.dom.events.Event;
|
||||
import org.teavm.jso.dom.events.EventListener;
|
||||
import org.teavm.jso.dom.events.MessageEvent;
|
||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||
import org.teavm.jso.websocket.WebSocket;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.EagUtils;
|
||||
@ -73,7 +71,7 @@ public class TeaVMWebSocketClient extends AbstractWebSocketClient {
|
||||
public boolean connectBlocking(int timeoutMS) {
|
||||
long startTime = PlatformRuntime.steadyTimeMillis();
|
||||
while(!sockIsConnected && !sockIsFailed) {
|
||||
EagUtils.sleep(50l);
|
||||
EagUtils.sleep(50);
|
||||
if(PlatformRuntime.steadyTimeMillis() - startTime > timeoutMS * 1000) {
|
||||
break;
|
||||
}
|
||||
@ -112,13 +110,10 @@ public class TeaVMWebSocketClient extends AbstractWebSocketClient {
|
||||
}
|
||||
}
|
||||
|
||||
@JSBody(params = { "sock", "buffer" }, script = "sock.send(buffer);")
|
||||
protected static native void nativeBinarySend(WebSocket sock, ArrayBuffer buffer);
|
||||
|
||||
@Override
|
||||
public void send(byte[] bytes) {
|
||||
if(sockIsConnected) {
|
||||
nativeBinarySend(sock, TeaVMUtils.unwrapArrayBuffer(bytes));
|
||||
sock.send(TeaVMUtils.unwrapArrayBuffer(bytes));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,9 @@ public abstract class JSEaglercraftXOptsRoot implements JSObject {
|
||||
@JSBody(script = "return (typeof this.relays === \"object\") ? this.relays : null;")
|
||||
public native JSArrayReader<JSEaglercraftXOptsRelay> getRelays();
|
||||
|
||||
@JSBody(params = { "def" }, script = "return (typeof this.checkGLErrors === \"boolean\") ? this.checkGLErrors : def;")
|
||||
public native boolean getCheckGLErrors(boolean defaultValue);
|
||||
|
||||
@JSBody(params = { "def" }, script = "return (typeof this.checkShaderGLErrors === \"boolean\") ? this.checkShaderGLErrors : def;")
|
||||
public native boolean getCheckShaderGLErrors(boolean defaultValue);
|
||||
|
||||
|
@ -216,7 +216,7 @@ public class ServerPlatformSingleplayer {
|
||||
logger.error("Fast immediate continue will be disabled for server context due to actually continuing immediately");
|
||||
return;
|
||||
}
|
||||
EagUtils.sleep(10l);
|
||||
EagUtils.sleep(10);
|
||||
currentContinueHack = null;
|
||||
if(!checkMe[0]) {
|
||||
if(immediateContinueChannel != null) {
|
||||
@ -255,7 +255,7 @@ public class ServerPlatformSingleplayer {
|
||||
if(immediateContinueSupport) {
|
||||
immediateContinueTeaVM();
|
||||
}else {
|
||||
EagUtils.sleep(0l);
|
||||
EagUtils.sleep(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user