Re-implement map compass
This commit is contained in:
@@ -100,20 +100,25 @@ directory.
|
||||
dump = dict()
|
||||
dump['CONST'] = dict(tileSize=384)
|
||||
dump['CONST']['image'] = {
|
||||
'defaultMarker': 'signpost.png',
|
||||
'signMarker': 'signpost_icon.png',
|
||||
'bedMarker': 'bed.png',
|
||||
'spawnMarker': 'icons/marker_home.png',
|
||||
'spawnMarker2x': 'icons/marker_home_2x.png',
|
||||
'queryMarker': 'icons/marker_location.png',
|
||||
'queryMarker2x': 'icons/marker_location_2x.png'
|
||||
}
|
||||
'defaultMarker': 'signpost.png',
|
||||
'signMarker': 'signpost_icon.png',
|
||||
'bedMarker': 'bed.png',
|
||||
'spawnMarker': 'icons/marker_home.png',
|
||||
'spawnMarker2x': 'icons/marker_home_2x.png',
|
||||
'queryMarker': 'icons/marker_location.png',
|
||||
'queryMarker2x': 'icons/marker_location_2x.png'
|
||||
}
|
||||
dump['CONST']['mapDivId'] = 'mcmap'
|
||||
dump['CONST']['regionStrokeWeight'] = 2 # Obselete
|
||||
dump['CONST']['UPPERLEFT'] = world.UPPER_LEFT;
|
||||
dump['CONST']['UPPERRIGHT'] = world.UPPER_RIGHT;
|
||||
dump['CONST']['LOWERLEFT'] = world.LOWER_LEFT;
|
||||
dump['CONST']['LOWERRIGHT'] = world.LOWER_RIGHT;
|
||||
dump['CONST']['UPPERLEFT'] = world.UPPER_LEFT
|
||||
dump['CONST']['UPPERRIGHT'] = world.UPPER_RIGHT
|
||||
dump['CONST']['LOWERLEFT'] = world.LOWER_LEFT
|
||||
dump['CONST']['LOWERRIGHT'] = world.LOWER_RIGHT
|
||||
dump['CONST']['image']['compass'] = {
|
||||
world.UPPER_LEFT:'compass_upper-left.png',
|
||||
world.UPPER_RIGHT:'compass_upper-right.png',
|
||||
world.LOWER_LEFT:'compass_lower-left.png',
|
||||
world.LOWER_RIGHT:'compass_lower-right.png'
|
||||
}
|
||||
|
||||
# based on the tilesets we have, group them by worlds
|
||||
worlds = []
|
||||
@@ -136,7 +141,6 @@ directory.
|
||||
'mapType': True,
|
||||
'overlays': True,
|
||||
'coordsBox': True,
|
||||
'searchBox': True # Lolwat. Obselete
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ var overviewer = {};
|
||||
overviewer.map = null;
|
||||
overviewer.worldCtrl = null;
|
||||
overviewer.layerCtrl = null;
|
||||
overviewer.compass = null;
|
||||
overviewer.current_world = null;
|
||||
|
||||
/// Records the current layer by name (if any) of each world
|
||||
|
||||
@@ -38,7 +38,19 @@ overviewer.util = {
|
||||
|
||||
document.getElementById('NoJSWarning').remove();
|
||||
|
||||
|
||||
overviewer.compassClass = L.Control.extend({
|
||||
initialize: function(imagedict, options) {
|
||||
L.Util.setOptions(this, options);
|
||||
this.compass_img = L.DomUtil.create('img', 'compass');
|
||||
this.imagedict = imagedict;
|
||||
},
|
||||
render: function(direction) {
|
||||
this.compass_img.src = this.imagedict[direction];
|
||||
},
|
||||
onAdd: function() {
|
||||
return this.compass_img;
|
||||
}
|
||||
});
|
||||
overviewer.control = L.Control.extend({
|
||||
initialize: function(options) {
|
||||
L.Util.setOptions(this, options);
|
||||
@@ -119,6 +131,9 @@ overviewer.util = {
|
||||
overviewer.current_layer[overviewer.current_world] = ev.layer;
|
||||
var ovconf = ev.layer.tileSetConfig;
|
||||
|
||||
// Change the compass
|
||||
overviewer.compass.render(ovconf.north_direction);
|
||||
|
||||
// Set the background colour
|
||||
document.getElementById("mcmap").style.backgroundColor = ovconf.bgcolor;
|
||||
|
||||
@@ -176,6 +191,8 @@ overviewer.util = {
|
||||
var tilesetLayers = {}
|
||||
|
||||
overviewer.worldCtrl = new overviewer.control();
|
||||
overviewer.compass = new overviewer.compassClass(
|
||||
overviewerConfig.CONST.image.compass);
|
||||
|
||||
|
||||
$.each(overviewerConfig.worlds, function(idx, world_name) {
|
||||
@@ -184,6 +201,7 @@ overviewer.util = {
|
||||
overviewer.worldCtrl.addWorld(world_name);
|
||||
});
|
||||
|
||||
overviewer.compass.addTo(overviewer.map);
|
||||
overviewer.worldCtrl.addTo(overviewer.map);
|
||||
|
||||
$.each(overviewerConfig.tilesets, function(idx, obj) {
|
||||
|
||||
Reference in New Issue
Block a user