This repository was archived by the owner on Jan 24, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathQuickMenuExtensions.cs
127 lines (104 loc) · 5.96 KB
/
QuickMenuExtensions.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
using System;
using System.Linq;
using System.Reflection;
using UnhollowerRuntimeLib.XrefScans;
using VRC.UI;
using VRC.UI.Elements;
namespace ReMod.Core.VRChat
{
public static class QuickMenuExtensions
{
public delegate void ShowConfirmDialogDelegate(UIMenu uiMenu, string title, string body, Il2CppSystem.Action onYes, Il2CppSystem.Action onNo=null, string confirmText = "Yes", string declineText = "No");
private static ShowConfirmDialogDelegate _showConfirmDialogDelegate;
private static ShowConfirmDialogDelegate ShowConfirmDialogFn
{
get
{
if (_showConfirmDialogDelegate != null)
return _showConfirmDialogDelegate;
var showConfirmDialogFn = typeof(UIMenu).GetMethods().FirstOrDefault(m =>
{
if (!m.Name.Contains("Public_Void_String_String_Action_Action_String_String_"))
return false;
return XrefUtils.CheckMethod(m, "ConfirmDialog");
});
_showConfirmDialogDelegate = (ShowConfirmDialogDelegate)Delegate.CreateDelegate(typeof(ShowConfirmDialogDelegate), showConfirmDialogFn);
return _showConfirmDialogDelegate;
}
}
public static bool IsActive(this VRC.UI.Elements.QuickMenu quickMenu)
{
return quickMenu.gameObject.activeSelf;
}
public delegate void ShowConfirmDialogWithCancelDelegate(UIMenu uiMenu, string title, string body, string yesLabel, string noLabel, string cancelLabel, Il2CppSystem.Action onYes, Il2CppSystem.Action onNo, Il2CppSystem.Action onCancel);
private static ShowConfirmDialogWithCancelDelegate _showConfirmDialogWithCancelDelegate;
private static ShowConfirmDialogWithCancelDelegate ShowConfirmDialogWithCancelFn
{
get
{
if (_showConfirmDialogWithCancelDelegate != null)
return _showConfirmDialogWithCancelDelegate;
var showConfirmDialogWithCancelFn = typeof(UIMenu).GetMethods().FirstOrDefault(m =>
{
if (!m.Name.Contains("Method_Public_Void_String_String_String_String_String_Action_Action_Action_"))
return false;
return XrefUtils.CheckMethod(m, "ConfirmDialog");
});
_showConfirmDialogWithCancelDelegate = (ShowConfirmDialogWithCancelDelegate)Delegate.CreateDelegate(typeof(ShowConfirmDialogWithCancelDelegate), showConfirmDialogWithCancelFn);
return _showConfirmDialogWithCancelDelegate;
}
}
public delegate void ShowAlertDialogDelegate(UIMenu uiMenu, string title, string body, Il2CppSystem.Action onClose, string closeText = "Close", bool unknown = false);
private static ShowAlertDialogDelegate _showAlertDialogDelegate;
private static ShowAlertDialogDelegate ShowAlertDialogFn
{
get
{
if (_showAlertDialogDelegate != null)
return _showAlertDialogDelegate;
var showAlertDialogFn = typeof(UIMenu).GetMethods().FirstOrDefault(m =>
{
if (!m.Name.Contains("Method_Public_Void_String_String_Action_String_Boolean_PDM"))
return false;
return XrefUtils.CheckMethod(m, "ConfirmDialog");
});
_showAlertDialogDelegate = (ShowAlertDialogDelegate)Delegate.CreateDelegate(typeof(ShowAlertDialogDelegate), showAlertDialogFn);
return _showAlertDialogDelegate;
}
}
public static void ShowConfirmDialog(this UIMenu uiMenu, string title, string body, Action onYes, Action onNo = null)
{
ShowConfirmDialog(uiMenu, title, body, "Yes", "No", onYes, onNo);
}
public static void ShowConfirmDialog(this UIMenu uiMenu, string title, string body, string confirmText, string declineText, Action onYes, Action onNo=null)
{
ShowConfirmDialogFn.Invoke(uiMenu, title, body, onYes, onNo, confirmText, declineText);
}
public static void ShowConfirmDialogWithCancel(this UIMenu uiMenu, string title, string body, string yesLabel, string noLabel, string cancelLabel, Action onYes, Action onNo, Action onCancel)
{
ShowConfirmDialogWithCancelFn.Invoke(uiMenu, title, body, yesLabel, noLabel, cancelLabel, onYes, onNo, onCancel);
}
public static void ShowAlertDialog(this UIMenu uiMenu, string title, string body, Action onClose = null)
{
ShowAlertDialog(uiMenu, title, body, "Close", onClose);
}
public static void ShowAlertDialog(this UIMenu uiMenu, string title, string body, string closeText, Action onClose = null)
{
ShowAlertDialogFn.Invoke(uiMenu, title, body, onClose, closeText, false);
}
private static MethodInfo _closeQuickMenuMethod;
public static void CloseQuickMenu(this UIManagerImpl uiManager)
{
if (_closeQuickMenuMethod == null)
{
var closeMenuMethod = typeof(UIManagerImpl).GetMethods()
.First(method => method.Name.StartsWith("Method_Public_Virtual_Final_New_Void_") && XrefScanner.XrefScan(method).Count() == 2);
_closeQuickMenuMethod = typeof(UIManagerImpl).GetMethods()
.First(method => method.Name.StartsWith("Method_Public_Void_Boolean_") && XrefUtils.CheckUsedBy(method, closeMenuMethod.Name));
VRCUiCursorManager.field_Private_Static_VRCUiCursorManager_0.field_Private_Boolean_6 = false;
VRCUiCursorManager.field_Private_Static_VRCUiCursorManager_0.field_Private_Boolean_0 = true;
}
_closeQuickMenuMethod.Invoke(uiManager, new object[1] { false });
}
}
}