|
2 | 2 | <html lang="en"> |
3 | 3 | <head> |
4 | 4 | <meta charset="utf-8"> |
5 | | - <meta name="viewport" content="width=device-width, user-scalable=no"> |
| 5 | + <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"> |
6 | 6 | <title>$GODOT_PROJECT_NAME</title> |
7 | 7 | <style> |
8 | | -body { |
9 | | - touch-action: none; |
| 8 | +html, body, #canvas { |
10 | 9 | margin: 0; |
11 | | - border: 0 none; |
12 | 10 | padding: 0; |
13 | | - text-align: center; |
| 11 | + border: 0; |
| 12 | +} |
| 13 | + |
| 14 | +body { |
| 15 | + color: white; |
14 | 16 | background-color: black; |
| 17 | + overflow: hidden; |
| 18 | + touch-action: none; |
15 | 19 | } |
16 | 20 |
|
17 | 21 | #canvas { |
18 | 22 | display: block; |
19 | | - margin: 0; |
20 | | - color: white; |
21 | 23 | } |
22 | 24 |
|
23 | 25 | #canvas:focus { |
24 | 26 | outline: none; |
25 | 27 | } |
26 | 28 |
|
27 | | -.godot { |
28 | | - font-family: 'Noto Sans', 'Droid Sans', Arial, sans-serif; |
29 | | - color: #e0e0e0; |
30 | | - background-color: #3b3943; |
31 | | - background-image: linear-gradient(to bottom, #403e48, #35333c); |
32 | | - border: 1px solid #45434e; |
33 | | - box-shadow: 0 0 1px 1px #2f2d35; |
34 | | -} |
35 | | - |
36 | | -/* Status display */ |
37 | | - |
38 | | -#status { |
| 29 | +#status, #status-splash, #status-progress { |
39 | 30 | position: absolute; |
40 | 31 | left: 0; |
41 | | - top: 0; |
42 | 32 | right: 0; |
| 33 | +} |
| 34 | + |
| 35 | +#status, #status-splash { |
| 36 | + top: 0; |
43 | 37 | bottom: 0; |
| 38 | +} |
| 39 | + |
| 40 | +#status { |
| 41 | + background-color: #38363A; |
44 | 42 | display: flex; |
| 43 | + flex-direction: column; |
45 | 44 | justify-content: center; |
46 | 45 | align-items: center; |
47 | | - /* don't consume click events - make children visible explicitly */ |
48 | 46 | visibility: hidden; |
49 | 47 | } |
50 | 48 |
|
51 | | -#status-progress { |
52 | | - width: 366px; |
53 | | - height: 7px; |
54 | | - background-color: #38363A; |
55 | | - border: 1px solid #444246; |
56 | | - padding: 1px; |
57 | | - box-shadow: 0 0 2px 1px #1B1C22; |
58 | | - border-radius: 2px; |
59 | | - visibility: visible; |
60 | | -} |
61 | | - |
62 | | -@media only screen and (orientation:portrait) { |
63 | | - #status-progress { |
64 | | - width: 61.8%; |
65 | | - } |
| 49 | +#status-splash { |
| 50 | + max-height: 100%; |
| 51 | + max-width: 100%; |
| 52 | + margin: auto; |
66 | 53 | } |
67 | 54 |
|
68 | | -#status-progress-inner { |
69 | | - height: 100%; |
70 | | - width: 0; |
71 | | - box-sizing: border-box; |
72 | | - transition: width 0.5s linear; |
73 | | - background-color: #202020; |
74 | | - border: 1px solid #222223; |
75 | | - box-shadow: 0 0 1px 1px #27282E; |
76 | | - border-radius: 3px; |
| 55 | +#status-progress, #status-notice { |
| 56 | + display: none; |
77 | 57 | } |
78 | 58 |
|
79 | | -#status-indeterminate { |
80 | | - height: 42px; |
81 | | - visibility: visible; |
82 | | - position: relative; |
83 | | -} |
84 | | - |
85 | | -#status-indeterminate > div { |
86 | | - width: 4.5px; |
87 | | - height: 0; |
88 | | - border-style: solid; |
89 | | - border-width: 9px 3px 0 3px; |
90 | | - border-color: #2b2b2b transparent transparent transparent; |
91 | | - transform-origin: center 21px; |
92 | | - position: absolute; |
| 59 | +#status-progress { |
| 60 | + bottom: 10%; |
| 61 | + width: 50%; |
| 62 | + margin: 0 auto; |
93 | 63 | } |
94 | 64 |
|
95 | | -#status-indeterminate > div:nth-child(1) { transform: rotate( 22.5deg); } |
96 | | -#status-indeterminate > div:nth-child(2) { transform: rotate( 67.5deg); } |
97 | | -#status-indeterminate > div:nth-child(3) { transform: rotate(112.5deg); } |
98 | | -#status-indeterminate > div:nth-child(4) { transform: rotate(157.5deg); } |
99 | | -#status-indeterminate > div:nth-child(5) { transform: rotate(202.5deg); } |
100 | | -#status-indeterminate > div:nth-child(6) { transform: rotate(247.5deg); } |
101 | | -#status-indeterminate > div:nth-child(7) { transform: rotate(292.5deg); } |
102 | | -#status-indeterminate > div:nth-child(8) { transform: rotate(337.5deg); } |
103 | | - |
104 | 65 | #status-notice { |
105 | | - margin: 0 100px; |
| 66 | + background-color: #5b3943; |
| 67 | + border-radius: 0.5rem; |
| 68 | + border: 1px solid #9b3943; |
| 69 | + color: #e0e0e0; |
| 70 | + font-family: 'Noto Sans', 'Droid Sans', Arial, sans-serif; |
106 | 71 | line-height: 1.3; |
107 | | - visibility: visible; |
108 | | - padding: 4px 6px; |
109 | | - visibility: visible; |
| 72 | + margin: 0 2rem; |
| 73 | + overflow: hidden; |
| 74 | + padding: 1rem; |
| 75 | + text-align: center; |
| 76 | + z-index: 1; |
110 | 77 | } |
111 | 78 | </style> |
112 | 79 | $GODOT_HEAD_INCLUDE |
113 | 80 | </head> |
114 | 81 | <body> |
115 | 82 | <canvas id="canvas"> |
116 | | - HTML5 canvas appears to be unsupported in the current browser.<br > |
117 | | - Please try updating or use a different browser. |
| 83 | + Your browser does not support the canvas tag. |
118 | 84 | </canvas> |
| 85 | + |
| 86 | + <noscript> |
| 87 | + Your browser does not support JavaScript. |
| 88 | + </noscript> |
| 89 | + |
119 | 90 | <div id="status"> |
120 | | - <div id="status-progress" style="display: none;" oncontextmenu="event.preventDefault();"> |
121 | | - <div id ="status-progress-inner"></div> |
122 | | - </div> |
123 | | - <div id="status-indeterminate" style="display: none;" oncontextmenu="event.preventDefault();"> |
124 | | - <div></div> |
125 | | - <div></div> |
126 | | - <div></div> |
127 | | - <div></div> |
128 | | - <div></div> |
129 | | - <div></div> |
130 | | - <div></div> |
131 | | - <div></div> |
132 | | - </div> |
133 | | - <div id="status-notice" class="godot" style="display: none;"></div> |
| 91 | + <img id="status-splash" src="$GODOT_SPLASH" alt=""> |
| 92 | + <progress id="status-progress"></progress> |
| 93 | + <div id="status-notice"></div> |
134 | 94 | </div> |
135 | 95 |
|
136 | 96 | <script src="$GODOT_URL"></script> |
|
140 | 100 | const engine = new Engine(GODOT_CONFIG); |
141 | 101 |
|
142 | 102 | (function () { |
143 | | - const INDETERMINATE_STATUS_STEP_MS = 100; |
| 103 | + const statusOverlay = document.getElementById('status'); |
144 | 104 | const statusProgress = document.getElementById('status-progress'); |
145 | | - const statusProgressInner = document.getElementById('status-progress-inner'); |
146 | | - const statusIndeterminate = document.getElementById('status-indeterminate'); |
147 | 105 | const statusNotice = document.getElementById('status-notice'); |
148 | 106 |
|
149 | 107 | let initializing = true; |
150 | | - let statusMode = 'hidden'; |
151 | | - |
152 | | - let animationCallbacks = []; |
153 | | - function animate(time) { |
154 | | - animationCallbacks.forEach((callback) => callback(time)); |
155 | | - requestAnimationFrame(animate); |
156 | | - } |
157 | | - requestAnimationFrame(animate); |
158 | | - |
159 | | - function animateStatusIndeterminate(ms) { |
160 | | - const i = Math.floor((ms / INDETERMINATE_STATUS_STEP_MS) % 8); |
161 | | - if (statusIndeterminate.children[i].style.borderTopColor === '') { |
162 | | - Array.prototype.slice.call(statusIndeterminate.children).forEach((child) => { |
163 | | - child.style.borderTopColor = ''; |
164 | | - }); |
165 | | - statusIndeterminate.children[i].style.borderTopColor = '#dfdfdf'; |
166 | | - } |
167 | | - } |
| 108 | + let statusMode = ''; |
168 | 109 |
|
169 | 110 | function setStatusMode(mode) { |
170 | 111 | if (statusMode === mode || !initializing) { |
171 | 112 | return; |
172 | 113 | } |
173 | | - [statusProgress, statusIndeterminate, statusNotice].forEach((elem) => { |
174 | | - elem.style.display = 'none'; |
175 | | - }); |
176 | | - animationCallbacks = animationCallbacks.filter(function (value) { |
177 | | - return (value !== animateStatusIndeterminate); |
178 | | - }); |
179 | | - switch (mode) { |
180 | | - case 'progress': |
181 | | - statusProgress.style.display = 'block'; |
182 | | - break; |
183 | | - case 'indeterminate': |
184 | | - statusIndeterminate.style.display = 'block'; |
185 | | - animationCallbacks.push(animateStatusIndeterminate); |
186 | | - break; |
187 | | - case 'notice': |
188 | | - statusNotice.style.display = 'block'; |
189 | | - break; |
190 | | - case 'hidden': |
191 | | - break; |
192 | | - default: |
193 | | - throw new Error('Invalid status mode'); |
| 114 | + if (mode === 'hidden') { |
| 115 | + statusOverlay.remove(); |
| 116 | + initializing = false; |
| 117 | + return; |
194 | 118 | } |
| 119 | + statusOverlay.style.visibility = 'visible'; |
| 120 | + statusProgress.style.display = mode === 'progress' ? 'block' : 'none'; |
| 121 | + statusNotice.style.display = mode === 'notice' ? 'block' : 'none'; |
195 | 122 | statusMode = mode; |
196 | 123 | } |
197 | 124 |
|
|
217 | 144 | const missing = Engine.getMissingFeatures({ |
218 | 145 | threads: GODOT_THREADS_ENABLED, |
219 | 146 | }); |
| 147 | + |
220 | 148 | if (missing.length !== 0) { |
221 | 149 | if (GODOT_CONFIG['serviceWorker'] && GODOT_CONFIG['ensureCrossOriginIsolationHeaders'] && 'serviceWorker' in navigator) { |
222 | 150 | // There's a chance that installing the service worker would fix the issue |
|
242 | 170 | displayFailureNotice(missingMsg + missing.join('\n')); |
243 | 171 | } |
244 | 172 | } else { |
245 | | - setStatusMode('indeterminate'); |
| 173 | + setStatusMode('progress'); |
246 | 174 | engine.startGame({ |
247 | 175 | 'onProgress': function (current, total) { |
248 | | - if (total > 0) { |
249 | | - statusProgressInner.style.width = `${(current / total) * 100}%`; |
250 | | - setStatusMode('progress'); |
251 | | - if (current === total) { |
252 | | - // wait for progress bar animation |
253 | | - setTimeout(() => { |
254 | | - setStatusMode('indeterminate'); |
255 | | - }, 500); |
256 | | - } |
| 176 | + if (current > 0 && total > 0) { |
| 177 | + statusProgress.value = current; |
| 178 | + statusProgress.max = total; |
257 | 179 | } else { |
258 | | - setStatusMode('indeterminate'); |
| 180 | + statusProgress.removeAttribute('value'); |
| 181 | + statusProgress.removeAttribute('max'); |
259 | 182 | } |
260 | 183 | }, |
261 | 184 | }).then(() => { |
262 | 185 | setStatusMode('hidden'); |
263 | | - initializing = false; |
264 | 186 | }, displayFailureNotice); |
265 | 187 | } |
266 | 188 | }()); |
|
0 commit comments