-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.as
87 lines (69 loc) · 2.21 KB
/
Main.as
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
Statistics g_stats;
UI::Font@ g_fontBold;
void RenderStat(const string &in icon, const string &in name, const string &in value)
{
UI::Text(icon + " " + name); UI::NextColumn();
UI::Text(value); UI::NextColumn();
}
void RenderMenu()
{
UI::SetNextWindowContentSize(300, 0);
if (UI::BeginMenu("\\$9cf" + Icons::LineChart + "\\$z Statistics")) {
UI::Columns(2, "statistics");
UI::PushFont(g_fontBold);
UI::Text("Statistic"); UI::NextColumn();
UI::Text("Value"); UI::NextColumn();
UI::PopFont();
UI::Separator();
RenderStat(Icons::ClockO, "Total time", Time::Format(g_stats.TotalTime * 1000, false));
RenderStat(Icons::ClockO, "Solo time", Time::Format(g_stats.SoloTime * 1000, false));
RenderStat(Icons::ClockO, "Online time", Time::Format(g_stats.OnlineTime * 1000, false));
UI::Separator();
RenderStat(Icons::ClockO, "Map editor time", Time::Format(g_stats.MapEditorTime * 1000, false));
RenderStat(Icons::ClockO, "Map editor test time", Time::Format(g_stats.MapEditorTestTime * 1000, false));
UI::Separator();
RenderStat(Icons::ClockO, "Skin editor time", Time::Format(g_stats.SkinEditorTime * 1000, false));
UI::Separator();
RenderStat(Icons::ClockO, "Mediatracker time", Time::Format(g_stats.MediaTrackerTime * 1000, false));
UI::Columns(1);
UI::EndMenu();
}
}
void OnDestroyed()
{
g_stats.Save();
}
void Main()
{
auto app = GetApp();
@g_fontBold = UI::LoadFont("DroidSans-Bold.ttf");
g_stats.Load();
int saveTimer = 0;
while (true) {
g_stats.TotalTime++;
auto serverInfo = cast<CGameCtnNetServerInfo>(app.Network.ServerInfo);
if (serverInfo !is null && serverInfo.ServerLogin != "") {
g_stats.OnlineTime++;
} else if (app.RootMap !is null && app.Editor is null) {
g_stats.SoloTime++;
}
if (app.Editor !is null) {
if (cast<CGameCtnEditorFree>(app.Editor) !is null) {
g_stats.MapEditorTime++;
if (app.CurrentPlayground !is null) {
g_stats.MapEditorTestTime++;
}
} else if (cast<CGameEditorSkin>(app.Editor) !is null) {
g_stats.SkinEditorTime++;
} else if (cast<CGameEditorMediaTracker>(app.Editor) !is null) {
g_stats.MediaTrackerTime++;
}
}
saveTimer++;
if (saveTimer >= 60) {
g_stats.Save();
saveTimer = 0;
}
sleep(1000);
}
}