Change the gui

This commit is contained in:
2026-09-27 14:52:30 -03:00
parent d0cbec1846
commit 29e61a235b
20 changed files with 451 additions and 359 deletions
+5 -7
View File
@@ -2,7 +2,8 @@
import { EverythingRegistry, ItemRegistry } from "$/common/everything_registry.ts";
import type { ItemStack } from "$/common/inventory.ts";
import { display_name } from "$/common/utils.ts";
import { canvas, draw_rect, draw_text, measure_text } from "$/client/renderer/mod.ts";
import { canvas, draw_text, measure_text } from "$/client/renderer/mod.ts";
import { draw_gui_sprite, GUI_SCALE } from "./gui_sprites.ts";
import { TEXT_HEIGHT, TEXT_SCALE } from "./widgets.ts";
type Color = [number, number, number, number];
@@ -10,10 +11,8 @@ type Color = [number, number, number, number];
const NAME_COLOR: Color = [1, 1, 1, 1];
const LORE_COLOR: Color = [0.66, 0.66, 0.66, 1];
const FOOD_COLOR: Color = [0.85, 0.6, 0.35, 1];
const BACKGROUND: Color = [0.06, 0.02, 0.1, 0.94];
const BORDER: Color = [0.31, 0.1, 0.6, 1];
const BORDER_WIDTH = 2;
const PADDING = 8;
// from the edge of the tooltip sprite to the text
const PADDING = 4 * GUI_SCALE;
const LINE_GAP = 4;
// from the mouse, so the cursor doesn't cover it
const OFFSET = 16;
@@ -52,8 +51,7 @@ export function draw_tooltip(lines: TooltipLine[], mouse_x: number, mouse_y: num
x = Math.max(0, x);
y = Math.max(0, y);
draw_rect(x, y, width, height, BORDER);
draw_rect(x + BORDER_WIDTH, y + BORDER_WIDTH, width - BORDER_WIDTH * 2, height - BORDER_WIDTH * 2, BACKGROUND);
draw_gui_sprite("tooltip", x, y, width, height);
lines.forEach((line, i) => {
draw_text(line.text, x + PADDING, y + PADDING + i * (line_height + LINE_GAP), TEXT_SCALE, line.color);
});