2011-03-31 12:44:42 +02:00
|
|
|
componentconstructors['playermarkers'] = function(dynmap, configuration) {
|
2011-03-31 12:54:32 +02:00
|
|
|
var me = this;
|
|
|
|
$(dynmap).bind('playeradded', function(event, player) {
|
|
|
|
// Create the player-marker.
|
|
|
|
var markerPosition = dynmap.map.getProjection().fromWorldToLatLng(player.location.x, player.location.y, player.location.z);
|
|
|
|
player.marker = new CustomMarker(markerPosition, dynmap.map, function(div) {
|
|
|
|
var playerImage;
|
|
|
|
$(div)
|
|
|
|
.addClass('Marker')
|
|
|
|
.addClass('playerMarker')
|
|
|
|
.append(playerImage = $('<img/>')
|
|
|
|
.attr({ src: 'images/player.png' }))
|
|
|
|
.append($('<span/>')
|
|
|
|
.addClass('playerName')
|
|
|
|
.text(player.name));
|
|
|
|
|
|
|
|
if (configuration.showplayerfaces) {
|
2011-05-21 07:59:08 +02:00
|
|
|
getMinecraftHead(player.account, 32, function(head) {
|
2011-03-31 12:54:32 +02:00
|
|
|
$(head)
|
|
|
|
.addClass('playericon')
|
|
|
|
.prependTo(div);
|
|
|
|
playerImage.remove();
|
2011-03-31 12:44:42 +02:00
|
|
|
});
|
2011-03-31 12:54:32 +02:00
|
|
|
}
|
2011-05-18 16:38:50 +02:00
|
|
|
if (configuration.showplayerhealth) {
|
|
|
|
player.healthBar = $('<div/>')
|
|
|
|
.addClass('playerHealth')
|
|
|
|
.css('width', (player.health/2*9) + 'px')
|
|
|
|
.appendTo(div);
|
|
|
|
}
|
2011-03-31 12:54:32 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
$(dynmap).bind('playerremoved', function(event, player) {
|
|
|
|
// Remove the marker.
|
|
|
|
player.marker.remove();
|
|
|
|
});
|
|
|
|
$(dynmap).bind('playerupdated', function(event, player) {
|
|
|
|
// Update the marker.
|
|
|
|
var markerPosition = dynmap.map.getProjection().fromWorldToLatLng(player.location.x, player.location.y, player.location.z);
|
|
|
|
player.marker.toggle(dynmap.world === player.location.world);
|
|
|
|
player.marker.setPosition(markerPosition);
|
2011-05-18 16:38:50 +02:00
|
|
|
// Update health
|
|
|
|
if (configuration.showplayerhealth)
|
|
|
|
player.healthBar.css('width', (player.health/2*9) + 'px');
|
2011-03-31 12:54:32 +02:00
|
|
|
});
|
2011-03-31 12:44:42 +02:00
|
|
|
};
|