-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.as
149 lines (131 loc) · 4.94 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
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
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);
CopyableItem("Webservices ID", userInfo.WebServicesUserId);
UI::EndMenu();
}
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);
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::EndMenu();
}
if (serverInfo !is null && serverInfo.ServerLogin != "" && UI::BeginMenu(Icons::Server + " Current server")) {
CopyableItem("Name", serverInfo.ServerName);
CopyableItem("Login", serverInfo.ServerLogin);
CopyableItem("Joinlink", serverInfo.JoinLink);
CopyableItem("Version", serverInfo.ServerVersionBuild);
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 == serverInfo.ServerLogin) {
continue;
}
if (UI::BeginMenu(Icons::User + " " + Text::OpenplanetFormatCodes(playerInfo.Name))) {
CopyableItem("Name", playerInfo.Name);
CopyableItem("Login", playerInfo.Login);
CopyableItem("Webservices ID", playerInfo.WebServicesUserId);
UI::Separator();
CopyableItem("Language", playerInfo.Language);
CopyableItem("Trigram", playerInfo.Trigram);
if (playerInfo.ClubTag != "") {
CopyableItem("Clubtag", playerInfo.ClubTag);
}
UI::EndMenu();
}
}
UI::EndMenu();
}
UI::EndMenu();
}
UI::EndMenu();
}