Fluid slots and kegs !

This commit is contained in:
2026-10-31 17:35:27 -03:00
parent 65934d34a1
commit 658a6453b7
19 changed files with 494 additions and 34 deletions
+14
View File
@@ -9,6 +9,7 @@ import { display_name } from "$/common/utils.ts";
import { fluid_rules } from "$/client/fluid_rules.ts";
import { canvas, draw_text, draw_texture_region, measure_text, type Texture } from "$/client/renderer/mod.ts";
import { AssetManager } from "$/client/assets.ts";
import type { MenuTank } from "$/common/protocol.ts";
import { get_sprite_region } from "$/client/sprites.ts";
import { draw_gui_sprite, GUI_SCALE } from "./gui_sprites.ts";
import { TEXT_HEIGHT, TEXT_SCALE } from "./widgets.ts";
@@ -62,6 +63,19 @@ export function item_tooltip(item: ItemStack): TooltipLine[] {
return lines;
}
// a menu's fluid slot, like modern industrialization's: the fluid, how much of the tank it fills, and what clicking it
// with a fluid container does
export function tank_tooltip(tank: MenuTank, output: boolean): TooltipLine[] {
return [
tank.fluid ? { text: fluid_rules.name(tank.fluid), color: NAME_COLOR } : { text: "Empty", color: LORE_COLOR },
{ text: `${tank.amount} / ${tank.capacity} mB`, color: FLUID_COLOR },
{
text: output ? "Fluid Output, Click to Extract" : "Fluid Input, Click to Insert or Extract",
color: LORE_COLOR,
},
];
}
// below and right of the mouse, moved back inside the window when it would go past its edge
export function draw_tooltip(lines: TooltipLine[], mouse_x: number, mouse_y: number) {
const line_height = TEXT_HEIGHT * TEXT_SCALE;