-
Notifications
You must be signed in to change notification settings - Fork 5
/
Rendering.as
105 lines (94 loc) · 4.2 KB
/
Rendering.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
void render_stats() {
#if TMNEXT||MP4
auto map_info = GetApp().RootMap.MapInfo;
#elif TURBO
auto map_info = GetApp().Challenge.MapInfo;
#endif
UI::SetNextWindowPos(200, 200, false ? UI::Cond::Always : UI::Cond::FirstUseEver);
int window_flags = UI::WindowFlags::NoTitleBar | UI::WindowFlags::NoCollapse | UI::WindowFlags::AlwaysAutoResize | UI::WindowFlags::NoDocking;
if (!UI::IsOverlayShown()) window_flags |= UI::WindowFlags::NoInputs;
UI::Begin("Grinding Stats", window_flags);
UI::BeginGroup();
if (setting_show_map_name) {
UI::BeginTable("header",1,UI::TableFlags::SizingFixedFit);
UI::TableNextRow();
UI::TableNextColumn();
UI::Text("\\$ddd" + format_string(map_info.Name));
UI::TableNextRow();
UI::TableNextColumn();
UI::Text("\\$888" + format_string(map_info.AuthorNickName));
UI::EndTable();
}
UI::BeginTable("table",2,UI::TableFlags::SizingFixedFit);
if (setting_show_total_time &&
(!data.timer.same ||
(data.timer.same && !setting_show_session_time) ||
(data.timer.same && setting_show_session_time && setting_show_duplicates))) {
UI::TableNextRow();
UI::TableNextColumn();
UI::Text("\\$ddd" + (data.timer.isRunning() ? Icons::ClockO : Icons::PauseCircleO) + " Total Time");
UI::TableNextColumn();
UI::Text("\\$bbb" + Timer::to_string(data.timer.total));
}
if (setting_show_session_time) {
UI::TableNextRow();
UI::TableNextColumn();
UI::Text("\\$ddd" + (data.timer.isRunning() ? Icons::PlayCircleO : Icons::PauseCircleO) + " Session Time");
UI::TableNextColumn();
UI::Text("\\$bbb" + Timer::to_string(data.timer.session));
}
if (setting_show_finishes_session || setting_show_finishes_total) {
UI::TableNextRow();
UI::TableNextColumn();
UI::Text("\\$ddd" + Icons::Flag + " Finishes");
UI::TableNextColumn();
UI::Text("\\$bbb" + data.finishes.toString());
}
if (setting_show_resets_session || setting_show_resets_total) {
UI::TableNextRow();
UI::TableNextColumn();
UI::Text("\\$ddd" + Icons::Repeat + " Resets");
UI::TableNextColumn();
UI::Text(data.resets.toString());
}
#if TMNEXT
if (setting_show_respawns_current || setting_show_respawns_total || setting_show_respawns_session) {
UI::TableNextRow();
UI::TableNextColumn();
UI::Text("\\$ddd" + Icons::Refresh + " Respawns");
UI::TableNextColumn();
UI::Text(data.respawns.toString());
}
#endif
UI::EndTable();
UI::EndGroup();
UI::End();
}
enum RenderMode {
Normal,
Interface
}
void Render() {
if (can_render(RenderMode::Normal)) render_stats();
}
void RenderInterface() {
if (setting_recap_show_menu) RenderRecap();
if (can_render(RenderMode::Interface)) render_stats();
}
bool can_render(RenderMode rendermode) {
if (rendermode == RenderMode::Normal && (!setting_enabled || setting_display == displays::Only_when_Openplanet_menu_is_open)) return false;
if (rendermode == RenderMode::Interface && (!setting_enabled || setting_display != displays::Only_when_Openplanet_menu_is_open)) return false;
auto app = cast<CTrackMania>(GetApp());
#if TMNEXT||MP4
auto map = app.RootMap;
#elif TURBO
auto map = app.Challenge;
#endif
if (map is null || map.MapInfo.MapUid == "" || app.Editor !is null) return false;
if (app.CurrentPlayground is null || app.CurrentPlayground.Interface is null ||
(setting_display == displays::Always_except_when_interface_is_hidden && !UI::IsGameUIVisible())) return false;
return true;
}
string format_string(const string &in str) {
return setting_show_map_name_color ? ColoredString(str) : StripFormatCodes(str);
}