Put markers in a component, add generic component update messages

This commit is contained in:
Mike Primm 2011-09-03 16:49:18 -05:00
parent e4f0a17161
commit 0338bb6f3a
7 changed files with 151 additions and 46 deletions

View file

@ -499,6 +499,9 @@ DynMap.prototype = {
},
playerquit: function() {
$(me).trigger('playerquit', [ update.playerName ]);
},
component: function() {
$(me).trigger('component.' + update.ctype, [ update ]);
}
});
}

34
web/js/markers.js Normal file
View file

@ -0,0 +1,34 @@
var dynmapmarkersets = {};
componentconstructors['markers'] = function(dynmap, configuration) {
var me = this;
function loadmarkers(world) {
dynmapmarkersets = {};
$.getJSON(dynmap.options.tileUrl+'_markers_/marker_'+world+'.json', function(data) {
var ts = data.timestamp;
$.each(data.sets, function(name, markerset) {
dynmapmarkersets[name] = markerset;
});
});
}
$(dynmap).bind('component.markers', function(event, msg) {
console.log('got marker event - ' + msg.ctype + ', ' + msg.msg);
});
// Remove marker on start of map change
$(dynmap).bind('mapchanging', function(event) {
});
// Remove marker on map change - let update place it again
$(dynmap).bind('mapchanged', function(event) {
});
// Load markers for new world
$(dynmap).bind('worldchanged', function(event) {
loadmarkers(this.world.name);
});
loadmarkers(dynmap.world.name);
};