-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.as
More file actions
135 lines (111 loc) · 2.93 KB
/
Copy pathMain.as
File metadata and controls
135 lines (111 loc) · 2.93 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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));
#if TMNEXT
UI::Separator();
RenderStat(Icons::ClockO, "Skin editor time", Time::Format(g_stats.SkinEditorTime * 1000, false));
#endif
UI::Separator();
RenderStat(Icons::ClockO, "Mediatracker time", Time::Format(g_stats.MediaTrackerTime * 1000, false));
UI::Columns(1);
UI::EndMenu();
}
}
void OnDestroyed()
{
g_stats.Save();
}
bool InMap()
{
#if MP41 || TMNEXT
return GetApp().RootMap !is null;
#else
return GetApp().Challenge !is null;
#endif
}
bool InMapEditor()
{
#if FOREVER
auto app = cast<CTrackMania>(GetApp());
return cast<CTrackManiaEditorCatalog>(app.Editor) !is null;
#else
return cast<CGameCtnEditorFree>(GetApp().Editor) !is null;
#endif
}
bool InMediaTracker()
{
#if !TMNEXT
auto app = cast<CTrackMania>(GetApp());
return cast<CGameCtnMediaTracker>(app.Editor) !is null;
#else
return cast<CGameEditorMediaTracker>(GetApp().Editor) !is null;
#endif
}
bool InServer()
{
auto serverInfo = cast<CGameCtnNetServerInfo>(GetApp().Network.ServerInfo);
#if FOREVER
return serverInfo !is null && serverInfo.ServerHostName != "";
#else
return serverInfo !is null && serverInfo.ServerLogin != "";
#endif
}
void Main()
{
auto app = cast<CTrackMania>(GetApp());
@g_fontBold = UI::LoadFont("DroidSans-Bold.ttf");
g_stats.Load();
int saveTimer = 0;
while (true) {
g_stats.TotalTime++;
if (InServer()) {
g_stats.OnlineTime++;
} else if (InMap() && !InMapEditor()) {
g_stats.SoloTime++;
}
if (app.Editor !is null) {
if (InMapEditor()) {
g_stats.MapEditorTime++;
if (app.CurrentPlayground !is null
#if !FOREVER
&& app.CurrentPlayground.GameTerminals.Length > 0
#endif
) {
g_stats.MapEditorTestTime++;
}
#if TMNEXT
} else if (cast<CGameEditorSkin>(app.Editor) !is null) {
g_stats.SkinEditorTime++;
#endif
} else if (InMediaTracker()) {
g_stats.MediaTrackerTime++;
}
}
saveTimer++;
if (saveTimer >= 60) {
g_stats.Save();
saveTimer = 0;
}
sleep(1000);
}
}