Add support in web UI for automatic day/night cycle when night-and-day

set for a given map.
This commit is contained in:
Mike Primm 2011-05-29 17:24:46 -05:00
parent 544283a650
commit c00bd077cb
8 changed files with 64 additions and 6 deletions

View file

@ -25,8 +25,11 @@ FlatMapType.prototype = $.extend(new DynMapType(), {
var imgSize;
var tileName;
tileName = this.prefix + '_128_' + coord.x + '_' + coord.y + '.png';
var dnprefix = '';
if(this.dynmap.map.mapTypes[this.dynmap.map.mapTypeId].nightandday && this.dynmap.serverday)
dnprefix = '_day';
tileName = this.prefix + dnprefix + '_128_' + coord.x + '_' + coord.y + '.png';
imgSize = Math.pow(2, 7+zoom);
var tile = $('<div/>')
.addClass('tile')

View file

@ -42,18 +42,22 @@ KzedMapType.prototype = $.extend(new DynMapType(), {
var debugred;
var debugblue;
var dnprefix = '';
if(this.dynmap.map.mapTypes[this.dynmap.map.mapTypeId].nightandday && this.dynmap.serverday)
dnprefix = '_day';
if (zoom == 0) {
// Most zoomed out tiles.
tileSize = 128;
imgSize = tileSize;
tileName = 'z' + this.prefix + '_' + (-coord.x * tileSize*2) + '_' + (coord.y * tileSize*2) + '.png';
tileName = 'z' + this.prefix + dnprefix + '_' + (-coord.x * tileSize*2) + '_' + (coord.y * tileSize*2) + '.png';
} else {
// Other zoom levels.
tileSize = 128;
imgSize = Math.pow(2, 6+zoom);
tileName = this.prefix + '_' + (-coord.x*tileSize) + '_' + (coord.y*tileSize) + '.png';
tileName = this.prefix + dnprefix + '_' + (-coord.x*tileSize) + '_' + (coord.y*tileSize) + '.png';
}
var img;
var tile = $('<div/>')

View file

@ -91,6 +91,8 @@ DynMap.prototype = {
registeredTiles: [],
players: {},
lasttimestamp: '0',
servertime: 0,
serverday: false,
followingPlayer: '',
formatUrl: function(name, options) {
var url = this.options.url[name];
@ -369,7 +371,23 @@ DynMap.prototype = {
if (!me.options.jsonfile) {
me.lasttimestamp = update.timestamp;
}
me.servertime = update.servertime;
var oldday = me.serverday;
if(me.servertime > 23100 || me.servertime < 12900)
me.serverday = true;
else
me.serverday = false;
if(me.serverday != oldday) {
var mtid = me.map.mapTypeId;
if(me.map.mapTypes[mtid].nightandday) {
me.map.setMapTypeId('none');
window.setTimeout(function() {
me.map.setMapTypeId(mtid);
}, 1);
}
}
var newplayers = {};
$.each(update.players, function(index, playerUpdate) {
var name = playerUpdate.name;