File size: 10,769 Bytes
173b08a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3527080
c1937fc
173b08a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3527080
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' lang='' xml:lang=''>
<head>
	<meta charset='utf-8' />
	<meta name='viewport' content='width=device-width, user-scalable=no' />
	<title>TowerBlocksGame</title>
	<style type='text/css'>



		body {

			touch-action: none;

			margin: 0;

			border: 0 none;

			padding: 0;

			text-align: center;

			background-color: black;

		}

		

		#progress-container {

			display: flex;

			flex-direction: column;

			align-items: center;

			justify-content: center;

			height: 100vh; /* 垂直居中整个页面高度 */

		}

		

		#custom-loader {

			position: absolute;

			top: 0;

			left: 0;

			right: 0;

			bottom: 0;

			display: flex;

			flex-direction: column;

			justify-content: center;

			align-items: center;

		}

		

		#logo {

			width: 400px;

			max-width: 80vw;

			margin-bottom: 250px;

		}

		

		#bottom-text {

			position: absolute;

			bottom: 20px;

			font-size: 14px;

			width: 90%;

			color: white;

		}



		#canvas {

			display: block;

			margin: 0;

			color: white;

		}



		#canvas:focus {

			outline: none;

		}



		.godot {

			font-family: 'Noto Sans', 'Droid Sans', Arial, sans-serif;

			color: #e0e0e0;

			background-color: #3b3943;

			background-image: linear-gradient(to bottom, #403e48, #35333c);

			border: 1px solid #45434e;

			box-shadow: 0 0 1px 1px #2f2d35;

		}





		/* Status display

		 * ============== */



		#status {

			position: absolute;

			left: 0;

			top: 0;

			right: 0;

			bottom: 0;

			display: flex;

			justify-content: center;

			align-items: center;

			/* don't consume click events - make children visible explicitly */

			visibility: hidden;

		}



		@keyframes breathing {

			0% { opacity: 0.5; }

			50% { opacity: 1; }

			100% { opacity: 0.5; }

		}



		/* 外层背景(加载图) */

		#status-progress {

			width: 512px;

			height: 512px;

			background-image: url('loadback.png');

			background-size: contain;

			background-repeat: no-repeat;

			background-position: center;

			position: absolute;

			top: 50%;

			left: 50%;

			transform: translate(-50%, -50%);

			visibility: visible;

		}



		/* 前景进度图 */

		#status-progress-inner {

			width: 100%;

			height: 100%;

			background-image: url('loadfront.png');

			background-size: contain;

			background-repeat: no-repeat;

			background-position: center;

			position: absolute;

			top: 0;

			left: 0;

			clip-path: inset(0 100% 0 0);  /* 动态控制这里 */

			<!-- transition: clip-path 0.3s ease-out; -->

			visibility: visible;

			pointer-events: none;

		}

		

		/* 百分比文字 */

		#progress-percent {

			position: absolute;

			top: 55%;  /* ✅ 在进度条底下 */

			left: 50%;

			transform: translate(-50%, 10px);  /* ✅ 微调垂直距离 */

			color: orange;

			font-weight: bold;

			font-size: 20px;

			text-shadow: 1px 1px 2px #000;

			z-index: 2;

			pointer-events: none;

		}



		#status-indeterminate {

			height: 42px;

			visibility: visible;

			position: relative;

		}



		#status-indeterminate > div {

			width: 4.5px;

			height: 0;

			border-style: solid;

			border-width: 9px 3px 0 3px;

			border-color: #2b2b2b transparent transparent transparent;

			transform-origin: center 21px;

			position: absolute;

		}



		#status-indeterminate > div:nth-child(1) { transform: rotate( 22.5deg); }

		#status-indeterminate > div:nth-child(2) { transform: rotate( 67.5deg); }

		#status-indeterminate > div:nth-child(3) { transform: rotate(112.5deg); }

		#status-indeterminate > div:nth-child(4) { transform: rotate(157.5deg); }

		#status-indeterminate > div:nth-child(5) { transform: rotate(202.5deg); }

		#status-indeterminate > div:nth-child(6) { transform: rotate(247.5deg); }

		#status-indeterminate > div:nth-child(7) { transform: rotate(292.5deg); }

		#status-indeterminate > div:nth-child(8) { transform: rotate(337.5deg); }



		#status-notice {

			margin: 0 100px;

			line-height: 1.3;

			visibility: visible;

			padding: 4px 6px;

			visibility: visible;

		}

		

		/* 手机适配 */

		@media only screen and (orientation: portrait) {

			#status-progress {

			  width: 61.8vw;

			  height: 61.8vw;

			}

			#logo {

				width: 200px;

				margin-bottom: 150px;

			}

		}

		

	</style>
	<link id='-gd-engine-icon' rel='icon' type='image/png' href='TowerBlocksGame.icon.png' />
<link rel='apple-touch-icon' href='TowerBlocksGame.apple-touch-icon.png'/>

	<link rel='apple-touch-icon' href='TowerBlocksGame.apple-touch-icon.png'/>
	<script type="text/javascript" src="./uni.webview.1.5.5.js"></script>
	<script type="text/javascript" src="./anan.tool.js"></script>
	<script type="text/javascript" src="./gameapp.js"></script>
</head>
<body>
<canvas id='canvas'>
	HTML5 canvas appears to be unsupported in the current browser.<br />
	Please try updating or use a different browser.
</canvas>
<div id="custom-loader">
	<div id="progress-container">
		<img id="logo" src="Logo.png" alt="Loading Logo"/>
		<div id='status-progress'>
			<div id ='status-progress-inner'></div>
		</div>
		<div id="progress-percent">0%</div>
	</div>
	<div id="bottom-text">Set your favorite music as the background music for your work,<br>so that you can share it with others.</div>
</div>
<div id='status'>
	<div id='status-indeterminate' style='display: none;' oncontextmenu='event.preventDefault();'>
		<div></div>
		<div></div>
		<div></div>
		<div></div>
		<div></div>
		<div></div>
		<div></div>
		<div></div>
	</div>
	<div id='status-notice' class='godot' style='display: none;'></div>
</div>

<!-- // 文字轮播效果  -->
<script type='text/javascript'>

	const textElement = document.getElementById("bottom-text");

	let currentIndex = 0;

	let textList = [];

	

	// 从文件读取内容

	fetch("./HintText.json")

		.then(response => response.json())

		.then(data => {

			textList = data;

			if (textList.length > 0) {

				updateText(); // 初始显示

				setInterval(updateText, 5000); // 每 5 秒切换一次

			}

		})

		.catch(error => {

			console.error("加载消息列表失败:", error);

		});

	function updateText() {

		textElement.innerText = textList[currentIndex];

		currentIndex = (currentIndex + 1) % textList.length;

	}

</script>

<script type='text/javascript' src='TowerBlocksGame.js'></script>
<script type='text/javascript'>//<![CDATA[

const GODOT_CONFIG = {"args":[],"canvasResizePolicy":0,"executable":"TowerBlocksGame","experimentalVK":false,"fileSizes":{"TowerBlocksGame.pck":56207824,"TowerBlocksGame.wasm":25658069},"focusCanvas":true,"gdnativeLibs":[]};

var engine = new Engine(GODOT_CONFIG);



(function() {

	const INDETERMINATE_STATUS_STEP_MS = 100;

	var logo = document.getElementById('logo');

	var statusProgress = document.getElementById('status-progress');

	var statusProgressInner = document.getElementById('status-progress-inner');

	var statusIndeterminate = document.getElementById('status-indeterminate');

	var statusNotice = document.getElementById('status-notice');



	var initializing = true;

	var statusMode = 'hidden';



	var animationCallbacks = [];

	

	const textElement = document.getElementById("bottom-text");

	let currentIndex = 0;

	let textList = [];

	

	//定义给 Godot 调用的函数

	window.godotFinishedLoading = function () {

		console.log('Godot 内部加载完成!');

		document.getElementById('status-progress-inner').style.clipPath = `inset(0 0% 0 0)`; // 100%

		setTimeout(() => {

			<!-- setStatusMode('hidden'); -->

			document.getElementById("custom-loader").style.display = "none";

			setStatusMode('hidden');

			initializing = false;

		}, 500); // 延迟一点

	};

	

	function animate(time) {

		animationCallbacks.forEach(callback => callback(time));

		requestAnimationFrame(animate);

	}

	requestAnimationFrame(animate);



	function setStatusMode(mode) {



		if (statusMode === mode || !initializing)

			return;

		[statusProgress, statusIndeterminate, statusNotice].forEach(elem => {

			elem.style.display = 'none';

		});

		animationCallbacks = animationCallbacks.filter(function(value) {

			return (value != animateStatusIndeterminate);

		});

		switch (mode) {

			case 'progress':

				statusProgress.style.display = 'block';

				logo.style.display = 'block';

				break;

			case 'indeterminate':

				statusIndeterminate.style.display = 'block';

				logo.style.display = 'block';

				animationCallbacks.push(animateStatusIndeterminate);

				break;

			case 'notice':

				statusNotice.style.display = 'block';

				logo.style.display = 'block';

				break;

			case 'hidden':

				if (logo) logo.style.display = 'none';

				break;

			default:

				throw new Error('Invalid status mode');

		}

		statusMode = mode;

	}



	function animateStatusIndeterminate(ms) {

		var i = Math.floor(ms / INDETERMINATE_STATUS_STEP_MS % 8);

		if (statusIndeterminate.children[i].style.borderTopColor == '') {

			Array.prototype.slice.call(statusIndeterminate.children).forEach(child => {

				child.style.borderTopColor = '';

			});

			statusIndeterminate.children[i].style.borderTopColor = '#dfdfdf';

		}

	}



	function setStatusNotice(text) {

		while (statusNotice.lastChild) {

			statusNotice.removeChild(statusNotice.lastChild);

		}

		var lines = text.split('\n');

		lines.forEach((line) => {

			statusNotice.appendChild(document.createTextNode(line));

			statusNotice.appendChild(document.createElement('br'));

		});

	};



	function displayFailureNotice(err) {

		var msg = err.message || err;

		console.error(msg);

		setStatusNotice(msg);

		setStatusMode('notice');

		initializing = false;

	};



	if (!Engine.isWebGLAvailable()) {

		displayFailureNotice('WebGL not available');

	} else {

		setStatusMode('indeterminate');

		engine.startGame({

			'onProgress': function (current, total) {

				if (total > 0) {

					let progress = Math.min((current / total) * 100, 90);  //进度条卡在90 等待游戏内加载

					progress = Math.floor(progress);

					document.getElementById("progress-percent").innerText = `${progress}%`;

					statusProgressInner.style.clipPath = `inset(0 ${100 - progress}% 0 0)`;

					setStatusMode('progress');

					if (current === total) {

						// wait for progress bar animation

						setTimeout(() => {

							setStatusMode('indeterminate');

						}, 500);

					}

				} else {

					setStatusMode('indeterminate');

				}

			},

		}).then(() => {

			// 不隐藏, 等待游戏通知

			console.log('Godot 引擎已启动, 等待游戏内资源加载完成...');

			//setStatusMode('hidden');

			//initializing = false;

		}, displayFailureNotice);



	}

})();

//]]></script>
</body>
</html>