2018-08-23 18:01:30 +00:00
|
|
|
<!DOCTYPE html>
|
2022-10-11 11:48:16 +00:00
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
2024-04-25 00:09:48 +00:00
|
|
|
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0">
|
2022-10-11 11:48:16 +00:00
|
|
|
<title>$GODOT_PROJECT_NAME</title>
|
|
|
|
<style>
|
2024-04-25 00:09:48 +00:00
|
|
|
html, body, #canvas {
|
2022-10-11 11:48:16 +00:00
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
2024-04-25 00:09:48 +00:00
|
|
|
border: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
body {
|
|
|
|
color: white;
|
2022-10-11 11:48:16 +00:00
|
|
|
background-color: black;
|
2024-04-25 00:09:48 +00:00
|
|
|
overflow: hidden;
|
|
|
|
touch-action: none;
|
2022-10-11 11:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#canvas {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
|
|
|
|
#canvas:focus {
|
|
|
|
outline: none;
|
|
|
|
}
|
|
|
|
|
2024-04-25 00:09:48 +00:00
|
|
|
#status, #status-splash, #status-progress {
|
2022-10-11 11:48:16 +00:00
|
|
|
position: absolute;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
2024-04-25 00:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#status, #status-splash {
|
|
|
|
top: 0;
|
2022-10-11 11:48:16 +00:00
|
|
|
bottom: 0;
|
2024-04-25 00:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#status {
|
2024-05-11 23:02:14 +00:00
|
|
|
background-color: #242424;
|
2022-10-11 11:48:16 +00:00
|
|
|
display: flex;
|
2024-04-25 00:09:48 +00:00
|
|
|
flex-direction: column;
|
2022-10-11 11:48:16 +00:00
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
visibility: hidden;
|
|
|
|
}
|
|
|
|
|
2024-04-25 00:09:48 +00:00
|
|
|
#status-splash {
|
|
|
|
max-height: 100%;
|
|
|
|
max-width: 100%;
|
|
|
|
margin: auto;
|
2022-10-11 11:48:16 +00:00
|
|
|
}
|
|
|
|
|
2024-04-25 00:09:48 +00:00
|
|
|
#status-progress, #status-notice {
|
|
|
|
display: none;
|
2022-10-11 11:48:16 +00:00
|
|
|
}
|
|
|
|
|
2024-04-25 00:09:48 +00:00
|
|
|
#status-progress {
|
|
|
|
bottom: 10%;
|
|
|
|
width: 50%;
|
|
|
|
margin: 0 auto;
|
2022-10-11 11:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#status-notice {
|
2024-04-25 00:09:48 +00:00
|
|
|
background-color: #5b3943;
|
|
|
|
border-radius: 0.5rem;
|
|
|
|
border: 1px solid #9b3943;
|
|
|
|
color: #e0e0e0;
|
|
|
|
font-family: 'Noto Sans', 'Droid Sans', Arial, sans-serif;
|
2022-10-11 11:48:16 +00:00
|
|
|
line-height: 1.3;
|
2024-04-25 00:09:48 +00:00
|
|
|
margin: 0 2rem;
|
|
|
|
overflow: hidden;
|
|
|
|
padding: 1rem;
|
|
|
|
text-align: center;
|
|
|
|
z-index: 1;
|
2022-10-11 11:48:16 +00:00
|
|
|
}
|
|
|
|
</style>
|
|
|
|
$GODOT_HEAD_INCLUDE
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<canvas id="canvas">
|
2024-04-25 00:09:48 +00:00
|
|
|
Your browser does not support the canvas tag.
|
2022-10-11 11:48:16 +00:00
|
|
|
</canvas>
|
2024-04-25 00:09:48 +00:00
|
|
|
|
|
|
|
<noscript>
|
|
|
|
Your browser does not support JavaScript.
|
|
|
|
</noscript>
|
|
|
|
|
2022-10-11 11:48:16 +00:00
|
|
|
<div id="status">
|
2024-04-25 00:09:48 +00:00
|
|
|
<img id="status-splash" src="$GODOT_SPLASH" alt="">
|
|
|
|
<progress id="status-progress"></progress>
|
|
|
|
<div id="status-notice"></div>
|
2022-10-11 11:48:16 +00:00
|
|
|
</div>
|
2018-08-23 18:01:30 +00:00
|
|
|
|
2022-10-11 11:48:16 +00:00
|
|
|
<script src="$GODOT_URL"></script>
|
|
|
|
<script>
|
|
|
|
const GODOT_CONFIG = $GODOT_CONFIG;
|
2023-12-01 18:39:09 +00:00
|
|
|
const GODOT_THREADS_ENABLED = $GODOT_THREADS_ENABLED;
|
2022-10-11 11:48:16 +00:00
|
|
|
const engine = new Engine(GODOT_CONFIG);
|
|
|
|
|
|
|
|
(function () {
|
2024-04-25 00:09:48 +00:00
|
|
|
const statusOverlay = document.getElementById('status');
|
2022-10-11 11:48:16 +00:00
|
|
|
const statusProgress = document.getElementById('status-progress');
|
|
|
|
const statusNotice = document.getElementById('status-notice');
|
|
|
|
|
|
|
|
let initializing = true;
|
2024-04-25 00:09:48 +00:00
|
|
|
let statusMode = '';
|
2018-08-23 18:01:30 +00:00
|
|
|
|
2022-10-11 11:48:16 +00:00
|
|
|
function setStatusMode(mode) {
|
|
|
|
if (statusMode === mode || !initializing) {
|
|
|
|
return;
|
2018-08-23 18:01:30 +00:00
|
|
|
}
|
2024-04-25 00:09:48 +00:00
|
|
|
if (mode === 'hidden') {
|
|
|
|
statusOverlay.remove();
|
|
|
|
initializing = false;
|
|
|
|
return;
|
2018-08-23 18:01:30 +00:00
|
|
|
}
|
2024-04-25 00:09:48 +00:00
|
|
|
statusOverlay.style.visibility = 'visible';
|
|
|
|
statusProgress.style.display = mode === 'progress' ? 'block' : 'none';
|
|
|
|
statusNotice.style.display = mode === 'notice' ? 'block' : 'none';
|
2022-10-11 11:48:16 +00:00
|
|
|
statusMode = mode;
|
|
|
|
}
|
2018-08-23 18:01:30 +00:00
|
|
|
|
2022-10-11 11:48:16 +00:00
|
|
|
function setStatusNotice(text) {
|
|
|
|
while (statusNotice.lastChild) {
|
|
|
|
statusNotice.removeChild(statusNotice.lastChild);
|
2018-08-23 18:01:30 +00:00
|
|
|
}
|
2022-10-11 11:48:16 +00:00
|
|
|
const lines = text.split('\n');
|
|
|
|
lines.forEach((line) => {
|
|
|
|
statusNotice.appendChild(document.createTextNode(line));
|
|
|
|
statusNotice.appendChild(document.createElement('br'));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function displayFailureNotice(err) {
|
|
|
|
const msg = err.message || err;
|
|
|
|
console.error(msg);
|
|
|
|
setStatusNotice(msg);
|
|
|
|
setStatusMode('notice');
|
|
|
|
initializing = false;
|
|
|
|
}
|
|
|
|
|
2023-12-01 18:39:09 +00:00
|
|
|
const missing = Engine.getMissingFeatures({
|
|
|
|
threads: GODOT_THREADS_ENABLED,
|
|
|
|
});
|
2024-04-25 00:09:48 +00:00
|
|
|
|
2022-10-11 11:48:16 +00:00
|
|
|
if (missing.length !== 0) {
|
2023-12-12 20:39:25 +00:00
|
|
|
if (GODOT_CONFIG['serviceWorker'] && GODOT_CONFIG['ensureCrossOriginIsolationHeaders'] && 'serviceWorker' in navigator) {
|
|
|
|
// There's a chance that installing the service worker would fix the issue
|
|
|
|
Promise.race([
|
|
|
|
navigator.serviceWorker.getRegistration().then((registration) => {
|
|
|
|
if (registration != null) {
|
|
|
|
return Promise.reject(new Error('Service worker already exists.'));
|
|
|
|
}
|
|
|
|
return registration;
|
|
|
|
}).then(() => engine.installServiceWorker()),
|
|
|
|
// For some reason, `getRegistration()` can stall
|
|
|
|
new Promise((resolve) => {
|
|
|
|
setTimeout(() => resolve(), 2000);
|
|
|
|
}),
|
|
|
|
]).catch((err) => {
|
|
|
|
console.error('Error while registering service worker:', err);
|
|
|
|
}).then(() => {
|
|
|
|
window.location.reload();
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// Display the message as usual
|
|
|
|
const missingMsg = 'Error\nThe following features required to run Godot projects on the Web are missing:\n';
|
|
|
|
displayFailureNotice(missingMsg + missing.join('\n'));
|
|
|
|
}
|
2022-10-11 11:48:16 +00:00
|
|
|
} else {
|
2024-04-25 00:09:48 +00:00
|
|
|
setStatusMode('progress');
|
2022-10-11 11:48:16 +00:00
|
|
|
engine.startGame({
|
|
|
|
'onProgress': function (current, total) {
|
2024-04-25 00:09:48 +00:00
|
|
|
if (current > 0 && total > 0) {
|
|
|
|
statusProgress.value = current;
|
|
|
|
statusProgress.max = total;
|
2022-10-11 11:48:16 +00:00
|
|
|
} else {
|
2024-04-25 00:09:48 +00:00
|
|
|
statusProgress.removeAttribute('value');
|
|
|
|
statusProgress.removeAttribute('max');
|
2022-10-11 11:48:16 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}).then(() => {
|
|
|
|
setStatusMode('hidden');
|
|
|
|
}, displayFailureNotice);
|
|
|
|
}
|
|
|
|
}());
|
|
|
|
</script>
|
|
|
|
</body>
|
2018-08-23 18:01:30 +00:00
|
|
|
</html>
|