Change whole gui system
This commit is contained in:
@@ -3,12 +3,11 @@
|
||||
// with any mod's, and draws the ones it doesn't know as their items in, then what comes out
|
||||
import type { ClientContext, Color, Graphics, InventoryScreenView, TagApi } from "bworld/client";
|
||||
|
||||
// items and slots are drawn this big
|
||||
const CELL = 54;
|
||||
const GAP = 16;
|
||||
const TEXT = 22;
|
||||
const LINE = 30;
|
||||
const BUTTON = 32;
|
||||
// in gui pixels. items and slots are drawn this big
|
||||
const CELL = 18;
|
||||
const GAP = 5;
|
||||
const LINE = 10;
|
||||
const BUTTON = 11;
|
||||
// catppuccin mocha, like the engine's gui: crust, pink, subtext 0 and blue
|
||||
const SLOT_COLOR: Color = [0.07, 0.07, 0.11, 0.6];
|
||||
const HOVER_COLOR: Color = [0.96, 0.76, 0.91, 0.35];
|
||||
@@ -67,6 +66,12 @@ class RecipeViewer {
|
||||
if (this.#view && g.key_pressed("Backspace")) this.#back();
|
||||
}
|
||||
|
||||
// the recipe views go with the inventory, it opens again on the item list
|
||||
on_close() {
|
||||
this.#view = undefined;
|
||||
this.#history = [];
|
||||
}
|
||||
|
||||
#open(item: string, mode: Mode) {
|
||||
if (this.#find(item, mode).length === 0) return;
|
||||
if (this.#view) this.#history.push(this.#view);
|
||||
@@ -106,7 +111,7 @@ class RecipeViewer {
|
||||
this.#page = (this.#page + 1) % pages;
|
||||
}
|
||||
const label = `${this.#page + 1}/${pages}`;
|
||||
g.text(label, left + (columns * CELL - g.measure_text(label)) / 2, GAP + (BUTTON - TEXT) / 2);
|
||||
g.text(label, left + (columns * CELL - g.measure_text(label)) / 2, GAP + (BUTTON - g.text_height) / 2);
|
||||
|
||||
let hovered: string | undefined;
|
||||
items.slice(this.#page * per_page, (this.#page + 1) * per_page).forEach((id, i) => {
|
||||
@@ -184,7 +189,7 @@ class RecipeViewer {
|
||||
view.page = (view.page + 1) % page_count;
|
||||
}
|
||||
const label = `${view.page + 1}/${page_count}`;
|
||||
g.text(label, x + (width - g.measure_text(label)) / 2, bottom + (BUTTON - TEXT) / 2, {
|
||||
g.text(label, x + (width - g.measure_text(label)) / 2, bottom + (BUTTON - g.text_height) / 2, {
|
||||
color: LABEL_COLOR,
|
||||
});
|
||||
}
|
||||
@@ -270,7 +275,7 @@ class RecipeViewer {
|
||||
cell(output, x + 5 * CELL, made.length > 1 ? top + i * CELL : top + CELL / 2)
|
||||
);
|
||||
if (typeof recipe.cook_time === "number") {
|
||||
g.text(seconds(recipe.cook_time), x + 5 * CELL, top + CELL * 1.5 + (CELL - TEXT) / 2, {
|
||||
g.text(seconds(recipe.cook_time), x + 5 * CELL, top + CELL * 1.5 + (CELL - g.text_height) / 2, {
|
||||
color: LABEL_COLOR,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user