Files
whale-town-front-v2/web/progressive_shell.html
xiangwang fc6c3c1bd3 feat: expand multiplayer, chat, and release support
- add network NPC synchronization and dialogue interactions
- add world bulletin publishing and display
- improve authentication, session refresh, and appearance sync
- synchronize player direction and movement animations
- improve input focus and progressive Web loading
- add macOS/Windows builds and deployment configuration
- include required fonts, shaders, and runtime assets
2026-09-08 21:37:43 +08:00

101 lines
4.7 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>$GODOT_PROJECT_NAME</title>
$GODOT_HEAD_INCLUDE
<style>
:root { color-scheme: light; font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; }
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #b9d9df; }
#canvas { position: fixed; inset: 0; display: block; width: 100%; height: 100%; border: 0; background: #0a2437; }
#loading-shell { position: fixed; inset: 0; z-index: 10; display: grid; place-items: end center; padding: 0 24px max(9vh, 34px); background: #b9d9df url("auth-background.jpg") center / cover no-repeat; transition: opacity .18s ease; }
#loading-shell::before { content: ""; position: absolute; inset: 0; background: rgba(222, 242, 244, .22); }
.loading { position: relative; width: min(420px, 88vw); color: #174f72; text-align: center; text-shadow: 0 1px 0 rgba(255, 255, 255, .9); }
.status { min-height: 24px; margin: 0 0 10px; font-size: 15px; font-weight: 700; line-height: 1.5; letter-spacing: 0; }
.track { height: 7px; overflow: hidden; border: 1px solid rgba(23, 79, 114, .28); border-radius: 4px; background: rgba(255, 255, 255, .78); box-shadow: 0 2px 8px rgba(15, 65, 89, .16); }
.bar { width: 0; height: 100%; background: #2b86b6; transition: width .2s ease; }
.failure { display: none; margin-top: 10px; color: #8f2634; font-size: 13px; line-height: 1.5; }
#loading-shell.done { opacity: 0; pointer-events: none; }
</style>
</head>
<body>
<canvas id="canvas" tabindex="0" aria-label="WhaleTown 游戏画布">当前浏览器不支持游戏画布。</canvas>
<div id="loading-shell" aria-live="polite">
<div class="loading">
<p class="status" id="status">正在加载小镇 0%</p>
<div class="track" aria-hidden="true"><div class="bar" id="bar"></div></div>
<div class="failure" id="failure" role="alert"></div>
</div>
</div>
<noscript>当前浏览器未启用 JavaScript无法运行鲸鱼小镇。</noscript>
<script src="$GODOT_URL"></script>
<script>
const GODOT_CONFIG = $GODOT_CONFIG;
const GODOT_THREADS_ENABLED = $GODOT_THREADS_ENABLED;
const CORE_PACK_URL = '__WHALETOWN_CORE_PACK__';
const CORE_PACK_SIZE = __WHALETOWN_CORE_PACK_SIZE__;
const AUTH_PACK_SIZE = __WHALETOWN_AUTH_PACK_SIZE__;
GODOT_CONFIG.mainPack = CORE_PACK_URL;
GODOT_CONFIG.fileSizes[CORE_PACK_URL] = CORE_PACK_SIZE;
const shell = document.getElementById('loading-shell');
const status = document.getElementById('status');
const bar = document.getElementById('bar');
const failure = document.getElementById('failure');
const canvas = document.getElementById('canvas');
canvas.addEventListener('pointerdown', function () { canvas.focus(); });
canvas.addEventListener('keydown', function (event) {
if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', ' ', 'w', 'a', 's', 'd', 'W', 'A', 'S', 'D'].includes(event.key)) {
event.preventDefault();
}
});
const engine = new Engine(GODOT_CONFIG);
let corePhaseTotal = 0;
function updateTownProgress(loaded, total) {
if (total <= 0) return;
const percent = Math.min(100, Math.round(loaded / total * 100));
bar.style.width = percent + '%';
status.textContent = '正在加载小镇 ' + percent + '%';
}
window.whaletownGodotReady = function () {
bar.style.width = '100%';
shell.classList.add('done');
window.setTimeout(function () { shell.style.display = 'none'; }, 220);
canvas.focus();
};
window.whaletownPackProgress = function (downloaded, total) {
const authTotal = total > 0 ? total : AUTH_PACK_SIZE;
updateTownProgress(corePhaseTotal + downloaded, corePhaseTotal + authTotal);
};
const missing = Engine.getMissingFeatures({ threads: GODOT_THREADS_ENABLED });
if (missing.length) {
failure.style.display = 'block';
failure.textContent = '当前浏览器缺少运行游戏所需能力:' + missing.join('、');
} else {
engine.startGame({
onProgress(current, total) {
if (total <= 0) return;
corePhaseTotal = total;
if (current >= total) {
const percent = Math.min(100, Math.round(current / (total + AUTH_PACK_SIZE) * 100));
bar.style.width = percent + '%';
status.textContent = '正在加载小镇,正在启动登录界面...';
} else {
updateTownProgress(current, total + AUTH_PACK_SIZE);
}
},
}).then(function () {
status.textContent = '正在加载小镇,正在启动登录界面...';
}).catch(function (error) {
failure.style.display = 'block';
failure.textContent = error && error.message ? error.message : '主程序加载失败,请刷新重试';
});
}
</script>
</body>
</html>