From f5379e13a6ce1a03cd297465f9a5c7d2124071ac Mon Sep 17 00:00:00 2001 From: Cole Crouter Date: Sun, 3 Dec 2023 17:01:43 -0600 Subject: [PATCH] Temp fix for copper pan hat --- src/routes/(edit)/appearance/Preview.svelte | 18 ++++++++++++++++-- src/routes/(edit)/inventory/+page.svelte | 13 +++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/routes/(edit)/appearance/Preview.svelte b/src/routes/(edit)/appearance/Preview.svelte index 090fe2c..207aafb 100644 --- a/src/routes/(edit)/appearance/Preview.svelte +++ b/src/routes/(edit)/appearance/Preview.svelte @@ -128,7 +128,18 @@ } } - const hatData = character.hat && itemData.get(character.hat.name); + let hatData: ItemInformation | undefined; + if (character.hat?.name === 'Copper Pan') { + // I hate this so much, but there's no way to grab the info from itemData because +layout.ts converts iteminfo.json into a Map, + // so the hat entry gets nuked. Maybe in the future we'll use a Map> instead. + const res = await fetch(base + '/iteminfo.json'); + const allItems = (await res.json()) as Array<[string, ItemInformation]>; + const pan = allItems.find(([name]) => name === 'Copper Pan')![1]; + hatData = pan; + } else { + hatData = character.hat && itemData.get(character.hat.name); + } + if (hatData) { hatPosition = hatData.sprite; showHair = hatData?._type == 'Hat' && hatData.showRealHair; @@ -257,7 +268,10 @@ position: absolute; width: 100%; height: 100%; - box-shadow: 0 0 0 2px #8e3d04, 0 0 0 4px #d97804, 0 0 0 6px #5b2b29; + box-shadow: + 0 0 0 2px #8e3d04, + 0 0 0 4px #d97804, + 0 0 0 6px #5b2b29; border-radius: 2px; } diff --git a/src/routes/(edit)/inventory/+page.svelte b/src/routes/(edit)/inventory/+page.svelte index d092f95..d448d47 100644 --- a/src/routes/(edit)/inventory/+page.svelte +++ b/src/routes/(edit)/inventory/+page.svelte @@ -208,6 +208,11 @@ // This is required for the game to recognize the item as the correct type, but isn't part of the XML structureS // @ts-expect-error newItem['@_xsi:type'] = type; + + if (symbol === 'hat' && newItemName === 'Copper Pan') { + // @ts-expect-error + newItem['@_xsi:type'] = 'Hat'; + } } if (newItemData._type === 'ObjectInformation') { @@ -308,6 +313,14 @@ player[symbol] = newItem; } + if (symbol === 'hat' && newItem.name === 'Copper Pan') { + newItem.ignoreHairstyleOffset = true; + newItem.parentSheetIndex = 71; + newItem.indexInTileSheet = 71; + newItem.category = Category.Hat; + newItem.which = 71; + } + // Clear item from the editor window newItemName = '';