This is good enough

This commit is contained in:
2026-10-02 22:38:39 -03:00
parent 4fb392adae
commit 50d47cedef
4 changed files with 35 additions and 6 deletions
+22 -6
View File
@@ -87,16 +87,20 @@ export abstract class GuiMenuScreen extends GuiScreen {
draw_rect(0, 0, canvas.width, canvas.height, [0, 0, 0, 0.8]);
const g = this.graphics;
g.begin();
g.origin_x = this.x;
g.origin_y = this.y;
this.render_background(g);
this.#render_slots();
this.render_labels(g);
// an overlay drawing something in the screen's place, like the recipe viewer's recipes, hides all of it
const hidden = this.#overlay_hides_screen();
if (!hidden) {
g.origin_x = this.x;
g.origin_y = this.y;
this.render_background(g);
this.#render_slots();
this.render_labels(g);
}
// 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 (g.mouse_blocked()) {
if (hidden || g.mouse_blocked()) {
this.hovering = undefined;
} else {
this.handle_interaction();
@@ -151,6 +155,18 @@ export abstract class GuiMenuScreen extends GuiScreen {
highlight("slot_highlight_front");
}
#overlay_hides_screen() {
for (const entry of [...inventory_overlays]) {
try {
if (entry.overlay.hides_screen?.()) return true;
} catch (e) {
console.error(`[${entry.mod}] inventory overlay's hides_screen threw, removing it:`, e);
inventory_overlays.splice(inventory_overlays.indexOf(entry), 1);
}
}
return false;
}
#render_overlays() {
const hovered = this.hovering && this.hovering.container.get_item(this.hovering.index);
const view = {