Recipe viewer
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// what client scripts get, see "Client scripts" and "GUIs" in MODS.md
|
||||
import type { Id, KeyCode, ModInfo, Position } from "./shared.ts";
|
||||
import type { Id, ItemStack, KeyCode, ModInfo, Position } from "./shared.ts";
|
||||
|
||||
export type { Id, ItemStack, KeyCode, ModInfo, Position } from "./shared.ts";
|
||||
|
||||
@@ -16,6 +16,20 @@ export interface ClientContext {
|
||||
// ticks since 06:00 of day 1, see ServerWorld.time
|
||||
readonly time: number;
|
||||
};
|
||||
// every item any mod registered, in load order
|
||||
items: {
|
||||
ids(): Id[];
|
||||
exists(id: Id): boolean;
|
||||
// what players see, like "Cooked Rice"
|
||||
name(id: Id): string;
|
||||
// the mod that registered it
|
||||
mod(id: Id): string;
|
||||
};
|
||||
// every recipe as its json (see Recipes in MODS.md), including mods' own types, in load order. copies
|
||||
recipes: {
|
||||
// deno-lint-ignore no-explicit-any
|
||||
list(type?: Id): any[];
|
||||
};
|
||||
log(...args: unknown[]): void;
|
||||
}
|
||||
|
||||
@@ -36,7 +50,7 @@ export type Color = [number, number, number, number];
|
||||
export interface Graphics {
|
||||
readonly width: number;
|
||||
readonly height: number;
|
||||
readonly mouse: { x: number; y: number; down: boolean; pressed: boolean };
|
||||
readonly mouse: { x: number; y: number; down: boolean; pressed: boolean; right_pressed: boolean };
|
||||
rect(x: number, y: number, w: number, h: number, color?: Color): void;
|
||||
panel(x: number, y: number, w: number, h: number): void;
|
||||
text(text: string, x: number, y: number, options?: { scale?: number; color?: Color }): void;
|
||||
@@ -49,13 +63,38 @@ export interface Graphics {
|
||||
slider(id: string, x: number, y: number, w: number, min: number, max: number): number;
|
||||
// server synced slots, same rules as container screens
|
||||
slots(container: string, layout: { slot: number; x: number; y: number }[], x: number, y: number): void;
|
||||
// false while a text input has the keyboard
|
||||
key_pressed(key: KeyCode): boolean;
|
||||
// shown next to the mouse over everything else, the last one this frame wins
|
||||
tooltip(lines: (string | { text: string; color?: Color })[], x: number, y: number): void;
|
||||
// the game's tooltip for an item (its name, food, lore), with extra lines under it
|
||||
item_tooltip(id: Id, x: number, y: number, extra?: (string | { text: string; color?: Color })[]): void;
|
||||
// the click was used, so nothing under it (like slots) gets it
|
||||
consume_click(): void;
|
||||
// the screen underneath ignores the mouse over this area this frame, for something drawn over it
|
||||
block_mouse(x: number, y: number, w: number, h: number): void;
|
||||
}
|
||||
|
||||
// drawn on every inventory screen (the player's inventory, chests, furnaces...), over it, like just enough items'
|
||||
// item list. it gets the screen's box to lay itself out around
|
||||
export interface InventoryOverlay {
|
||||
on_render(g: Graphics, screen: InventoryScreenView): void;
|
||||
}
|
||||
|
||||
export interface InventoryScreenView {
|
||||
readonly x: number;
|
||||
readonly y: number;
|
||||
readonly width: number;
|
||||
readonly height: number;
|
||||
// what's in the slot under the mouse
|
||||
readonly hovered_item: ItemStack | undefined;
|
||||
}
|
||||
|
||||
export interface ClientUi {
|
||||
register_screen<Props>(id: Id, create: (props: Props) => ModScreen<Props>): void;
|
||||
// open a screen that doesn't involve the server, like a settings page
|
||||
open<Props>(id: Id, props: Props): void;
|
||||
add_inventory_overlay(overlay: InventoryOverlay): void;
|
||||
}
|
||||
|
||||
export interface HudRegistry {
|
||||
|
||||
Reference in New Issue
Block a user