-
Notifications
You must be signed in to change notification settings - Fork 8
/
Navigation.cs
129 lines (116 loc) · 3.79 KB
/
Navigation.cs
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
using System.Linq;
using UnityEngine;
namespace UmbraMenu
{
static class Navigation
{
public static int menuIndex = 0;
public static int buttonIndex = 0;
public static int prevButtonIndex;
public static void PressBtn(int menuId, int btnId)
{
Button button = Utility.FindButtonById(menuId, btnId);
button?.GetAction()?.Invoke();
button.ToggleButton();
if (menuIndex != 9)
{
prevButtonIndex = buttonIndex;
}
if (menuIndex == 9)
{
menuIndex = 8;
}
}
public static void IncreaseValue(int menuId, int btnId)
{
Utility.FindButtonById(menuId, btnId)?.GetIncreaseAction()?.Invoke();
}
public static void DecreaseValue(int menuId, int btnId)
{
Utility.FindButtonById(menuId, btnId)?.GetDecreaseAction()?.Invoke();
}
public static void GoBackAMenu()
{
if (menuIndex == 0 && buttonIndex == 8)
{
Utility.FindButtonById(0, 8).SetEnabled(false);
return;
}
else if (menuIndex == 0)
{
UmbraMenu.navigationToggle = false;
menuIndex = 0;
buttonIndex = 0;
return;
}
else if (menuIndex == 1 && buttonIndex == 11)
{
Utility.FindButtonById(1, 11).SetEnabled(false);
return;
}
if (!UmbraMenu.lowResolutionMonitor)
{
Menu menu = UmbraMenu.menus[menuIndex];
menu.SetEnabled(false);
menuIndex = menu.GetPrevMenuId();
buttonIndex = prevButtonIndex;
}
else
{
Menu menu = UmbraMenu.menus[menuIndex];
menu.SetEnabled(false);
bool mainMenusIndex = Enumerable.Range(1, 7).Contains(menuIndex);
if (mainMenusIndex)
{
menuIndex = menu.GetPrevMenuId();
}
else
{
UmbraMenu.menus[menu.GetPrevMenuId()].SetEnabled(true);
}
buttonIndex = prevButtonIndex;
}
}
public static GUIStyle HighlighedCheck(GUIStyle defaultStyle, int currentMenu, int currentBtn)
{
if (UmbraMenu.navigationToggle)
{
if (currentBtn == buttonIndex && currentMenu == menuIndex)
{
return Styles.HighlightBtnStyle;
}
else
{
return defaultStyle;
}
}
return defaultStyle;
}
public static void UpdateIndexValues()
{
Menu menu = UmbraMenu.menus[menuIndex];
int menuLength = menu.GetNumberOfButtons();
bool listMenuHighlighted = Enumerable.Range(10, 17).Contains(menuIndex);
if (!UmbraMenu.scrolled && listMenuHighlighted)
{
menu.SetScrollPosition(new Vector2(0, 40 * (buttonIndex - 1)));
}
if (buttonIndex > menuLength)
{
buttonIndex = 1;
if (!UmbraMenu.scrolled && listMenuHighlighted)
{
menu.SetScrollPosition(Vector2.zero);
}
}
if (buttonIndex < 1)
{
buttonIndex = menuLength;
if (!UmbraMenu.scrolled && listMenuHighlighted)
{
menu.SetScrollPosition(new Vector2(0, menu.GetNumberOfButtons() * 40));
}
}
}
}
}