This repository has been archived by the owner on Jul 27, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
NewUi.cs
194 lines (161 loc) · 8.42 KB
/
NewUi.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
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
using System.Collections;
using MelonLoader;
using ReMod.Core.UI.QuickMenu;
using ReMod.Core.VRChat;
using TeleporterVR.Logic;
using TeleporterVR.Rendering;
using TeleporterVR.Utils;
using UnityEngine;
using VRC.UI.Core;
using static TeleporterVR.Menu;
namespace TeleporterVR {
public static class NewUi {
internal static IEnumerator OnQuickMenu() {
while (UIManager.field_Private_Static_UIManager_0 == null) yield return null;
while (GameObject.Find("UserInterface").GetComponentInChildren<VRC.UI.Elements.QuickMenu>(true) == null) yield return null;
ReMod.Core.Unity.EnableDisableListener.RegisterSafe();
BuildUi();
}
private static ReCategoryPage _teleportVr;
private static ReMenuCategory _mainCat, _waypointsCat;
private static ReMenuButton _tpKeyboard, _tpCoord, _wp1, _wp2, _wp3, _wp4, _wpl1, _wpl2, _wpl3, _wpl4, _userSelTp;
private static ReMenuToggle _handChange, _tpAction;
private static bool _built;
private static void BuildUi() {
_teleportVr = new ReCategoryPage("TeleporterVR", true);
_teleportVr.GameObject.SetActive(false);
ReTabButton.Create("TPVRTab", "Open the TeleporterVR Menu", "TeleporterVR", ResourceManager.Tab);
_mainCat = _teleportVr.AddCategory("TPVR Actions", false);
_tpKeyboard = _mainCat.AddButton(Language.TpToNameText, Language.TpToNameTooltip, OpenKeyboardForPlayerTP, ResourceManager.keyboard);
_tpCoord = _mainCat.AddButton(Language.TpToCoordText, Language.TpToCoordTooltip, OpenKeyboardForCoordTP, ResourceManager.mapmarker);
_handChange = _mainCat.AddToggle(Language.PreferedHandedTextOn, Language.PerferedHandTooltip, b =>
MelonPreferences.GetEntry<bool>(Main.Melon.Identifier, Main.PreferRightHand.Identifier).Value = b);
_handChange.Toggle(Main.PreferRightHand.Value);
_tpAction = _mainCat.AddToggle(Language.TheWordTeleport, $"Activate {Language.TheWordTeleport}", b => {
if (!CheckWorldAllowed.RiskyFunctionAllowed) return;
VRUtils.Active = !VRUtils.Active;
TPLocationIndicator.Toggle();
}, false, ResourceManager.mapmarker, null);
//TPAction.Toggle(VRUtils.active);
_waypointsCat = _teleportVr.AddCategory("Waypoints");
_wp1 = _waypointsCat.AddButton(Language.SavePos, Language.SavePosToolTip, () => SaveAction(1),
ResourceManager.one);
_wp2 = _waypointsCat.AddButton(Language.SavePos, Language.SavePosToolTip, () => SaveAction(2),
ResourceManager.two);
_wp3 = _waypointsCat.AddButton(Language.SavePos, Language.SavePosToolTip, () => SaveAction(3),
ResourceManager.three);
_wp4 = _waypointsCat.AddButton(Language.SavePos, Language.SavePosToolTip, () => SaveAction(4),
ResourceManager.four);
_wpl1 = _waypointsCat.AddButton(Language.LoadPos, Language.LoadPosTooltip, () => LoadAction(1),
ResourceManager.one);
_wpl2 = _waypointsCat.AddButton(Language.LoadPos, Language.LoadPosTooltip, () => LoadAction(2),
ResourceManager.two);
_wpl3 = _waypointsCat.AddButton(Language.LoadPos, Language.LoadPosTooltip, () => LoadAction(3),
ResourceManager.three);
_wpl4 = _waypointsCat.AddButton(Language.LoadPos, Language.LoadPosTooltip, () => LoadAction(4),
ResourceManager.four);
var t = _teleportVr.AddCategory("Information");
t.AddButton($"Mod v{BuildInfo.Version}", "", () => Main.Log("You're Cute!"), ResourceManager.ver);
t.AddButton("VRCMG", "Opens webpage to VRChat Modding Group's Discord Invite", () => OpenWebpage("https://discord.gg/7EQCmgrUnH"), ResourceManager.DiscordLogo);
t.AddButton("GitHub", "Opens a webpage to the Mod\'s GitHub project", () => OpenWebpage(BuildInfo.DownloadLink), ResourceManager.GitHubLogo);
BuildUserSelectMenu();
}
private static ReMenuCategory _userSelectCategory;
private static void BuildUserSelectMenu() {
var menuSelectedUserLocal = QuickMenuEx.Instance.field_Public_Transform_0.Find("Window/QMParent/Menu_SelectedUser_Local");
var theSelectedUserMenu = menuSelectedUserLocal.Find("ScrollRect/Viewport/VerticalLayoutGroup");
_userSelectCategory = new ReMenuCategory("TPVR", theSelectedUserMenu);
_userSelTp = _userSelectCategory.AddButton(Language.TheWordTeleport, $"{Language.TheWordTeleport} to Selected User", () => {
if (CheckWorldAllowed.RiskyFunctionAllowed)
PlayerActions.Teleport(PlayerActions.SelVRCPlayer());
}, ResourceManager.mapmarker);
_built = true;
}
internal static void OnPrefSave() {
if (!_built) return;
if (_teleportVr != null && _handChange != null)
_handChange.Toggle(Main.PreferRightHand.Value);
if (_userSelectCategory == null || _userSelTp == null) return;
_userSelectCategory.Active = Main.VRTeleportVisible.Value;
_userSelTp.Active = Main.VRTeleportVisible.Value;
UpdateButtonLanguage();
}
internal static void UpdateWorldActions(bool status) {
if (_mainCat != null)
_mainCat.Title = $"TPVR Actions ({(status ? "<color=#00ff00>Allowed</color>" : "<color=#ff0000>Disallowed</color>")})";
if (_tpAction != null)
_tpAction.Interactable = status;
if (_tpKeyboard != null)
_tpKeyboard.Interactable = status;
if (_tpCoord != null)
_tpCoord.Interactable = status;
if (_wp1 != null)
_wp1.Interactable = status;
if (_wp2 != null)
_wp2.Interactable = status;
if (_wp3 != null)
_wp3.Interactable = status;
if (_wp4 != null)
_wp4.Interactable = status;
if (_wpl1 != null)
_wpl1.Interactable = status;
if (_wpl2 != null)
_wpl2.Interactable = status;
if (_wpl3 != null)
_wpl3.Interactable = status;
if (_wpl4 != null)
_wpl4.Interactable = status;
}
private static void UpdateButtonLanguage() {
Language.InitLanguageChange();
if (_tpKeyboard != null) {
_tpKeyboard.Text = Language.TpToNameText;
_tpKeyboard.Tooltip = Language.TpToNameTooltip;
}
if (_tpCoord != null) {
_tpCoord.Text = Language.TpToCoordText;
_tpCoord.Tooltip = Language.TpToCoordTooltip;
}
if (_tpAction != null) {
_tpAction.Text = Language.TheWordTeleport;
_tpAction.Tooltip = $"Activate {Language.TheWordTeleport}";
}
if (_handChange != null) {
_handChange.Text = Language.PreferedHandedTextOn;
_handChange.Tooltip = Language.PerferedHandTooltip;
}
if (_wp1 != null) {
_wp1.Text = Language.SavePos;
_wp1.Tooltip = Language.SavePosToolTip;
}
if (_wp2 != null) {
_wp2.Text = Language.SavePos;
_wp2.Tooltip = Language.SavePosToolTip;
}
if (_wp3 != null) {
_wp3.Text = Language.SavePos;
_wp3.Tooltip = Language.SavePosToolTip;
}
if (_wp4 != null) {
_wp4.Text = Language.SavePos;
_wp4.Tooltip = Language.SavePosToolTip;
}
if (_wpl1 != null) {
_wpl1.Text = Language.LoadPos;
_wpl1.Tooltip = Language.LoadPosTooltip;
}
if (_wpl2 != null) {
_wpl2.Text = Language.LoadPos;
_wpl2.Tooltip = Language.LoadPosTooltip;
}
if (_wpl3 != null) {
_wpl3.Text = Language.LoadPos;
_wpl3.Tooltip = Language.LoadPosTooltip;
}
if (_wpl4 != null) {
_wpl4.Text = Language.LoadPos;
_wpl4.Tooltip = Language.LoadPosTooltip;
}
}
}
}