aboutsummaryrefslogtreecommitdiff
path: root/render/timerGui.js
blob: a46451ffb6f5e23ae6651ea8ba15bf1642bd106f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import settings from "../settings";
import constants from "../util/constants";


const timerMove = new Gui(),
 timerGui = new Display()

timerGui.setBackgroundColor(Renderer.color(0, 0, 0, 50));
timerGui.setBackground("full");

export function openTimerGui()
{
    timerMove.open()
}

register("dragged", (dx, dy, x, y) => {
    if (!timerMove.isOpen()) return
    constants.timerdata.x = x
    constants.timerdata.y = y
    constants.timerdata.save()
});

register("renderOverlay", () => {
    timerGui.setShouldRender(false)
    timerGui.clearLines()
    timerGui.setRenderLoc(constants.timerdata.x, constants.timerdata.y)
    
    if (timerMove.isOpen())
    {
        let txt = "Click anywhere to move!"
        Renderer.drawStringWithShadow(txt, Renderer.screen.getWidth()/2 - Renderer.getStringWidth(txt)/2, Renderer.screen.getHeight()/2)
        timerGui.addLines([`&aTimer: &b0h 0m`])
        timerGui.setShouldRender(true)
        return
    }

    if(!settings.timerVisible) return
    timerGui.setShouldRender(true)
    let timerHr = Math.floor(constants.timerdata.timer/60/60)
    

    if(timerHr >= 1)
        timerGui.addLine(`&aTimer: &b${timerHr}h ${Math.floor(constants.timerdata.timer/60) - timerHr*60}m`)
    else
        timerGui.addLine(`&aTimer: &b${Math.floor(constants.timerdata.timer/60)}m ${Math.floor(constants.timerdata.timer%60)}s`)
})

register('worldLoad', () => {
    constants.timerdata.timer = 0
})

register("step", () => {
    constants.timerdata.timer += 1
}).setFps(1)