Curios and artifacts !

This commit is contained in:
2026-09-30 15:22:32 -03:00
parent 342b45d593
commit 3af5f6e54b
45 changed files with 729 additions and 43 deletions
+8 -1
View File
@@ -36,7 +36,14 @@ export class GuiContainer extends GuiInventoryScreen {
for (const slot of layout.slots) {
this.slots.push(
new Slot("screen", slot.index, MARGIN + slot.x * SLOT_SIZE, AREA_Y + slot.y * SLOT_SIZE, slot.output),
new Slot(
"screen",
slot.index,
MARGIN + slot.x * SLOT_SIZE,
AREA_Y + slot.y * SLOT_SIZE,
slot.output,
slot.icon,
),
);
}
}
+13 -2
View File
@@ -5,7 +5,9 @@ import { ClientMessage, ContainerKey, CRAFTING_RESULT_SLOT } from "$/common/prot
import { point_inside_rec } from "../../common/utils.ts";
import { InputManager } from "../input_manager.ts";
import { ClientInventories } from "../inventory.ts";
import { canvas } from "../renderer/mod.ts";
import { canvas, draw_texture_region, Texture } from "../renderer/mod.ts";
import { AssetManager } from "../assets.ts";
import { get_sprite_region } from "../sprites.ts";
import { draw_item } from "../rendering/render_utils.ts";
import { draw_tooltip, item_tooltip } from "./tooltip.ts";
import { ModGraphics } from "./mod_graphics.ts";
@@ -22,13 +24,16 @@ export class Slot {
y: number;
// can only be taken from, like the crafting or furnace result
output: boolean;
// a texture drawn while it's empty, like minecraft's armor slots
icon: string | undefined;
constructor(container: ContainerKey, index: number, x: number, y: number, output = false) {
constructor(container: ContainerKey, index: number, x: number, y: number, output = false, icon?: string) {
this.container = container;
this.index = index;
this.x = x;
this.y = y;
this.output = output;
this.icon = icon;
}
}
@@ -102,6 +107,12 @@ export class GuiInventoryScreen extends GuiScreen {
const item = this.get_container(slot.container)?.get_item(slot.index);
if (item) {
draw_item(item, this.x + slot.x, this.y + slot.y);
} else if (slot.icon) {
// where an item's sprite would be
const icon = get_sprite_region(slot.icon);
const atlas = AssetManager.instance.get<Texture>("bworld:textures");
const [x, y, size] = [this.x + slot.x + 3, this.y + slot.y + 3, SLOT_SIZE - 6];
draw_texture_region(atlas, icon.x, icon.y, icon.width, icon.height, x, y, size, size);
}
}
highlight("slot_highlight_front");