From a5bc33e1e926f9080b4b189d299b1959ef05e32c Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Tue, 3 Jan 2012 15:21:12 +0800 Subject: [PATCH] Add 'followmap' and 'followzoom' to allow setting of map and zoom when starting to follow a player --- .../java/org/dynmap/ClientConfigurationComponent.java | 4 ++++ src/main/resources/configuration.txt | 3 +++ web/js/map.js | 10 +++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/dynmap/ClientConfigurationComponent.java b/src/main/java/org/dynmap/ClientConfigurationComponent.java index 8d3e37db..ab548615 100644 --- a/src/main/java/org/dynmap/ClientConfigurationComponent.java +++ b/src/main/java/org/dynmap/ClientConfigurationComponent.java @@ -55,6 +55,10 @@ public class ClientConfigurationComponent extends Component { } s(t, "defaultworld", c.getString("defaultworld", defaultWorld == null ? "world" : defaultWorld.world.getName())); s(t, "defaultmap", c.getString("defaultmap", defmap == null ? "surface" : defmap)); + if(c.getString("followmap", null) != null) + s(t, "followmap", c.getString("followmap")); + if(c.getInteger("followzoom",-1) >= 0) + s(t, "followzoom", c.getInteger("followzoom", 0)); } }); } diff --git a/src/main/resources/configuration.txt b/src/main/resources/configuration.txt index b6d591cb..702ac232 100644 --- a/src/main/resources/configuration.txt +++ b/src/main/resources/configuration.txt @@ -277,6 +277,9 @@ check-banned-ips: true defaultzoom: 0 defaultworld: world defaultmap: flat +# (optional) Zoom level and map to switch to when following a player, if possible +#followzoom: 3 +#followmap: surface # Option to enable workaround for incorrectly encoded unicode in Cyrillic MC/Bukkit (not good for other code pages) cyrillic-support: false diff --git a/web/js/map.js b/web/js/map.js index c3dbaa49..1b263886 100644 --- a/web/js/map.js +++ b/web/js/map.js @@ -719,7 +719,15 @@ DynMap.prototype = { if(player) { $(player.menuitem).addClass('following'); - me.panToLocation(player.location); + me.panToLocation(player.location, function() { + if(me.options.followmap && me.world) { + var pmap = me.world.maps[me.options.followmap]; + if(pmap) + me.selectMapAndPan(pmap); + } + if(me.options.followzoom) + me.map.setZoom(me.options.followzoom); + }); } this.followingPlayer = player; },