Merge pull request #2093 from zethnest/map-center

[QOL] Center Map to Player Implementation
This commit is contained in:
Anuken 2020-07-14 20:41:03 -04:00 committed by GitHub
commit 23e1d0998a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 0 deletions

View File

@ -647,6 +647,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)[]

View File

@ -242,6 +242,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 -> {

View File

@ -111,6 +111,12 @@ public class MinimapFragment extends Fragment{
}
public void toggle(){
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;
}
}