mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Shape tooltip adjustments
This commit is contained in:
@@ -16,6 +16,7 @@ import { HUDEntityDebugger } from "./parts/entity_debugger";
|
||||
import { HUDModalDialogs } from "./parts/modal_dialogs";
|
||||
import { enumNotificationType } from "./parts/notifications";
|
||||
import { HUDSettingsMenu } from "./parts/settings_menu";
|
||||
import { HUDShapeTooltip } from "./parts/shape_tooltip";
|
||||
import { HUDVignetteOverlay } from "./parts/vignette_overlay";
|
||||
import { TrailerMaker } from "./trailer_maker";
|
||||
|
||||
@@ -49,6 +50,8 @@ export class GameHUD {
|
||||
blueprintPlacer: new HUDBlueprintPlacer(this.root),
|
||||
buildingPlacer: new HUDBuildingPlacer(this.root),
|
||||
|
||||
shapeTooltip: new HUDShapeTooltip(this.root),
|
||||
|
||||
// Must always exist
|
||||
settingsMenu: new HUDSettingsMenu(this.root),
|
||||
debugInfo: new HUDDebugInfo(this.root),
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { DrawParameters } from "../../../core/draw_parameters";
|
||||
import { Vector } from "../../../core/vector";
|
||||
import { enumDirectionToVector, Vector } from "../../../core/vector";
|
||||
import { Entity } from "../../entity";
|
||||
import { KEYMAPPINGS } from "../../key_action_mapper";
|
||||
import { THEME } from "../../theme";
|
||||
import { BaseHUDPart } from "../base_hud_part";
|
||||
|
||||
export class HUDShapeTooltip extends BaseHUDPart {
|
||||
@@ -68,6 +69,8 @@ export class HUDShapeTooltip extends BaseHUDPart {
|
||||
const ejectorComp = this.currentEntity.components.ItemEjector;
|
||||
const staticComp = this.currentEntity.components.StaticMapEntity;
|
||||
|
||||
const context = parameters.context;
|
||||
|
||||
for (let i = 0; i < ejectorComp.slots.length; ++i) {
|
||||
const slot = ejectorComp.slots[i];
|
||||
|
||||
@@ -75,15 +78,34 @@ export class HUDShapeTooltip extends BaseHUDPart {
|
||||
continue;
|
||||
}
|
||||
|
||||
/** @type {Vector} */
|
||||
let drawPos = null;
|
||||
if (ejectorComp.slots.length == 1) {
|
||||
drawPos = staticComp.getTileSpaceBounds().getCenter().toWorldSpace();
|
||||
} else {
|
||||
drawPos = staticComp.localTileToWorld(slot.pos).toWorldSpaceCenterOfTile();
|
||||
}
|
||||
const drawPos = staticComp
|
||||
.localTileToWorld(slot.pos.add(enumDirectionToVector[slot.direction].multiplyScalar(1)))
|
||||
.toWorldSpaceCenterOfTile();
|
||||
|
||||
slot.lastItem.drawItemCenteredClipped(drawPos.x, drawPos.y, parameters, 25);
|
||||
const slotCenterPos = staticComp
|
||||
.localTileToWorld(slot.pos.add(enumDirectionToVector[slot.direction].multiplyScalar(0.2)))
|
||||
.toWorldSpaceCenterOfTile();
|
||||
|
||||
context.fillStyle = THEME.shapeTooltip.outline;
|
||||
context.strokeStyle = THEME.shapeTooltip.outline;
|
||||
|
||||
context.lineWidth = 1.5;
|
||||
context.beginPath();
|
||||
context.moveTo(slotCenterPos.x, slotCenterPos.y);
|
||||
context.lineTo(drawPos.x, drawPos.y);
|
||||
context.stroke();
|
||||
|
||||
context.beginCircle(slotCenterPos.x, slotCenterPos.y, 3.5);
|
||||
context.fill();
|
||||
|
||||
context.fillStyle = THEME.shapeTooltip.background;
|
||||
context.strokeStyle = THEME.shapeTooltip.outline;
|
||||
|
||||
context.lineWidth = 1.2;
|
||||
context.beginCircle(drawPos.x, drawPos.y, 11 + 1.2 / 2);
|
||||
context.fill();
|
||||
context.stroke();
|
||||
slot.lastItem.drawItemCenteredClipped(drawPos.x, drawPos.y, parameters, 22);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user