|
5 | 5 | using System.Collections.Generic; |
6 | 6 | using UnityEngine; |
7 | 7 |
|
8 | | -[assembly: MelonInfo(typeof(Astrum.AstralUI.UIMGUI), "AstralUI.UIMGUI", "1.0.0", downloadLink: "github.com/Astrum-Project/AstralUI.UIMGUI")] |
| 8 | +[assembly: MelonInfo(typeof(Astrum.AstralUI.UIMGUI), "AstralUI.UIMGUI", "1.1.0", downloadLink: "github.com/Astrum-Project/AstralUI.UIMGUI")] |
9 | 9 | [assembly: MelonColor(ConsoleColor.DarkMagenta)] |
10 | 10 |
|
11 | 11 | namespace Astrum.AstralUI |
12 | 12 | { |
13 | 13 | public class UIMGUI : MelonMod |
14 | 14 | { |
| 15 | + private static readonly UnhollowerBaseLib.Il2CppReferenceArray<GUILayoutOption> options = new(0); |
| 16 | + |
15 | 17 | public static Color32 color = new(0x56, 0x00, 0xA5, 0xFF); |
16 | 18 | public static Module currentModule = null; |
17 | 19 |
|
18 | 20 | private static Rect position = new(Screen.width / 2 - 78, Screen.height / 2 - 307, 156, 482); |
| 21 | + private static Vector2 scrollModules = default; |
| 22 | + private static Vector2 scrollCommands = default; |
19 | 23 |
|
20 | 24 | public override void OnApplicationStart() |
21 | 25 | { |
@@ -46,37 +50,39 @@ public override void OnGUI() |
46 | 50 |
|
47 | 51 | private void ModulesWindow(int id) |
48 | 52 | { |
49 | | - int i = 0; |
| 53 | + scrollModules = GUILayout.BeginScrollView(scrollModules, options); |
50 | 54 |
|
51 | 55 | foreach (KeyValuePair<string, Module> module in CoreUI.Modules) |
52 | | - if (GUI.Button(new Rect(3, i++ * 22 + 21, 150, 20), module.Key)) |
| 56 | + if (GUILayout.Button(module.Key, options)) |
53 | 57 | currentModule = module.Value; |
| 58 | + |
| 59 | + GUILayout.EndScrollView(true); |
54 | 60 |
|
55 | 61 | GUI.DragWindow(new Rect(0, 0, 156, 20)); |
56 | 62 | } |
57 | 63 |
|
58 | 64 | private void CommandsWindow(int windowID) |
59 | 65 | { |
60 | | - int i = 0; |
| 66 | + scrollCommands = GUILayout.BeginScrollView(scrollCommands, options); |
61 | 67 |
|
62 | 68 | foreach (KeyValuePair<string, UIBase> command in currentModule.Commands) |
63 | 69 | { |
64 | 70 | if (command.Value is UIFieldProp<bool> cb) |
65 | | - cb.Value = GUI.Toggle(CreateRect(ref i), cb.Value, command.Key); |
| 71 | + cb.Value = GUILayout.Toggle(cb.Value, command.Key, options); |
66 | 72 | else if (command.Value is UIFieldProp<float> cf) |
67 | 73 | { |
68 | | - GUI.Label(CreateRect(ref i), command.Key + $": ({cf.Value:0.00})"); |
69 | | - cf.Value = GUI.HorizontalSlider(CreateRect(ref i), cf.Value, cf.Value - 10, cf.Value + 10); |
| 74 | + GUILayout.Label(command.Key + $": ({cf.Value:0.00})", options); |
| 75 | + cf.Value = GUILayout.HorizontalSlider(cf.Value, cf.Value - 10, cf.Value + 10, options); |
70 | 76 | } |
71 | 77 | else if (command.Value is UIButton) |
72 | 78 | { |
73 | | - if (GUI.Button(CreateRect(ref i), command.Key)) |
| 79 | + if (GUILayout.Button(command.Key, options)) |
74 | 80 | (command.Value as UIButton)?.Click(); |
75 | 81 | } |
76 | | - else GUI.Label(CreateRect(ref i), command.Key + " (Unsupported type)"); |
| 82 | + else GUILayout.Label(command.Key + " (Unsupported type)", options); |
77 | 83 | } |
78 | | - } |
79 | 84 |
|
80 | | - private static Rect CreateRect(ref int i) => new(3, i++ * 22 + 21, 300, 20); |
| 85 | + GUILayout.EndScrollView(true); |
| 86 | + } |
81 | 87 | } |
82 | 88 | } |
0 commit comments