forked from astra1dev/MalumMenu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuUI.cs
More file actions
639 lines (548 loc) · 30.2 KB
/
Copy pathMenuUI.cs
File metadata and controls
639 lines (548 loc) · 30.2 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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
using System;
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
using HarmonyLib;
namespace MalumMenu;
public class MenuUI : MonoBehaviour
{
public List<GroupInfo> groups = [];
private bool isDragging = false;
private Rect windowRect = new(10, 10, 300, 500);
private Rect horizontalWindowRect = new(10, 10, 700, 550);
private bool isGUIActive = false;
public static bool isPanicked = false;
public int selectedTab;
// Styles
private GUIStyle submenuButtonStyle;
private GUIStyle tabButtonStyle;
public GUIStyle tabTitleStyle;
public GUIStyle tabSubtitleStyle;
private float hue; // For RGB mode
// Create all groups (buttons) and their toggles on start
private void Start()
{
groups.Add(new GroupInfo("Player", false, [
new ToggleInfo(" NoClip", () => CheatToggles.noClip, x => CheatToggles.noClip = x),
new ToggleInfo(" Fake Revive", () => CheatToggles.revive, x => CheatToggles.revive = x),
new ToggleInfo(" Invert Controls", () => CheatToggles.invertControls, x => CheatToggles.invertControls = x)
], [
new SubmenuInfo("Teleport", false, [
new ToggleInfo(" to Cursor", () => CheatToggles.teleportCursor, x => CheatToggles.teleportCursor = x),
new ToggleInfo(" to Player", () => CheatToggles.teleportPlayer, x => CheatToggles.teleportPlayer = x)
])
]));
groups.Add(new GroupInfo("ESP", false, [
new ToggleInfo(" Show Player Info", () => CheatToggles.showPlayerInfo, x => CheatToggles.showPlayerInfo = x),
new ToggleInfo(" See Roles", () => CheatToggles.seeRoles, x => CheatToggles.seeRoles = x),
new ToggleInfo(" See Ghosts", () => CheatToggles.seeGhosts, x => CheatToggles.seeGhosts = x),
new ToggleInfo(" No Shadows", () => CheatToggles.fullBright, x => CheatToggles.fullBright = x),
new ToggleInfo(" Show Task Arrows", () => CheatToggles.showTaskArrows, x => CheatToggles.showTaskArrows = x),
new ToggleInfo(" Reveal Votes", () => CheatToggles.revealVotes, x => CheatToggles.revealVotes = x),
new ToggleInfo(" More Lobby Info", () => CheatToggles.moreLobbyInfo, x => CheatToggles.moreLobbyInfo = x)
], [
new SubmenuInfo("Camera", false, [
new ToggleInfo(" Zoom Out", () => CheatToggles.zoomOut, x => CheatToggles.zoomOut = x),
new ToggleInfo(" Spectate", () => CheatToggles.spectate, x => CheatToggles.spectate = x),
new ToggleInfo(" Freecam", () => CheatToggles.freecam, x => CheatToggles.freecam = x)
]),
new SubmenuInfo("Tracers", false, [
new ToggleInfo(" Crewmates", () => CheatToggles.tracersCrew, x => CheatToggles.tracersCrew = x),
new ToggleInfo(" Impostors", () => CheatToggles.tracersImps, x => CheatToggles.tracersImps = x),
new ToggleInfo(" Ghosts", () => CheatToggles.tracersGhosts, x => CheatToggles.tracersGhosts = x),
new ToggleInfo(" Dead Bodies", () => CheatToggles.tracersBodies, x => CheatToggles.tracersBodies = x),
new ToggleInfo(" Color-based", () => CheatToggles.colorBasedTracers, x => CheatToggles.colorBasedTracers = x),
new ToggleInfo(" Distance-based", () => CheatToggles.distanceBasedTracers, x => CheatToggles.distanceBasedTracers = x)
]),
new SubmenuInfo("Minimap", false, [
new ToggleInfo(" Crewmates", () => CheatToggles.mapCrew, x => CheatToggles.mapCrew = x),
new ToggleInfo(" Impostors", () => CheatToggles.mapImps, x => CheatToggles.mapImps = x),
new ToggleInfo(" Ghosts", () => CheatToggles.mapGhosts, x => CheatToggles.mapGhosts = x),
new ToggleInfo(" Color-based", () => CheatToggles.colorBasedMap, x => CheatToggles.colorBasedMap = x)
])
]));
groups.Add(new GroupInfo("Roles", false, [
new ToggleInfo(" Set Fake Role", () => CheatToggles.changeRole, x => CheatToggles.changeRole = x)
],
[
new SubmenuInfo("Impostor", false, [
new ToggleInfo(" Kill Reach", () => CheatToggles.killReach, x => CheatToggles.killReach = x),
new ToggleInfo(" Do Tasks", () => CheatToggles.impostorTasks, x => CheatToggles.impostorTasks = x)
]),
new SubmenuInfo("Shapeshifter", false, [
new ToggleInfo(" No Ss Animation", () => CheatToggles.noShapeshiftAnim, x => CheatToggles.noShapeshiftAnim = x),
new ToggleInfo(" Endless Ss Duration", () => CheatToggles.endlessSsDuration, x => CheatToggles.endlessSsDuration = x)
]),
new SubmenuInfo("Crewmate", false, [
new ToggleInfo(" Show Tasks Menu", () => CheatToggles.showTasksMenu, x => CheatToggles.showTasksMenu = x)
]),
new SubmenuInfo("Tracker", false, [
new ToggleInfo(" Endless Tracking", () => CheatToggles.endlessTracking, x => CheatToggles.endlessTracking = x),
new ToggleInfo(" No Track Delay", () => CheatToggles.noTrackingDelay, x => CheatToggles.noTrackingDelay = x),
new ToggleInfo(" No Track Cooldown", () => CheatToggles.noTrackingCooldown, x => CheatToggles.noTrackingCooldown = x),
new ToggleInfo(" Track Reach", () => CheatToggles.trackReach, x => CheatToggles.trackReach = x)
]),
new SubmenuInfo("Engineer", false, [
new ToggleInfo(" Endless Vent Time", () => CheatToggles.endlessVentTime, x => CheatToggles.endlessVentTime = x),
new ToggleInfo(" No Vent Cooldown", () => CheatToggles.noVentCooldown, x => CheatToggles.noVentCooldown = x)
]),
new SubmenuInfo("Scientist", false, [
new ToggleInfo(" Endless Battery", () => CheatToggles.endlessBattery, x => CheatToggles.endlessBattery = x),
new ToggleInfo(" No Vitals Cooldown", () => CheatToggles.noVitalsCooldown, x => CheatToggles.noVitalsCooldown = x)
]),
new SubmenuInfo("Detective", false, [
new ToggleInfo(" Interrogate Reach", () => CheatToggles.interrogateReach, x => CheatToggles.interrogateReach = x)
])
]));
groups.Add(new GroupInfo("Ship", false, [
new ToggleInfo(" Unfixable Lights", () => CheatToggles.unfixableLights, x => CheatToggles.unfixableLights = x),
new ToggleInfo(" Report Body", () => CheatToggles.reportBody, x => CheatToggles.reportBody = x),
new ToggleInfo(" Call Meeting", () => CheatToggles.callMeeting, x => CheatToggles.callMeeting = x),
new ToggleInfo(" Close Meeting", () => CheatToggles.closeMeeting, x => CheatToggles.closeMeeting = x),
new ToggleInfo(" Auto-Open Doors On Use", () => CheatToggles.autoOpenDoorsOnUse, x => CheatToggles.autoOpenDoorsOnUse = x)
], [
new SubmenuInfo("Sabotage", false, [
new ToggleInfo(" Reactor", () => CheatToggles.reactorSab, x => CheatToggles.reactorSab = x),
new ToggleInfo(" Oxygen", () => CheatToggles.oxygenSab, x => CheatToggles.oxygenSab = x),
new ToggleInfo(" Lights", () => CheatToggles.elecSab, x => CheatToggles.elecSab = x),
new ToggleInfo(" Comms", () => CheatToggles.commsSab, x => CheatToggles.commsSab = x),
new ToggleInfo(" Show Doors Menu", () => CheatToggles.showDoorsMenu, x => CheatToggles.showDoorsMenu = x),
new ToggleInfo(" MushroomMixup", () => CheatToggles.mushSab, x => CheatToggles.mushSab = x),
new ToggleInfo(" Trigger Spores", () => CheatToggles.mushSpore, x => CheatToggles.mushSpore = x),
new ToggleInfo(" Open Sabotage Map", () => CheatToggles.sabotageMap, x => CheatToggles.sabotageMap = x)
]),
new SubmenuInfo("Vents", false, [
new ToggleInfo(" Unlock Vents", () => CheatToggles.useVents, x => CheatToggles.useVents = x),
new ToggleInfo(" Kick All From Vents", () => CheatToggles.kickVents, x => CheatToggles.kickVents = x),
new ToggleInfo(" Walk In Vents", () => CheatToggles.walkVent, x => CheatToggles.walkVent = x)
])
]));
groups.Add(new GroupInfo("Chat", false, [
new ToggleInfo(" Enable Chat", () => CheatToggles.alwaysChat, x => CheatToggles.alwaysChat = x),
new ToggleInfo(" Unlock Textbox", () => CheatToggles.chatJailbreak, x => CheatToggles.chatJailbreak = x)
], []));
groups.Add(new GroupInfo("Console", false, [
new ToggleInfo(" Show Console", () => CheatToggles.showConsole, x => CheatToggles.showConsole = x),
new ToggleInfo(" Log Deaths", () => CheatToggles.logDeaths, x => CheatToggles.logDeaths = x),
new ToggleInfo(" Log Shapeshifts", () => CheatToggles.logShapeshifts, x => CheatToggles.logShapeshifts = x),
new ToggleInfo(" Log Vents", () => CheatToggles.logVents, x => CheatToggles.logVents = x),
], []));
groups.Add(new GroupInfo("Host-Only", false,
[
new ToggleInfo(" Kill While Vanished", () => CheatToggles.killVanished, x => CheatToggles.killVanished = x),
new ToggleInfo(" Kill Anyone", () => CheatToggles.killAnyone, x => CheatToggles.killAnyone = x),
new ToggleInfo(" No Kill Cooldown", () => CheatToggles.zeroKillCd, x => CheatToggles.zeroKillCd = x),
new ToggleInfo(" Show Protect Menu", () => CheatToggles.showProtectMenu, x => CheatToggles.showProtectMenu = x),
new ToggleInfo(" Force Role", () => CheatToggles.showRolesMenu, x => CheatToggles.showRolesMenu = x),
new ToggleInfo(" No Options Limits", () => CheatToggles.noOptionsLimits, x => CheatToggles.noOptionsLimits = x)
],
[
new SubmenuInfo("Murder", false, [
new ToggleInfo(" Kill Player", () => CheatToggles.killPlayer, x => CheatToggles.killPlayer = x),
new ToggleInfo(" Telekill Player", () => CheatToggles.telekillPlayer, x => CheatToggles.telekillPlayer = x),
new ToggleInfo(" Kill All Crewmates", () => CheatToggles.killAllCrew, x => CheatToggles.killAllCrew = x),
new ToggleInfo(" Kill All Impostors", () => CheatToggles.killAllImps, x => CheatToggles.killAllImps = x),
new ToggleInfo(" Kill Everyone", () => CheatToggles.killAll, x => CheatToggles.killAll = x)
]),
new SubmenuInfo("Game State", false, [
new ToggleInfo(" Force Start Game", () => CheatToggles.forceStartGame, x => CheatToggles.forceStartGame = x),
new ToggleInfo(" No Game End", () => CheatToggles.noGameEnd, x => CheatToggles.noGameEnd = x)
]),
new SubmenuInfo("Meetings", false, [
new ToggleInfo(" Skip Meeting", () => CheatToggles.skipMeeting, x => CheatToggles.skipMeeting = x),
new ToggleInfo(" VoteImmune", () => CheatToggles.voteImmune, x => CheatToggles.voteImmune = x),
new ToggleInfo(" Eject Player", () => CheatToggles.ejectPlayer, x => CheatToggles.ejectPlayer = x),
])
]));
groups.Add(new GroupInfo("Passive", false, [
new ToggleInfo(" Free Cosmetics", () => CheatToggles.freeCosmetics, x => CheatToggles.freeCosmetics = x),
new ToggleInfo(" Avoid Penalties", () => CheatToggles.avoidBans, x => CheatToggles.avoidBans = x),
new ToggleInfo(" Copy Lobby Code on Disconnect", () => CheatToggles.copyLobbyCodeOnDisconnect, x => CheatToggles.copyLobbyCodeOnDisconnect = x),
new ToggleInfo(" Unlock Extra Features", () => CheatToggles.unlockFeatures, x => CheatToggles.unlockFeatures = x),
new ToggleInfo(" Spoof Date to April 1st", () => CheatToggles.spoofAprilFoolsDate, x => CheatToggles.spoofAprilFoolsDate = x),
new ToggleInfo(" Stealth Mode", () => CheatToggles.stealthMode, x => CheatToggles.stealthMode = x),
new ToggleInfo(" Panic (Disable MalumMenu)", () => CheatToggles.panic, x => CheatToggles.panic = x)
], []));
groups.Add(new GroupInfo("Animations", false, [
new ToggleInfo(" Shields", () => CheatToggles.animShields, x => CheatToggles.animShields = x),
new ToggleInfo(" Asteroids", () => CheatToggles.animAsteroids, x => CheatToggles.animAsteroids = x),
new ToggleInfo(" Empty Garbage", () => CheatToggles.animEmptyGarbage, x => CheatToggles.animEmptyGarbage = x),
new ToggleInfo(" Medbay Scan", () => CheatToggles.animScan, x => CheatToggles.animScan = x),
new ToggleInfo(" Fake Cams In Use", () => CheatToggles.animCamsInUse, x => CheatToggles.animCamsInUse = x),
new ToggleInfo(" Pet", () => CheatToggles.animPet, x => CheatToggles.animPet = x)
], [
new SubmenuInfo("Client-Sided", false, [
new ToggleInfo(" Moonwalk", () => CheatToggles.moonwalk, x => CheatToggles.moonwalk = x)
])
]));
groups.Add(new GroupInfo("Config", false, [
new ToggleInfo(" Open plugin config", () => false, x => Utils.OpenConfigFile()),
new ToggleInfo(" Reload plugin config", () => CheatToggles.reloadConfig, x => CheatToggles.reloadConfig = x),
new ToggleInfo(" Save to Profile", () => false, x => CheatToggles.SaveTogglesToProfile()),
new ToggleInfo(" Load from Profile", () => false, x => CheatToggles.LoadTogglesFromProfile()),
new ToggleInfo(" RGB Mode", () => CheatToggles.RGBMode, x => CheatToggles.RGBMode = x)
], []));
}
public void InitStyles()
{
if (!MalumMenu.useHorizontalUI.Value && (GUI.skin.toggle.fontSize == 13 || GUI.skin.toggle.fontSize == 0))
{
//Debug.Log($"current style: {GUI.skin.button.fontSize}, {GUI.skin.toggle.fontSize}, {GUI.skin.button.normal.textColor}, {GUI.skin.button.normal.background}");
GUI.skin.toggle.fontSize = GUI.skin.button.fontSize = 20;
}
else if (MalumMenu.useHorizontalUI.Value && GUI.skin.toggle.fontSize != 13)
{
GUI.skin.toggle.fontSize = GUI.skin.button.fontSize = GUI.skin.label.fontSize = 13;
}
if (submenuButtonStyle != null) return;
submenuButtonStyle = new GUIStyle(GUI.skin.button)
{
normal = { textColor = Color.white, background = Texture2D.grayTexture },
fontSize = 18
};
submenuButtonStyle.normal.background.Apply();
tabButtonStyle = new GUIStyle(GUI.skin.button)
{
fontSize = 18,
fontStyle = FontStyle.Bold,
};
tabTitleStyle = new GUIStyle(GUI.skin.label)
{
fontSize = 20,
fontStyle = FontStyle.Bold,
alignment = TextAnchor.MiddleLeft,
};
tabSubtitleStyle = new GUIStyle(GUI.skin.label)
{
fontSize = 15,
fontStyle = FontStyle.Bold,
alignment = TextAnchor.MiddleLeft,
};
}
private void Update(){
if (Input.GetKeyDown(Utils.stringToKeycode(MalumMenu.menuKeybind.Value)))
{
//Enable-disable GUI with DELETE key
isGUIActive = !isGUIActive;
if (MalumMenu.teleportMenuToMouse.Value)
{
// Teleport the window to the mouse for immediate use
Vector2 mousePosition = Input.mousePosition;
windowRect.position = new Vector2(mousePosition.x, Screen.height - mousePosition.y);
horizontalWindowRect.position = new Vector2(mousePosition.x, Screen.height - mousePosition.y);
}
}
if (CheatToggles.RGBMode)
{
hue += Time.deltaTime * 0.3f; // Adjust speed of color change, higher multiplier = faster
if (hue > 1f) hue -= 1f; // Loop hue back to 0 when it exceeds 1
}
if (CheatToggles.stealthMode && ModManager.Instance.ModStamp && ModManager.Instance.ModStamp.enabled)
{
ModManager.Instance.ModStamp.enabled = false;
}
else if (!CheatToggles.stealthMode && ModManager.Instance.ModStamp && !ModManager.Instance.ModStamp.enabled)
{
ModManager.Instance.ShowModStamp();
}
if (CheatToggles.panic)
{
Utils.Panic();
isPanicked = true;
CheatToggles.panic = false;
}
//Passive cheats are always on to avoid problems
//CheatToggles.unlockFeatures = CheatToggles.freeCosmetics = CheatToggles.avoidBans = true;
if(!Utils.isPlayer){
CheatToggles.changeRole = CheatToggles.killAll = CheatToggles.telekillPlayer = CheatToggles.killAllCrew = CheatToggles.killAllImps = CheatToggles.teleportCursor = CheatToggles.teleportPlayer = CheatToggles.spectate = CheatToggles.freecam = CheatToggles.killPlayer = false;
}
if(!Utils.isHost && !Utils.isFreePlay){
CheatToggles.killAll = CheatToggles.telekillPlayer = CheatToggles.killAllCrew = CheatToggles.killAllImps = CheatToggles.killPlayer = CheatToggles.ejectPlayer = CheatToggles.zeroKillCd = CheatToggles.killAnyone = CheatToggles.killVanished = CheatToggles.forceStartGame = CheatToggles.noGameEnd = CheatToggles.skipMeeting = false;
}
//Host-only cheats are turned off if LocalPlayer is not the game's host
//if(!CheatChecks.isHost){
// CheatToggles.voteImmune = CheatToggles.godMode = CheatToggles.impostorHack = CheatToggles.evilVote = false;
//}
//Some cheats only work if the ship is present, so they are turned off if it is not
if(!Utils.isShip){
CheatToggles.revive = CheatToggles.sabotageMap = CheatToggles.unfixableLights = CheatToggles.completeMyTasks = CheatToggles.kickVents = CheatToggles.reportBody = CheatToggles.ejectPlayer = CheatToggles.closeMeeting = CheatToggles.skipMeeting = CheatToggles.reactorSab = CheatToggles.oxygenSab = CheatToggles.commsSab = CheatToggles.elecSab = CheatToggles.mushSab = CheatToggles.closeAllDoors = CheatToggles.openAllDoors = CheatToggles.spamCloseAllDoors = CheatToggles.spamOpenAllDoors = CheatToggles.autoOpenDoorsOnUse = CheatToggles.mushSpore = CheatToggles.animShields = CheatToggles.animAsteroids = CheatToggles.animEmptyGarbage = CheatToggles.animScan = CheatToggles.animCamsInUse = false;
}
}
public void OnGUI()
{
if (!isGUIActive || isPanicked) return;
InitStyles();
// Only change the window height while the user is not dragging it, or else dragging breaks
if (!isDragging)
{
var windowHeight = CalculateWindowHeight();
windowRect.height = windowHeight;
}
if (CheatToggles.RGBMode)
{
GUI.backgroundColor = Color.HSVToRGB(hue, 1f, 1f); // Set background color based on hue
}
else
{
var configHtmlColor = MalumMenu.menuHtmlColor.Value;
if (!ColorUtility.TryParseHtmlString(configHtmlColor, out var uiColor))
{
if (!configHtmlColor.StartsWith("#"))
{
if (ColorUtility.TryParseHtmlString("#" + configHtmlColor, out uiColor))
{
GUI.backgroundColor = uiColor;
}
}
}
else
{
GUI.backgroundColor = uiColor;
}
}
if (MalumMenu.useHorizontalUI.Value)
{
horizontalWindowRect = GUI.Window(0, horizontalWindowRect, (GUI.WindowFunction)HorizontalWindowFunction, "MalumMenu v" + MalumMenu.malumVersion);
}
else
{
windowRect = GUI.Window(0, windowRect, (GUI.WindowFunction)WindowFunction, "MalumMenu v" + MalumMenu.malumVersion);
}
}
public void WindowFunction(int windowID)
{
int groupSpacing = 50;
int toggleSpacing = 40;
int submenuSpacing = 40;
int currentYPosition = 20;
for (int groupId = 0; groupId < groups.Count; groupId++)
{
GroupInfo group = groups[groupId];
if (GUI.Button(new Rect(10, currentYPosition, 280, 40), group.name))
{
group.isExpanded = !group.isExpanded;
groups[groupId] = group;
CloseAllGroupsExcept(groupId); // Close all other groups when one is expanded
}
currentYPosition += groupSpacing;
if (!group.isExpanded) continue;
// Render direct toggles for the group
foreach (var toggle in group.toggles)
{
bool currentState = toggle.getState();
bool newState = GUI.Toggle(new Rect(20, currentYPosition, 260, 30), currentState, toggle.label);
if (newState != currentState)
{
toggle.setState(newState);
}
currentYPosition += toggleSpacing;
}
if (group.name == "Player")
{
try
{
if (PlayerControl.LocalPlayer.Data.IsDead)
{
PlayerControl.LocalPlayer.MyPhysics.GhostSpeed = GUI.HorizontalSlider(new Rect(20, currentYPosition, 250, 30), PlayerControl.LocalPlayer.MyPhysics.GhostSpeed, 0f, 20f);
Utils.snapSpeedToDefault(0.05f, true);
GUI.Label(new Rect(20, currentYPosition + 10, 250, 20), $"Current Speed: {PlayerControl.LocalPlayer?.MyPhysics.GhostSpeed} {(Utils.isSpeedDefault(true) ? "(Default)" : "")}");
currentYPosition += toggleSpacing;
}
else
{
PlayerControl.LocalPlayer.MyPhysics.Speed = GUI.HorizontalSlider(new Rect(20, currentYPosition, 250, 30), PlayerControl.LocalPlayer.MyPhysics.Speed, 0f, 20f);
Utils.snapSpeedToDefault(0.05f);
GUI.Label(new Rect(20, currentYPosition + 10, 250, 20), $"Current Speed: {PlayerControl.LocalPlayer?.MyPhysics.Speed} {(Utils.isSpeedDefault() ? "(Default)" : "")}");
currentYPosition += toggleSpacing;
}
}catch (NullReferenceException) {}
}
for (int submenuId = 0; submenuId < group.submenus.Count; submenuId++)
{
var submenu = group.submenus[submenuId];
// Add a button for each submenu and toggle its expansion state when clicked
if (GUI.Button(new Rect(20, currentYPosition, 260, 30), submenu.name, submenuButtonStyle))
{
submenu.isExpanded = !submenu.isExpanded;
group.submenus[submenuId] = submenu;
if (submenu.isExpanded)
{
CloseAllSubmenusExcept(group, submenuId);
}
}
currentYPosition += submenuSpacing;
if (!submenu.isExpanded) continue;
// Show all the toggles in the expanded submenu
foreach (var toggle in submenu.toggles)
{
bool currentState = toggle.getState();
bool newState = GUI.Toggle(new Rect(30, currentYPosition, 250, 30), currentState, toggle.label);
if (newState != currentState)
{
toggle.setState(newState);
}
currentYPosition += toggleSpacing;
}
}
}
isDragging = Event.current.type switch
{
EventType.MouseDrag => true,
EventType.MouseUp => false,
_ => isDragging
};
GUI.DragWindow(); //Allows dragging the GUI window with mouse
}
// Dynamically calculate the window's height depending on
// The number of toggles & group expansion
private int CalculateWindowHeight()
{
int totalHeight = 70; // Base height for the window
int groupHeight = 50; // Height for each group title
int toggleHeight = 30; // Height for each toggle
int submenuHeight = 40; // Height for each submenu title
foreach (GroupInfo group in groups)
{
totalHeight += groupHeight; // Always add height for the group title
if (!group.isExpanded) continue;
totalHeight += group.toggles.Count * toggleHeight; // Add height for toggles in the group
foreach (SubmenuInfo submenu in group.submenus)
{
totalHeight += submenuHeight; // Always add height for the submenu title
if (submenu.isExpanded)
{
totalHeight += submenu.toggles.Count * toggleHeight; // Add height for toggles in the expanded submenu
}
}
}
return totalHeight;
}
// Closes all expanded groups other than indexToKeepOpen
private void CloseAllGroupsExcept(int indexToKeepOpen)
{
for (int i = 0; i < groups.Count; i++)
{
if (i == indexToKeepOpen) continue;
GroupInfo group = groups[i];
group.isExpanded = false;
groups[i] = group;
}
}
private void CloseAllSubmenusExcept(GroupInfo group, int submenuIndexToKeepOpen)
{
for (int i = 0; i < group.submenus.Count; i++)
{
if (i == submenuIndexToKeepOpen) continue;
var submenu = group.submenus[i];
submenu.isExpanded = false;
group.submenus[i] = submenu;
}
}
public void HorizontalWindowFunction(int windowID)
{
GUILayout.BeginHorizontal();
// Left tab selector (15% width)
GUILayout.BeginVertical(GUILayout.Width(horizontalWindowRect.width * 0.15f));
for (var i = 0; i < groups.Count; i++)
{
if (GUILayout.Button(groups[i].name, tabButtonStyle, GUILayout.Height(35)))
selectedTab = i;
}
GUILayout.EndVertical();
// Invisible vertical separator line to create some space between the tab selector and the content
GUILayout.Box("", GUIStyles.SeparatorStyle, GUILayout.Width(1f), GUILayout.ExpandHeight(true));
GUILayout.Box("", GUIStyle.none, GUILayout.Width(10f), GUILayout.ExpandHeight(true));
// Right tab content and controls (85% width)
GUILayout.BeginVertical(GUILayout.Width(horizontalWindowRect.width * 0.85f));
// Tab-specific content
if (selectedTab >= 0 && selectedTab < groups.Count)
{
GUILayout.Label(groups[selectedTab].name, tabTitleStyle);
HorizontalDrawContent(selectedTab);
}
GUILayout.EndVertical();
GUILayout.EndHorizontal();
// Make the window draggable
GUI.DragWindow();
}
/// <summary>
/// Gets the hardcoded number of left column submenus for each tab
/// </summary>
/// <param name="groupId">The group (tab) index</param>
/// <returns>The number of left column submenus</returns>
private int GetLeftSubmenuCount(int groupId)
{
return groups[groupId].name switch
{
"Player" => 1,
"ESP" => 2,
"Roles" => 4,
"Ship" => 1,
"Chat" => 1,
"Host-Only" => 2,
"Passive" => 1,
"Animations" => 1,
"Config" => 1,
_ => 2
};
}
public void HorizontalDrawContent(int groupId)
{
var group = groups[groupId];
var submenuCount = group.submenus.Count;
GUILayout.BeginHorizontal();
GUILayout.BeginVertical(GUILayout.Width(horizontalWindowRect.width * 0.425f));
HorizontalDrawToggles(group.toggles);
if (group.name == "Player")
{
try
{
if (PlayerControl.LocalPlayer.Data.IsDead)
{
PlayerControl.LocalPlayer.MyPhysics.GhostSpeed = GUILayout.HorizontalSlider(PlayerControl.LocalPlayer.MyPhysics.GhostSpeed, 0f, 20f, GUILayout.Width(250f));
Utils.snapSpeedToDefault(0.05f, true);
GUILayout.Label($"Current Speed: {PlayerControl.LocalPlayer?.MyPhysics.GhostSpeed} {(Utils.isSpeedDefault(true) ? "(Default)" : "")}");
}
else
{
PlayerControl.LocalPlayer.MyPhysics.Speed = GUILayout.HorizontalSlider(PlayerControl.LocalPlayer.MyPhysics.Speed, 0f, 20f, GUILayout.Width(250f));
Utils.snapSpeedToDefault(0.05f);
GUILayout.Label($"Current Speed: {PlayerControl.LocalPlayer?.MyPhysics.Speed} {(Utils.isSpeedDefault() ? "(Default)" : "")}");
}
}catch (NullReferenceException) {}
}
var desiredLeft = GetLeftSubmenuCount(groupId);
var leftCount = Mathf.Clamp(desiredLeft, 0, submenuCount);
// Left column submenus
var leftSubmenus = group.submenus.GetRange(0, leftCount);
foreach (var submenu in leftSubmenus)
{
GUILayout.Label(submenu.name, tabSubtitleStyle, GUILayout.Height(30));
HorizontalDrawToggles(submenu.toggles);
}
GUILayout.EndVertical();
// Right column submenus (if any)
GUILayout.BeginVertical();
if (submenuCount > leftCount)
{
var rightSubmenus = group.submenus.GetRange(leftCount, submenuCount - leftCount);
foreach (var submenu in rightSubmenus)
{
GUILayout.Label(submenu.name, tabSubtitleStyle, GUILayout.Height(30));
HorizontalDrawToggles(submenu.toggles);
}
}
GUILayout.EndVertical();
GUILayout.EndHorizontal();
}
public void HorizontalDrawToggles(List<ToggleInfo> toggles)
{
foreach (var toggle in toggles)
{
var currentState = toggle.getState();
var newState = GUILayout.Toggle(currentState, toggle.label, GUILayout.Height(20));
if (newState != currentState)
toggle.setState(newState);
}
}
}