|
| 1 | +<!DOCTYPE html> |
| 2 | +<!-- Created with https://packager.turbowarp.org/ --> |
| 3 | +<html> |
| 4 | +<head> |
| 5 | + <meta charset="utf-8"> |
| 6 | + <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> |
| 7 | + <!-- We only include this to explicitly loosen the CSP of various packager environments. It does not provide any security. --> |
| 8 | + <meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline' 'unsafe-eval' data: blob:"> |
| 9 | + <title>XInghui官网(测试)</title> |
| 10 | + <style> |
| 11 | + body { |
| 12 | + color: #ffffff; |
| 13 | + font-family: sans-serif; |
| 14 | + overflow: hidden; |
| 15 | + margin: 0; |
| 16 | + padding: 0; |
| 17 | + } |
| 18 | + :root, body.is-fullscreen { |
| 19 | + background-color: #000000; |
| 20 | + } |
| 21 | + [hidden] { |
| 22 | + display: none !important; |
| 23 | + } |
| 24 | + h1 { |
| 25 | + font-weight: normal; |
| 26 | + } |
| 27 | + a { |
| 28 | + color: inherit; |
| 29 | + text-decoration: underline; |
| 30 | + cursor: pointer; |
| 31 | + } |
| 32 | + |
| 33 | + #app, #loading, #error, #launch { |
| 34 | + position: absolute; |
| 35 | + top: 0; |
| 36 | + left: 0; |
| 37 | + width: 100%; |
| 38 | + height: 100%; |
| 39 | + } |
| 40 | + .screen { |
| 41 | + display: flex; |
| 42 | + flex-direction: column; |
| 43 | + align-items: center; |
| 44 | + justify-content: center; |
| 45 | + text-align: center; |
| 46 | + cursor: default; |
| 47 | + user-select: none; |
| 48 | + -webkit-user-select: none; |
| 49 | + background-color: #000000; |
| 50 | + } |
| 51 | + #launch { |
| 52 | + background-color: rgba(0, 0, 0, 0.7); |
| 53 | + cursor: pointer; |
| 54 | + } |
| 55 | + .green-flag { |
| 56 | + width: 80px; |
| 57 | + height: 80px; |
| 58 | + padding: 16px; |
| 59 | + border-radius: 100%; |
| 60 | + background: rgba(255, 255, 255, 0.75); |
| 61 | + border: 3px solid hsla(0, 100%, 100%, 1); |
| 62 | + display: flex; |
| 63 | + justify-content: center; |
| 64 | + align-items: center; |
| 65 | + box-sizing: border-box; |
| 66 | + } |
| 67 | + #loading { |
| 68 | + |
| 69 | + } |
| 70 | + .progress-bar-outer { |
| 71 | + border: 1px solid currentColor; |
| 72 | + height: 10px; |
| 73 | + width: 200px; |
| 74 | + max-width: 200px; |
| 75 | + } |
| 76 | + .progress-bar-inner { |
| 77 | + height: 100%; |
| 78 | + width: 0; |
| 79 | + background-color: currentColor; |
| 80 | + } |
| 81 | + .loading-text, noscript { |
| 82 | + font-weight: normal; |
| 83 | + font-size: 36px; |
| 84 | + margin: 0 0 16px; |
| 85 | + } |
| 86 | + .loading-image { |
| 87 | + margin: 0 0 16px; |
| 88 | + } |
| 89 | + #error-message, #error-stack { |
| 90 | + font-family: monospace; |
| 91 | + max-width: 600px; |
| 92 | + white-space: pre-wrap; |
| 93 | + user-select: text; |
| 94 | + -webkit-user-select: text; |
| 95 | + } |
| 96 | + #error-stack { |
| 97 | + text-align: left; |
| 98 | + max-height: 200px; |
| 99 | + overflow: auto; |
| 100 | + } |
| 101 | + .control-button { |
| 102 | + width: 2rem; |
| 103 | + height: 2rem; |
| 104 | + padding: 0.375rem; |
| 105 | + margin-top: 0.5rem; |
| 106 | + margin-bottom: 0.5rem; |
| 107 | + user-select: none; |
| 108 | + -webkit-user-select: none; |
| 109 | + cursor: pointer; |
| 110 | + border: 0; |
| 111 | + border-radius: 4px; |
| 112 | + } |
| 113 | + .control-button-highlight:hover { |
| 114 | + background: #ff4c4c26; |
| 115 | + } |
| 116 | + .control-button-highlight.active { |
| 117 | + background: #ff4c4c59; |
| 118 | + } |
| 119 | + .fullscreen-button { |
| 120 | + background: white; |
| 121 | + } |
| 122 | + .standalone-fullscreen-button { |
| 123 | + position: absolute; |
| 124 | + top: 0; |
| 125 | + right: 0; |
| 126 | + background-color: rgba(0, 0, 0, 0.5); |
| 127 | + border-radius: 0 0 0 4px; |
| 128 | + padding: 4px; |
| 129 | + cursor: pointer; |
| 130 | + } |
| 131 | + .sc-canvas { |
| 132 | + cursor: auto; |
| 133 | + } |
| 134 | + .sc-monitor-root[data-opcode^="data_"] .sc-monitor-value-color { |
| 135 | + background-color: #ff8c1a; |
| 136 | + } |
| 137 | + .sc-monitor-row-value-outer { |
| 138 | + background-color: #fc662c; |
| 139 | + } |
| 140 | + .sc-monitor-row-value-editing .sc-monitor-row-value-outer { |
| 141 | + background-color: #e25b27; |
| 142 | + } |
| 143 | + |
| 144 | + </style> |
| 145 | + <meta name="theme-color" content="#000000"> |
| 146 | + |
| 147 | +</head> |
| 148 | +<body> |
| 149 | + <div id="app"></div> |
| 150 | + |
| 151 | + <div id="launch" class="screen" hidden title="Click to start"> |
| 152 | + <div class="green-flag"> |
| 153 | + <svg viewBox="0 0 16.63 17.5" width="42" height="44"> |
| 154 | + <defs><style>.cls-1,.cls-2{fill:#4cbf56;stroke:#45993d;stroke-linecap:round;stroke-linejoin:round;}.cls-2{stroke-width:1.5px;}</style></defs> |
| 155 | + <path class="cls-1" d="M.75,2A6.44,6.44,0,0,1,8.44,2h0a6.44,6.44,0,0,0,7.69,0V12.4a6.44,6.44,0,0,1-7.69,0h0a6.44,6.44,0,0,0-7.69,0"/> |
| 156 | + <line class="cls-2" x1="0.75" y1="16.75" x2="0.75" y2="0.75"/> |
| 157 | + </svg> |
| 158 | + </div> |
| 159 | + </div> |
| 160 | + |
| 161 | + <div id="loading" class="screen"> |
| 162 | + <noscript>Enable JavaScript</noscript> |
| 163 | + <h1 class="loading-text">加载XingHui官网中(测试)。。。</h1> |
| 164 | + |
| 165 | + <div class="progress-bar-outer"><div class="progress-bar-inner" id="loading-inner"></div></div> |
| 166 | + </div> |
| 167 | + |
| 168 | + <div id="error" class="screen" hidden> |
| 169 | + <h1>Error</h1> |
| 170 | + <details> |
| 171 | + <summary id="error-message"></summary> |
| 172 | + <p id="error-stack"></p> |
| 173 | + </details> |
| 174 | + </div> |
| 175 | + |
| 176 | + <script src="script.js"></script> |
| 177 | + <script> |
| 178 | + const appElement = document.getElementById('app'); |
| 179 | + const launchScreen = document.getElementById('launch'); |
| 180 | + const loadingScreen = document.getElementById('loading'); |
| 181 | + const loadingInner = document.getElementById('loading-inner'); |
| 182 | + const errorScreen = document.getElementById('error'); |
| 183 | + const errorScreenMessage = document.getElementById('error-message'); |
| 184 | + const errorScreenStack = document.getElementById('error-stack'); |
| 185 | + |
| 186 | + const handleError = (error) => { |
| 187 | + console.error(error); |
| 188 | + if (!errorScreen.hidden) return; |
| 189 | + errorScreen.hidden = false; |
| 190 | + errorScreenMessage.textContent = '' + error; |
| 191 | + let debug = error && error.stack || 'no stack'; |
| 192 | + debug += '\nUser agent: ' + navigator.userAgent; |
| 193 | + errorScreenStack.textContent = debug; |
| 194 | + }; |
| 195 | + const setProgress = (progress) => { |
| 196 | + if (loadingInner) loadingInner.style.width = progress * 100 + '%'; |
| 197 | + }; |
| 198 | + const interpolate = (a, b, t) => a + t * (b - a); |
| 199 | + |
| 200 | + try { |
| 201 | + setProgress(0.1); |
| 202 | + |
| 203 | + const scaffolding = new Scaffolding.Scaffolding(); |
| 204 | + scaffolding.width = 640; |
| 205 | + scaffolding.height = 360; |
| 206 | + scaffolding.resizeMode = "preserve-ratio"; |
| 207 | + scaffolding.editableLists = false; |
| 208 | + scaffolding.usePackagedRuntime = true; |
| 209 | + scaffolding.setup(); |
| 210 | + scaffolding.appendTo(appElement); |
| 211 | + |
| 212 | + const vm = scaffolding.vm; |
| 213 | + window.scaffolding = scaffolding; |
| 214 | + window.vm = scaffolding.vm; |
| 215 | + window.Scratch = { |
| 216 | + vm, |
| 217 | + renderer: vm.renderer, |
| 218 | + audioEngine: vm.runtime.audioEngine, |
| 219 | + bitmapAdapter: vm.runtime.v2BitmapAdapter, |
| 220 | + videoProvider: vm.runtime.ioDevices.video.provider |
| 221 | + }; |
| 222 | + |
| 223 | + scaffolding.setUsername("player####".replace(/#/g, () => Math.floor(Math.random() * 10))); |
| 224 | + scaffolding.setAccentColor("#ff4c4c"); |
| 225 | + |
| 226 | + try { |
| 227 | + scaffolding.addCloudProvider(new Scaffolding.Cloud.WebSocketProvider(["wss://clouddata.turbowarp.org","wss://clouddata.turbowarp.xyz"], "p4-@作品.sb3")); |
| 228 | + } catch (error) { |
| 229 | + console.error(error); |
| 230 | + } |
| 231 | + |
| 232 | + vm.setTurboMode(false); |
| 233 | + if (vm.setInterpolation) vm.setInterpolation(false); |
| 234 | + if (vm.setFramerate) vm.setFramerate(60); |
| 235 | + if (vm.renderer.setUseHighQualityRender) vm.renderer.setUseHighQualityRender(true); |
| 236 | + if (vm.setRuntimeOptions) vm.setRuntimeOptions({ |
| 237 | + fencing: false, |
| 238 | + miscLimits: false, |
| 239 | + maxClones: 9999999999, |
| 240 | + }); |
| 241 | + if (vm.setCompilerOptions) vm.setCompilerOptions({ |
| 242 | + enabled: true, |
| 243 | + warpTimer: false |
| 244 | + }); |
| 245 | + if (vm.renderer.setMaxTextureDimension) vm.renderer.setMaxTextureDimension(2048); |
| 246 | + |
| 247 | + // enforcePrivacy threat model only makes sense in the editor |
| 248 | + if (vm.runtime.setEnforcePrivacy) vm.runtime.setEnforcePrivacy(false); |
| 249 | + |
| 250 | + if (typeof ScaffoldingAddons !== 'undefined') { |
| 251 | + ScaffoldingAddons.run(scaffolding, {"gamepad":false,"pointerlock":false,"specialCloudBehaviors":false,"unsafeCloudBehaviors":false,"pause":false}); |
| 252 | + } |
| 253 | + |
| 254 | + scaffolding.setExtensionSecurityManager({ |
| 255 | + getSandboxMode: () => 'unsandboxed', |
| 256 | + canLoadExtensionFromProject: () => true |
| 257 | + }); |
| 258 | + for (const extension of []) { |
| 259 | + vm.extensionManager.loadExtensionURL(extension); |
| 260 | + } |
| 261 | + |
| 262 | + vm.runtime.on('PROJECT_RUN_STOP', () => { |
| 263 | + if (!vm.isPaused || !vm.isPaused()) { |
| 264 | + window.close(); |
| 265 | + } |
| 266 | + }); |
| 267 | + |
| 268 | + } catch (e) { |
| 269 | + handleError(e); |
| 270 | + } |
| 271 | + </script> |
| 272 | + |
| 273 | + |
| 274 | + <script> |
| 275 | + const getProjectData = (function() { |
| 276 | + const storage = scaffolding.storage; |
| 277 | + storage.onprogress = (total, loaded) => { |
| 278 | + setProgress(interpolate(0.2, 0.98, loaded / total)); |
| 279 | + }; |
| 280 | + |
| 281 | + storage.addWebStore( |
| 282 | + [ |
| 283 | + storage.AssetType.ImageVector, |
| 284 | + storage.AssetType.ImageBitmap, |
| 285 | + storage.AssetType.Sound, |
| 286 | + storage.AssetType.Font |
| 287 | + ].filter(i => i), |
| 288 | + (asset) => new URL('./assets/' + asset.assetId + '.' + asset.dataFormat, location).href |
| 289 | + ); |
| 290 | + return () => new Promise((resolve, reject) => { |
| 291 | + const xhr = new XMLHttpRequest(); |
| 292 | + xhr.onload = () => { |
| 293 | + resolve(xhr.response); |
| 294 | + }; |
| 295 | + xhr.onerror = () => { |
| 296 | + if (location.protocol === 'file:') { |
| 297 | + reject(new Error('Zip environment must be used on a website, not on a local file. To fix this error, use the "Plain HTML" environment instead.')); |
| 298 | + } else { |
| 299 | + reject(new Error('Request to load project data failed.')); |
| 300 | + } |
| 301 | + }; |
| 302 | + xhr.onprogress = (e) => { |
| 303 | + if (e.lengthComputable) { |
| 304 | + setProgress(interpolate(0.1, 0.2, e.loaded / e.total)); |
| 305 | + } |
| 306 | + }; |
| 307 | + xhr.responseType = 'arraybuffer'; |
| 308 | + xhr.open('GET', "./assets/project.json"); |
| 309 | + xhr.send(); |
| 310 | + }); |
| 311 | + })(); |
| 312 | + </script> |
| 313 | + <script> |
| 314 | + const run = async () => { |
| 315 | + const projectData = await getProjectData(); |
| 316 | + await scaffolding.loadProject(projectData); |
| 317 | + setProgress(1); |
| 318 | + loadingScreen.hidden = true; |
| 319 | + if (true) { |
| 320 | + scaffolding.start(); |
| 321 | + } else { |
| 322 | + launchScreen.hidden = false; |
| 323 | + launchScreen.addEventListener('click', () => { |
| 324 | + launchScreen.hidden = true; |
| 325 | + scaffolding.start(); |
| 326 | + }); |
| 327 | + launchScreen.focus(); |
| 328 | + } |
| 329 | + }; |
| 330 | + run().catch(handleError); |
| 331 | + </script> |
| 332 | +</body> |
| 333 | +</html> |
0 commit comments