From 9f4c532e9a18733ddcfe7d2cb4c8037713214c22 Mon Sep 17 00:00:00 2001 From: Cole Crouter Date: Sat, 17 Aug 2024 16:31:38 -0600 Subject: [PATCH] Fixed clothing colors --- src/dump.ts | 369 +++++++++++------ src/lib/CharacterColors.ts | 298 +++++++------- src/lib/SaveFile.ts | 6 + src/lib/Spritesheet.ts | 210 ++++++---- src/routes/(edit)/inventory/+page.svelte | 46 ++- src/types/items/1.6.ts | 501 ++++++++++++++++------- static/iteminfo.json | 2 +- 7 files changed, 903 insertions(+), 529 deletions(-) diff --git a/src/dump.ts b/src/dump.ts index fa7e2b8..d89eafc 100644 --- a/src/dump.ts +++ b/src/dump.ts @@ -1,152 +1,279 @@ -import { copyFile, mkdir, readFile, writeFile } from 'fs/promises'; -import { GetSprite } from './lib/Spritesheet.js'; -import type { BigCraftable, Boots, Clothing, Furniture, FurnitureType, Hat, Object, Tool, Weapon } from './types/items/1.6.js'; +import { copyFile, mkdir, readFile, writeFile } from "fs/promises"; +import { GetSprite } from "./lib/Spritesheet.js"; +import type { + BigCraftable, + Boots, + Clothing, + Furniture, + FurnitureType, + Hat, + Object, + Tool, + Weapon, +} from "./types/items/1.6.js"; -const objects = JSON.parse(await readFile('./content/Data/Objects.json', 'utf-8')) as Record; +const objects = JSON.parse( + await readFile("./content/Data/Objects.json", "utf-8"), +) as Record; const objectsArray = Object.values(objects).map((obj) => - // There's a ton of "Stone" entries in objects, only use the one that has an id of 390 - (obj.Name === 'Stone' && obj.SpriteIndex !== 390) - ? undefined - : ({ ...obj, _type: 'Object' })); + // There's a ton of "Stone" entries in objects, only use the one that has an id of 390 + obj.Name === "Stone" && obj.SpriteIndex !== 390 + ? undefined + : { ...obj, _type: "Object" }, +); -const bigCraftables = JSON.parse(await readFile('./content/Data/BigCraftables.json', 'utf-8')) as Record; -const bigCraftablesArray = Object.values(bigCraftables).map(obj => ({ ...obj, _type: 'BigCraftable' })); +const bigCraftables = JSON.parse( + await readFile("./content/Data/BigCraftables.json", "utf-8"), +) as Record; +const bigCraftablesArray = Object.values(bigCraftables).map((obj) => ({ + ...obj, + _type: "BigCraftable", +})); -const boots = JSON.parse(await readFile('./content/Data/Boots.json', 'utf-8')) as Record; +const boots = JSON.parse( + await readFile("./content/Data/Boots.json", "utf-8"), +) as Record; const bootsArray = Object.entries(boots).map(([key, value]) => { - const props = value.split('/'); - return { - _type: 'Boots', - Name: props[0], - Description: props[1], - Price: Number(props[2]), - Defense: Number(props[3]), - Immunity: Number(props[4]), - ColorIndex: Number(props[5]), - DisplayName: props[6], - Sprite: GetSprite('Boots', Number(key)), - ParentSheetIndex: Number(key), - } satisfies Boots; + const props = value.split("/"); + return { + _type: "Boots", + Name: props[0], + Description: props[1], + Price: Number(props[2]), + Defense: Number(props[3]), + Immunity: Number(props[4]), + ColorIndex: Number(props[5]), + DisplayName: props[6], + Sprite: GetSprite("Boots", Number(key)), + ParentSheetIndex: Number(key), + } satisfies Boots; }); -const shirts = JSON.parse(await readFile('./content/Data/Shirts.json', 'utf-8')) as Record; -const pants = JSON.parse(await readFile('./content/Data/Pants.json', 'utf-8')) as Record; -const shirtsArray = Object.values(shirts).map((shirt, i) => ({ ...shirt, _type: 'Shirt', ParentSheetIndex: i, Type: 'Shirt' })); -const pantsArray = Object.values(pants).map((pant, i) => ({ ...pant, _type: 'Pants', ParentSheetIndex: i, Type: 'Pants' })); +const shirts = JSON.parse( + await readFile("./content/Data/Shirts.json", "utf-8"), +) as Record; +const pants = JSON.parse( + await readFile("./content/Data/Pants.json", "utf-8"), +) as Record; +const shirtsArray = Object.entries(shirts).map(([key, value], i) => ({ + ...value, + id: key, + _type: "Shirt", + ParentSheetIndex: i, + Type: "Shirt", +})); +const pantsArray = Object.entries(pants).map(([key, value], i) => ({ + ...value, + id: key, + _type: "Pants", + ParentSheetIndex: i, + Type: "Pants", +})); const clothingArray = [...shirtsArray, ...pantsArray]; -const furniture = JSON.parse(await readFile('./content/Data/Furniture.json', 'utf-8')) as Record; +const furniture = JSON.parse( + await readFile("./content/Data/Furniture.json", "utf-8"), +) as Record; const furnitureArray = Object.entries(furniture).map(([key, value]) => { - const props = value.split('/'); - const split2 = props[2].split(' '); - const split3 = props[3].split(' '); + const props = value.split("/"); + const split2 = props[2].split(" "); + const split3 = props[3].split(" "); - return { - _type: 'Furniture', - Name: props[0], - Type: props[1] as FurnitureType, - TilesheetSize: split2[0] === '-1' ? -1 : { width: Number(split2[0]), height: Number(split2[1]) }, - BoundingBoxSize: split3[0] === '-1' ? -1 : { width: Number(split3[0]), height: Number(split3[1]) }, - Rotations: Number(props[4]), - Price: Number(props[5]), - DisplayName: props[6], - PlacementRestriction: Number(props[7]), - Sprite: GetSprite('Furniture', Number(key)), - ParentSheetIndex: Number(key), - } satisfies Furniture; + return { + _type: "Furniture", + Name: props[0], + Type: props[1] as FurnitureType, + TilesheetSize: + split2[0] === "-1" + ? -1 + : { width: Number(split2[0]), height: Number(split2[1]) }, + BoundingBoxSize: + split3[0] === "-1" + ? -1 + : { width: Number(split3[0]), height: Number(split3[1]) }, + Rotations: Number(props[4]), + Price: Number(props[5]), + DisplayName: props[6], + PlacementRestriction: Number(props[7]), + Sprite: GetSprite("Furniture", Number(key)), + ParentSheetIndex: Number(key), + } satisfies Furniture; }); -const hats = JSON.parse(await readFile('./content/Data/Hats.json', 'utf-8')) as Record; -const hatsArray = Object.entries(hats).map(([key, value]) => { - const props = value.split('/'); - return { - _type: 'Hat', - Name: props[0], - Description: props[1], - ShowRealHair: props[2] === 'true', - SkipHairstyleOffset: props[3] === 'true', - DisplayName: props[4], - Sprite: GetSprite('Hat', Number(key)), - ParentSheetIndex: Number(key), - } satisfies Hat; +const hats = JSON.parse( + await readFile("./content/Data/Hats.json", "utf-8"), +) as Record; +const hatsArray = Object.entries(hats).map(([key, value], i) => { + const props = value.split("/"); + return { + _type: "Hat", + id: key, + Name: props[0], + Description: props[1], + ShowRealHair: props[2] === "true", + SkipHairstyleOffset: props[3] === "true", + DisplayName: props[4], + ParentSheetIndex: Number(key), + Sprite: GetSprite("Hat", Number(key)), + } satisfies Hat; }); -const weapons = JSON.parse(await readFile('./content/Data/Weapons.json', 'utf-8')) as Record; -const weaponsArray = Object.values(weapons).map(weapon => ({ ...weapon, _type: 'Weapon' })); -const tools = JSON.parse(await readFile('./content/Data/Tools.json', 'utf-8')) as Record; -const toolsArray = Object.values(tools).map(tool => ({ ...tool, _type: 'Tool' })); +const weapons = JSON.parse( + await readFile("./content/Data/Weapons.json", "utf-8"), +) as Record; +const weaponsArray = Object.values(weapons).map((weapon) => ({ + ...weapon, + _type: "Weapon", +})); +const tools = JSON.parse( + await readFile("./content/Data/Tools.json", "utf-8"), +) as Record; +const toolsArray = Object.values(tools).map((tool) => ({ + ...tool, + _type: "Tool", +})); -const cookingRecipes = JSON.parse(await readFile('./content/Data/CookingRecipes.json', 'utf-8')) as Record; +const cookingRecipes = JSON.parse( + await readFile("./content/Data/CookingRecipes.json", "utf-8"), +) as Record; const cookingRecipesArray = Object.entries(cookingRecipes).map(([key]) => key); -await writeFile('./static/cookingrecipes.json', JSON.stringify(cookingRecipesArray)); +await writeFile( + "./static/cookingrecipes.json", + JSON.stringify(cookingRecipesArray), +); -const craftingRecipes = JSON.parse(await readFile('./content/Data/CraftingRecipes.json', 'utf-8')) as Record; -const craftingRecipesArray = Object.entries(craftingRecipes).map(([key]) => key); -await writeFile('./static/craftingrecipes.json', JSON.stringify(craftingRecipesArray)); +const craftingRecipes = JSON.parse( + await readFile("./content/Data/CraftingRecipes.json", "utf-8"), +) as Record; +const craftingRecipesArray = Object.entries(craftingRecipes).map( + ([key]) => key, +); +await writeFile( + "./static/craftingrecipes.json", + JSON.stringify(craftingRecipesArray), +); -const writeToFile = JSON.stringify([...objectsArray, ...bigCraftablesArray, ...bootsArray, ...clothingArray, ...furnitureArray, ...hatsArray, ...weaponsArray, ...toolsArray].filter((o) => o).map(item => [item.Name, item])); -await writeFile('./static/iteminfo.json', writeToFile); +const writeToFile = JSON.stringify( + [ + ...objectsArray, + ...bigCraftablesArray, + ...bootsArray, + ...clothingArray, + ...furnitureArray, + ...hatsArray, + ...weaponsArray, + ...toolsArray, + ] + .filter((o) => o) + .map((item) => [item.Name, item]), +); +await writeFile("./static/iteminfo.json", writeToFile); // Copy all textures into assets folder -await copyFile(`./content/TileSheets/Craftables.png`, `./static/assets/Craftables.png`); -await copyFile(`./content/TileSheets/furniture.png`, `./static/assets/furniture.png`); -await copyFile(`./content/TileSheets/weapons.png`, `./static/assets/weapons.png`); +await copyFile( + `./content/TileSheets/Craftables.png`, + `./static/assets/Craftables.png`, +); +await copyFile( + `./content/TileSheets/furniture.png`, + `./static/assets/furniture.png`, +); +await copyFile( + `./content/TileSheets/weapons.png`, + `./static/assets/weapons.png`, +); await copyFile(`./content/TileSheets/tools.png`, `./static/assets/tools.png`); -await copyFile(`./content/Characters/Farmer/pants.png`, `./static/assets/pants.png`); -await copyFile(`./content/Characters/Farmer/shirts.png`, `./static/assets/shirts.png`); -await copyFile(`./content/Characters/Farmer/accessories.png`, `./static/assets/accessories.png`); -await copyFile(`./content/Characters/Farmer/farmer_base.png`, `./static/assets/farmer_base.png`); -await copyFile(`./content/Characters/Farmer/farmer_base_bald.png`, `./static/assets/farmer_base_bald.png`); -await copyFile(`./content/Characters/Farmer/farmer_girl_base.png`, `./static/assets/farmer_girl_base.png`); -await copyFile(`./content/Characters/Farmer/farmer_girl_base_bald.png`, `./static/assets/farmer_girl_base_bald.png`); -await copyFile(`./content/Characters/Farmer/hairstyles.png`, `./static/assets/hairstyles.png`); -await copyFile(`./content/Characters/Farmer/hairstyles2.png`, `./static/assets/hairstyles2.png`); -await copyFile('./content/maps/springobjects.png', './static/assets/springobjects.png'); -await copyFile('./content/Characters/Farmer/hats.png', './static/assets/hats.png'); -await copyFile('./content/LooseSprites/daybg.png', './static/assets/daybg.png'); +await copyFile( + `./content/Characters/Farmer/pants.png`, + `./static/assets/pants.png`, +); +await copyFile( + `./content/Characters/Farmer/shirts.png`, + `./static/assets/shirts.png`, +); +await copyFile( + `./content/Characters/Farmer/accessories.png`, + `./static/assets/accessories.png`, +); +await copyFile( + `./content/Characters/Farmer/farmer_base.png`, + `./static/assets/farmer_base.png`, +); +await copyFile( + `./content/Characters/Farmer/farmer_base_bald.png`, + `./static/assets/farmer_base_bald.png`, +); +await copyFile( + `./content/Characters/Farmer/farmer_girl_base.png`, + `./static/assets/farmer_girl_base.png`, +); +await copyFile( + `./content/Characters/Farmer/farmer_girl_base_bald.png`, + `./static/assets/farmer_girl_base_bald.png`, +); +await copyFile( + `./content/Characters/Farmer/hairstyles.png`, + `./static/assets/hairstyles.png`, +); +await copyFile( + `./content/Characters/Farmer/hairstyles2.png`, + `./static/assets/hairstyles2.png`, +); +await copyFile( + "./content/maps/springobjects.png", + "./static/assets/springobjects.png", +); +await copyFile( + "./content/Characters/Farmer/hats.png", + "./static/assets/hats.png", +); +await copyFile("./content/LooseSprites/daybg.png", "./static/assets/daybg.png"); // Copy all portraits into assets folder const chars = [ - 'Abigail', - 'Alex', - 'Caroline', - 'Clint', - 'Demetrius', - 'Dwarf', - 'Elliott', - 'Emily', - 'Evelyn', - 'George', - 'Gus', - 'Haley', - 'Harvey', - 'Jas', - 'Jodi', - 'Kent', - 'Krobus', - 'Leah', - 'Lewis', - 'Linus', - 'Marnie', - 'Maru', - 'Pam', - 'Penny', - 'Pierre', - 'Robin', - 'Sam', - 'Sandy', - 'Sebastian', - 'Shane', - 'Vincent', - 'Willy', - 'Wizard', + "Abigail", + "Alex", + "Caroline", + "Clint", + "Demetrius", + "Dwarf", + "Elliott", + "Emily", + "Evelyn", + "George", + "Gus", + "Haley", + "Harvey", + "Jas", + "Jodi", + "Kent", + "Krobus", + "Leah", + "Lewis", + "Linus", + "Marnie", + "Maru", + "Pam", + "Penny", + "Pierre", + "Robin", + "Sam", + "Sandy", + "Sebastian", + "Shane", + "Vincent", + "Willy", + "Wizard", ]; // Create portraits folder if it doesn't exist try { - await mkdir('./static/assets/portraits'); -} catch (e) { } + await mkdir("./static/assets/portraits"); +} catch (e) {} for (const char of chars) { - await copyFile(`./content/Portraits/${char}.png`, `./static/assets/portraits/${char}.png`); -}; \ No newline at end of file + await copyFile( + `./content/Portraits/${char}.png`, + `./static/assets/portraits/${char}.png`, + ); +} diff --git a/src/lib/CharacterColors.ts b/src/lib/CharacterColors.ts index af4871e..c38b5a9 100644 --- a/src/lib/CharacterColors.ts +++ b/src/lib/CharacterColors.ts @@ -1,172 +1,172 @@ import type { HairstyleColor } from "$types/save/1.5"; export const PrimarySkinColors: Array = [ - { R: 249, G: 174, B: 137, A: 255, PackedValue: 0 }, - { R: 225, G: 140, B: 102, A: 255, PackedValue: 0 }, - { R: 240, G: 160, B: 130, A: 255, PackedValue: 0 }, - { R: 247, G: 185, B: 154, A: 255, PackedValue: 0 }, - { R: 196, G: 100, B: 71, A: 255, PackedValue: 0 }, - { R: 174, G: 95, B: 57, A: 255, PackedValue: 0 }, - { R: 162, G: 70, B: 18, A: 255, PackedValue: 0 }, - { R: 210, G: 138, B: 59, A: 255, PackedValue: 0 }, - { R: 189, G: 121, B: 68, A: 255, PackedValue: 0 }, - { R: 255, G: 171, B: 178, A: 255, PackedValue: 0 }, - { R: 214, G: 178, B: 169, A: 255, PackedValue: 0 }, - { R: 232, G: 138, B: 94, A: 255, PackedValue: 0 }, - { R: 226, G: 226, B: 177, A: 255, PackedValue: 0 }, - { R: 239, G: 140, B: 160, A: 255, PackedValue: 0 }, - { R: 140, G: 84, B: 41, A: 255, PackedValue: 0 }, - { R: 218, G: 131, B: 84, A: 255, PackedValue: 0 }, - { R: 104, G: 191, B: 232, A: 255, PackedValue: 0 }, - { R: 189, G: 232, B: 136, A: 255, PackedValue: 0 }, - { R: 255, G: 142, B: 142, A: 255, PackedValue: 0 }, - { R: 178, G: 145, B: 255, A: 255, PackedValue: 0 }, - { R: 255, G: 221, B: 140, A: 255, PackedValue: 0 }, - { R: 221, G: 210, B: 211, A: 255, PackedValue: 0 }, - { R: 255, G: 205, B: 158, A: 255, PackedValue: 0 }, - { R: 255, G: 211, B: 181, A: 255, PackedValue: 0 }, + { R: 249, G: 174, B: 137, A: 255, PackedValue: 0 }, + { R: 225, G: 140, B: 102, A: 255, PackedValue: 0 }, + { R: 240, G: 160, B: 130, A: 255, PackedValue: 0 }, + { R: 247, G: 185, B: 154, A: 255, PackedValue: 0 }, + { R: 196, G: 100, B: 71, A: 255, PackedValue: 0 }, + { R: 174, G: 95, B: 57, A: 255, PackedValue: 0 }, + { R: 162, G: 70, B: 18, A: 255, PackedValue: 0 }, + { R: 210, G: 138, B: 59, A: 255, PackedValue: 0 }, + { R: 189, G: 121, B: 68, A: 255, PackedValue: 0 }, + { R: 255, G: 171, B: 178, A: 255, PackedValue: 0 }, + { R: 214, G: 178, B: 169, A: 255, PackedValue: 0 }, + { R: 232, G: 138, B: 94, A: 255, PackedValue: 0 }, + { R: 226, G: 226, B: 177, A: 255, PackedValue: 0 }, + { R: 239, G: 140, B: 160, A: 255, PackedValue: 0 }, + { R: 140, G: 84, B: 41, A: 255, PackedValue: 0 }, + { R: 218, G: 131, B: 84, A: 255, PackedValue: 0 }, + { R: 104, G: 191, B: 232, A: 255, PackedValue: 0 }, + { R: 189, G: 232, B: 136, A: 255, PackedValue: 0 }, + { R: 255, G: 142, B: 142, A: 255, PackedValue: 0 }, + { R: 178, G: 145, B: 255, A: 255, PackedValue: 0 }, + { R: 255, G: 221, B: 140, A: 255, PackedValue: 0 }, + { R: 221, G: 210, B: 211, A: 255, PackedValue: 0 }, + { R: 255, G: 205, B: 158, A: 255, PackedValue: 0 }, + { R: 255, G: 211, B: 181, A: 255, PackedValue: 0 }, ]; export const SecondarySkinColors: Array = [ - { R: 224, G: 107, B: 101, A: 255, PackedValue: 0 }, - { R: 168, G: 67, B: 61, A: 255, PackedValue: 0 }, - { R: 209, G: 110, B: 72, A: 255, PackedValue: 0 }, - { R: 227, G: 149, B: 135, A: 255, PackedValue: 0 }, - { R: 154, G: 63, B: 45, A: 255, PackedValue: 0 }, - { R: 112, G: 42, B: 25, A: 255, PackedValue: 0 }, - { R: 119, G: 32, B: 20, A: 255, PackedValue: 0 }, - { R: 190, G: 94, B: 44, A: 255, PackedValue: 0 }, - { R: 162, G: 72, B: 26, A: 255, PackedValue: 0 }, - { R: 194, G: 115, B: 110, A: 255, PackedValue: 0 }, - { R: 154, G: 97, B: 108, A: 255, PackedValue: 0 }, - { R: 163, G: 64, B: 45, A: 255, PackedValue: 0 }, - { R: 152, G: 130, B: 95, A: 255, PackedValue: 0 }, - { R: 172, G: 78, B: 90, A: 255, PackedValue: 0 }, - { R: 90, G: 40, B: 19, A: 255, PackedValue: 0 }, - { R: 175, G: 64, B: 41, A: 255, PackedValue: 0 }, - { R: 0, G: 113, B: 206, A: 255, PackedValue: 0 }, - { R: 64, G: 178, B: 22, A: 255, PackedValue: 0 }, - { R: 175, G: 22, B: 22, A: 255, PackedValue: 0 }, - { R: 120, G: 0, B: 206, A: 255, PackedValue: 0 }, - { R: 204, G: 133, B: 26, A: 255, PackedValue: 0 }, - { R: 136, G: 124, B: 129, A: 255, PackedValue: 0 }, - { R: 250, G: 130, B: 117, A: 255, PackedValue: 0 }, - { R: 255, G: 155, B: 135, A: 255, PackedValue: 0 }, + { R: 224, G: 107, B: 101, A: 255, PackedValue: 0 }, + { R: 168, G: 67, B: 61, A: 255, PackedValue: 0 }, + { R: 209, G: 110, B: 72, A: 255, PackedValue: 0 }, + { R: 227, G: 149, B: 135, A: 255, PackedValue: 0 }, + { R: 154, G: 63, B: 45, A: 255, PackedValue: 0 }, + { R: 112, G: 42, B: 25, A: 255, PackedValue: 0 }, + { R: 119, G: 32, B: 20, A: 255, PackedValue: 0 }, + { R: 190, G: 94, B: 44, A: 255, PackedValue: 0 }, + { R: 162, G: 72, B: 26, A: 255, PackedValue: 0 }, + { R: 194, G: 115, B: 110, A: 255, PackedValue: 0 }, + { R: 154, G: 97, B: 108, A: 255, PackedValue: 0 }, + { R: 163, G: 64, B: 45, A: 255, PackedValue: 0 }, + { R: 152, G: 130, B: 95, A: 255, PackedValue: 0 }, + { R: 172, G: 78, B: 90, A: 255, PackedValue: 0 }, + { R: 90, G: 40, B: 19, A: 255, PackedValue: 0 }, + { R: 175, G: 64, B: 41, A: 255, PackedValue: 0 }, + { R: 0, G: 113, B: 206, A: 255, PackedValue: 0 }, + { R: 64, G: 178, B: 22, A: 255, PackedValue: 0 }, + { R: 175, G: 22, B: 22, A: 255, PackedValue: 0 }, + { R: 120, G: 0, B: 206, A: 255, PackedValue: 0 }, + { R: 204, G: 133, B: 26, A: 255, PackedValue: 0 }, + { R: 136, G: 124, B: 129, A: 255, PackedValue: 0 }, + { R: 250, G: 130, B: 117, A: 255, PackedValue: 0 }, + { R: 255, G: 155, B: 135, A: 255, PackedValue: 0 }, ]; export const TertiarySkinColors: Array = [ - { R: 107, G: 0, B: 58, A: 255, PackedValue: 0 }, - { R: 85, G: 36, B: 53, A: 255, PackedValue: 0 }, - { R: 85, G: 36, B: 53, A: 255, PackedValue: 0 }, - { R: 112, G: 51, B: 57, A: 255, PackedValue: 0 }, - { R: 88, G: 29, B: 21, A: 255, PackedValue: 0 }, - { R: 65, G: 24, B: 18, A: 255, PackedValue: 0 }, - { R: 66, G: 19, B: 11, A: 255, PackedValue: 0 }, - { R: 102, G: 32, B: 26, A: 255, PackedValue: 0 }, - { R: 85, G: 37, B: 24, A: 255, PackedValue: 0 }, - { R: 124, G: 57, B: 52, A: 255, PackedValue: 0 }, - { R: 83, G: 52, B: 76, A: 255, PackedValue: 0 }, - { R: 85, G: 33, B: 39, A: 255, PackedValue: 0 }, - { R: 84, G: 54, B: 52, A: 255, PackedValue: 0 }, - { R: 85, G: 36, B: 53, A: 255, PackedValue: 0 }, - { R: 46, G: 11, B: 4, A: 255, PackedValue: 0 }, - { R: 85, G: 38, B: 49, A: 255, PackedValue: 0 }, - { R: 0, G: 6, B: 81, A: 255, PackedValue: 0 }, - { R: 3, G: 65, B: 16, A: 255, PackedValue: 0 }, - { R: 63, G: 3, B: 3, A: 255, PackedValue: 0 }, - { R: 60, G: 26, B: 86, A: 255, PackedValue: 0 }, - { R: 78, G: 39, B: 3, A: 255, PackedValue: 0 }, - { R: 66, G: 60, B: 67, A: 255, PackedValue: 0 }, - { R: 121, G: 12, B: 62, A: 255, PackedValue: 0 }, - { R: 114, G: 47, B: 50, A: 255, PackedValue: 0 }, + { R: 107, G: 0, B: 58, A: 255, PackedValue: 0 }, + { R: 85, G: 36, B: 53, A: 255, PackedValue: 0 }, + { R: 85, G: 36, B: 53, A: 255, PackedValue: 0 }, + { R: 112, G: 51, B: 57, A: 255, PackedValue: 0 }, + { R: 88, G: 29, B: 21, A: 255, PackedValue: 0 }, + { R: 65, G: 24, B: 18, A: 255, PackedValue: 0 }, + { R: 66, G: 19, B: 11, A: 255, PackedValue: 0 }, + { R: 102, G: 32, B: 26, A: 255, PackedValue: 0 }, + { R: 85, G: 37, B: 24, A: 255, PackedValue: 0 }, + { R: 124, G: 57, B: 52, A: 255, PackedValue: 0 }, + { R: 83, G: 52, B: 76, A: 255, PackedValue: 0 }, + { R: 85, G: 33, B: 39, A: 255, PackedValue: 0 }, + { R: 84, G: 54, B: 52, A: 255, PackedValue: 0 }, + { R: 85, G: 36, B: 53, A: 255, PackedValue: 0 }, + { R: 46, G: 11, B: 4, A: 255, PackedValue: 0 }, + { R: 85, G: 38, B: 49, A: 255, PackedValue: 0 }, + { R: 0, G: 6, B: 81, A: 255, PackedValue: 0 }, + { R: 3, G: 65, B: 16, A: 255, PackedValue: 0 }, + { R: 63, G: 3, B: 3, A: 255, PackedValue: 0 }, + { R: 60, G: 26, B: 86, A: 255, PackedValue: 0 }, + { R: 78, G: 39, B: 3, A: 255, PackedValue: 0 }, + { R: 66, G: 60, B: 67, A: 255, PackedValue: 0 }, + { R: 121, G: 12, B: 62, A: 255, PackedValue: 0 }, + { R: 114, G: 47, B: 50, A: 255, PackedValue: 0 }, ]; export const PrimaryBootColors: Array = [ - { R: 212, G: 0, B: 0, A: 255, PackedValue: 0 }, - { R: 136, G: 178, B: 77, A: 255, PackedValue: 0 }, - { R: 179, G: 85, B: 0, A: 255, PackedValue: 0 }, - { R: 163, G: 118, B: 42, A: 255, PackedValue: 0 }, - { R: 150, G: 162, B: 162, A: 255, PackedValue: 0 }, - { R: 181, G: 125, B: 116, A: 255, PackedValue: 0 }, - { R: 92, G: 239, B: 255, A: 255, PackedValue: 0 }, - { R: 66, G: 66, B: 66, A: 255, PackedValue: 0 }, - { R: 103, G: 0, B: 0, A: 255, PackedValue: 0 }, - { R: 188, G: 0, B: 235, A: 255, PackedValue: 0 }, - { R: 99, G: 1, B: 229, A: 255, PackedValue: 0 }, - { R: 179, G: 85, B: 0, A: 255, PackedValue: 0 }, - { R: 119, G: 47, B: 21, A: 255, PackedValue: 0 }, - { R: 11, G: 99, B: 180, A: 255, PackedValue: 0 }, - { R: 50, G: 133, B: 48, A: 255, PackedValue: 0 }, - { R: 113, G: 7, B: 39, A: 255, PackedValue: 0 }, - { R: 9, G: 101, B: 130, A: 255, PackedValue: 0 }, - { R: 170, G: 129, B: 196, A: 255, PackedValue: 0 }, - { R: 242, G: 242, B: 242, A: 255, PackedValue: 0 }, + { R: 212, G: 0, B: 0, A: 255, PackedValue: 0 }, + { R: 136, G: 178, B: 77, A: 255, PackedValue: 0 }, + { R: 179, G: 85, B: 0, A: 255, PackedValue: 0 }, + { R: 163, G: 118, B: 42, A: 255, PackedValue: 0 }, + { R: 150, G: 162, B: 162, A: 255, PackedValue: 0 }, + { R: 181, G: 125, B: 116, A: 255, PackedValue: 0 }, + { R: 92, G: 239, B: 255, A: 255, PackedValue: 0 }, + { R: 66, G: 66, B: 66, A: 255, PackedValue: 0 }, + { R: 103, G: 0, B: 0, A: 255, PackedValue: 0 }, + { R: 188, G: 0, B: 235, A: 255, PackedValue: 0 }, + { R: 99, G: 1, B: 229, A: 255, PackedValue: 0 }, + { R: 179, G: 85, B: 0, A: 255, PackedValue: 0 }, + { R: 119, G: 47, B: 21, A: 255, PackedValue: 0 }, + { R: 11, G: 99, B: 180, A: 255, PackedValue: 0 }, + { R: 50, G: 133, B: 48, A: 255, PackedValue: 0 }, + { R: 113, G: 7, B: 39, A: 255, PackedValue: 0 }, + { R: 9, G: 101, B: 130, A: 255, PackedValue: 0 }, + { R: 170, G: 129, B: 196, A: 255, PackedValue: 0 }, + { R: 242, G: 242, B: 242, A: 255, PackedValue: 0 }, ]; export const SecondaryBootColors: Array = [ - { R: 170, G: 0, B: 0, A: 255, PackedValue: 0 }, - { R: 95, G: 124, B: 50, A: 255, PackedValue: 0 }, - { R: 142, G: 66, B: 0, A: 255, PackedValue: 0 }, - { R: 123, G: 85, B: 26, A: 255, PackedValue: 0 }, - { R: 109, G: 116, B: 131, A: 255, PackedValue: 0 }, - { R: 152, G: 105, B: 96, A: 255, PackedValue: 0 }, - { R: 43, G: 197, B: 226, A: 255, PackedValue: 0 }, - { R: 54, G: 54, B: 54, A: 255, PackedValue: 0 }, - { R: 77, G: 0, B: 0, A: 255, PackedValue: 0 }, - { R: 140, G: 0, B: 175, A: 255, PackedValue: 0 }, - { R: 75, G: 1, B: 151, A: 255, PackedValue: 0 }, - { R: 142, G: 66, B: 0, A: 255, PackedValue: 0 }, - { R: 91, G: 32, B: 16, A: 255, PackedValue: 0 }, - { R: 0, G: 56, B: 145, A: 255, PackedValue: 0 }, - { R: 14, G: 93, B: 58, A: 255, PackedValue: 0 }, - { R: 65, G: 4, B: 28, A: 255, PackedValue: 0 }, - { R: 0, G: 56, B: 145, A: 255, PackedValue: 0 }, - { R: 92, G: 74, B: 147, A: 255, PackedValue: 0 }, - { R: 219, G: 215, B: 206, A: 255, PackedValue: 0 }, + { R: 170, G: 0, B: 0, A: 255, PackedValue: 0 }, + { R: 95, G: 124, B: 50, A: 255, PackedValue: 0 }, + { R: 142, G: 66, B: 0, A: 255, PackedValue: 0 }, + { R: 123, G: 85, B: 26, A: 255, PackedValue: 0 }, + { R: 109, G: 116, B: 131, A: 255, PackedValue: 0 }, + { R: 152, G: 105, B: 96, A: 255, PackedValue: 0 }, + { R: 43, G: 197, B: 226, A: 255, PackedValue: 0 }, + { R: 54, G: 54, B: 54, A: 255, PackedValue: 0 }, + { R: 77, G: 0, B: 0, A: 255, PackedValue: 0 }, + { R: 140, G: 0, B: 175, A: 255, PackedValue: 0 }, + { R: 75, G: 1, B: 151, A: 255, PackedValue: 0 }, + { R: 142, G: 66, B: 0, A: 255, PackedValue: 0 }, + { R: 91, G: 32, B: 16, A: 255, PackedValue: 0 }, + { R: 0, G: 56, B: 145, A: 255, PackedValue: 0 }, + { R: 14, G: 93, B: 58, A: 255, PackedValue: 0 }, + { R: 65, G: 4, B: 28, A: 255, PackedValue: 0 }, + { R: 0, G: 56, B: 145, A: 255, PackedValue: 0 }, + { R: 92, G: 74, B: 147, A: 255, PackedValue: 0 }, + { R: 219, G: 215, B: 206, A: 255, PackedValue: 0 }, ]; export const TertiaryBootColors: Array = [ - { R: 125, G: 0, B: 0, A: 255, PackedValue: 0 }, - { R: 67, G: 89, B: 37, A: 255, PackedValue: 0 }, - { R: 105, G: 44, B: 0, A: 255, PackedValue: 0 }, - { R: 87, G: 58, B: 11, A: 255, PackedValue: 0 }, - { R: 65, G: 70, B: 81, A: 255, PackedValue: 0 }, - { R: 88, G: 58, B: 54, A: 255, PackedValue: 0 }, - { R: 25, G: 92, B: 98, A: 255, PackedValue: 0 }, - { R: 38, G: 38, B: 38, A: 255, PackedValue: 0 }, - { R: 51, G: 7, B: 2, A: 255, PackedValue: 0 }, - { R: 107, G: 0, B: 151, A: 255, PackedValue: 0 }, - { R: 54, G: 0, B: 101, A: 255, PackedValue: 0 }, - { R: 83, G: 28, B: 0, A: 255, PackedValue: 0 }, - { R: 63, G: 21, B: 28, A: 255, PackedValue: 0 }, - { R: 18, G: 28, B: 107, A: 255, PackedValue: 0 }, - { R: 0, G: 62, B: 65, A: 255, PackedValue: 0 }, - { R: 44, G: 6, B: 17, A: 255, PackedValue: 0 }, - { R: 30, G: 38, B: 104, A: 255, PackedValue: 0 }, - { R: 40, G: 37, B: 107, A: 255, PackedValue: 0 }, - { R: 145, G: 140, B: 127, A: 255, PackedValue: 0 }, + { R: 125, G: 0, B: 0, A: 255, PackedValue: 0 }, + { R: 67, G: 89, B: 37, A: 255, PackedValue: 0 }, + { R: 105, G: 44, B: 0, A: 255, PackedValue: 0 }, + { R: 87, G: 58, B: 11, A: 255, PackedValue: 0 }, + { R: 65, G: 70, B: 81, A: 255, PackedValue: 0 }, + { R: 88, G: 58, B: 54, A: 255, PackedValue: 0 }, + { R: 25, G: 92, B: 98, A: 255, PackedValue: 0 }, + { R: 38, G: 38, B: 38, A: 255, PackedValue: 0 }, + { R: 51, G: 7, B: 2, A: 255, PackedValue: 0 }, + { R: 107, G: 0, B: 151, A: 255, PackedValue: 0 }, + { R: 54, G: 0, B: 101, A: 255, PackedValue: 0 }, + { R: 83, G: 28, B: 0, A: 255, PackedValue: 0 }, + { R: 63, G: 21, B: 28, A: 255, PackedValue: 0 }, + { R: 18, G: 28, B: 107, A: 255, PackedValue: 0 }, + { R: 0, G: 62, B: 65, A: 255, PackedValue: 0 }, + { R: 44, G: 6, B: 17, A: 255, PackedValue: 0 }, + { R: 30, G: 38, B: 104, A: 255, PackedValue: 0 }, + { R: 40, G: 37, B: 107, A: 255, PackedValue: 0 }, + { R: 145, G: 140, B: 127, A: 255, PackedValue: 0 }, ]; export const QuaternaryBootColors: Array = [ - { R: 85, G: 0, B: 0, A: 255, PackedValue: 0 }, - { R: 3, G: 50, B: 43, A: 255, PackedValue: 0 }, - { R: 67, G: 22, B: 0, A: 255, PackedValue: 0 }, - { R: 35, G: 0, B: 0, A: 255, PackedValue: 0 }, - { R: 15, G: 20, B: 47, A: 255, PackedValue: 0 }, - { R: 41, G: 25, B: 32, A: 255, PackedValue: 0 }, - { R: 0, G: 53, B: 57, A: 255, PackedValue: 0 }, - { R: 0, G: 0, B: 0, A: 255, PackedValue: 0 }, - { R: 17, G: 13, B: 8, A: 255, PackedValue: 0 }, - { R: 46, G: 0, B: 74, A: 255, PackedValue: 0 }, - { R: 15, G: 20, B: 47, A: 255, PackedValue: 0 }, - { R: 35, G: 0, B: 0, A: 255, PackedValue: 0 }, - { R: 33, G: 11, B: 5, A: 255, PackedValue: 0 }, - { R: 0, G: 0, B: 51, A: 255, PackedValue: 0 }, - { R: 0, G: 30, B: 42, A: 255, PackedValue: 0 }, - { R: 16, G: 10, B: 9, A: 255, PackedValue: 0 }, - { R: 14, G: 14, B: 51, A: 255, PackedValue: 0 }, - { R: 30, G: 38, B: 104, A: 255, PackedValue: 0 }, - { R: 33, G: 33, B: 33, A: 255, PackedValue: 0 }, + { R: 85, G: 0, B: 0, A: 255, PackedValue: 0 }, + { R: 3, G: 50, B: 43, A: 255, PackedValue: 0 }, + { R: 67, G: 22, B: 0, A: 255, PackedValue: 0 }, + { R: 35, G: 0, B: 0, A: 255, PackedValue: 0 }, + { R: 15, G: 20, B: 47, A: 255, PackedValue: 0 }, + { R: 41, G: 25, B: 32, A: 255, PackedValue: 0 }, + { R: 0, G: 53, B: 57, A: 255, PackedValue: 0 }, + { R: 0, G: 0, B: 0, A: 255, PackedValue: 0 }, + { R: 17, G: 13, B: 8, A: 255, PackedValue: 0 }, + { R: 46, G: 0, B: 74, A: 255, PackedValue: 0 }, + { R: 15, G: 20, B: 47, A: 255, PackedValue: 0 }, + { R: 35, G: 0, B: 0, A: 255, PackedValue: 0 }, + { R: 33, G: 11, B: 5, A: 255, PackedValue: 0 }, + { R: 0, G: 0, B: 51, A: 255, PackedValue: 0 }, + { R: 0, G: 30, B: 42, A: 255, PackedValue: 0 }, + { R: 16, G: 10, B: 9, A: 255, PackedValue: 0 }, + { R: 14, G: 14, B: 51, A: 255, PackedValue: 0 }, + { R: 30, G: 38, B: 104, A: 255, PackedValue: 0 }, + { R: 33, G: 33, B: 33, A: 255, PackedValue: 0 }, ]; -export const AccessoryIsTinted = (index: number) => (index >= 0 && index <= 5); \ No newline at end of file +export const AccessoryIsTinted = (index: number) => index >= 0 && index <= 5; diff --git a/src/lib/SaveFile.ts b/src/lib/SaveFile.ts index 48c2a13..ac54214 100644 --- a/src/lib/SaveFile.ts +++ b/src/lib/SaveFile.ts @@ -239,6 +239,12 @@ export const SaveConverter = { recipe.item = [recipe.item]; } } + + // Don't forget to add which nil="true" on hats; + if (player.hat) { + // @ts-expect-error + player.hat.which = { "@_xsi:nil": "true" }; + } } // Copy name to Name, and stack to Stack for every item in the inventory diff --git a/src/lib/Spritesheet.ts b/src/lib/Spritesheet.ts index 3bf9d93..a3292c0 100644 --- a/src/lib/Spritesheet.ts +++ b/src/lib/Spritesheet.ts @@ -2,110 +2,148 @@ import type { Clothing, ItemInformation } from "$types/items/1.6"; import type { HairstyleColor } from "$types/save/1.5"; const ShirtsWithFemaleVariant = new Set([ - "Plain Shirt", - "Tank Top", - "Crop Tank Top", - "80's Shirt", - "Basic Pullover", - "Classy Top", + "Plain Shirt", + "Tank Top", + "Crop Tank Top", + "80's Shirt", + "Basic Pullover", + "Classy Top", ]); -const ShirtsWithMessedUpSpriteIndex = new Map([ - [1997, { x: 256, y: 64 }], - [1998, { x: 256, y: 0 }] -]); +const ShirtsWithMessedUpSpriteIndex = new Map( + [ + [1997, { x: 256, y: 64 }], + [1998, { x: 256, y: 0 }], + ], +); export const GetSpritesheet = (lookupItem: ItemInformation): string => { - let spritesheet = ''; - switch (lookupItem?._type) { - case 'Object': - case 'Boots': - spritesheet = 'springobjects.png'; - break; - case 'BigCraftable': - spritesheet = 'Craftables.png'; - break; - case 'Pants': - spritesheet = 'pants.png'; - break; - case 'Shirt': - spritesheet = 'shirts.png'; - break; - case 'Hat': - spritesheet = 'hats.png'; - break; - case 'Furniture': - spritesheet = 'furniture.png'; - break; - case 'Weapon': - spritesheet = 'weapons.png'; - break; - case 'Tool': - spritesheet = 'tools.png'; - break; - default: - // @ts-expect-error - console.warn('Unknown item type', lookupItem?._type); - }; + let spritesheet = ""; + switch (lookupItem?._type) { + case "Object": + case "Boots": + spritesheet = "springobjects.png"; + break; + case "BigCraftable": + spritesheet = "Craftables.png"; + break; + case "Pants": + spritesheet = "pants.png"; + break; + case "Shirt": + spritesheet = "shirts.png"; + break; + case "Hat": + spritesheet = "hats.png"; + break; + case "Furniture": + spritesheet = "furniture.png"; + break; + case "Weapon": + spritesheet = "weapons.png"; + break; + case "Tool": + spritesheet = "tools.png"; + break; + default: + // @ts-expect-error + console.warn("Unknown item type", lookupItem?._type); + } - return spritesheet; + return spritesheet; }; -export const IndexToSprite = (index: number, itemW: number, itemH: number, sheetW: number, sheetH: number, padRight: number = 0) => { - const x = (sheetW + padRight) - ((index * itemW) % sheetW); - const y = sheetH - (Math.floor((index * itemW) / sheetW) * itemH); - return { x, y }; +export const IndexToSprite = ( + index: number, + itemW: number, + itemH: number, + sheetW: number, + sheetH: number, + padRight: number = 0, +) => { + const x = sheetW + padRight - ((index * itemW) % sheetW); + const y = sheetH - Math.floor((index * itemW) / sheetW) * itemH; + return { x, y }; }; -export const GetSprite = (type: ItemInformation['_type'], index: number, dyeable: boolean | undefined = undefined): { x: number, y: number; } => { - switch (type) { - case 'Object': - return IndexToSprite(index, 16, 16, 384, 624); - case 'BigCraftable': - return IndexToSprite(index, 16, 32, 128, 1472); - case 'Boots': - return IndexToSprite(index, 16, 16, 384, 624); - case 'Hat': - return IndexToSprite(index, 20, 80, 240, 880); - case 'Pants': - // Special case, pants have 192x672 of animation frames, then the pants themselves are underneath on the left - const pantSprite = IndexToSprite(index, 192, 686, 1920, 1376); - return { x: pantSprite.x, y: pantSprite.y - 672 }; - case 'Shirt': - // let shirtSprite = ShirtsWithMessedUpSpriteIndex.get(index); - // if (shirtSprite) { return shirtSprite; } - let shirtSprite = IndexToSprite(index, 8, 32, 128, 608, 128); - return dyeable ? { x: shirtSprite.x - 128, y: shirtSprite.y } : shirtSprite; - case 'Furniture': - return IndexToSprite(index, 16, 16, 512, 1488); - case 'Weapon': - return IndexToSprite(index, 16, 16, 128, 144); - case 'Tool': - return IndexToSprite(index, 16, 16, 336, 384); - default: - // @ts-expect-error - console.warn('Unknown item type', lookupItem?._type); - return { x: 0, y: 0 }; - }; +export const GetSprite = ( + type: ItemInformation["_type"], + index: number, + dyeable: boolean | undefined = undefined, +): { x: number; y: number } => { + switch (type) { + case "Object": + return IndexToSprite(index, 16, 16, 384, 624); + case "BigCraftable": + return IndexToSprite(index, 16, 32, 128, 1472); + case "Boots": + return IndexToSprite(index, 16, 16, 384, 624); + case "Hat": + return IndexToSprite(index, 20, 80, 240, 880); + case "Pants": + // Special case, pants have 192x672 of animation frames, then the pants themselves are underneath on the left + const pantSprite = IndexToSprite(index, 192, 686, 1920, 1376); + return { x: pantSprite.x, y: pantSprite.y - 672 }; + case "Shirt": + // let shirtSprite = ShirtsWithMessedUpSpriteIndex.get(index); + // if (shirtSprite) { return shirtSprite; } + let shirtSprite = IndexToSprite(index, 8, 32, 128, 608, 128); + return dyeable + ? { x: shirtSprite.x - 128, y: shirtSprite.y } + : shirtSprite; + case "Furniture": + return IndexToSprite(index, 16, 16, 512, 1488); + case "Weapon": + return IndexToSprite(index, 16, 16, 128, 144); + case "Tool": + return IndexToSprite(index, 16, 16, 336, 384); + default: + // @ts-expect-error + console.warn("Unknown item type", lookupItem?._type); + return { x: 0, y: 0 }; + } }; export const GetPlayerSpriteForPants = (index: number, isMale: boolean) => { - const { x, y } = IndexToSprite(index, 192, 688, 1920, 1376); - return isMale ? { x, y } : { x: x - 96, y }; + const { x, y } = IndexToSprite(index, 192, 688, 1920, 1376); + return isMale ? { x, y } : { x: x - 96, y }; }; export const HexToRGB = (hex: string): HairstyleColor => { - const R = parseInt(hex.slice(1, 3), 16); - const G = parseInt(hex.slice(3, 5), 16); - const B = parseInt(hex.slice(5, 7), 16); + const R = parseInt(hex.slice(1, 3), 16); + const G = parseInt(hex.slice(3, 5), 16); + const B = parseInt(hex.slice(5, 7), 16); - return { R, G, B, A: 255, PackedValue: 0 }; + console.log(PackedValue(R, G, B, 255)); + return PackedValue(R, G, B, 255); }; export const RGBToHex = (rgb: HairstyleColor): string => { - const { R, B, G } = rgb; + const { R, B, G } = rgb; + + const hex = ((R << 16) | (G << 8) | B).toString(16); - const hex = ((R << 16) | (G << 8) | B).toString(16); + return "#" + new Array(Math.abs(hex.length - 7)).join("0") + hex; +}; - return '#' + new Array(Math.abs(hex.length - 7)).join('0') + hex; -}; \ No newline at end of file +export const PackedValue = ( + red: number, + green: number, + blue: number, + alpha = 255, +) => { + // Ensure the values are within the valid range + const r = Math.max(0, Math.min(255, red)); + const g = Math.max(0, Math.min(255, green)); + const b = Math.max(0, Math.min(255, blue)); + + // Combine the values into a single integer + const packedValue = (r << 16) | (g << 8) | b; + return { + R: r, + G: g, + B: b, + A: alpha, + PackedValue: packedValue, + } as HairstyleColor; +}; diff --git a/src/routes/(edit)/inventory/+page.svelte b/src/routes/(edit)/inventory/+page.svelte index a1c16d1..c126ab9 100644 --- a/src/routes/(edit)/inventory/+page.svelte +++ b/src/routes/(edit)/inventory/+page.svelte @@ -9,10 +9,15 @@ import type { ParentIndex } from '$lib/ItemParentIndex'; import { CalculateEdibility, CalculatePrice } from '$lib/ItemQuality'; import { Character } from '$lib/SaveFile'; - import { HexToRGB, RGBToHex } from '$lib/Spritesheet'; + import { HexToRGB, PackedValue, RGBToHex } from '$lib/Spritesheet'; import { FurnitureType, type ItemInformation } from '$types/items/1.6'; import { Category } from '$types/save/1.5'; - import type { Item, Player, TypeEnum } from '$types/save/1.6'; + import { + ClothesType, + type Item, + type Player, + type TypeEnum, + } from '$types/save/1.6'; import { getContext } from 'svelte'; import Container from '../../Container.svelte'; import Preview from '../appearance/Preview.svelte'; @@ -149,11 +154,12 @@ const newItem: Item = { name: newItemName, itemId: - 'ParentSheetIndex' in newItemData - ? newItemData.ParentSheetIndex - : 'SpriteIndex' in newItemData - ? newItemData.SpriteIndex + 'id' in newItemData + ? newItemData.id + : 'ParentSheetIndex' in newItemData + ? newItemData.ParentSheetIndex : 0, + // Kinda hacky, but it works I think stack: 1, quality: 0, isRecipe: false, @@ -309,7 +315,14 @@ } if ('CanBeDyed' in newItemData && newItemData.CanBeDyed) { - newItem.clothesColor = { R: 255, G: 255, B: 255, A: 255, PackedValue: 0 }; + let defaultColor = '#000000'; + if ('DefaultColor' in newItemData && newItemData.DefaultColor) { + const [R, G, B] = newItemData.DefaultColor.split(' ').map(Number); + const A = 255; + defaultColor = RGBToHex({ R, G, B, A, PackedValue: 0 }); + } + + newItem.clothesColor = HexToRGB(defaultColor); } if (newItemData._type === 'Object') { @@ -328,6 +341,12 @@ newItem.Price = newItemData.Price ?? 0; } + if (newItemData._type === 'Shirt') { + newItem.clothesType = ClothesType.Shirt; + } else if (newItemData._type === 'Pants') { + newItem.clothesType = ClothesType.Pants; + } + if (typeof symbol === 'number') { inventory[symbol] = newItem; } else { @@ -585,26 +604,21 @@ rerender(selectedItem, selectedIndex); }} /> - {:else if selectedItemData._type === 'Shirt'} + {:else if selectedItemData._type === 'Shirt' || selectedItemData._type === 'Pants'} {#if selectedItemData.CanBeDyed}