Repository navigation
Expand file tree
/
Copy pathModuleSettingWindow.cs
More file actions
126 lines (104 loc) · 3.87 KB
/
Copy pathModuleSettingWindow.cs
File metadata and controls
126 lines (104 loc) · 3.87 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
using UnityEngine;
using System.Collections.Generic;
using BrokeProtocolClient.modules;
using BrokeProtocolClient.settings;
using BrokeProtocolClient.utils;
using BrokeProtocolClient.UI.setting;
namespace BrokeProtocolClient.UI
{
class ModuleSettingWindow : GuiWindow
{
protected static int index;
public bool visible = false;
public Module module;
public GuiWindow parent;
protected List<Setting> settings = new List<Setting>();
private readonly List<setting.Component> components = new List<setting.Component>();
public ModuleSettingWindow(Module module, GuiWindow parent) : base(module.name)
{
this.module = module;
this.parent = parent;
this.settings = module.getSettings();
this.components = new List<setting.Component>();
int offset = headerPad;
foreach (Setting setting in settings)
{
if (setting is BooleanSetting)
{
components.Add(new CheckBox(setting, this, offset));
}
else if(setting is InfoSetting)
{
components.Add(new InfoLabel(setting, this, offset));
}
else if (setting is ModeSetting)
{
components.Add(new ModeBox(setting, this, offset));
}
else if (setting is NumberSetting)
{
components.Add(new Slider(setting, this, offset));
offset += controlHeight + pad;
controlIndex++;
}
else if (setting is InputSetting)
{
components.Add(new InputBox(setting, this, offset));
offset += controlHeight + pad;
controlIndex++;
}
else if (setting is ColorSetting)
{
components.Add(new ColorPicker(setting, this, offset));
offset += controlHeight + pad;
controlIndex++;
}
else if (setting is BindSetting)
{
components.Add(new Keybinder(setting, this, offset));
}
else if (setting is FileSetting)
{
components.Add(new FileExplorer(setting, this, offset));
}
else if (setting is ActionSetting)
{
components.Add(new ActionButton(setting, this, offset));
}
offset += controlHeight + pad;
controlIndex++;
}
init();
}
protected override void init()
{
windowSpace = new Rect(parent.windowSpace.x, parent.windowSpace.height, windowSpace.width, windowSpace.height);
windowIndex = rollingIndex;
index += 1;
rollingIndex++;
ResizeWindowToFitControls();
}
protected override void WindowCore()
{
foreach (setting.Component component in components)
{
component.onRender();
}
}
protected override void WindowWrapper(int id)
{
WindowCore();
}
public override void onRender()
{
if (visible)
{
windowSpace = new Rect(parent.windowSpace.x, parent.windowSpace.y + parent.windowSpace.height, windowSpace.width, windowSpace.height);
windowSpace = GUI.Window(windowIndex, windowSpace, this.WindowWrapper, windowTitle);
}
}
public override void onUpdate()
{
}
}
}