Skip to content

Commit

Permalink
Saving progress
Browse files Browse the repository at this point in the history
  • Loading branch information
colecrouter committed Nov 29, 2024
1 parent f6ae42c commit 287028a
Show file tree
Hide file tree
Showing 12 changed files with 570 additions and 783 deletions.
395 changes: 221 additions & 174 deletions src/dump.ts

Large diffs are not rendered by default.

36 changes: 19 additions & 17 deletions src/lib/ItemData.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Size } from "$types/items/1.5";
import type { Size } from "$types/items/1.6";
import {
type Clothing,
FurnitureType,
ObjectCategory,
type ItemInformation,
type Shirt,
} from "$types/items/1.6";
import { Category } from "$types/save/1.5";
import type { Item } from "$types/save/1.6";
import jsondata from "../../static/iteminfo.json";

Expand Down Expand Up @@ -135,18 +135,18 @@ export const QualityToEdibilityMultiplier = new Map([

// TODO: I don't know what items are allowed to have quality, or if there's some sort of rule.
export const CategoriesWithQuality = new Set([
Category.Fish,
Category.Egg,
Category.Milk,
Category.Cooking,
Category.SellAtPierres,
Category.SellAtPierresAndMarnies,
Category.ArtisanGoods,
Category.Syrup,
Category.Vegetable,
Category.Fruit,
Category.Flower,
Category.Forage,
ObjectCategory.Fish,
ObjectCategory.Egg,
ObjectCategory.Milk,
ObjectCategory.Cooking,
ObjectCategory.SellAtPierres,
ObjectCategory.SellAtPierresAndMarnies,
ObjectCategory.ArtisanGoods,
ObjectCategory.Syrup,
ObjectCategory.Vegetable,
ObjectCategory.Fruit,
ObjectCategory.Flower,
ObjectCategory.Forage,
]);

export const DefaultFurnitureSizes = new Map<FurnitureType, Size>([
Expand Down Expand Up @@ -282,8 +282,10 @@ export const ItemNameHelper = (item: Item) => {
return item.name;
};

export const Shirts = new Map<string, Clothing>(
export const Shirts = new Map<string, Shirt>(
jsondata
.filter(([name, item]) => item._type === "Shirt")
.map(([name, item]) => [item.ItemId, item]),
.map(([name, item]) => [item._key, item]),
);

console.log(Shirts);
52 changes: 44 additions & 8 deletions src/lib/Spritesheet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import type { ItemInformation } from "$types/items/1.6";
import { DefaultFurnitureSizes } from "$lib/ItemData";
import {
FurnitureType,
type ItemInformation,
type Size,
} from "$types/items/1.6";

const ShirtsWithFemaleVariant = new Set<string>([
"Plain Shirt",
Expand All @@ -21,7 +26,7 @@ export const GetSpritesheet = (lookupItem: ItemInformation): string => {
switch (lookupItem._type) {
case "Object":
case "Boots":
if (lookupItem.Texture === "TileSheets\\Objects_2") {
if (lookupItem.texture === "TileSheets\\Objects_2") {
spritesheet = "Objects_2.png";
} else {
spritesheet = "springobjects.png";
Expand Down Expand Up @@ -66,14 +71,17 @@ export const IndexToSprite = (
return { x, y };
};

export const GetSprite = (
info: Pick<ItemInformation, "_type" | "Texture">,
index: number,
dyeable: boolean | undefined = undefined,
): { x: number; y: number } => {
export const GetSprite = (info: ItemInformation): { x: number; y: number } => {
const index =
"menuSpriteIndex" in info && info.menuSpriteIndex !== undefined
? info.menuSpriteIndex
: (info.spriteIndex ?? Number(info.spriteIndex ?? info._key));
if (Number.isNaN(index)) throw new Error("Invalid sprite index");

const dyeable = "dyeable" in info && info.dyeable;
switch (info._type) {
case "Object":
if (info.Texture === "TileSheets\\Objects_2") {
if (info.texture === "TileSheets\\Objects_2") {
return IndexToSprite(index, 16, 16, 128, 320);
}
return IndexToSprite(index, 16, 16, 384, 624);
Expand Down Expand Up @@ -109,6 +117,34 @@ export const GetSprite = (
}
};

export const GetSize = (info: ItemInformation): Size => {
switch (info._type) {
case "BigCraftable":
return { width: 16, height: 32 };
case "Shirt":
return { width: 8, height: 8 };
case "Hat":
return { width: 20, height: 20 };
case "Furniture": {
if (info.tilesheetSize) {
return {
width: info.tilesheetSize.width * 16,
height: info.tilesheetSize.height * 16,
};
}

return (
DefaultFurnitureSizes.get(info.type) ?? {
width: 16,
height: 16,
}
);
}
default:
return { width: 16, height: 16 };
}
};

export const GetPlayerSpriteForPants = (index: number, isMale: boolean) => {
const { x, y } = IndexToSprite(index, 192, 688, 1920, 1376);
return isMale ? { x, y } : { x: x - 96, y };
Expand Down
Loading

0 comments on commit 287028a

Please sign in to comment.