Skip to content
This repository was archived by the owner on Jan 24, 2023. It is now read-only.

Commit 3eee461

Browse files
committed
Made reflection reflect more betterer, fixed tooltips not tooltipping, fixed toggles not updating visually.
1 parent 3f9a638 commit 3eee461

File tree

4 files changed

+43
-20
lines changed

4 files changed

+43
-20
lines changed

UI/QuickMenu/ReMenuButton.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,23 @@ public ReMenuButton(string text, string tooltip, Action onClick, Transform paren
9898
Object.DestroyImmediate(RectTransform.Find("Badge_Close").gameObject);
9999
Object.DestroyImmediate(RectTransform.Find("Badge_MMJump").gameObject);
100100

101-
var uiTooltip = GameObject.GetComponent<VRC.UI.Elements.Tooltips.UiTooltip>();
102-
uiTooltip.field_Public_String_0 = tooltip;
103-
uiTooltip.field_Public_String_1 = tooltip;
104-
101+
var uiTooltips = GameObject.GetComponents<VRC.UI.Elements.Tooltips.UiTooltip>();
102+
VRC.UI.Elements.Tooltips.UiTooltip uiTooltip = null;
103+
if (uiTooltips.Length > 0)
104+
{
105+
//Fuck tooltips, all my friends hate tooltips
106+
uiTooltip = uiTooltips[0];
107+
108+
for(int i=1; i<uiTooltips.Length; i++)
109+
Object.DestroyImmediate(uiTooltips[i]);
110+
}
111+
112+
if (uiTooltip != null)
113+
{
114+
uiTooltip.field_Public_String_0 = tooltip;
115+
uiTooltip.field_Public_String_1 = tooltip;
116+
}
117+
105118
if (onClick != null)
106119
{
107120
_button = GameObject.GetComponent<Button>();

UI/QuickMenu/ReMenuToggle.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,23 +124,23 @@ private void FindToggleIcon()
124124
}
125125
}
126126

127-
private List<Action<bool>> _onValueChanged;
127+
private List<Action> _onValueChanged;
128128

129129
private void OnValueChanged(bool arg0)
130130
{
131131
if (_onValueChanged == null)
132132
{
133-
_onValueChanged = new List<Action<bool>>();
133+
_onValueChanged = new List<Action>();
134134
foreach (var methodInfo in _toggleIcon.GetType().GetMethods().Where(m =>
135-
m.Name.StartsWith("Method_Private_Void_Boolean_PDM_") && XrefUtils.CheckMethod(m, "Toggled")))
135+
m.Name.StartsWith("Method_Public_Void_") && XrefUtils.CheckMethod(m, "Toggled")))
136136
{
137-
_onValueChanged.Add((Action<bool>)Delegate.CreateDelegate(typeof(Action<bool>), _toggleIcon, methodInfo));
137+
_onValueChanged.Add((Action)Delegate.CreateDelegate(typeof(Action), _toggleIcon, methodInfo));
138138
}
139139
}
140140

141141
foreach (var onValueChanged in _onValueChanged)
142142
{
143-
onValueChanged(arg0);
143+
onValueChanged();
144144
}
145145
}
146146

VRChat/QuickMenuExtensions.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace ReMod.Core.VRChat
99
{
1010
public static class QuickMenuExtensions
1111
{
12-
public delegate void ShowConfirmDialogDelegate(UIMenu uiMenu, string title, string body, Il2CppSystem.Action onYes, Il2CppSystem.Action onNo=null);
12+
public delegate void ShowConfirmDialogDelegate(UIMenu uiMenu, string title, string body, Il2CppSystem.Action onYes, Il2CppSystem.Action onNo=null, string confirmText = "Yes", string declineText = "No");
1313
private static ShowConfirmDialogDelegate _showConfirmDialogDelegate;
1414

1515
private static ShowConfirmDialogDelegate ShowConfirmDialogFn
@@ -21,7 +21,7 @@ private static ShowConfirmDialogDelegate ShowConfirmDialogFn
2121

2222
var showConfirmDialogFn = typeof(UIMenu).GetMethods().FirstOrDefault(m =>
2323
{
24-
if (!m.Name.Contains("Public_Void_String_String_Action_Action_PDM_"))
24+
if (!m.Name.Contains("Public_Void_String_String_Action_Action_String_String_"))
2525
return false;
2626

2727
return XrefUtils.CheckMethod(m, "ConfirmDialog");
@@ -49,7 +49,7 @@ private static ShowConfirmDialogWithCancelDelegate ShowConfirmDialogWithCancelFn
4949

5050
var showConfirmDialogWithCancelFn = typeof(UIMenu).GetMethods().FirstOrDefault(m =>
5151
{
52-
if (!m.Name.Contains("Method_Public_Void_String_String_String_String_String_Action_Action_Action"))
52+
if (!m.Name.Contains("Method_Public_Void_String_String_String_String_String_Action_Action_Action_"))
5353
return false;
5454

5555
return XrefUtils.CheckMethod(m, "ConfirmDialog");
@@ -72,7 +72,7 @@ private static ShowAlertDialogDelegate ShowAlertDialogFn
7272

7373
var showAlertDialogFn = typeof(UIMenu).GetMethods().FirstOrDefault(m =>
7474
{
75-
if (!m.Name.Contains("Method_Public_Void_String_String_Action_PDM"))
75+
if (!m.Name.Contains("Method_Public_Void_String_String_Action_String_Boolean_PDM"))
7676
return false;
7777

7878
return XrefUtils.CheckMethod(m, "ConfirmDialog");
@@ -82,10 +82,15 @@ private static ShowAlertDialogDelegate ShowAlertDialogFn
8282
return _showAlertDialogDelegate;
8383
}
8484
}
85+
86+
public static void ShowConfirmDialog(this UIMenu uiMenu, string title, string body, Action onYes, Action onNo = null)
87+
{
88+
ShowConfirmDialog(uiMenu, title, body, "Yes", "No", onYes, onNo);
89+
}
8590

86-
public static void ShowConfirmDialog(this UIMenu uiMenu, string title, string body, Action onYes, Action onNo=null)
91+
public static void ShowConfirmDialog(this UIMenu uiMenu, string title, string body, string confirmText, string declineText, Action onYes, Action onNo=null)
8792
{
88-
ShowConfirmDialogFn.Invoke(uiMenu, title, body, onYes, onNo);
93+
ShowConfirmDialogFn.Invoke(uiMenu, title, body, onYes, onNo, confirmText, declineText);
8994
}
9095

9196
public static void ShowConfirmDialogWithCancel(this UIMenu uiMenu, string title, string body, string yesLabel, string noLabel, string cancelLabel, Action onYes, Action onNo, Action onCancel)
@@ -94,6 +99,11 @@ public static void ShowConfirmDialogWithCancel(this UIMenu uiMenu, string title,
9499
}
95100

96101
public static void ShowAlertDialog(this UIMenu uiMenu, string title, string body, Action onClose = null)
102+
{
103+
ShowAlertDialog(uiMenu, title, body, "Close", onClose);
104+
}
105+
106+
public static void ShowAlertDialog(this UIMenu uiMenu, string title, string body, string closeText, Action onClose = null)
97107
{
98108
ShowAlertDialogFn.Invoke(uiMenu, title, body, onClose);
99109
}

VRChat/VrcUiExtensions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static class VrcUiExtensions
1515
{
1616
public static GameObject MenuContent(this VRCUiManager uiManager)
1717
{
18-
return uiManager.field_Public_GameObject_0;
18+
return uiManager.field_Private_Transform_0.gameObject;
1919
}
2020

2121
public static void StartRenderElementsCoroutine(this UiVRCList instance, Il2CppSystem.Collections.Generic.List<ApiAvatar> avatarList, int offset = 0, bool endOfPickers = true, VRCUiContentButton contentHeaderElement = null)
@@ -44,19 +44,19 @@ public static void QueueHudMessage(this VRCUiManager uiManager, string notificat
4444
}
4545

4646
private delegate void PushPageDelegate(MenuStateController menuStateCtrl, string pageName, UIContext uiContext,
47-
bool clearPageStack);
47+
bool clearPageStack, UIPage.TransitionType transitionType);
4848
private static PushPageDelegate _pushPage;
4949

5050
public static void PushPage(this MenuStateController menuStateCtrl, string pageName, UIContext uiContext = null,
51-
bool clearPageStack = false)
51+
bool clearPageStack = false, UIPage.TransitionType transitionType = UIPage.TransitionType.Right)
5252
{
5353
if (_pushPage == null)
5454
{
5555
_pushPage = (PushPageDelegate)Delegate.CreateDelegate(typeof(PushPageDelegate),
56-
typeof(MenuStateController).GetMethods().FirstOrDefault(m => m.GetParameters().Length == 3 && m.Name.StartsWith("Method_Public_Void_String_UIContext_Boolean_") && XrefUtils.CheckMethod(m, "No page named")));
56+
typeof(MenuStateController).GetMethods().FirstOrDefault(m => m.GetParameters().Length == 4 && m.Name.StartsWith("Method_Public_Void_String_UIContext_Boolean_TransitionType_") && XrefUtils.CheckMethod(m, "No page named")));
5757
}
5858

59-
_pushPage(menuStateCtrl, pageName, uiContext, clearPageStack);
59+
_pushPage(menuStateCtrl, pageName, uiContext, clearPageStack, transitionType);
6060
}
6161

6262
private delegate void SwitchToRootPageDelegate(MenuStateController menuStateCtrl, string pageName, UIContext uiContext,

0 commit comments

Comments
 (0)