Improve recipe viewer
This commit is contained in:
@@ -87,20 +87,16 @@ 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();
|
||||
// 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);
|
||||
}
|
||||
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 (hidden || g.mouse_blocked()) {
|
||||
if (g.mouse_blocked()) {
|
||||
this.hovering = undefined;
|
||||
} else {
|
||||
this.handle_interaction();
|
||||
@@ -155,18 +151,6 @@ 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 = {
|
||||
|
||||
Reference in New Issue
Block a user