fix this cursorlock pause issue on chrome and this minor thing

This commit is contained in:
RandomityGuy 2026-03-28 12:40:49 +00:00
parent 724ebbda99
commit d8cee80266
3 changed files with 52 additions and 48 deletions

View file

@ -88,7 +88,6 @@ class MarbleGame {
return; // don't pause
}
paused = true;
handlePauseGame();
// Focus the shit again
var jsCanvas = @:privateAccess Window.getInstance().canvas;
@ -260,7 +259,6 @@ class MarbleGame {
|| (Net.isMP && paused && !(MarbleGame.canvas.children[MarbleGame.canvas.children.length - 1] is MPExitGameDlg))) {
return; // don't pause
}
paused = !paused;
handlePauseGame();
}
}
@ -288,57 +286,63 @@ class MarbleGame {
}
}
public function showPauseUI() {
if (world.isMultiplayer) {
exitGameDlg = new MPExitGameDlg(() -> {
canvas.popDialog(exitGameDlg);
paused = !paused;
var w = getWorld();
w.setCursorLock(true);
}, () -> {
canvas.popDialog(exitGameDlg);
quitMission(Net.isClient);
if (Net.isMP && Net.isClient) {
Net.disconnect();
canvas.setContent(new JoinServerGui());
}
});
} else {
exitGameDlg = new ExitGameDlg((sender) -> {
canvas.popDialog(exitGameDlg);
var w = getWorld();
if (MarbleGame.instance.toRecord) {
MarbleGame.canvas.pushDialog(new ReplayNameDlg(() -> {
quitMission();
}));
} else {
quitMission(Net.isClient);
if (Net.isMP && Net.isClient) {
Net.disconnect();
}
}
}, (sender) -> {
canvas.popDialog(exitGameDlg);
paused = !paused;
var w = getWorld();
w.setCursorLock(true);
}, (sender) -> {
canvas.popDialog(exitGameDlg);
var w = getWorld();
w.restart(w.marble, true);
// world.setCursorLock(true);
paused = !paused;
});
}
canvas.pushDialog(exitGameDlg);
}
public function handlePauseGame() {
if (paused && world._ready) {
if (!paused && world._ready) {
paused = true;
Console.log("Game paused");
world.setCursorLock(false);
if (Util.isTouchDevice()) {
this.touchInput.movementInput.forceRelease();
}
if (world.isMultiplayer) {
exitGameDlg = new MPExitGameDlg(() -> {
canvas.popDialog(exitGameDlg);
paused = !paused;
var w = getWorld();
w.setCursorLock(true);
}, () -> {
canvas.popDialog(exitGameDlg);
quitMission(Net.isClient);
if (Net.isMP && Net.isClient) {
Net.disconnect();
canvas.setContent(new JoinServerGui());
}
});
} else {
exitGameDlg = new ExitGameDlg((sender) -> {
canvas.popDialog(exitGameDlg);
var w = getWorld();
if (MarbleGame.instance.toRecord) {
MarbleGame.canvas.pushDialog(new ReplayNameDlg(() -> {
quitMission();
}));
} else {
quitMission(Net.isClient);
if (Net.isMP && Net.isClient) {
Net.disconnect();
}
}
}, (sender) -> {
canvas.popDialog(exitGameDlg);
paused = !paused;
var w = getWorld();
w.setCursorLock(true);
}, (sender) -> {
canvas.popDialog(exitGameDlg);
var w = getWorld();
w.restart(w.marble, true);
// world.setCursorLock(true);
paused = !paused;
});
}
canvas.pushDialog(exitGameDlg);
showPauseUI();
} else {
if (world._ready) {
paused = false;
Console.log("Game unpaused");
if (exitGameDlg != null)
canvas.popDialog(exitGameDlg);

View file

@ -77,10 +77,11 @@ class InputBitStream {
public function readString() {
var length = readUInt16();
var str = "";
var buf = new StringBuf();
for (i in 0...length) {
str += String.fromCharCode(readByte());
buf.addChar(readByte());
}
return str;
return buf.toString();
}
}

View file

@ -102,7 +102,6 @@ class MasterServerClient {
instance = null;
}
#if hl
stopMutex.acquire();
stopping = true;
stopMutex.release();
if (myToken == wsToken) {