Allow for textures that aren't 16x16
This commit is contained in:
+13
-13
@@ -1,7 +1,7 @@
|
||||
import { add_player_hotbar, add_player_inventory, GuiInventoryScreen, Slot } from "./gui_screen.ts";
|
||||
import { canvas, draw_rect, draw_texture_region, Texture } from "$/client/renderer/mod.ts";
|
||||
import { AssetManager } from "../assets.ts";
|
||||
import { SLOT_SIZE, TEXTURE_SIZE } from "$/common/constants.ts";
|
||||
import { SLOT_SIZE } from "$/common/constants.ts";
|
||||
import { ClientMessage, ScreenLayout } from "$/common/protocol.ts";
|
||||
import { draw_gui_sprite, GUI_SCALE } from "./gui_sprites.ts";
|
||||
import { get_sprite_region } from "$/client/sprites.ts";
|
||||
@@ -62,10 +62,10 @@ export class GuiContainer extends GuiInventoryScreen {
|
||||
const empty = get_sprite_region(bar.empty_texture);
|
||||
draw_texture_region(
|
||||
atlas,
|
||||
empty.x * TEXTURE_SIZE,
|
||||
empty.y * TEXTURE_SIZE,
|
||||
TEXTURE_SIZE,
|
||||
TEXTURE_SIZE,
|
||||
empty.x,
|
||||
empty.y,
|
||||
empty.width,
|
||||
empty.height,
|
||||
x,
|
||||
y,
|
||||
SLOT_SIZE,
|
||||
@@ -76,10 +76,10 @@ export class GuiContainer extends GuiInventoryScreen {
|
||||
if (bar.direction === "right") {
|
||||
draw_texture_region(
|
||||
atlas,
|
||||
full.x * TEXTURE_SIZE,
|
||||
full.y * TEXTURE_SIZE,
|
||||
TEXTURE_SIZE * pct,
|
||||
TEXTURE_SIZE,
|
||||
full.x,
|
||||
full.y,
|
||||
full.width * pct,
|
||||
full.height,
|
||||
x,
|
||||
y,
|
||||
SLOT_SIZE * pct,
|
||||
@@ -89,10 +89,10 @@ export class GuiContainer extends GuiInventoryScreen {
|
||||
// fills from the bottom up
|
||||
draw_texture_region(
|
||||
atlas,
|
||||
full.x * TEXTURE_SIZE,
|
||||
full.y * TEXTURE_SIZE + TEXTURE_SIZE * (1 - pct),
|
||||
TEXTURE_SIZE,
|
||||
TEXTURE_SIZE * pct,
|
||||
full.x,
|
||||
full.y + full.height * (1 - pct),
|
||||
full.width,
|
||||
full.height * pct,
|
||||
x,
|
||||
y + SLOT_SIZE * (1 - pct),
|
||||
SLOT_SIZE,
|
||||
|
||||
Reference in New Issue
Block a user