diff --git a/src/main/java/org/dynmap/DynmapPlugin.java b/src/main/java/org/dynmap/DynmapPlugin.java index 023ffcd9..d589e66b 100644 --- a/src/main/java/org/dynmap/DynmapPlugin.java +++ b/src/main/java/org/dynmap/DynmapPlugin.java @@ -75,7 +75,7 @@ public class DynmapPlugin extends JavaPlugin { /* Add/Replace branches in configuration tree with contribution from a separate file */ @SuppressWarnings("unchecked") - private void mergeConfigurationBranch(ConfigurationNode cfgnode, String branch, boolean replace_existing) { + private void mergeConfigurationBranch(ConfigurationNode cfgnode, String branch, boolean replace_existing, boolean islist) { Object srcbranch = cfgnode.getObject(branch); if(srcbranch == null) return; @@ -86,9 +86,9 @@ public class DynmapPlugin extends JavaPlugin { return; } /* If list, merge by "name" attribute */ - if((srcbranch instanceof List) && (destbranch instanceof List)) { - List dest = (List)destbranch; - List src = (List)srcbranch; + if(islist) { + List dest = configuration.getNodes(branch); + List src = cfgnode.getNodes(branch); /* Go through new records : see what to do with each */ for(ConfigurationNode node : src) { String name = node.getString("name", null); @@ -96,7 +96,7 @@ public class DynmapPlugin extends JavaPlugin { /* Walk destination - see if match */ boolean matched = false; for(ConfigurationNode dnode : dest) { - String dname = node.getString("name", null); + String dname = dnode.getString("name", null); if(dname == null) continue; if(dname.equals(name)) { /* Match? */ if(replace_existing) { @@ -112,11 +112,12 @@ public class DynmapPlugin extends JavaPlugin { dest.add(node); } } + configuration.put(branch,dest); } /* If configuration node, merge by key */ - else if((srcbranch instanceof ConfigurationNode) && (destbranch instanceof ConfigurationNode)) { - ConfigurationNode src = (ConfigurationNode)srcbranch; - ConfigurationNode dest = (ConfigurationNode)destbranch; + else { + ConfigurationNode src = cfgnode.getNode(branch); + ConfigurationNode dest = configuration.getNode(branch); for(String key : src.keySet()) { /* Check each contribution */ if(dest.containsKey(key)) { /* Exists? */ if(replace_existing) { /* If replacing, do so */ @@ -173,7 +174,7 @@ public class DynmapPlugin extends JavaPlugin { org.bukkit.util.config.Configuration cfg = new org.bukkit.util.config.Configuration(f); cfg.load(); ConfigurationNode cn = new ConfigurationNode(cfg); - mergeConfigurationBranch(cn, "worlds", true); + mergeConfigurationBranch(cn, "worlds", true, true); } else { try { @@ -192,7 +193,7 @@ public class DynmapPlugin extends JavaPlugin { org.bukkit.util.config.Configuration cfg = new org.bukkit.util.config.Configuration(f); cfg.load(); ConfigurationNode cn = new ConfigurationNode(cfg); - mergeConfigurationBranch(cn, "templates", false); + mergeConfigurationBranch(cn, "templates", false, false); } /* Now, process custom-templates.txt - these are user supplied, so override anything matcing */ @@ -201,7 +202,7 @@ public class DynmapPlugin extends JavaPlugin { org.bukkit.util.config.Configuration cfg = new org.bukkit.util.config.Configuration(f); cfg.load(); ConfigurationNode cn = new ConfigurationNode(cfg); - mergeConfigurationBranch(cn, "templates", true); + mergeConfigurationBranch(cn, "templates", true, false); } else { try { diff --git a/src/main/java/org/dynmap/flat/FlatMap.java b/src/main/java/org/dynmap/flat/FlatMap.java index 1e619811..4296371c 100644 --- a/src/main/java/org/dynmap/flat/FlatMap.java +++ b/src/main/java/org/dynmap/flat/FlatMap.java @@ -518,6 +518,7 @@ public class FlatMap extends MapType { s(o, "backgroundday", c.getString("backgroundday")); s(o, "backgroundnight", c.getString("backgroundnight")); s(o, "bigmap", this.isBigWorldMap(world)); + s(o, "compassview", "S"); /* Always from south */ a(worldObject, "maps", o); } } diff --git a/src/main/java/org/dynmap/hdmap/IsoHDPerspective.java b/src/main/java/org/dynmap/hdmap/IsoHDPerspective.java index 8db1de0d..ec5b1c2a 100644 --- a/src/main/java/org/dynmap/hdmap/IsoHDPerspective.java +++ b/src/main/java/org/dynmap/hdmap/IsoHDPerspective.java @@ -928,6 +928,7 @@ public class IsoHDPerspective implements HDPerspective { return name; } + private static String[] directions = { "N", "NE", "E", "SE", "S", "SW", "W", "NW" }; @Override public void addClientConfiguration(JSONObject mapObject) { s(mapObject, "perspective", name); @@ -936,5 +937,8 @@ public class IsoHDPerspective implements HDPerspective { s(mapObject, "scale", scale); s(mapObject, "worldtomap", world_to_map.toJSON()); s(mapObject, "maptoworld", map_to_world.toJSON()); + int dir = ((360 + (int)(22.5+azimuth)) / 45) % 8;; + s(mapObject, "compassview", directions[dir]); + } } diff --git a/src/main/java/org/dynmap/kzedmap/DefaultTileRenderer.java b/src/main/java/org/dynmap/kzedmap/DefaultTileRenderer.java index 67c392e3..dc6d4d28 100644 --- a/src/main/java/org/dynmap/kzedmap/DefaultTileRenderer.java +++ b/src/main/java/org/dynmap/kzedmap/DefaultTileRenderer.java @@ -579,6 +579,7 @@ public class DefaultTileRenderer implements MapTileRenderer { s(o, "backgroundday", c.getString("backgroundday")); s(o, "backgroundnight", c.getString("backgroundnight")); s(o, "bigmap", map.isBigWorldMap(world)); + s(o, "compassview", "SE"); /* Always from southeast */ a(worldObject, "maps", o); } } diff --git a/web/css/dynmap_style.css b/web/css/dynmap_style.css index af147263..d45e852a 100644 --- a/web/css/dynmap_style.css +++ b/web/css/dynmap_style.css @@ -565,31 +565,57 @@ * Compass */ -.compass { +.compass, .compass_NE, .compass_SE, .compass_NW, .compass_SW { display: block; position: absolute; z-index: 10; - top: 20px; right: 32px; - height: 84px; width: 83px; - background-repeat: no-repeat; +} + +.compass, .compass_SE { background-image: url(../images/compass.png); } -.compass_flat { +.compass_NE { + background-image: url(../images/compass_NE.png); +} + +.compass_NW { + background-image: url(../images/compass_NW.png); +} + +.compass_SW { + background-image: url(../images/compass_SW.png); +} + +.compass_flat, .compass_N, .compass_E, .compass_W, .compass_S { top: 10px; right: 21px; height: 105px; width: 105px; +} +.compass_flat, .compass_S { background-image: url(../images/compass_flat.png); } +.compass_N { + background-image: url(../images/compass_N.png); +} + +.compass_E { + background-image: url(../images/compass_E.png); +} + +.compass_W { + background-image: url(../images/compass_W.png); +} + /******************* * Chat */ diff --git a/web/images/compass.png b/web/images/compass.png index a7e13e54..2614dd30 100644 Binary files a/web/images/compass.png and b/web/images/compass.png differ diff --git a/web/images/compass_E.png b/web/images/compass_E.png new file mode 100644 index 00000000..a12f9878 Binary files /dev/null and b/web/images/compass_E.png differ diff --git a/web/images/compass_N.png b/web/images/compass_N.png new file mode 100644 index 00000000..4794e361 Binary files /dev/null and b/web/images/compass_N.png differ diff --git a/web/images/compass_NE.png b/web/images/compass_NE.png new file mode 100644 index 00000000..a7e13e54 Binary files /dev/null and b/web/images/compass_NE.png differ diff --git a/web/images/compass_NW.png b/web/images/compass_NW.png new file mode 100644 index 00000000..b657abf8 Binary files /dev/null and b/web/images/compass_NW.png differ diff --git a/web/images/compass_SW.png b/web/images/compass_SW.png new file mode 100644 index 00000000..f85c0d3b Binary files /dev/null and b/web/images/compass_SW.png differ diff --git a/web/images/compass_W.png b/web/images/compass_W.png new file mode 100644 index 00000000..a90055f3 Binary files /dev/null and b/web/images/compass_W.png differ diff --git a/web/js/map.js b/web/js/map.js index 60446c92..09fa7d58 100644 --- a/web/js/map.js +++ b/web/js/map.js @@ -292,7 +292,6 @@ DynMap.prototype = { var updateHeight = function() { playerlist.height(sidebar.innerHeight() - (playerlist.offset().top - worldlist.offset().top) - 64); // here we need a fix to avoid the static value, but it works fine this way :P - console.log('scrollheight=' + playerlist.scrollHeight() + ', height=' + playerlist.height()); var scrollable = playerlist.scrollHeight() < playerlist.height(); upbtn.toggle(scrollable); downbtn.toggle(scrollable); @@ -357,8 +356,10 @@ DynMap.prototype = { } $(me).trigger('mapchanging'); if (me.maptype) { + $('.compass').removeClass('compass_' + me.maptype.compassview); $('.compass').removeClass('compass_' + me.maptype.name); } + $('.compass').addClass('compass_' + map.compassview); $('.compass').addClass('compass_' + map.name); var worldChanged = me.world !== map.world; var projectionChanged = me.map.getProjection() !== map.projection;