Server authority
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
let stopped = false;
|
||||
|
||||
// replaces the game with a message, for when it can't go on (no server, lost connection)
|
||||
export function show_fatal_error(message: string) {
|
||||
if (stopped) {
|
||||
return;
|
||||
}
|
||||
stopped = true;
|
||||
document.exitPointerLock?.();
|
||||
|
||||
const overlay = document.createElement("div");
|
||||
overlay.style.cssText =
|
||||
"position:fixed;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;" +
|
||||
"gap:12px;background:rgba(0,0,0,0.85);color:white;font:20px system-ui,sans-serif;text-align:center;";
|
||||
const text = document.createElement("div");
|
||||
text.textContent = message;
|
||||
const hint = document.createElement("div");
|
||||
hint.textContent = "Reload the page to try again.";
|
||||
hint.style.cssText = "font-size:14px;opacity:0.7;";
|
||||
overlay.append(text, hint);
|
||||
document.body.append(overlay);
|
||||
}
|
||||
|
||||
export function is_stopped() {
|
||||
return stopped;
|
||||
}
|
||||
Reference in New Issue
Block a user