27 lines
985 B
TypeScript
27 lines
985 B
TypeScript
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
import type { Client } from "@/client/client.ts";
|
|
import { render_hud_layers } from "@/client/mods.ts";
|
|
import { canvas } from "@/client/renderer/mod.ts";
|
|
import type { HudSpace } from "@/common/mod_api/client.ts";
|
|
import { ModGraphics } from "./mod_graphics.ts";
|
|
import { GUI_SCALE } from "./gui_sprites.ts";
|
|
|
|
// between the top of the hud and the bottom of chat, in gui pixels
|
|
const CHAT_GAP = 4;
|
|
|
|
// what's drawn over the world while playing, like minecraft's Gui: mods' layers (ctx.hud), then chat above them
|
|
export class Hud {
|
|
#graphics = new ModGraphics();
|
|
|
|
render(client: Client) {
|
|
const space: HudSpace = { left_height: 0, right_height: 0 };
|
|
this.#graphics.begin();
|
|
render_hud_layers(this.#graphics, space);
|
|
this.#graphics.end();
|
|
const top = Math.max(space.left_height, space.right_height) + CHAT_GAP;
|
|
client.chat.render(false, canvas.height - top * GUI_SCALE);
|
|
}
|
|
}
|