-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.as
More file actions
204 lines (179 loc) · 4.68 KB
/
Copy pathMain.as
File metadata and controls
204 lines (179 loc) · 4.68 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
200
201
202
203
204
[Setting name="Disable edge camera movement"]
bool Setting_DisableEdgeCamera = true;
#if !FOREVER
[Setting name="Show Nadeo developer tools"]
#endif
bool Setting_NadeoDeveloperTools = false;
#if MP4 || TMNEXT
[Setting name="Show offzone button"]
#endif
bool Setting_OffzoneButton = true;
PatternPatch@ g_patchEnableOffzone;
PatternPatch@ g_patchDisableScroll;
#if MP4 || TMNEXT
CControlBase@ g_frameLightTools;
#endif
void RenderMenu()
{
#if MP4 || TMNEXT
if (g_frameLightTools !is null && UI::MenuItem("\\$cf9" + Icons::Sun + "\\$z Show light tools bar", "", g_frameLightTools.IsVisible)) {
g_frameLightTools.IsVisible = !g_frameLightTools.IsVisible;
}
#endif
}
#if FOREVER
CTrackManiaEditorCatalog@ GetEditor()
{
return cast<CTrackManiaEditorCatalog>(cast<CTrackMania>(GetApp()).Editor);
}
#else
CGameCtnEditorFree@ GetEditor()
{
return cast<CGameCtnEditorFree>(GetApp().Editor);
}
#endif
CControlBase@ FindControl(CControlContainer@ container, const string &in id)
{
for (uint i = 0; i < container.Childs.Length; i++) {
auto child = container.Childs[i];
if (child.IdName == id) {
return child;
}
auto childContainer = cast<CControlContainer>(child);
if (childContainer !is null) {
auto ret = FindControl(childContainer, id);
if (ret !is null) {
return ret;
}
}
}
return null;
}
void OnEditorOpened()
{
auto editor = GetEditor();
auto scene = editor.EditorInterface.InterfaceScene;
auto root = cast<CControlContainer>(scene.Mobils[0]);
#if !FOREVER
// Nadeo's developer tools
if (Setting_NadeoDeveloperTools) {
auto frameDeveloperTools = cast<CControlContainer>(FindControl(root, "FrameDeveloperTools"));
if (frameDeveloperTools !is null) {
frameDeveloperTools.Show();
for (uint i = 0; i < frameDeveloperTools.Childs.Length; i++) {
frameDeveloperTools.Childs[i].Show();
}
}
}
#endif
#if MP4 || TMNEXT
// Offzone
if (Setting_OffzoneButton) {
auto frameEditTools = cast<CControlContainer>(FindControl(root, "FrameEditTools"));
if (frameEditTools !is null) {
auto buttonOffZone = FindControl(frameEditTools, "ButtonOffZone");
if (buttonOffZone !is null) {
buttonOffZone.Show();
try {
g_patchEnableOffzone.Apply();
} catch {
warn("Unable to find offzone patch!");
}
}
}
}
#endif
// Editor scrolling
if (g_patchDisableScroll !is null && Setting_DisableEdgeCamera) {
g_patchDisableScroll.Apply();
}
#if MP4 || TMNEXT
// Light tools
@g_frameLightTools = FindControl(root, "FrameLightTools");
#endif
}
void OnEditorClosed()
{
if (g_patchEnableOffzone !is null && g_patchEnableOffzone.IsApplied()) {
g_patchEnableOffzone.Revert();
}
if (g_patchDisableScroll !is null && g_patchDisableScroll.IsApplied()) {
g_patchDisableScroll.Revert();
}
#if MP4 || TMNEXT
@g_frameLightTools = null;
#endif
}
void OnSettingsChanged()
{
if (g_patchDisableScroll !is null) {
if (Setting_DisableEdgeCamera && !g_patchDisableScroll.IsApplied()) {
g_patchDisableScroll.Apply();
} else if (!Setting_DisableEdgeCamera && g_patchDisableScroll.IsApplied()) {
g_patchDisableScroll.Revert();
}
}
}
void OnDestroyed()
{
OnEditorClosed();
}
void Main()
{
#if MP4 || TMNEXT
@g_patchEnableOffzone = PatternPatch(
#if TMNEXT && !LOGS
"0F 84 ?? ?? ?? ?? 4C 8D 45 ?? BA 13",
"90 90 90 90 90 90"
#elif TMNEXT && LOGS
"0F 84 ?? ?? ?? ?? 4C 8D 45 F0 BA ?? ?? ?? ?? 48 8B CF E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 45 85 FF 0F 84 ?? ?? ?? ?? 83 BF ?? ?? ?? ?? ?? 0F 84 ?? ?? ?? ?? 39",
"90 90 90 90 90 90"
#elif MP41
"F6 86 ?? ?? ?? ?? ?? 0F 84 ?? ?? ?? ?? 4C 8D 44 24 70 BA",
"90 90 90 90 90 90 90 90 90 90 90 90 90"
#else
"0F 84 ?? ?? ?? ?? 8D ?? ?? ?? ?? ?? ?? 50 6A 12",
"90 90 90 90 90 90"
#endif
);
#endif
#if FOREVER
@g_patchDisableScroll = PatternPatch(
"83 EC 3C D9 EE",
"C2 0C 00"
);
#endif
bool hadEditor = false;
while (true) {
auto editor = GetEditor();
bool hasEditorNow = editor !is null;
if (!hadEditor && hasEditorNow) {
OnEditorOpened();
} else if (hadEditor && !hasEditorNow) {
OnEditorClosed();
}
hadEditor = hasEditorNow;
#if !FOREVER
if (editor !is null && editor.OrbitalCameraControl !is null) {
if (Setting_DisableEdgeCamera) {
#if TURBO
editor.OrbitalCameraControl.ParamScrollAreaStart = 1.1f;
editor.OrbitalCameraControl.ParamScrollAreaMax = 1.1f;
#else
editor.OrbitalCameraControl.m_ParamScrollAreaStart = 1.1f;
editor.OrbitalCameraControl.m_ParamScrollAreaMax = 1.1f;
#endif
} else {
#if TURBO
editor.OrbitalCameraControl.ParamScrollAreaStart = 0.7f;
editor.OrbitalCameraControl.ParamScrollAreaMax = 0.98f;
#else
editor.OrbitalCameraControl.m_ParamScrollAreaStart = 0.7f;
editor.OrbitalCameraControl.m_ParamScrollAreaMax = 0.98f;
#endif
}
}
#endif
yield();
}
}