From f30b24f4ace27ffdf120135ad224a9e307d43370 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 25 May 2024 22:40:37 -0400 Subject: [PATCH] Closes Anuken/Mindustry-Suggestions/issues/5012 --- core/src/mindustry/ui/Minimap.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/core/src/mindustry/ui/Minimap.java b/core/src/mindustry/ui/Minimap.java index ad828a8dd2..99c7a32303 100644 --- a/core/src/mindustry/ui/Minimap.java +++ b/core/src/mindustry/ui/Minimap.java @@ -3,9 +3,11 @@ package mindustry.ui; import arc.*; import arc.graphics.g2d.*; import arc.input.*; +import arc.math.*; import arc.scene.*; import arc.scene.event.*; import arc.scene.ui.layout.*; +import arc.util.*; import mindustry.gen.*; import static mindustry.Vars.*; @@ -20,6 +22,22 @@ public class Minimap extends Table{ add(new Element(){ { setSize(Scl.scl(140f)); + + addListener(new ClickListener(KeyCode.mouseRight){ + @Override + public void clicked(InputEvent event, float cx, float cy){ + var region = renderer.minimap.getRegion(); + if(region == null) return; + + float + sx = (cx - x) / width, + sy = (cy - y) / height, + scaledX = Mathf.lerp(region.u, region.u2, sx) * world.width() * tilesize, + scaledY = Mathf.lerp(1f - region.v2, 1f - region.v, sy) * world.height() * tilesize; + + control.input.panCamera(Tmp.v1.set(scaledX, scaledY)); + } + }); } @Override