27 lines
865 B
TypeScript
27 lines
865 B
TypeScript
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;
|
|
}
|