Hold and valley minigames

This commit is contained in:
2026-10-11 14:58:01 -03:00
parent 21442fb822
commit c71584eeea
10 changed files with 617 additions and 30 deletions
+8
View File
@@ -75,6 +75,14 @@ export class GuiModMenuScreen extends GuiMenuScreen {
if (tick) this.#ticker.run(delta, () => this.#guarded("on_tick", () => tick.call(this.#screen)));
}
override get dim_background(): boolean {
return this.#screen.dim_background !== false;
}
override get inventory_overlays(): boolean {
return this.#screen.inventory_overlays !== false;
}
render_background(g: ModGraphics): void {
const render = this.#screen.on_render_background;
if (render) this.#guarded("on_render_background", () => render.call(this.#screen, g));
+11 -2
View File
@@ -78,13 +78,21 @@ export abstract class GuiMenuScreen extends GuiScreen {
this.y = Math.floor((canvas.height - this.height * GUI_SCALE) / 2);
}
// whether the world behind it is darkened, and mods' inventory overlays show on it
get dim_background(): boolean {
return true;
}
get inventory_overlays(): boolean {
return true;
}
// under the slots, from the screen's top left
abstract render_background(g: ModGraphics): void;
// over the slots
abstract render_labels(g: ModGraphics): void;
on_render(): void {
draw_rect(0, 0, canvas.width, canvas.height, [0, 0, 0, 0.8]);
if (this.dim_background) draw_rect(0, 0, canvas.width, canvas.height, [0, 0, 0, 0.8]);
const g = this.graphics;
g.begin();
g.origin_x = this.x;
@@ -95,7 +103,7 @@ export abstract class GuiMenuScreen extends GuiScreen {
// mods' overlays go on top and get the mouse first, then the slots get what they left
g.origin_x = g.origin_y = 0;
this.#render_overlays();
if (this.inventory_overlays) this.#render_overlays();
if (g.mouse_blocked()) {
this.hovering = undefined;
} else {
@@ -173,6 +181,7 @@ export abstract class GuiMenuScreen extends GuiScreen {
}
override on_removed(): void {
if (!this.inventory_overlays) return;
for (const entry of [...inventory_overlays]) {
try {
entry.overlay.on_close?.();