-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.as
More file actions
199 lines (180 loc) · 6.26 KB
/
Copy pathMain.as
File metadata and controls
199 lines (180 loc) · 6.26 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
void CopyableItem(const string &in name, const string &in value, bool showValue = true)
{
string itemText = Icons::Clipboard + " " + name;
if (showValue) {
itemText += "\\$999 (" + Text::OpenplanetFormatCodes(value) + ")";
}
if (UI::MenuItem(itemText)) {
IO::SetClipboard(value);
}
}
void CopyableItem(const string &in name, int value, bool showValue = true) { CopyableItem(name, "" + value, showValue); }
void CopyableItem(const string &in name, uint value, bool showValue = true) { CopyableItem(name, "" + value, showValue); }
void CopyableItem(const string &in name, float value, bool showValue = true) { CopyableItem(name, "" + value, showValue); }
enum ListType
{
Simple,
Advanced,
}
string PluginsList(Meta::Plugin@[]@ plugins, ListType listType)
{
string pluginList = "";
for (uint i = 0; i < plugins.Length; i++) {
auto plugin = plugins[i];
if (listType == ListType::Simple) {
pluginList += SimplePluginInfo(plugin);
} else if (listType == ListType::Advanced) {
pluginList += AdvancedPluginInfo(plugin);
}
}
return pluginList;
}
string SimplePluginInfo(Meta::Plugin@ plugin)
{
string enabledText = plugin.Enabled ? "Enabled" : "Disabled";
return plugin.Name + " | " + plugin.Version + " | " + enabledText + "\n";
}
string AdvancedPluginInfo(Meta::Plugin@ plugin)
{
string output = plugin.ID + "\n";
output += " name: " + plugin.Name + "\n";
output += " version: " + plugin.Version + "\n";
output += " type: " + tostring(plugin.Type) + "\n";
output += " author: " + plugin.Author + "\n";
output += " category: " + plugin.Category + "\n";
output += " siteId: " + tostring(plugin.SiteID) + "\n";
output += " isEnabled: " + tostring(plugin.Enabled) + "\n";
return output;
}
void RenderMenu()
{
if (!UI::BeginMenu("\\$9cf" + Icons::InfoCircle + "\\$z Useful information")) {
return;
}
auto app = cast<CTrackMania>(GetApp());
auto network = cast<CTrackManiaNetwork>(app.Network);
auto client = network.Client;
auto plugins = Meta::AllPlugins();
auto serverInfo = cast<CGameCtnNetServerInfo>(network.ServerInfo);
auto userInfo = cast<CTrackManiaPlayerInfo>(network.PlayerInfo);
if (plugins !is null && UI::BeginMenu(Icons::Tasks + " Plugins")) {
if (UI::MenuItem(Icons::Clipboard + " Simple List")) {
IO::SetClipboard(PluginsList(plugins, ListType::Simple));
}
if (UI::MenuItem(Icons::Clipboard + " Advanced List")) {
IO::SetClipboard(PluginsList(plugins, ListType::Advanced));
}
UI::EndMenu();
}
if (userInfo !is null && UI::BeginMenu(Icons::User + " Local user")) {
CopyableItem("Name", userInfo.Name);
CopyableItem("Login", userInfo.Login);
#if TMNEXT
CopyableItem("Webservices ID", userInfo.WebServicesUserId);
#endif
UI::EndMenu();
}
#if TURBO || FOREVER
if (app.Challenge !is null && UI::BeginMenu(Icons::Map + " Current map")) {
auto map = app.Challenge;
#if FOREVER
CopyableItem("Name", map.ChallengeName);
CopyableItem("UID", map.Name);
#else
CopyableItem("Name", map.MapName);
CopyableItem("UID", map.MapInfo.MapUid);
#endif
auto fid = GetFidFromNod(map);
if (fid !is null) {
CopyableItem("Filename", fid.FileName);
}
CopyableItem("Coppers", map.CopperPrice);
UI::Separator();
#if FOREVER
CopyableItem("Author", map.Author);
#else
CopyableItem("Author", map.AuthorNickName);
CopyableItem("Author Login", map.AuthorLogin);
#endif
UI::Separator();
CopyableItem("Author Time", Time::Format(map.ChallengeParameters.AuthorTime));
CopyableItem("Gold Time", Time::Format(map.ChallengeParameters.GoldTime));
CopyableItem("Silver Time", Time::Format(map.ChallengeParameters.SilverTime));
CopyableItem("Bronze Time", Time::Format(map.ChallengeParameters.BronzeTime));
UI::EndMenu();
}
#else
if (app.RootMap !is null && UI::BeginMenu(Icons::Map + " Current map")) {
auto mapInfo = app.RootMap.MapInfo;
CopyableItem("Name", mapInfo.Name);
CopyableItem("UID", mapInfo.MapUid);
CopyableItem("Filename", mapInfo.FileName);
CopyableItem("Coppers", mapInfo.CopperString);
CopyableItem("Type", mapInfo.MapType);
UI::Separator();
CopyableItem("Author", mapInfo.AuthorNickName);
CopyableItem("Author Login", mapInfo.AuthorLogin);
UI::Separator();
CopyableItem("Author Time", Time::Format(mapInfo.TMObjective_AuthorTime));
CopyableItem("Gold Time", Time::Format(mapInfo.TMObjective_GoldTime));
CopyableItem("Silver Time", Time::Format(mapInfo.TMObjective_SilverTime));
CopyableItem("Bronze Time", Time::Format(mapInfo.TMObjective_BronzeTime));
UI::Separator();
CopyableItem("Play URL", Meta::FromUrlProtocol("play/nadeo/" + mapInfo.MapUid));
UI::EndMenu();
}
#endif
#if FOREVER
string serverLogin = serverInfo.ServerHostName;
#else
string serverLogin = serverInfo.ServerLogin;
#endif
if (serverInfo !is null && serverLogin != "" && UI::BeginMenu(Icons::Server + " Current server")) {
CopyableItem("Name", serverInfo.ServerName);
#if FOREVER
CopyableItem("Hostname", serverLogin);
#else
CopyableItem("Login", serverLogin);
CopyableItem("Joinlink", serverInfo.JoinLink);
CopyableItem("Version", serverInfo.ServerVersionBuild);
#endif
if (client.Connections.Length > 0) {
auto connection = client.Connections[0];
if (connection.ClientToServer) {
auto connectionInfo = cast<CNetServerInfo>(connection.Info);
UI::Separator();
CopyableItem("IP", connectionInfo.RemoteIP);
CopyableItem("UDP Port", connectionInfo.RemoteUDPPort);
CopyableItem("TCP Port", connectionInfo.RemoteTCPPort);
}
}
UI::Separator();
if (UI::BeginMenu(Icons::Users + " Players")) {
for (uint i = 0; i < network.PlayerInfos.Length; i++) {
auto playerInfo = cast<CTrackManiaPlayerInfo>(network.PlayerInfos[i]);
if (playerInfo is null || playerInfo is userInfo || playerInfo.Login == serverLogin) {
continue;
}
if (UI::BeginMenu(Icons::User + " " + Text::OpenplanetFormatCodes(playerInfo.Name))) {
CopyableItem("Name", playerInfo.Name);
CopyableItem("Login", playerInfo.Login);
#if TMNEXT
CopyableItem("Webservices ID", playerInfo.WebServicesUserId);
#endif
UI::Separator();
CopyableItem("Language", playerInfo.Language);
#if TMNEXT
CopyableItem("Trigram", playerInfo.Trigram);
if (playerInfo.ClubTag != "") {
CopyableItem("Clubtag", playerInfo.ClubTag);
}
#endif
UI::EndMenu();
}
}
UI::EndMenu();
}
UI::EndMenu();
}
UI::EndMenu();
}