mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-27 20:58:40 +01:00
Dynamic Time of the day Added
This commit is contained in:
parent
60ea503053
commit
51e7420bdb
BIN
web/compass.png
Normal file
BIN
web/compass.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.3 KiB |
72
web/map.js
72
web/map.js
@ -72,24 +72,57 @@ MinecraftClock.prototype = {
|
|||||||
function MinecraftTimeOfDay(element) { this.element = element; }
|
function MinecraftTimeOfDay(element) { this.element = element; }
|
||||||
MinecraftTimeOfDay.prototype = {
|
MinecraftTimeOfDay.prototype = {
|
||||||
element: null,
|
element: null,
|
||||||
|
elementsun: null,
|
||||||
|
elementmoon: null,
|
||||||
create: function(element) {
|
create: function(element) {
|
||||||
if (!element) element = $('<div/>');
|
if (!element) element = $('<div/>');
|
||||||
this.element = element;
|
this.element = element;
|
||||||
return element;
|
return element;
|
||||||
},
|
},
|
||||||
|
initialize: function(elementsun, elementmoon) {
|
||||||
|
if (!elementsun) elementsun = $('<div/>');
|
||||||
|
this.elementsun = elementsun;
|
||||||
|
this.elementsun.appendTo(this.element);
|
||||||
|
if (!elementmoon) elementmoon = $('<div/>');
|
||||||
|
this.elementmoon = elementmoon;
|
||||||
|
this.elementmoon.appendTo(this.elementsun);
|
||||||
|
this.element.height(60);
|
||||||
|
this.element.addClass('timeofday');
|
||||||
|
this.elementsun.height(60);
|
||||||
|
this.elementsun.addClass('timeofday');
|
||||||
|
this.elementsun.addClass('sun');
|
||||||
|
this.elementmoon.height(60);
|
||||||
|
this.elementmoon.addClass('timeofday');
|
||||||
|
this.elementmoon.addClass('moon');
|
||||||
|
this.elementmoon.html(" ‏ ");
|
||||||
|
this.elementsun.css("background-position", (-120) + "px " + (-120) + "px");
|
||||||
|
this.elementmoon.css("background-position", (-120) + "px " + (-120) + "px");
|
||||||
|
},
|
||||||
setTime: function(time) {
|
setTime: function(time) {
|
||||||
this.element
|
var sunangle;
|
||||||
.removeClass('time1')
|
|
||||||
.removeClass('time2')
|
if(time > 23100 || time < 12900)
|
||||||
.removeClass('time3')
|
{
|
||||||
.removeClass('time4')
|
//day mode
|
||||||
.removeClass('time5')
|
var movedtime = time + 900;
|
||||||
.removeClass('time6')
|
movedtime = (movedtime >= 24000) ? movedtime - 24000 : movedtime;
|
||||||
.removeClass('time7')
|
//Now we have 0 -> 13800 for the day period
|
||||||
.removeClass('time8')
|
//Devide by 13800*2=27600 instead of 24000 to compress day
|
||||||
.addClass('time' + time.day)
|
sunangle = ((movedtime)/27600 * 2 * Math.PI);
|
||||||
.html(" ‏ ")
|
}
|
||||||
.height(60);
|
else
|
||||||
|
{
|
||||||
|
//night mode
|
||||||
|
var movedtime = time - 12900;
|
||||||
|
//Now we have 0 -> 10200 for the night period
|
||||||
|
//Devide by 10200*2=20400 instead of 24000 to expand night
|
||||||
|
sunangle = Math.PI + ((movedtime)/20400 * 2 * Math.PI);
|
||||||
|
}
|
||||||
|
|
||||||
|
var moonangle = sunangle + Math.PI;
|
||||||
|
|
||||||
|
this.elementsun.css("background-position", (-50 * Math.cos(sunangle)) + "px " + (-50 * Math.sin(sunangle)) + "px");
|
||||||
|
this.elementmoon.css("background-position", (-50 * Math.cos(moonangle)) + "px " + (-50 * Math.sin(moonangle)) + "px");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -117,7 +150,6 @@ function DynMap(options) {
|
|||||||
}
|
}
|
||||||
DynMap.prototype = {
|
DynMap.prototype = {
|
||||||
registeredTiles: new Array(),
|
registeredTiles: new Array(),
|
||||||
clock: null,
|
|
||||||
markers: new Array(),
|
markers: new Array(),
|
||||||
chatPopups: new Array(),
|
chatPopups: new Array(),
|
||||||
lasttimestamp: '0',
|
lasttimestamp: '0',
|
||||||
@ -248,19 +280,12 @@ DynMap.prototype = {
|
|||||||
.addClass('playerlist')
|
.addClass('playerlist')
|
||||||
.appendTo(sidebar);
|
.appendTo(sidebar);
|
||||||
|
|
||||||
// The Clock
|
|
||||||
var clock = me.clock = new MinecraftClock(
|
|
||||||
$('<div/>')
|
|
||||||
.addClass('clock')
|
|
||||||
.appendTo(sidebar)
|
|
||||||
);
|
|
||||||
|
|
||||||
// The TimeOfDay
|
// The TimeOfDay
|
||||||
var timeofday = me.timeofday = new MinecraftTimeOfDay(
|
var timeofday = me.timeofday = new MinecraftTimeOfDay(
|
||||||
$('<div/>')
|
$('<div/>')
|
||||||
.addClass('timeofday')
|
.appendTo(sidebar)
|
||||||
.appendTo(sidebar)
|
|
||||||
);
|
);
|
||||||
|
timeofday.initialize();
|
||||||
|
|
||||||
// The Compass
|
// The Compass
|
||||||
var compass = me.compass = new MinecraftCompass(
|
var compass = me.compass = new MinecraftCompass(
|
||||||
@ -295,8 +320,7 @@ DynMap.prototype = {
|
|||||||
me.alertbox.hide();
|
me.alertbox.hide();
|
||||||
|
|
||||||
me.lasttimestamp = update.timestamp;
|
me.lasttimestamp = update.timestamp;
|
||||||
me.clock.setTime(getMinecraftTime(update.servertime));
|
me.timeofday.setTime(update.servertime);
|
||||||
me.timeofday.setTime(me.clock.time);
|
|
||||||
|
|
||||||
var typeVisibleMap = {};
|
var typeVisibleMap = {};
|
||||||
var newmarkers = {};
|
var newmarkers = {};
|
||||||
|
@ -77,40 +77,3 @@ function getMinecraftHead(player,size,completed) {
|
|||||||
completed(resizeImage(head,size));
|
completed(resizeImage(head,size));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMinecraftTime(servertime) {
|
|
||||||
servertime = parseInt(servertime);
|
|
||||||
var hours = (parseInt(servertime / 1000)+8) % 24;
|
|
||||||
var minutes = parseInt(((servertime / 1000) % 1) * 60);
|
|
||||||
var seconds = parseInt(((((servertime / 1000) % 1) * 60) % 1) * 60);
|
|
||||||
|
|
||||||
var daytime = 0;
|
|
||||||
if(hours >= 6 && hours <= 7)
|
|
||||||
daytime = 1;
|
|
||||||
if(hours >= 8 && hours <= 9)
|
|
||||||
daytime = 2;
|
|
||||||
if(hours >= 10 && hours <= 17)
|
|
||||||
daytime = 3;
|
|
||||||
if(hours >= 18 && hours <= 19)
|
|
||||||
daytime = 4;
|
|
||||||
if(hours >= 20 && hours <= 21)
|
|
||||||
daytime = 5;
|
|
||||||
if(hours >= 22 && hours <= 23)
|
|
||||||
daytime = 6;
|
|
||||||
if(hours >= 0 && hours <= 3)
|
|
||||||
daytime = 7;
|
|
||||||
if(hours >= 4 && hours <= 5)
|
|
||||||
daytime = 8;
|
|
||||||
|
|
||||||
return {
|
|
||||||
servertime: servertime,
|
|
||||||
days: parseInt((servertime+8000) / 24000),
|
|
||||||
|
|
||||||
// Assuming it is day at 8:00
|
|
||||||
hours: hours,
|
|
||||||
minutes: minutes,
|
|
||||||
seconds: seconds,
|
|
||||||
|
|
||||||
day: daytime,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
BIN
web/moon.png
Normal file
BIN
web/moon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
@ -82,15 +82,12 @@ a, a:visited, label {
|
|||||||
background-image: url(compass.png);
|
background-image: url(compass.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
.timeofday { background-repeat: no-repeat; }
|
.timeofday {
|
||||||
.timeofday.time1 { background-image: url(time1.png); }
|
background-repeat: no-repeat;
|
||||||
.timeofday.time2 { background-image: url(time2.png); }
|
}
|
||||||
.timeofday.time3 { background-image: url(time3.png); }
|
|
||||||
.timeofday.time4 { background-image: url(time4.png); }
|
.timeofday.sun { background-image: url(sun.png); }
|
||||||
.timeofday.time5 { background-image: url(time5.png); }
|
.timeofday.moon { background-image: url(moon.png); }
|
||||||
.timeofday.time6 { background-image: url(time6.png); }
|
|
||||||
.timeofday.time7 { background-image: url(time7.png); }
|
|
||||||
.timeofday.time8 { background-image: url(time8.png); }
|
|
||||||
|
|
||||||
.alertbox {
|
.alertbox {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
|
BIN
web/sun.png
Normal file
BIN
web/sun.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
Loading…
Reference in New Issue
Block a user