mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-25 18:17:37 +01:00
Optionally add player health bars to map markers.
This commit is contained in:
parent
728cd8304a
commit
6bea667659
@ -117,6 +117,7 @@ web:
|
||||
messagettl: 5
|
||||
- type: playermarkers
|
||||
showplayerfaces: true
|
||||
showplayerhealth: true
|
||||
#- type: digitalclock
|
||||
- type: timeofdayclock
|
||||
showdigitalclock: true
|
||||
|
@ -529,6 +529,19 @@
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.dynmap .playerHealth {
|
||||
position: absolute;
|
||||
bottom: 3px;
|
||||
left: 34px;
|
||||
height: 11px;
|
||||
|
||||
background: url(../images/heart.png) rgba(0,0,0,0.6) repeat-x left center;
|
||||
padding: 1px 0;
|
||||
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
|
||||
/*******************
|
||||
* Compass
|
||||
|
BIN
web/images/heart.png
Normal file
BIN
web/images/heart.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 180 B |
@ -452,7 +452,8 @@ DynMap.prototype = {
|
||||
var me = this;
|
||||
var player = me.players[update.name] = {
|
||||
name: update.name,
|
||||
location: new Location(me.worlds[update.world], parseFloat(update.x), parseFloat(update.y), parseFloat(update.z))
|
||||
location: new Location(me.worlds[update.world], parseFloat(update.x), parseFloat(update.y), parseFloat(update.z)),
|
||||
health: update.health
|
||||
};
|
||||
|
||||
$(me).trigger('playeradded', [ player ]);
|
||||
@ -494,6 +495,7 @@ DynMap.prototype = {
|
||||
updatePlayer: function(player, update) {
|
||||
var me = this;
|
||||
var location = player.location = new Location(me.worlds[update.world], parseFloat(update.x), parseFloat(update.y), parseFloat(update.z));
|
||||
player.health = update.health;
|
||||
|
||||
$(me).trigger('playerupdated', [ player ]);
|
||||
|
||||
|
@ -22,6 +22,12 @@ componentconstructors['playermarkers'] = function(dynmap, configuration) {
|
||||
playerImage.remove();
|
||||
});
|
||||
}
|
||||
if (configuration.showplayerhealth) {
|
||||
player.healthBar = $('<div/>')
|
||||
.addClass('playerHealth')
|
||||
.css('width', (player.health/2*9) + 'px')
|
||||
.appendTo(div);
|
||||
}
|
||||
});
|
||||
});
|
||||
$(dynmap).bind('playerremoved', function(event, player) {
|
||||
@ -33,5 +39,8 @@ componentconstructors['playermarkers'] = function(dynmap, configuration) {
|
||||
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);
|
||||
// Update health
|
||||
if (configuration.showplayerhealth)
|
||||
player.healthBar.css('width', (player.health/2*9) + 'px');
|
||||
});
|
||||
};
|
Loading…
Reference in New Issue
Block a user