-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUIController.cs
More file actions
369 lines (321 loc) · 16.4 KB
/
Copy pathUIController.cs
File metadata and controls
369 lines (321 loc) · 16.4 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RapidGUI;
using UnityEngine;
using UnityModManagerNet;
namespace grabs_customizer
{
class UIController : MonoBehaviour
{
Color on_press = new Color(46 / 255, 204 / 255, 113 / 255, 1);
private bool showMainMenu;
private Rect MainMenuRect;
string selected_grab = "";
int selected_grab_index = 0;
string[] grabNames = new string[] { "Indy", "Melon", "NoseGrab", "TailGrab", "WeddleGrab", "Stalefish" };
string[] animNames = new string[] { "Disabled", "Falling" };
string[] stances = new string[] { "Default", "On right stick press", "On left stick press" };
string[] detachOptions = new string[] { "None", "Left", "Right", "Both" };
bool on_pressed = false, leftstick = false;
GUIStyle bg = new GUIStyle("Box")
{
alignment = TextAnchor.UpperLeft
};
GUIStyle options = new GUIStyle("Label") { };
Texture2D white_texture;
private void Start()
{
selected_grab = grabNames[0];
showMainMenu = false;
white_texture = new Texture2D(1, 1);
white_texture.SetPixels(new[] { new Color(1, 1, 1, 1) });
white_texture.Apply();
bg.border = new RectOffset(8, 8, 8, 8);
bg.padding = new RectOffset(20, 20, 20, 20);
bg.normal.background = white_texture;
bg.fontSize = 20;
options.fontSize = 16;
MainMenuRect = new Rect(0, 0, 462, Screen.height);
MainMenuRect = new Rect(-MainMenuRect.width, 0, 462, Screen.height);
//Screen.SetResolution(720, 1280, FullScreenMode.Windowed);
}
private void Update()
{
if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) && Input.GetKeyDown("g"))
{
if (showMainMenu)
{
intention_to_close = true;
}
else
{
showMainMenu = true;
intention_to_close = false;
}
}
if (showMainMenu)
{
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
}
}
int frame_open_count = 0;
private void Open()
{
frame_count = 0;
left = -MainMenuRect.width + ((MainMenuRect.width / 36) * frame_open_count);
if (frame_open_count <= 36)
{
frame_open_count++;
}
}
float left = 0;
int frame_count = 0;
bool intention_to_close = false;
private void Close()
{
if (frame_count == 0)
{
Cursor.visible = false;
Main.settings.Save(Main.modEntry);
}
if (frame_count >= 36)
{
frame_open_count = 0;
showMainMenu = false;
}
else
{
left = -(MainMenuRect.width / 36) * frame_count;
frame_count++;
}
}
private void OnGUI()
{
if (showMainMenu)
{
MainMenuRect = new Rect(left, 0, 462, Screen.height);
GUI.backgroundColor = new Color32(18, 23, 29, 230);
MainMenuRect = GUILayout.Window(420, MainMenuRect, MainMenu, "<color=#FCFFFF><b>Grabs customizer</b></color>", bg);
if (intention_to_close)
{
if (frame_count >= 0 && frame_count <= 36) Close();
}
else if (frame_open_count >= 0 && frame_open_count <= 36) Open();
}
}
string selected_stance = "Default";
string selected_detach = "None";
Vector3 temp_vector_detach_left, temp_vector_detach_right;
Vector3 temp_vector_pos;
Vector3 temp_vector_rot;
int last_grab = -1;
private void MainMenu(int windowID)
{
GUI.backgroundColor = Color.black;
//GUI.DragWindow(new Rect(0, 0, 10000, 20));
GUILayout.Space(18);
GUILayout.Label("v1.8.0");
GUILayout.Space(14);
GUILayout.BeginVertical();
GUILayout.BeginHorizontal();
GUILayout.Label("<b>Grab</b>");
selected_grab_index = RGUI.SelectionPopup(selected_grab_index, grabNames);
if (last_grab != selected_grab_index) selected_stance = "Default";
last_grab = selected_grab_index;
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("<b>Stance</b>");
selected_stance = RGUI.SelectionPopup(selected_stance, stances);
GUILayout.EndHorizontal();
on_pressed = selected_stance == "On right stick press";
leftstick = selected_stance == "On left stick press";
GUILayout.Space(6);
GUILayout.Label("<b>Position</b>", GUILayout.Height(26f));
temp_vector_pos = !on_pressed ? leftstick ? Main.settings.position_offset_leftstick[selected_grab_index] : Main.settings.position_offset[selected_grab_index] : Main.settings.position_offset_onbutton[selected_grab_index];
temp_vector_pos.x = RGUI.SliderFloat(temp_vector_pos.x, -30f, 30f, 0f, "Left | Right");
temp_vector_pos.y = RGUI.SliderFloat(temp_vector_pos.y, -40f, 40f, 0f, "Down | Up");
temp_vector_pos.z = RGUI.SliderFloat(temp_vector_pos.z, -30f, 30f, 0f, "Backward | Forward");
if (!on_pressed)
{
if (leftstick) Main.settings.position_offset_leftstick[selected_grab_index] = temp_vector_pos;
else Main.settings.position_offset[selected_grab_index] = temp_vector_pos;
}
else
{
Main.settings.position_offset_onbutton[selected_grab_index] = temp_vector_pos;
}
GUILayout.Space(6);
GUILayout.Label("<b>Rotation</b>", GUILayout.Height(26f));
temp_vector_rot = !on_pressed ? leftstick ? Main.settings.rotation_offset_leftstick[selected_grab_index] : Main.settings.rotation_offset[selected_grab_index] : Main.settings.rotation_offset_onbutton[selected_grab_index];
temp_vector_rot.z = RGUI.SliderFloat(temp_vector_rot.z, -180f, 180f, 0f, "Roll");
temp_vector_rot.x = RGUI.SliderFloat(temp_vector_rot.x, -180f, 180f, 0f, "Pitch");
temp_vector_rot.y = RGUI.SliderFloat(temp_vector_rot.y, -180f, 180f, 0f, "Yaw");
if (!on_pressed)
{
if (leftstick) Main.settings.rotation_offset_leftstick[selected_grab_index] = temp_vector_rot;
else Main.settings.rotation_offset[selected_grab_index] = temp_vector_rot;
}
else
{
Main.settings.rotation_offset_onbutton[selected_grab_index] = temp_vector_rot;
}
GUILayout.Space(12);
/*GUILayout.Label("<b>Pelvis rotation</b>", GUILayout.Height(26f));
Vector3 temp_vector_pelvis_rot = !on_pressed ? Main.settings.pelvis_rotation_offset[selected_grab_index] : Main.settings.pelvis_rotation_offset_onbutton[selected_grab_index];
temp_vector_pelvis_rot.z = RGUI.SliderFloat(temp_vector_pelvis_rot.z, -180f, 180f, 0f, "Roll");
temp_vector_pelvis_rot.x = RGUI.SliderFloat(temp_vector_pelvis_rot.x, -180f, 180f, 0f, "Pitch");
temp_vector_pelvis_rot.y = RGUI.SliderFloat(temp_vector_pelvis_rot.y, -180f, 180f, 0f, "Yaw");
if (!on_pressed)
{
Main.settings.pelvis_rotation_offset[selected_grab_index] = temp_vector_pelvis_rot;
}
else
{
Main.settings.pelvis_rotation_offset_onbutton[selected_grab_index] = temp_vector_pelvis_rot;
}
GUILayout.Space(12);*/
if (!on_pressed)
{
if (leftstick) Main.settings.animation_length_leftstick[selected_grab_index] = (int)RGUI.SliderFloat(Main.settings.animation_length_leftstick[selected_grab_index], 1, 60f, 36f, "<b>Grab animation length</b>");
else Main.settings.animation_length[selected_grab_index] = (int)RGUI.SliderFloat(Main.settings.animation_length[selected_grab_index], 1, 60f, 36f, "<b>Grab animation length</b>");
}
else
{
Main.settings.animation_length_onbutton[selected_grab_index] = (int)RGUI.SliderFloat(Main.settings.animation_length_onbutton[selected_grab_index], 1, 60f, 36f, "<b>Grab animation length</b>");
}
GUILayout.Space(12);
GUILayout.BeginHorizontal();
GUILayout.Label("<b>Detach foot</b>");
if (!on_pressed)
{
if (leftstick) Main.settings.detach_feet_leftstick[selected_grab_index] = RGUI.SelectionPopup(Main.settings.detach_feet_leftstick[selected_grab_index], detachOptions);
else Main.settings.detach_feet[selected_grab_index] = RGUI.SelectionPopup(Main.settings.detach_feet[selected_grab_index], detachOptions);
}
else Main.settings.detach_feet_onbutton[selected_grab_index] = RGUI.SelectionPopup(Main.settings.detach_feet_onbutton[selected_grab_index], detachOptions);
GUILayout.EndHorizontal();
if (!on_pressed)
{
if (leftstick) Main.settings.animation_detach_length_leftstick[selected_grab_index] = (int)RGUI.SliderFloat(Main.settings.animation_detach_length_leftstick[selected_grab_index], 1, 60f, 24f, "<b>Detach animation length</b>");
else Main.settings.animation_detach_length[selected_grab_index] = (int)RGUI.SliderFloat(Main.settings.animation_detach_length[selected_grab_index], 1, 60f, 24f, "<b>Detach animation length</b>");
}
else
{
Main.settings.animation_detach_length_onbutton[selected_grab_index] = (int)RGUI.SliderFloat(Main.settings.animation_detach_length_onbutton[selected_grab_index], 1, 60f, 24f, "<b>Detach animation length</b>");
}
GUILayout.Space(6);
if ((leftstick && Main.BG.getDetachOnLeftStick_Left(selected_grab_index) == 0) || (on_pressed && Main.BG.getDetachOnButton_Left(selected_grab_index) == 0) || ((!on_pressed && !leftstick) && Main.BG.getDetachNoPress_Left(selected_grab_index) == 0))
{
GUILayout.BeginHorizontal();
//GUILayout.FlexibleSpace();
GUILayout.Label("<b><color=#bdc3c7>L</color></b>", options, GUILayout.Width(18));
temp_vector_detach_left = !on_pressed ? leftstick ? Main.settings.detach_left_leftstick[selected_grab_index] : Main.settings.detach_left[selected_grab_index] : Main.settings.detach_left_onbutton[selected_grab_index];
temp_vector_detach_left.x = RGUI.SliderFloatCompact(temp_vector_detach_left.x, -10f, 10f, 0, "X");
temp_vector_detach_left.y = RGUI.SliderFloatCompact(temp_vector_detach_left.y, -10f, 10f, -2f, "Y");
temp_vector_detach_left.z = RGUI.SliderFloatCompact(temp_vector_detach_left.z, -10f, 10f, .5f, "Z");
if (!on_pressed)
{
if (leftstick) Main.settings.detach_left_leftstick[selected_grab_index] = temp_vector_detach_left;
else Main.settings.detach_left[selected_grab_index] = temp_vector_detach_left;
}
else
{
Main.settings.detach_left_onbutton[selected_grab_index] = temp_vector_detach_left;
}
GUILayout.EndHorizontal();
}
if ((leftstick && Main.BG.getDetachOnLeftStick_Right(selected_grab_index) == 0) || (on_pressed && Main.BG.getDetachOnButton_Right(selected_grab_index) == 0) || ((!on_pressed && !leftstick) && Main.BG.getDetachNoPress_Right(selected_grab_index) == 0))
{
GUILayout.BeginHorizontal();
//GUILayout.FlexibleSpace();
GUILayout.Label("<b><color=#bdc3c7>R</color></b>", options, GUILayout.Width(18));
temp_vector_detach_right = !on_pressed ? leftstick ? Main.settings.detach_right_leftstick[selected_grab_index] : Main.settings.detach_right[selected_grab_index] : Main.settings.detach_right_onbutton[selected_grab_index];
temp_vector_detach_right.x = RGUI.SliderFloatCompact(temp_vector_detach_right.x, -10f, 10f, 0, "X");
temp_vector_detach_right.y = RGUI.SliderFloatCompact(temp_vector_detach_right.y, -10f, 10f, -2f, "Y");
temp_vector_detach_right.z = RGUI.SliderFloatCompact(temp_vector_detach_right.z, -10f, 10f, -.5f, "Z");
if (!on_pressed)
{
if (leftstick) Main.settings.detach_right_leftstick[selected_grab_index] = temp_vector_detach_right;
else Main.settings.detach_right[selected_grab_index] = temp_vector_detach_right;
}
else
{
Main.settings.detach_right_onbutton[selected_grab_index] = temp_vector_detach_right;
}
GUILayout.EndHorizontal();
}
GUILayout.EndVertical();
GUILayout.FlexibleSpace();
GUILayout.BeginVertical();
GUILayout.Label("<b><color=#718093>Options</color></b>", options);
GUILayout.Space(6);
if (RGUI.Button(Main.settings.BonedGrab, "<color=#718093>Enabled</color>"))
{
Main.settings.BonedGrab = !Main.settings.BonedGrab;
}
GUILayout.Space(4);
/*GUILayout.EndVertical();
GUILayout.BeginVertical("Box");*/
Main.settings.hand_animation_length = (int)RGUI.SliderFloat(Main.settings.hand_animation_length, 1, 60, 48, "<b><color=#718093>Hand animation length</color></b>");
Main.settings.kneeBendWeight = RGUI.SliderFloat(Main.settings.kneeBendWeight, 0, 1, .7f, "<b><color=#718093>Knee bend weight</color></b>");
GUILayout.Space(4);
if (RGUI.Button(Main.settings.continuously_detect, "<color=#718093>Continuously detect grab</color>"))
{
Main.settings.continuously_detect = !Main.settings.continuously_detect;
}
GUILayout.Label("<color=#636e72>Use the hand of one grab with all of the other grab stances</color>");
GUILayout.Space(4);
/* GUILayout.EndVertical();
GUILayout.BeginVertical("Box");*/
if (RGUI.Button(Main.settings.catch_anytime, "<color=#718093>Catch board at any moment</color>"))
{
Main.settings.catch_anytime = !Main.settings.catch_anytime;
}
GUILayout.Label("<color=#636e72>Use with XXL3 grab delay disabled</color>");
GUILayout.Space(4);
/* GUILayout.EndVertical();
GUILayout.BeginVertical("Box");*/
if (RGUI.Button(Main.settings.config_mode, "<color=#718093>Config mode</color>"))
{
Main.settings.config_mode = !Main.settings.config_mode;
}
GUILayout.Label("<color=#636e72>Float after pop for easily configuring stances</color>");
GUILayout.EndVertical();
}
public Vector3 getCustomRotation(int grab)
{
return Main.settings.rotation_offset[grab];
}
public Vector3 getCustomPosition(int grab)
{
return Main.settings.position_offset[grab];
}
string getNextGrab()
{
selected_grab_index++;
if (grabNames.ElementAtOrDefault(selected_grab_index) != null) { return grabNames[selected_grab_index]; }
else
{
selected_grab_index = 0;
return grabNames[selected_grab_index];
}
}
private void Title()
{/*
GUILayout.BeginHorizontal();
GUILayout.Label("<b></b>", GUILayout.Height(32f));
if (GUILayout.Button("<b>X</b>", GUILayout.Height(32f), GUILayout.Width(32f)))
{
Close();
}
GUILayout.EndHorizontal();*/
}
private void OnApplicationQuit()
{
Main.settings.Save(Main.modEntry);
}
}
}