From befae9a7c2d5ae0177e05f47c31538b680d04fe3 Mon Sep 17 00:00:00 2001 From: Izzat Nasrun <16971676+zethnest@users.noreply.github.com> Date: Thu, 21 May 2020 00:47:25 +0800 Subject: [PATCH 1/3] center map to player when opened implementation --- core/src/mindustry/ui/fragments/MinimapFragment.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/mindustry/ui/fragments/MinimapFragment.java b/core/src/mindustry/ui/fragments/MinimapFragment.java index 12195af8a9..ca5621f396 100644 --- a/core/src/mindustry/ui/fragments/MinimapFragment.java +++ b/core/src/mindustry/ui/fragments/MinimapFragment.java @@ -8,6 +8,7 @@ import arc.math.*; import arc.scene.*; import arc.scene.event.*; import arc.scene.ui.layout.*; +import arc.util.*; import mindustry.gen.*; import mindustry.input.*; import mindustry.ui.*; @@ -111,6 +112,10 @@ public class MinimapFragment extends Fragment{ } public void toggle(){ + float size = baseSize * zoom * world.width(); + float ratio = (float)renderer.minimap.getTexture().getHeight() / renderer.minimap.getTexture().getWidth(); + panx = size/2f - player.x() / (world.width() * tilesize) * size; + pany = size*ratio/2f - player.y() / (world.height() * tilesize) * size*ratio; shown = !shown; } } From f598ccb79b9c66a0667ca5e2aa7a5d3d45ba8e63 Mon Sep 17 00:00:00 2001 From: Izzat Nasrun <16971676+zethnest@users.noreply.github.com> Date: Thu, 21 May 2020 04:49:46 +0800 Subject: [PATCH 2/3] remove unnecessary imports --- core/src/mindustry/ui/fragments/MinimapFragment.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/mindustry/ui/fragments/MinimapFragment.java b/core/src/mindustry/ui/fragments/MinimapFragment.java index ca5621f396..3d8d71dab2 100644 --- a/core/src/mindustry/ui/fragments/MinimapFragment.java +++ b/core/src/mindustry/ui/fragments/MinimapFragment.java @@ -8,7 +8,6 @@ import arc.math.*; import arc.scene.*; import arc.scene.event.*; import arc.scene.ui.layout.*; -import arc.util.*; import mindustry.gen.*; import mindustry.input.*; import mindustry.ui.*; From 196a79a10c434142758a2b5883571b303693b311 Mon Sep 17 00:00:00 2001 From: Izzat Nasrun <16971676+zethnest@users.noreply.github.com> Date: Thu, 21 May 2020 12:26:20 +0800 Subject: [PATCH 3/3] togglable in settings.game fix zoom independency --- core/assets/bundles/bundle.properties | 1 + core/src/mindustry/ui/dialogs/SettingsMenuDialog.java | 1 + core/src/mindustry/ui/fragments/MinimapFragment.java | 10 ++++++---- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 2b5caeefa1..ed35c92033 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -639,6 +639,7 @@ setting.linear.name = Linear Filtering setting.hints.name = Hints setting.flow.name = Display Resource Flow Rate setting.buildautopause.name = Auto-Pause Building +setting.mapcenter.name = Auto Center Map To Player setting.animatedwater.name = Animated Fluids setting.animatedshields.name = Animated Shields setting.antialias.name = Antialias[lightgray] (requires restart)[] diff --git a/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java b/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java index 3b6ad2561e..11c03332d3 100644 --- a/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java +++ b/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java @@ -238,6 +238,7 @@ public class SettingsMenuDialog extends SettingsDialog{ if(!mobile){ game.checkPref("buildautopause", false); } + game.checkPref("mapcenter", true); if(steam){ game.sliderPref("playerlimit", 16, 2, 32, i -> { diff --git a/core/src/mindustry/ui/fragments/MinimapFragment.java b/core/src/mindustry/ui/fragments/MinimapFragment.java index 3d8d71dab2..a8ca154342 100644 --- a/core/src/mindustry/ui/fragments/MinimapFragment.java +++ b/core/src/mindustry/ui/fragments/MinimapFragment.java @@ -111,10 +111,12 @@ public class MinimapFragment extends Fragment{ } public void toggle(){ - float size = baseSize * zoom * world.width(); - float ratio = (float)renderer.minimap.getTexture().getHeight() / renderer.minimap.getTexture().getWidth(); - panx = size/2f - player.x() / (world.width() * tilesize) * size; - pany = size*ratio/2f - player.y() / (world.height() * tilesize) * size*ratio; + if(Core.settings.getBool("mapcenter")){ + float size = baseSize * zoom * world.width(); + float ratio = (float)renderer.minimap.getTexture().getHeight() / renderer.minimap.getTexture().getWidth(); + panx = (size/2f - player.x() / (world.width() * tilesize) * size) / zoom; + pany = (size*ratio/2f - player.y() / (world.height() * tilesize) * size*ratio) / zoom; + } shown = !shown; } }