diff --git a/index.html b/index.html index b88df36..8ad2b37 100644 --- a/index.html +++ b/index.html @@ -98,7 +98,7 @@ margin-top: 15px; /* Space below the quote block */ padding: 10px 15px; max-width: 280px; /* Slightly adjust if needed, to align nicely with quote block */ - width: 80%; /* Similar to quote block or adjust */ + width: 80%; /* Similar to quote block or adjust */ font-size: 0.8em; /* Smaller, informative text */ color: #b0b0b0; /* A lighter gray, like the attribution */ line-height: 1.5; @@ -615,14 +615,12 @@ .form-grid { grid-template-columns: 1fr; gap: 25px; - } - } + } + } -
-
-
- ← Back + ← Back

Read Me

Welcome to the LEGO Island web port project! This is a recreation of the classic 1997 PC game, rebuilt to run in modern web browsers using Emscripten.

@@ -659,7 +656,7 @@
- ← Back + ← Back
LEGO Island Shark and Brickster @@ -682,7 +679,7 @@ - +
@@ -748,7 +745,7 @@
+
@@ -776,7 +773,7 @@
- ← Back + ← Back
@@ -847,14 +844,12 @@
-
-
Loading game... @@ -879,7 +874,6 @@ preRun: function() { Module["addRunDependency"]("isle"); Module.running = true; - ENV.MY_FILE_ROOT = "/usr/lib/test"; }, canvas: (function() { return document.getElementById('canvas'); @@ -1036,9 +1030,9 @@ }, async saveConfig() { - const handle = await this.getFileHandle(); - if (!handle) return; - + // This function now uses an inline Web Worker for maximum compatibility, + // especially with Safari, which does not support createWritable(). + let iniContent = '[isle]\n'; const elements = this.form.elements; @@ -1064,10 +1058,50 @@ } } - const writable = await handle.createWritable(); - await writable.write(iniContent); - await writable.close(); - console.log('Config saved to', this.filePath); + const workerCode = ` + self.onmessage = async (e) => { + if (e.data.action === 'save') { + try { + const root = await navigator.storage.getDirectory(); + const handle = await root.getFileHandle(e.data.filePath, { create: true }); + const accessHandle = await handle.createSyncAccessHandle(); + const encoder = new TextEncoder(); + const encodedData = encoder.encode(e.data.content); + + accessHandle.truncate(0); + accessHandle.write(encodedData, { at: 0 }); + accessHandle.flush(); + accessHandle.close(); + + self.postMessage({ status: 'success', message: 'Config saved to ' + e.data.filePath }); + } catch (err) { + self.postMessage({ status: 'error', message: 'Failed to save config: ' + err.message }); + } + } + }; + `; + + const blob = new Blob([workerCode], { type: 'application/javascript' }); + const workerUrl = URL.createObjectURL(blob); + const worker = new Worker(workerUrl); + + worker.postMessage({ + action: 'save', + content: iniContent, + filePath: this.filePath + }); + + worker.onmessage = (e) => { + console.log(e.data.message); + URL.revokeObjectURL(workerUrl); // Clean up the temporary URL + worker.terminate(); + }; + + worker.onerror = (e) => { + console.error('An error occurred in the config-saving worker:', e.message); + URL.revokeObjectURL(workerUrl); + worker.terminate(); + }; }, async loadConfig() { @@ -1139,4 +1173,4 @@ - + \ No newline at end of file