-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtimer.ts
80 lines (69 loc) · 2.08 KB
/
timer.ts
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { int, xy, xyz, rgb, rgba } from "./util";
class Timer {
static instByTrig: Map<timer, Timer> = new Map<timer, Timer>();
constructor(timer?: timer) {
this.timer = timer == undefined ? CreateTimer() : timer;
Timer.instByTrig.set(this.timer, this);
}
static byTimer(timer: timer): Timer {
if (Timer.instByTrig.has(timer)) {
return Timer.instByTrig.get(timer) as Timer;
}
return new Timer(timer);
}
destroy(): void {
DestroyTimer(this.timer)
}
timer: timer;
static expiredTimer(): Timer {
return Timer.byTimer(GetExpiredTimer());
}
start(timeout: number, periodic: boolean, handlerFunc: () => void): void {
TimerStart(this.timer, timeout, periodic, handlerFunc);
}
elapsed(): number {
return TimerGetElapsed(this.timer);
}
remaining(): number {
return TimerGetRemaining(this.timer);
}
timeout(): number {
return TimerGetTimeout(this.timer);
}
pauseTimer(): void {
PauseTimer(this.timer);
}
resumeTimer(): void {
ResumeTimer(this.timer);
}
}
class TimerDialog {
constructor(t: timer) {
this.dialog = CreateTimerDialog(t);
}
destroyTimerDialog(): void {
DestroyTimerDialog(this.dialog);
}
dialog: timerdialog;
setTitle(title: string): void {
TimerDialogSetTitle(this.dialog, title);
}
setTitleColor(rgba: rgba): void {
TimerDialogSetTitleColor(this.dialog, rgba[0], rgba[1], rgba[2], rgba[3]);
}
setTimeColor(rgba: rgba): void {
TimerDialogSetTimeColor(this.dialog, rgba[0], rgba[1], rgba[2], rgba[3]);
}
setSpeed(speedMultFactor: number): void {
TimerDialogSetSpeed(this.dialog, speedMultFactor);
}
setRealTimeRemaining(timeRemaining: number): void {
TimerDialogSetRealTimeRemaining(this.dialog, timeRemaining);
}
display(display: boolean): void {
TimerDialogDisplay(this.dialog, display);
}
displayed(): boolean {
return IsTimerDialogDisplayed(this.dialog);
}
}