Change the gui
This commit is contained in:
@@ -1,26 +1,27 @@
|
||||
import { add_player_hotbar, add_player_inventory, GuiInventoryScreen, Slot } from "./gui_screen.ts";
|
||||
import { canvas, draw_rect, Texture } from "$/client/renderer/mod.ts";
|
||||
import { AssetManager } from "../assets.ts";
|
||||
import { canvas, draw_rect } from "$/client/renderer/mod.ts";
|
||||
import { SLOT_SIZE } from "../../common/constants.ts";
|
||||
import { draw_nine_slice } from "../rendering/render_utils.ts";
|
||||
import { draw_gui_sprite, GUI_SCALE } from "./gui_sprites.ts";
|
||||
import { ClientInventories } from "../inventory.ts";
|
||||
import { ClientMessage, CRAFTING_RESULT_SLOT } from "$/common/protocol.ts";
|
||||
|
||||
const PADDING = 10;
|
||||
// around the slots, and between the hotbar, the rest of the inventory and what's below, like minecraft's
|
||||
const MARGIN = 7 * GUI_SCALE;
|
||||
const GAP = 4 * GUI_SCALE;
|
||||
|
||||
// the recipes live on the server, which fills in the result slot
|
||||
export class GuiPlayerInventory extends GuiInventoryScreen {
|
||||
override inventory_width = PADDING * 2 + SLOT_SIZE * 9;
|
||||
override inventory_height = PADDING * 2 + SLOT_SIZE * 4 + PADDING + SLOT_SIZE * 3 + PADDING;
|
||||
override inventory_width = MARGIN * 2 + SLOT_SIZE * 9;
|
||||
override inventory_height = MARGIN * 2 + GAP * 2 + SLOT_SIZE * 7;
|
||||
|
||||
constructor(inventories: ClientInventories, send: (message: ClientMessage) => void) {
|
||||
super(inventories, send);
|
||||
|
||||
add_player_hotbar(this, PADDING, PADDING);
|
||||
add_player_inventory(this, PADDING, PADDING * 2 + SLOT_SIZE);
|
||||
add_player_hotbar(this, MARGIN, MARGIN);
|
||||
add_player_inventory(this, MARGIN, MARGIN + GAP + SLOT_SIZE);
|
||||
|
||||
const crafting_x = PADDING;
|
||||
const crafting_y = PADDING * 3 + SLOT_SIZE * 4;
|
||||
const crafting_x = MARGIN;
|
||||
const crafting_y = MARGIN + GAP * 2 + SLOT_SIZE * 4;
|
||||
|
||||
for (let i = 0; i < 3; i += 1) {
|
||||
for (let j = 0; j < 3; j += 1) {
|
||||
@@ -38,23 +39,7 @@ export class GuiPlayerInventory extends GuiInventoryScreen {
|
||||
override on_render(): void {
|
||||
draw_rect(0, 0, canvas.width, canvas.height, [0, 0, 0, 0.8]);
|
||||
|
||||
const ui = AssetManager.instance.get<Texture>("bworld:ui");
|
||||
|
||||
draw_nine_slice(
|
||||
ui,
|
||||
160,
|
||||
0,
|
||||
16,
|
||||
16,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
this.x,
|
||||
this.y,
|
||||
this.inventory_width,
|
||||
this.inventory_height,
|
||||
);
|
||||
draw_gui_sprite("panel", this.x, this.y, this.inventory_width, this.inventory_height);
|
||||
|
||||
super.on_render();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user