Change curios to always show on inventory
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
import { GuiMenuScreen } from "./gui_screen.ts";
|
||||
import { ClientInventories } from "../inventory.ts";
|
||||
import { ClientMessage } from "$/common/protocol.ts";
|
||||
import { ClientMessage, PLAYER_MENU_EXTRA } from "$/common/protocol.ts";
|
||||
import { player_menu } from "../menu.ts";
|
||||
import type { ModGraphics } from "./mod_graphics.ts";
|
||||
|
||||
const WIDTH = 176;
|
||||
const HEIGHT = 166;
|
||||
const SLOT = 18;
|
||||
// around the slots, like minecraft's
|
||||
const MARGIN = 7;
|
||||
|
||||
// menu 0's screen: the crafting grid over the inventory. the recipes live on the server, which fills in the result
|
||||
// menu 0's screen: the crafting grid over the inventory, and any slots mods added. the recipes live on the server,
|
||||
// which fills in the result
|
||||
export class GuiPlayerInventory extends GuiMenuScreen {
|
||||
constructor(inventories: ClientInventories, send: (message: ClientMessage) => void) {
|
||||
super(inventories, send, player_menu(inventories), WIDTH, HEIGHT);
|
||||
@@ -15,6 +19,16 @@ export class GuiPlayerInventory extends GuiMenuScreen {
|
||||
|
||||
render_background(g: ModGraphics): void {
|
||||
g.panel(0, 0, WIDTH, HEIGHT);
|
||||
// the slots mods added outside the panel get one of their own, around them with the same margin
|
||||
const outside = this.menu.slots.slice(PLAYER_MENU_EXTRA)
|
||||
.filter((s) => s.x + SLOT < 0 || s.x > WIDTH || s.y + SLOT < 0 || s.y > HEIGHT);
|
||||
if (outside.length > 0) {
|
||||
const left = Math.min(...outside.map((s) => s.x)) - MARGIN;
|
||||
const top = Math.min(...outside.map((s) => s.y)) - MARGIN;
|
||||
const right = Math.max(...outside.map((s) => s.x)) + SLOT + MARGIN;
|
||||
const bottom = Math.max(...outside.map((s) => s.y)) + SLOT + MARGIN;
|
||||
g.panel(left, top, right - left, bottom - top);
|
||||
}
|
||||
}
|
||||
|
||||
render_labels(g: ModGraphics): void {
|
||||
|
||||
@@ -154,6 +154,7 @@ export abstract class GuiMenuScreen extends GuiScreen {
|
||||
#render_overlays() {
|
||||
const hovered = this.hovering && this.hovering.container.get_item(this.hovering.index);
|
||||
const view = {
|
||||
menu_type: this.menu.id === PLAYER_MENU ? undefined : this.menu.type,
|
||||
x: this.x / GUI_SCALE,
|
||||
y: this.y / GUI_SCALE,
|
||||
width: this.width,
|
||||
|
||||
Reference in New Issue
Block a user