Tooltips
This commit is contained in:
@@ -7,6 +7,7 @@ import { InputManager } from "../input_manager.ts";
|
||||
import { ClientInventories } from "../inventory.ts";
|
||||
import { canvas, Texture } from "../renderer/mod.ts";
|
||||
import { draw_item, draw_nine_slice } from "../rendering/render_utils.ts";
|
||||
import { draw_tooltip, item_tooltip } from "./tooltip.ts";
|
||||
|
||||
export class Slot {
|
||||
container: ContainerKey;
|
||||
@@ -99,9 +100,15 @@ export class GuiInventoryScreen extends GuiScreen {
|
||||
}
|
||||
}
|
||||
|
||||
const mouse = InputManager.get_mouse_position();
|
||||
if (this.inventories.cursor.item) {
|
||||
const mouse = InputManager.get_mouse_position();
|
||||
draw_item(this.inventories.cursor.item, mouse.x, mouse.y);
|
||||
} else if (this.hovering) {
|
||||
// what's in the slot under the mouse, while not carrying anything
|
||||
const item = this.get_container(this.hovering.container)?.get_item(this.hovering.index);
|
||||
if (item) {
|
||||
draw_tooltip(item_tooltip(item), mouse.x, mouse.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user