Update #8 - Added ayunami's seamless fullscreen controls

When you enter fullscreen via F11 or video settings you can now use regular ESC again to pause and unpause the game and close your inventory and use CTRL as the sprint key without closing the tab.

This greatly improves user experience when you are a new player and don't understand yet that regular vanilla ESC and CTRL+W messes up the game.
This commit is contained in:
LAX1DUDE 2023-01-04 00:11:39 -08:00
parent 93eb1f51eb
commit 0aeb0ccac5
14 changed files with 164 additions and 28 deletions

View File

@ -16,6 +16,7 @@
- Many bug fixes
- Added resource packs
- Added screen recording
- Added seamless fullscreen
- Created the replit

View File

@ -1 +1 @@
u7
u8

View File

@ -20,6 +20,7 @@
> CHANGE 1 : 32 @ 1 : 4
~
~ import net.lax1dude.eaglercraft.v1_8.internal.PlatformInput;
~ import org.apache.commons.lang3.Validate;
~
~ import com.google.common.collect.Lists;
@ -32,7 +33,6 @@
~ import net.lax1dude.eaglercraft.v1_8.Mouse;
~ import net.lax1dude.eaglercraft.v1_8.futures.Executors;
~ import net.lax1dude.eaglercraft.v1_8.futures.FutureTask;
~ import net.lax1dude.eaglercraft.v1_8.futures.Futures;
~ import net.lax1dude.eaglercraft.v1_8.futures.ListenableFuture;
~ import net.lax1dude.eaglercraft.v1_8.futures.ListenableFutureTask;
~ import net.lax1dude.eaglercraft.v1_8.internal.EnumPlatformType;
@ -77,9 +77,7 @@
> DELETE 2 @ 2 : 3
> DELETE 14 @ 14 : 15
> DELETE 1 @ 1 : 3
> DELETE 14 @ 14 : 18
> DELETE 21 @ 21 : 25
@ -425,7 +423,7 @@
> CHANGE 108 : 109 @ 108 : 148
~ logger.error("Use F11 to toggle fullscreen!");
~ Display.toggleFullscreen();
> DELETE 11 @ 11 : 12
@ -466,7 +464,13 @@
~ if ((!this.inGameHasFocus || !Mouse.isActuallyGrabbed()) && Mouse.getEventButtonState()) {
~ this.inGameHasFocus = false;
> CHANGE 42 : 43 @ 42 : 43
> INSERT 16 : 19 @ 16
+ if (k == 0x1D && (areKeysLocked() || isFullScreen())) {
+ KeyBinding.setKeyBindState(gameSettings.keyBindSprint.getKeyCode(), Keyboard.getEventKeyState());
+ }
> CHANGE 26 : 27 @ 26 : 27
~ if (k == 1 || (k > -1 && k == this.gameSettings.keyBindClose.getKeyCode())) {
@ -545,7 +549,11 @@
~ return System.currentTimeMillis();
> DELETE 10 @ 10 : 27
> CHANGE 3 : 4 @ 3 : 4
~ return Display.isFullscreen();
> DELETE 6 @ 6 : 23
> DELETE 44 @ 44 : 48
@ -571,11 +579,15 @@
> DELETE 24 @ 24 : 32
> INSERT 7 : 11 @ 7
> INSERT 7 : 15 @ 7
+
+ public static int getGLMaximumTextureSize() {
+ return EaglercraftGPU.glGetInteger(GL_MAX_TEXTURE_SIZE);
+ }
+
+ public boolean areKeysLocked() {
+ return PlatformInput.lockKeys;
+ }
> EOF

View File

@ -34,15 +34,48 @@
+ this.buttonList.add(exitButton = new GuiButton(69, this.width - 100, 3, 97, 20, I18n.format("chat.exit")));
+ }
> CHANGE 18 : 19 @ 18 : 19
> CHANGE 18 : 20 @ 18 : 27
~ protected void keyTyped(char parChar1, int parInt1) {
~ if (parInt1 == 1 && (this.mc.gameSettings.keyBindClose.getKeyCode() == 0 || this.mc.areKeysLocked())) {
> CHANGE 7 : 8 @ 7 : 10
> CHANGE 1 : 5 @ 1 : 10
~ if (parInt1 != 28 && parInt1 != 156) {
~ } else {
~ this.waitingOnAutocomplete = false;
~ if (parInt1 == 15) {
~ this.autocompletePlayerNames();
> CHANGE 43 : 44 @ 43 : 44
> CHANGE 1 : 2 @ 1 : 2
~ this.playerNamesFound = false;
> DELETE 1 @ 1 : 6
> CHANGE 1 : 21 @ 1 : 2
~ if (parInt1 != 28 && parInt1 != 156) {
~ if (parInt1 == 200) {
~ this.getSentHistory(-1);
~ } else if (parInt1 == 208) {
~ this.getSentHistory(1);
~ } else if (parInt1 == 201) {
~ this.mc.ingameGUI.getChatGUI().scroll(this.mc.ingameGUI.getChatGUI().getLineCount() - 1);
~ } else if (parInt1 == 209) {
~ this.mc.ingameGUI.getChatGUI().scroll(-this.mc.ingameGUI.getChatGUI().getLineCount() + 1);
~ } else {
~ this.inputField.textboxKeyTyped(parChar1, parInt1);
~ }
~ } else {
~ String s = this.inputField.getText().trim();
~ if (s.length() > 0) {
~ this.sendChatMessage(s);
~ }
~
~ this.mc.displayGuiScreen((GuiScreen) null);
~ }
> CHANGE 25 : 26 @ 25 : 26
~ protected void mouseClicked(int parInt1, int parInt2, int parInt3) {

View File

@ -90,7 +90,7 @@
~ protected void keyTyped(char parChar1, int parInt1) {
~ if (((this.mc.theWorld == null || this.mc.thePlayer.getHealth() <= 0.0F) && parInt1 == 1)
~ || parInt1 == this.mc.gameSettings.keyBindClose.getKeyCode()
~ || (parInt1 == 1 && this.mc.gameSettings.keyBindClose.getKeyCode() == 0)) {
~ || (parInt1 == 1 && (this.mc.gameSettings.keyBindClose.getKeyCode() == 0 || this.mc.areKeysLocked()))) {
> INSERT 4 : 6 @ 4

View File

@ -13,9 +13,9 @@
~ GameSettings.Options.PARTICLES, GameSettings.Options.FXAA, GameSettings.Options.MIPMAP_LEVELS,
~ GameSettings.Options.BLOCK_ALTERNATIVES, GameSettings.Options.ENTITY_SHADOWS, GameSettings.Options.FOG,
~ GameSettings.Options.HUD_FPS, GameSettings.Options.HUD_COORDS, GameSettings.Options.HUD_PLAYER,
~ GameSettings.Options.HUD_STATS, GameSettings.Options.HUD_WORLD, GameSettings.Options.HUD_24H,
~ GameSettings.Options.CHUNK_FIX };
~ GameSettings.Options.FULLSCREEN, GameSettings.Options.HUD_FPS, GameSettings.Options.HUD_COORDS,
~ GameSettings.Options.HUD_PLAYER, GameSettings.Options.HUD_STATS, GameSettings.Options.HUD_WORLD,
~ GameSettings.Options.HUD_24H, GameSettings.Options.CHUNK_FIX };
> CHANGE 11 : 13 @ 11 : 14

View File

@ -41,7 +41,7 @@
~ protected void keyTyped(char parChar1, int parInt1) {
~ if (parInt1 == this.mc.gameSettings.keyBindClose.getKeyCode()
~ || parInt1 == this.mc.gameSettings.keyBindInventory.getKeyCode()
~ || (parInt1 == 1 && this.mc.gameSettings.keyBindClose.getKeyCode() == 0)) {
~ || (parInt1 == 1 && (this.mc.gameSettings.keyBindClose.getKeyCode() == 0 || this.mc.areKeysLocked()))) {
> CHANGE 1 : 3 @ 1 : 9

View File

@ -26,7 +26,7 @@
> CHANGE 13 : 16 @ 13 : 14
~ if (parInt1 == getCloseKey()) {
~ if (parInt1 == getCloseKey() || (parInt1 == 1 && this.mc.areKeysLocked())) {
~ mc.displayGuiScreen(null);
~ } else if (!this.checkHotbarKeys(parInt1)) {

View File

@ -124,7 +124,7 @@
> DELETE 58 @ 58 : 75
> INSERT 13 : 49 @ 13
> INSERT 13 : 53 @ 13
+ if (parOptions == GameSettings.Options.HUD_FPS) {
+ this.hudFps = !this.hudFps;
@ -162,10 +162,14 @@
+ this.fxaa = (this.fxaa + parInt1) % 3;
+ }
+
+ if (parOptions == GameSettings.Options.FULLSCREEN) {
+ this.mc.toggleFullscreen();
+ }
+
> DELETE 54 @ 54 : 60
> INSERT 12 : 28 @ 12
> INSERT 12 : 30 @ 12
+ case HUD_COORDS:
+ return this.hudCoords;
@ -183,6 +187,8 @@
+ return this.chunkFix;
+ case FOG:
+ return this.fog;
+ case FULLSCREEN:
+ return this.mc.isFullScreen();
> CHANGE 43 : 46 @ 43 : 47
@ -370,12 +376,13 @@
~ TOUCHSCREEN("options.touchscreen", false, true), CHAT_SCALE("options.chat.scale", true, false),
~ CHAT_WIDTH("options.chat.width", true, false), CHAT_HEIGHT_FOCUSED("options.chat.height.focused", true, false),
> CHANGE 14 : 19 @ 14 : 15
> CHANGE 14 : 20 @ 14 : 15
~ ENTITY_SHADOWS("options.entityShadows", false, true), HUD_FPS("options.hud.fps", false, true),
~ HUD_COORDS("options.hud.coords", false, true), HUD_STATS("options.hud.stats", false, true),
~ HUD_WORLD("options.hud.world", false, true), HUD_PLAYER("options.hud.player", false, true),
~ HUD_24H("options.hud.24h", false, true), CHUNK_FIX("options.chunkFix", false, true),
~ FOG("options.fog", false, true), FXAA("options.fxaa", false, false);
~ FOG("options.fog", false, true), FXAA("options.fxaa", false, false),
~ FULLSCREEN("options.fullscreen", false, true);
> EOF

View File

@ -49,6 +49,8 @@ public class PlatformInput {
private static boolean enableRepeatEvents = false;
private static int functionKeyModifier = GLFW_KEY_F;
public static boolean lockKeys = false;
private static final List<Character> keyboardCharList = new LinkedList();
private static class KeyboardEvent {
@ -370,5 +372,13 @@ public class PlatformInput {
public static void setFunctionKeyModifier(int key) {
functionKeyModifier = KeyboardConstants.getGLFWKeyFromEagler(key);
}
public static void toggleFullscreen() {
//
}
public static boolean isFullscreen() {
return false;
}
}

View File

@ -69,4 +69,12 @@ public class Display {
return PlatformInput.wasResized();
}
public static boolean isFullscreen() {
return PlatformInput.isFullscreen();
}
public static void toggleFullscreen() {
PlatformInput.toggleFullscreen();
}
}

View File

@ -8,7 +8,7 @@ public class EaglercraftVersion {
/// Customize these to fit your fork:
public static final String projectForkName = "EaglercraftX";
public static final String projectForkVersion = "u7";
public static final String projectForkVersion = "u8";
public static final String projectForkVendor = "lax1dude";
public static final String projectForkURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8";
@ -23,7 +23,7 @@ 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 = "u7";
public static final String projectOriginVersion = "u8";
public static final String projectOriginURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8";

View File

@ -16,6 +16,7 @@
- Many bug fixes
- Added resource packs
- Added screen recording
- Added seamless fullscreen
- Created the replit
@ -130,7 +131,7 @@
Project Author: Timothy Lottes, NVIDIA
Project URL: https://gist.github.com/kosua20/0c506b81b3812ac900048059d2383126
Used For: generating and applying patch files in build system
Used For: in-game hardware accelerated FXAA antialiasing (when enabled)
* ==============================================================================
*

View File

@ -3,14 +3,18 @@ package net.lax1dude.eaglercraft.v1_8.internal;
import java.util.LinkedList;
import java.util.List;
import net.lax1dude.eaglercraft.v1_8.internal.teavm.TeaVMUtils;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSObject;
import org.teavm.jso.browser.TimerHandler;
import org.teavm.jso.browser.Window;
import org.teavm.jso.dom.events.Event;
import org.teavm.jso.dom.events.EventListener;
import org.teavm.jso.dom.events.KeyboardEvent;
import org.teavm.jso.dom.events.MouseEvent;
import org.teavm.jso.dom.events.WheelEvent;
import org.teavm.jso.dom.html.HTMLCanvasElement;
import org.teavm.jso.dom.html.HTMLElement;
import org.teavm.jso.webgl.WebGLFramebuffer;
import org.teavm.jso.webgl.WebGLRenderbuffer;
@ -88,6 +92,11 @@ public class PlatformInput {
private static long mouseGrabTimer = 0l;
private static int mouseUngrabTimeout = -1;
private static boolean pointerLockFlag = false;
private static JSObject fullscreenQuery = null;
public static boolean keyboardLockSupported = false;
public static boolean lockKeys = false;
@JSBody(params = { }, script = "window.onbeforeunload = () => {return false;};")
private static native void onBeforeCloseRegister();
@ -153,7 +162,9 @@ public class PlatformInput {
@Override
public void handleEvent(KeyboardEvent evt) {
int w = getWhich(evt);
if (w == 122) return; // F11
if (w == 122) { // F11
toggleFullscreen();
}
evt.preventDefault();
evt.stopPropagation();
if(!enableRepeatEvents && evt.isRepeat()) return;
@ -166,7 +177,6 @@ public class PlatformInput {
@Override
public void handleEvent(KeyboardEvent evt) {
int w = getWhich(evt);
if (w == 122) return; // F11
evt.preventDefault();
evt.stopPropagation();
if(!enableRepeatEvents && evt.isRepeat()) return;
@ -230,6 +240,19 @@ public class PlatformInput {
}
});
onBeforeCloseRegister();
fullscreenQuery = fullscreenMediaQuery();
if (keyboardLockSupported = checkKeyboardLockSupported()) {
TeaVMUtils.addEventListener(fullscreenQuery, "change", new EventListener<Event>() {
@Override
public void handleEvent(Event evt) {
if (!mediaQueryMatches(evt)) {
unlockKeys();
lockKeys = false;
}
}
});
}
}
@JSBody(params = { }, script = "if(window.navigator.userActivation){return window.navigator.userActivation.hasBeenActive;}else{return false;}")
@ -526,5 +549,46 @@ public class PlatformInput {
mouseEvents.clear();
keyEvents.clear();
}
@JSBody(params = {}, script = "return window.matchMedia('(display-mode: fullscreen)');")
private static native JSObject fullscreenMediaQuery();
@JSBody(params = { "mediaQuery" }, script = "return mediaQuery.matches;")
private static native boolean mediaQueryMatches(JSObject mediaQuery);
public static void toggleFullscreen() {
if (isFullscreen()) {
if (keyboardLockSupported) {
unlockKeys();
lockKeys = false;
}
exitFullscreen();
} else {
if (keyboardLockSupported) {
lockKeys();
lockKeys = true;
}
requestFullscreen(canvas);
}
}
public static boolean isFullscreen() {
return mediaQueryMatches(fullscreenQuery);
}
@JSBody(params = { }, script = "window.navigator.keyboard.lock();")
private static native void lockKeys();
@JSBody(params = { }, script = "window.navigator.keyboard.unlock();")
private static native void unlockKeys();
@JSBody(params = { }, script = "return 'keyboard' in window.navigator && 'lock' in window.navigator.keyboard;")
private static native boolean checkKeyboardLockSupported();
@JSBody(params = { }, script = "document.exitFullscreen();")
private static native void exitFullscreen();
@JSBody(params = { "element" }, script = "element.requestFullscreen();")
private static native void requestFullscreen(HTMLElement element);
}