-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cs
112 lines (109 loc) · 1.64 KB
/
main.cs
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
using Godot;
using System;
public partial class main : Control
{
internal int h=0;
internal int m=0;
internal int s=0;
internal double ms=0;
internal string ht="00";
internal string mt="00";
internal string st="00";
internal string mst="00";
internal bool start=false;
public override void _Ready()
{
if (OS.GetLocale() == "zh_TW" || OS.GetLocale() == "zh_HK" || OS.GetLocale() == "zh_MO")
{
TranslationServer.SetLocale("zh_TW");
}
else if (OS.GetLocaleLanguage() == "zh" || OS.GetLocale() == "zh_CN" || OS.GetLocale() == "zh_SG")
{
TranslationServer.SetLocale("zh_CN");
}
else
{
TranslationServer.SetLocale(OS.GetLocale());
}
}
public void _on_start_pause_pressed()
{
if (start)
{
GetNode<Button>("StartPause").Text="locResume";
}
else
{
GetNode<Button>("StartPause").Text="locPause";
}
start=!start;
}
public override void _Process(double delta)
{
if (start)
{
ms+=delta*100;
}
if (GetNode<Button>("Reset").ButtonPressed)
{
GetNode<Button>("StartPause").Text="locStart";
start=false;
h=0;
m=0;
s=0;
ms=0;
ht="00";
mt="00";
st="00";
mst="00";
}
if (ms>=100)
{
ms=0;
s+=1;
}
if (s>=60)
{
s=0;
m+=1;
}
if (m>=60)
{
m=0;
h+=1;
}
if (ms<10)
{
mst="0"+((int)ms).ToString();
}
else
{
mst=((int)ms).ToString();
}
if (s<10)
{
st="0"+s.ToString();
}
else
{
st=s.ToString();
}
if (m<10)
{
mt="0"+m.ToString();
}
else
{
mt=m.ToString();
}
if (h<10)
{
ht="0"+h.ToString();
}
else
{
ht=h.ToString();
}
GetNode<Label>("Time").Text=ht+":"+mt+":"+st+":"+mst;
}
}