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,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// the immediate mode drawing mods' client scripts get (Graphics in common/mod_api/client.ts), on top of the renderer.
|
||||
// one per screen, so text inputs keep their text and focus while it's open
|
||||
import { SLOT_SIZE, TEXTURE_SIZE } from "$/common/constants.ts";
|
||||
import { SLOT_SIZE } from "$/common/constants.ts";
|
||||
import { EverythingRegistry, type ItemRegistry } from "$/common/everything_registry.ts";
|
||||
import { ItemStack } from "$/common/inventory.ts";
|
||||
import type { Color, Graphics } from "$/common/mod_api/client.ts";
|
||||
@@ -102,10 +102,10 @@ export class ModGraphics implements Graphics {
|
||||
const region = get_sprite_region(id);
|
||||
draw_texture_region(
|
||||
atlas,
|
||||
region.x * TEXTURE_SIZE,
|
||||
region.y * TEXTURE_SIZE,
|
||||
TEXTURE_SIZE,
|
||||
TEXTURE_SIZE,
|
||||
region.x,
|
||||
region.y,
|
||||
region.width,
|
||||
region.height,
|
||||
x,
|
||||
y,
|
||||
w,
|
||||
|
||||
Reference in New Issue
Block a user