// the curios button next to every inventory screen, or G like curios' keybind, asks the server to open the curios // menu, and its screen import type { ClientContext } from "bworld/client"; import { active_slots } from "./slots.ts"; // in gui pixels const GAP = 5; const BUTTON_WIDTH = 40; const BUTTON_HEIGHT = 11; const WIDTH = 176; export function setup(ctx: ClientContext) { // no item goes in any slot, so there's nothing to show if (active_slots(ctx.tags).length === 0) return; ctx.ui.add_inventory_overlay({ on_render(g, screen) { const clicked = g.button("Curios", screen.x - BUTTON_WIDTH - GAP, screen.y, BUTTON_WIDTH, BUTTON_HEIGHT); if (clicked || g.key_pressed("KeyG")) { ctx.net.send("curios:open", {}); } }, }); ctx.ui.register_menu_screen("curios:curios", (menu) => { const { rows } = menu.open_data as { rows: number }; const height = 114 + rows * 18; return { width: WIDTH, height, on_render_background(g) { g.panel(0, 0, WIDTH, height); }, on_render_labels(g) { g.text(menu.title, 8, 6); g.text("Inventory", 8, height - 93); }, }; }); }