mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Improve shape tooltip
This commit is contained in:
parent
2695694f50
commit
ae6c5b151e
@ -69,43 +69,27 @@ export class HUDShapeTooltip extends BaseHUDPart {
|
|||||||
const ejectorComp = this.currentEntity.components.ItemEjector;
|
const ejectorComp = this.currentEntity.components.ItemEjector;
|
||||||
const staticComp = this.currentEntity.components.StaticMapEntity;
|
const staticComp = this.currentEntity.components.StaticMapEntity;
|
||||||
|
|
||||||
const context = parameters.context;
|
const bounds = staticComp.getTileSize();
|
||||||
|
const totalArea = bounds.x * bounds.y;
|
||||||
|
const maxSlots = totalArea < 2 ? 1 : 1e10;
|
||||||
|
|
||||||
|
let slotsDrawn = 0;
|
||||||
|
|
||||||
for (let i = 0; i < ejectorComp.slots.length; ++i) {
|
for (let i = 0; i < ejectorComp.slots.length; ++i) {
|
||||||
const slot = ejectorComp.slots[i];
|
const slot = ejectorComp.slots[i];
|
||||||
|
|
||||||
if (!slot.lastItem || slot.lastItem._type != "shape") {
|
if (!slot.lastItem) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const drawPos = staticComp
|
if (++slotsDrawn > maxSlots) {
|
||||||
.localTileToWorld(slot.pos.add(enumDirectionToVector[slot.direction].multiplyScalar(1)))
|
continue;
|
||||||
.toWorldSpaceCenterOfTile();
|
}
|
||||||
|
|
||||||
const slotCenterPos = staticComp
|
/** @type {Vector} */
|
||||||
.localTileToWorld(slot.pos.add(enumDirectionToVector[slot.direction].multiplyScalar(0.2)))
|
const drawPos = staticComp.localTileToWorld(slot.pos).toWorldSpaceCenterOfTile();
|
||||||
.toWorldSpaceCenterOfTile();
|
|
||||||
|
|
||||||
context.fillStyle = THEME.shapeTooltip.outline;
|
slot.lastItem.drawItemCenteredClipped(drawPos.x, drawPos.y, parameters, 25);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user