From 6e701d8ac32e229a9968c55d07baf4b3dd3cd26d Mon Sep 17 00:00:00 2001 From: Theis Pieter Hollebeek Date: Mon, 13 Oct 2025 17:28:12 +0200 Subject: [PATCH] include project name in .karlkode --- src/index.js | 2 ++ src/vermiparous.js | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index cef10e0..61043f6 100644 --- a/src/index.js +++ b/src/index.js @@ -100,6 +100,7 @@ loadButton.onclick = async () => { spriteEditor.importSprites( sprites.map(({ name, mime, content }) => ({ name, mime, bytes: content })), ); + projectName.value = code.name; const dec = new TextDecoder(); editor.setValue(dec.decode(code.content)); }; @@ -131,6 +132,7 @@ function saveKarlKoder() { downloadFile( slugify(projectName.value) || "project", Vermiparous.en( + projectName.value, editor.getValue(), spriteEditor.sprites, ), diff --git a/src/vermiparous.js b/src/vermiparous.js index 4438a45..0913116 100644 --- a/src/vermiparous.js +++ b/src/vermiparous.js @@ -13,7 +13,7 @@ function strToBytes(str) { } export class Vermiparous { - static en(code, assets) { + static en(name, code, assets) { const ret = []; for (const asset of assets) { ret.push(...strToBytes("asset")); @@ -28,9 +28,11 @@ export class Vermiparous { ret.push(...asset.bytes); } ret.push(...strToBytes("code")); - ret.push(...strToBytes("0;0;")); + ret.push(...strToBytes(name.length.toString())); + ret.push(...strToBytes(";0;")); ret.push(...strToBytes(code.length.toString())); ret.push(...strToBytes(";")); + ret.push(...strToBytes(name)); ret.push(...strToBytes(code)); return new Uint8Array(ret); }