From 25c0b60ec692943cb2d3b1107696a658d8a826ba Mon Sep 17 00:00:00 2001 From: Chunkybanana <62921243+chunkybanana@users.noreply.github.com> Date: Wed, 21 Dec 2022 22:25:22 +0000 Subject: [PATCH] Show building on hover (pls don't break package.json) --- package-lock.json | 1 + src/data/layers/factory.tsx | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 590be8d..0834b90 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12083,6 +12083,7 @@ }, "vue-panzoom": { "version": "git+ssh://git@github.com/thepaperpilot/vue-panzoom.git#fa3cc91f6842cdfbd1bfb433c75cac01f177fe2d", + "integrity": "sha512-d4URo4PVl2jCFG1WNY+5lDQ8nloOVLf2gFLqE+TLNmF43+F/STgld0A58uf9aq2xbaupVJdZAp/prGtve9ESRQ==", "from": "vue-panzoom@https://github.com/thepaperpilot/vue-panzoom.git", "requires": { "panzoom": "^9.4.1" diff --git a/src/data/layers/factory.tsx b/src/data/layers/factory.tsx index 9c3c51d..a9bcffd 100644 --- a/src/data/layers/factory.tsx +++ b/src/data/layers/factory.tsx @@ -254,6 +254,7 @@ const factory = createLayer(id, () => { const graphicContainer = new Graphics(); let spriteContainer = new Container(); const movingBlocks = new Container(); + let hoverSprite = new Sprite(); spriteContainer.zIndex = 0; movingBlocks.zIndex = 1; @@ -591,6 +592,7 @@ const factory = createLayer(id, () => { spriteContainer.x = movingBlocks.x = calculatedX; spriteContainer.y = movingBlocks.y = calculatedY; + graphicContainer.removeChild(hoverSprite); if ( isMouseHoverShown.value && compSelected.value !== "cursor" && @@ -604,6 +606,14 @@ const factory = createLayer(id, () => { blockSize, blockSize ); + const factoryBaseData = FACTORY_COMPONENTS[compSelected.value]; + const sheet = Assets.get(factoryBaseData.imageSrc); + hoverSprite = new Sprite(sheet); + hoverSprite.x = roundDownTo(mouseCoords.x - tx, blockSize) + tx - blockSize / 2; + hoverSprite.y = roundDownTo(mouseCoords.y - ty, blockSize) + ty - blockSize / 2; + hoverSprite.width = blockSize; + hoverSprite.height = blockSize; + graphicContainer.addChild(hoverSprite); } } watchEffect(updateGraphics); @@ -862,7 +872,7 @@ const factory = createLayer(id, () => { onMouseenter={() => onComponentMouseEnter(key)} onMouseleave={() => onComponentMouseLeave()} onClick={() => onCompClick(key)} - > + /> ); })}