Update #46 - Fix pointer lock issue (sorta)
This commit is contained in:
parent
346047cf24
commit
3288d05a9a
|
@ -1 +1 @@
|
|||
u45
|
||||
u46
|
|
@ -336,7 +336,7 @@
|
|||
+ }
|
||||
+
|
||||
|
||||
> INSERT 27 : 243 @ 27
|
||||
> INSERT 27 : 247 @ 27
|
||||
|
||||
+
|
||||
+ private int hotbarAreaX = -1;
|
||||
|
@ -369,12 +369,16 @@
|
|||
+ && touchVPosX < interactButtonX + interactButtonW && touchVPosY < interactButtonY + interactButtonH;
|
||||
+ float f = MathHelper.clamp_float(mc.gameSettings.touchControlOpacity, 0.0f, 1.0f);
|
||||
+ if (f > 0.0f) {
|
||||
+ if (f < 1.0f)
|
||||
+ GlStateManager.enableBlend();
|
||||
+ GlStateManager.color(1.0f, 1.0f, 1.0f, f);
|
||||
+ drawTexturedModalRect(xx, yy, 0, hover ? 216 : 236, 118, 20);
|
||||
+ GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
+ drawCenteredString(mc.fontRendererObj, I18n.format("touch.interact.entity"),
|
||||
+ parScaledResolution.getScaledWidth() / 2, yy + 6,
|
||||
+ (hover ? 16777120 : 14737632) | ((int) (f * 255.0f) << 24));
|
||||
+ if (f < 1.0f)
|
||||
+ GlStateManager.disableBlend();
|
||||
+ }
|
||||
+ } else {
|
||||
+ interactButtonX = -1;
|
||||
|
|
|
@ -96,4 +96,8 @@ public class ServerPlatformSingleplayer {
|
|||
|
||||
}
|
||||
|
||||
public static boolean isTabAboutToCloseWASM() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ public class EaglercraftVersion {
|
|||
/// Customize these to fit your fork:
|
||||
|
||||
public static final String projectForkName = "EaglercraftX";
|
||||
public static final String projectForkVersion = "u45";
|
||||
public static final String projectForkVersion = "u46";
|
||||
public static final String projectForkVendor = "lax1dude";
|
||||
|
||||
public static final String projectForkURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8";
|
||||
|
@ -20,20 +20,20 @@ public class EaglercraftVersion {
|
|||
public static final String projectOriginName = "EaglercraftX";
|
||||
public static final String projectOriginAuthor = "lax1dude";
|
||||
public static final String projectOriginRevision = "1.8";
|
||||
public static final String projectOriginVersion = "u45";
|
||||
public static final String projectOriginVersion = "u46";
|
||||
|
||||
public static final String projectOriginURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; // rest in peace
|
||||
|
||||
// EPK Version Identifier
|
||||
|
||||
public static final String EPKVersionIdentifier = "u45"; // Set to null to disable EPK version check
|
||||
public static final String EPKVersionIdentifier = "u46"; // Set to null to disable EPK version check
|
||||
|
||||
// Updating configuration
|
||||
|
||||
public static final boolean enableUpdateService = true;
|
||||
|
||||
public static final String updateBundlePackageName = "net.lax1dude.eaglercraft.v1_8.client";
|
||||
public static final int updateBundlePackageVersionInt = 45;
|
||||
public static final int updateBundlePackageVersionInt = 46;
|
||||
|
||||
public static final String updateLatestLocalStorageKey = "latestUpdate_" + updateBundlePackageName;
|
||||
|
||||
|
|
|
@ -86,6 +86,11 @@ public class EaglerIntegratedServerWorker {
|
|||
}
|
||||
}
|
||||
}
|
||||
if(ServerPlatformSingleplayer.isTabAboutToCloseWASM() && !isServerStopped()) {
|
||||
logger.info("Autosaving worlds because the tab is about to close!");
|
||||
currentProcess.getConfigurationManager().saveAllPlayerData();
|
||||
currentProcess.saveAllWorlds(false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void tick() {
|
||||
|
|
|
@ -1 +1 @@
|
|||
u45
|
||||
u46
|
|
@ -162,7 +162,7 @@ void main() {
|
|||
|
||||
#ifdef COMPILE_ENABLE_MC_LIGHTING
|
||||
#ifdef COMPILE_NORMAL_ATTRIB
|
||||
vec3 normal = normalize(v_normal3f);
|
||||
vec3 normal = v_normal3f;
|
||||
#else
|
||||
vec3 normal = u_uniformNormal3f;
|
||||
#endif
|
||||
|
|
|
@ -104,7 +104,7 @@ void main() {
|
|||
|
||||
vec3 normal;
|
||||
#ifdef COMPILE_NORMAL_ATTRIB
|
||||
normal = normalize(v_normal3f);
|
||||
normal = v_normal3f;
|
||||
#else
|
||||
normal = u_uniformNormal3f;
|
||||
#endif
|
||||
|
|
|
@ -206,8 +206,8 @@ void main() {
|
|||
#endif
|
||||
|
||||
#ifdef COMPILE_NORMAL_ATTRIB
|
||||
normalVector3f = normalize(v_normal3f);
|
||||
block1f = v_block1f;
|
||||
normalVector3f = v_normal3f;
|
||||
block1f = round(v_block1f);
|
||||
#else
|
||||
normalVector3f = u_uniformNormal3f;
|
||||
block1f = u_blockConstant1f;
|
||||
|
|
|
@ -199,7 +199,7 @@ void main() {
|
|||
#endif
|
||||
|
||||
#ifdef COMPILE_NORMAL_ATTRIB
|
||||
normalVector3f = normalize(v_normal3f);
|
||||
normalVector3f = v_normal3f;
|
||||
block1f = round(v_block1f);
|
||||
#else
|
||||
normalVector3f = u_uniformNormal3f;
|
||||
|
|
|
@ -146,7 +146,7 @@ void main() {
|
|||
#endif
|
||||
|
||||
#ifdef COMPILE_NORMAL_ATTRIB
|
||||
vec3 normal = normalize(v_normal3f);
|
||||
vec3 normal = v_normal3f;
|
||||
#else
|
||||
vec3 normal = u_uniformNormal3f;
|
||||
#endif
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
client-version-integer=45
|
||||
client-version-integer=46
|
||||
client-package-name=net.lax1dude.eaglercraft.v1_8.client
|
||||
client-origin-name=EaglercraftX
|
||||
client-origin-version=u45
|
||||
client-origin-version=u46
|
||||
client-origin-vendor=lax1dude
|
||||
client-fork-name=EaglercraftX
|
||||
client-fork-version=u45
|
||||
client-fork-version=u46
|
||||
client-fork-vendor=lax1dude
|
||||
|
|
|
@ -99,6 +99,7 @@ public class PlatformInput {
|
|||
private static EventListener<?> focus = null;
|
||||
private static EventListener<?> blur = null;
|
||||
private static EventListener<?> pointerlock = null;
|
||||
private static EventListener<?> pointerlockerr = null;
|
||||
private static EventListener<?> fullscreen = null;
|
||||
|
||||
private static Map<String,LegacyKeycodeTranslator.LegacyKeycode> keyCodeTranslatorMap = null;
|
||||
|
@ -224,6 +225,7 @@ public class PlatformInput {
|
|||
private static long mouseGrabTimer = 0l;
|
||||
private static int mouseUngrabTimeout = -1;
|
||||
private static boolean pointerLockFlag = false;
|
||||
private static boolean pointerLockWaiting = false;
|
||||
|
||||
private static final int FULLSCREEN_NONE = 0;
|
||||
private static final int FULLSCREEN_CORE = 1;
|
||||
|
@ -643,7 +645,7 @@ public class PlatformInput {
|
|||
Window.setTimeout(new TimerHandler() {
|
||||
@Override
|
||||
public void onTimer() {
|
||||
boolean grab = isPointerLocked();
|
||||
boolean grab = isPointerLockedImpl();
|
||||
if(!grab) {
|
||||
if(pointerLockFlag) {
|
||||
mouseUngrabTimer = PlatformRuntime.steadyTimeMillis();
|
||||
|
@ -654,6 +656,13 @@ public class PlatformInput {
|
|||
}, 60);
|
||||
mouseDX = 0.0D;
|
||||
mouseDY = 0.0D;
|
||||
pointerLockWaiting = false;
|
||||
}
|
||||
});
|
||||
win.getDocument().addEventListener(pointerLockSupported == POINTER_LOCK_MOZ ? "mozpointerlockerror" : "pointerlockerror", pointerlockerr = new EventListener<Event>() {
|
||||
@Override
|
||||
public void handleEvent(Event evt) {
|
||||
pointerLockWaiting = false;
|
||||
}
|
||||
});
|
||||
if(pointerLockSupported == POINTER_LOCK_MOZ) {
|
||||
|
@ -693,9 +702,9 @@ public class PlatformInput {
|
|||
}
|
||||
});
|
||||
}
|
||||
if(pointerLockSupported == FULLSCREEN_WEBKIT) {
|
||||
if(fullscreenSupported == FULLSCREEN_WEBKIT) {
|
||||
PlatformRuntime.logger.info("Using webkit- vendor prefix for fullscreen");
|
||||
}else if(pointerLockSupported == FULLSCREEN_MOZ) {
|
||||
}else if(fullscreenSupported == FULLSCREEN_MOZ) {
|
||||
PlatformRuntime.logger.info("Using moz- vendor prefix for fullscreen");
|
||||
}
|
||||
}else {
|
||||
|
@ -1322,6 +1331,7 @@ public class PlatformInput {
|
|||
pointerLockFlag = grab;
|
||||
mouseGrabTimer = t;
|
||||
if(grab) {
|
||||
pointerLockWaiting = true;
|
||||
callRequestPointerLock(canvas);
|
||||
if(mouseUngrabTimeout != -1) Window.clearTimeout(mouseUngrabTimeout);
|
||||
mouseUngrabTimeout = -1;
|
||||
|
@ -1336,8 +1346,10 @@ public class PlatformInput {
|
|||
}else {
|
||||
if(mouseUngrabTimeout != -1) Window.clearTimeout(mouseUngrabTimeout);
|
||||
mouseUngrabTimeout = -1;
|
||||
if(!pointerLockWaiting) {
|
||||
callExitPointerLock(win.getDocument());
|
||||
}
|
||||
}
|
||||
mouseDX = 0.0D;
|
||||
mouseDY = 0.0D;
|
||||
}
|
||||
|
@ -1408,6 +1420,11 @@ public class PlatformInput {
|
|||
}
|
||||
|
||||
public static boolean isPointerLocked() {
|
||||
if(pointerLockWaiting) return true; // workaround for chrome bug
|
||||
return isPointerLockedImpl();
|
||||
}
|
||||
|
||||
private static boolean isPointerLockedImpl() {
|
||||
switch(pointerLockSupported) {
|
||||
case POINTER_LOCK_CORE:
|
||||
return isPointerLocked0(win.getDocument(), canvas);
|
||||
|
@ -1534,6 +1551,10 @@ public class PlatformInput {
|
|||
win.getDocument().removeEventListener("pointerlockchange", pointerlock);
|
||||
pointerlock = null;
|
||||
}
|
||||
if(pointerlockerr != null) {
|
||||
win.getDocument().removeEventListener("pointerlockerror", pointerlockerr);
|
||||
pointerlockerr = null;
|
||||
}
|
||||
if(fullscreen != null) {
|
||||
TeaVMUtils.removeEventListener(fullscreenQuery, "change", fullscreen);
|
||||
fullscreen = null;
|
||||
|
|
|
@ -296,4 +296,8 @@ public class ServerPlatformSingleplayer {
|
|||
|
||||
}
|
||||
|
||||
public static boolean isTabAboutToCloseWASM() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -143,4 +143,7 @@ public class ServerPlatformSingleplayer {
|
|||
@Import(module = "serverPlatformSingleplayer", name = "setCrashCallback")
|
||||
private static native JSWASMCrashCallbackInterface setCrashCallbackWASM0();
|
||||
|
||||
@Import(module = "serverPlatformSingleplayer", name = "isTabAboutToClose")
|
||||
public static native boolean isTabAboutToCloseWASM();
|
||||
|
||||
}
|
||||
|
|
|
@ -196,6 +196,13 @@ function initializeClientPlatfSP(spImports) {
|
|||
}
|
||||
};
|
||||
|
||||
window.__curEaglerX188UnloadListenerCB = function() {
|
||||
if(workerObj) {
|
||||
workerObj.postMessage({
|
||||
"ch": "~!WASM_AUTOSAVE"
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function initializeNoClientPlatfSP(spImports) {
|
||||
|
|
|
@ -133,9 +133,6 @@ async function initializeContext() {
|
|||
|
||||
currentRedirectorFunc = addLogMessageImpl;
|
||||
|
||||
window.__curEaglerX188UnloadListenerCB = function() {
|
||||
//TODO: Autosave somehow?
|
||||
};
|
||||
if(window.__isEaglerX188UnloadListenerSet !== "yes") {
|
||||
window.onbeforeunload = function(evt) {
|
||||
if(window.__curEaglerX188UnloadListenerCB) {
|
||||
|
|
|
@ -80,6 +80,7 @@ async function initPlatformInput(inputImports) {
|
|||
|
||||
var pointerLockSupported = false;
|
||||
var pointerLockFlag = false;
|
||||
var pointerLockWaiting = false;
|
||||
var mouseUngrabTimer = 0;
|
||||
var mouseGrabTimer = 0;
|
||||
var mouseUngrabTimeout = -1;
|
||||
|
@ -116,6 +117,7 @@ async function initPlatformInput(inputImports) {
|
|||
focus: null,
|
||||
blur: null,
|
||||
pointerlock: null,
|
||||
pointerlockerr: null,
|
||||
fullscreenChange: null
|
||||
};
|
||||
|
||||
|
@ -412,6 +414,10 @@ async function initPlatformInput(inputImports) {
|
|||
}
|
||||
pointerLockFlag = grab;
|
||||
}, 60);
|
||||
pointerLockWaiting = false;
|
||||
}));
|
||||
document.addEventListener("pointerlockerror", /** @type {function(Event)} */ (currentEventListeners.pointerlockerr = function(evt) {
|
||||
pointerLockWaiting = false;
|
||||
}));
|
||||
}else {
|
||||
eagError("Pointer lock is not supported on this browser");
|
||||
|
@ -646,6 +652,7 @@ async function initPlatformInput(inputImports) {
|
|||
const t = performance.now() | 0;
|
||||
mouseGrabTimer = t;
|
||||
if(grab) {
|
||||
pointerLockWaiting = true;
|
||||
try {
|
||||
canvasElement.requestPointerLock();
|
||||
}catch(ex) {
|
||||
|
@ -663,11 +670,13 @@ async function initPlatformInput(inputImports) {
|
|||
}else {
|
||||
if(mouseUngrabTimeout !== -1) window.clearTimeout(mouseUngrabTimeout);
|
||||
mouseUngrabTimeout = -1;
|
||||
if(!pointerLockWaiting) {
|
||||
try {
|
||||
document.exitPointerLock();
|
||||
}catch(ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
inputImports["mouseSetGrabbed"] = mouseSetGrabbed;
|
||||
|
@ -690,7 +699,7 @@ async function initPlatformInput(inputImports) {
|
|||
* @return {boolean}
|
||||
*/
|
||||
inputImports["isPointerLocked"] = function() {
|
||||
return pointerLockSupported && document.pointerLockElement === canvasElement;
|
||||
return pointerLockSupported && (pointerLockWaiting || document.pointerLockElement === canvasElement);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1124,6 +1133,10 @@ async function initPlatformInput(inputImports) {
|
|||
document.removeEventListener("pointerlockchange", /** @type {function(Event)} */ (currentEventListeners.pointerlock));
|
||||
currentEventListeners.pointerlock = null;
|
||||
}
|
||||
if(currentEventListeners.pointerlockerr) {
|
||||
document.removeEventListener("pointerlockerror", /** @type {function(Event)} */ (currentEventListeners.pointerlockerr));
|
||||
currentEventListeners.pointerlockerr = null;
|
||||
}
|
||||
if(currentEventListeners.fullscreenChange) {
|
||||
fullscreenQuery.removeEventListener("change", /** @type {function(Event)} */ (currentEventListeners.fullscreenChange));
|
||||
currentEventListeners.fullscreenChange = null;
|
||||
|
|
|
@ -19,6 +19,9 @@ const serverPlatfSPName = "serverPlatformSingleplayer";
|
|||
/** @type {function(string, boolean)|null} */
|
||||
var sendIntegratedServerCrash = null;
|
||||
|
||||
/** @type {boolean} */
|
||||
var isTabClosingFlag = false;
|
||||
|
||||
function initializeServerPlatfSP(spImports) {
|
||||
|
||||
const serverMessageQueue = new EaglerLinkedQueue();
|
||||
|
@ -35,6 +38,11 @@ function initializeServerPlatfSP(spImports) {
|
|||
return;
|
||||
}
|
||||
|
||||
if(channel === "~!WASM_AUTOSAVE") {
|
||||
isTabClosingFlag = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if(!buf) {
|
||||
eagError("Recieved IPC packet with null buffer");
|
||||
return;
|
||||
|
@ -72,6 +80,14 @@ function initializeServerPlatfSP(spImports) {
|
|||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
spImports["isTabAboutToClose"] = function() {
|
||||
const ret = isTabClosingFlag;
|
||||
isTabClosingFlag = false;
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
function initializeNoServerPlatfSP(spImports) {
|
||||
|
@ -79,4 +95,5 @@ function initializeNoServerPlatfSP(spImports) {
|
|||
setUnsupportedFunc(spImports, serverPlatfSPName, "getAvailablePackets");
|
||||
setUnsupportedFunc(spImports, serverPlatfSPName, "getNextPacket");
|
||||
setUnsupportedFunc(spImports, serverPlatfSPName, "setCrashCallback");
|
||||
setUnsupportedFunc(spImports, serverPlatfSPName, "isTabAboutToClose");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user