mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-18 17:27:50 -05:00
Deliver the in-game moderation and event overlays, theatre playback bridge, room-effect controls, staff shortcuts, friend-game prompts, and Windows emoji handling fixes. Improve den editing with explicit front, behind, and natural stacking choices that persist without changing item position. Correct item display layers and custom artwork behavior, and make popup controls reliably closable. Include performance-mode settings, animation and input safeguards, and rebuild ajclient.swf from the patched sources so the served client exactly matches the feature set.
182 lines
6.1 KiB
HTML
182 lines
6.1 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Game Client</title>
|
|
</head>
|
|
<body>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
overflow: hidden;
|
|
}
|
|
#flash-content {
|
|
position: relative;
|
|
z-index: 1;
|
|
}
|
|
#theatre-video {
|
|
position: fixed;
|
|
z-index: 2;
|
|
display: none;
|
|
left: 8.4vw;
|
|
top: 6.2vh;
|
|
width: 56.8vw;
|
|
height: 52.8vh;
|
|
border: 0;
|
|
background: #000;
|
|
pointer-events: auto;
|
|
}
|
|
#theatre-video.visible {
|
|
display: block;
|
|
}
|
|
</style>
|
|
<embed id="flash-content"></embed>
|
|
<iframe id="theatre-video" title="Theatre video" allow="autoplay; encrypted-media" referrerpolicy="strict-origin-when-cross-origin"></iframe>
|
|
<script>
|
|
"use strict";
|
|
|
|
// local stand-in for desktop.animaljam.com/gameClient/game/index.html.
|
|
// same contract with the launcher (gui/gamePreload.js) and the SWF.
|
|
|
|
const flashContent = document.getElementById("flash-content");
|
|
const theatreVideo = document.getElementById("theatre-video");
|
|
// only a SWF from this server may call into this page. with "always"
|
|
// any SWF the game came to load, from anywhere, could: and this page
|
|
// is handed the player's login token.
|
|
flashContent.setAttribute("allowScriptAccess", "sameDomain");
|
|
// The theatre's staff-controlled browser video must be able to appear
|
|
// over the SWF screen. "window" puts Flash above every HTML element;
|
|
// opaque keeps the normal game drawing while allowing that overlay.
|
|
flashContent.setAttribute("wmode", "opaque");
|
|
flashContent.style.width = "100vw";
|
|
flashContent.style.height = "100vh";
|
|
|
|
window.ipc.on("flashVarsReady", (event, flashVars) => {
|
|
const flashVarsParams = Object.entries(flashVars)
|
|
.map(([key, val]) => `${encodeURIComponent(key)}=${encodeURIComponent(val)}`)
|
|
.join("&");
|
|
|
|
flashContent.setAttribute("FlashVars", flashVarsParams);
|
|
// the game from the address this page came from, whatever name the
|
|
// server knows itself by: "sameDomain" above goes by that.
|
|
const client = new URL(flashVars.clientURL, location.href);
|
|
flashContent.src = location.origin + client.pathname + client.search;
|
|
flashContent.style.display = "block";
|
|
});
|
|
|
|
window.ipc.on("removed", () => document.body.innerHTML = "");
|
|
|
|
// the client's top bar: the game's HUD shown or hidden (AJClient.setHudShown
|
|
// in the patched SWF).
|
|
window.ipc.on("hud", (event, shown) => {
|
|
try {
|
|
flashContent.ajHud(shown === true);
|
|
}
|
|
catch (err) {
|
|
// not this server's SWF, or the game is not up yet.
|
|
}
|
|
});
|
|
|
|
window.addEventListener("resize", resize);
|
|
|
|
// ExternalInterface functions called by the SWF.
|
|
function complete_signup(username, password) {
|
|
window.ipc.sendToHost("signupCompleted", {username, password});
|
|
}
|
|
|
|
function aj_initialized() {
|
|
// the game has read its start values; the login token among them
|
|
// need not stay in the page.
|
|
flashContent.removeAttribute("FlashVars");
|
|
window.ipc.sendToHost("initialized");
|
|
for (let i = 0; i < 50; i++) {
|
|
setTimeout(() => resize(), i * 500);
|
|
}
|
|
}
|
|
|
|
// pictures drawn in the last second, told by the patched SWF once a
|
|
// second (AJClient.onSmoothFrame), for the client's top bar.
|
|
function ajFps(count) {
|
|
window.ipc.sendToHost("fps", count);
|
|
}
|
|
|
|
// an address the SWF wants open (AJClient.finderLink): the client opens
|
|
// it in the system browser, being a webview that may open no window.
|
|
function ajOpenPage(url) {
|
|
if (/^https:\/\//.test(String(url))) {
|
|
window.ipc.sendToHost("openPage", String(url));
|
|
}
|
|
}
|
|
|
|
// where the player is, for the client's Discord rich presence
|
|
// (AJClient.presenceRoom): a short line such as "In Jamaa Township".
|
|
function ajPresence(text) {
|
|
window.ipc.sendToHost("presence", String(text).slice(0, 100));
|
|
}
|
|
|
|
function ajPrint(imageData) {
|
|
window.ipc.sendToHost("printImage", imageData);
|
|
}
|
|
|
|
// The server validates the id and decides who in the theatre gets this
|
|
// call. The page merely displays it over the theatre's screen area.
|
|
function ajTheatreVideo(videoId) {
|
|
const id = String(videoId || "");
|
|
if (!/^[A-Za-z0-9_-]{11}$/.test(id)) {
|
|
theatreVideo.removeAttribute("src");
|
|
theatreVideo.classList.remove("visible");
|
|
return;
|
|
}
|
|
theatreVideo.src = `https://www.youtube-nocookie.com/embed/${id}?autoplay=1&rel=0&modestbranding=1`;
|
|
theatreVideo.classList.add("visible");
|
|
}
|
|
|
|
// The native theatre sign calls this through ExternalInterface. The
|
|
// SWF performs its own permission check before showing the controls.
|
|
function ajOpenTheatreControl() {
|
|
if (flashContent && typeof flashContent.openTheatreControl === "function") {
|
|
try {
|
|
flashContent.openTheatreControl();
|
|
}
|
|
catch (err) {
|
|
}
|
|
}
|
|
}
|
|
|
|
function reloadSwfOrGetIP(reloadSwf, params) {
|
|
window.ipc.sendToHost("reloadGame", reloadSwf, params);
|
|
}
|
|
|
|
// moderator remote-control and analytics hooks; nothing to do locally.
|
|
function mrc() {}
|
|
function handleGAEvent() {}
|
|
function handleKey() {}
|
|
|
|
function resize() {
|
|
if (flashContent && flashContent.handleResize) {
|
|
try {
|
|
flashContent.handleResize(window.innerWidth, window.innerHeight);
|
|
}
|
|
catch (err) {
|
|
}
|
|
}
|
|
}
|
|
|
|
window.addEventListener("error", event => {
|
|
window.ipc.sendToHost("reportError", (event.error && event.error.stack) || event.message);
|
|
});
|
|
|
|
window.addEventListener("beforeunload", event => {
|
|
if (flashContent && typeof flashContent.unloadAJClient === "function") {
|
|
try {
|
|
flashContent.unloadAJClient();
|
|
}
|
|
catch (err) {
|
|
}
|
|
}
|
|
delete event["returnValue"];
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|