From 70ae581f6931db19abcdfad4555e8cd382a67113 Mon Sep 17 00:00:00 2001 From: xMiraiChan Date: Sun, 28 Nov 2021 16:03:05 -0500 Subject: [PATCH 1/3] project refactoring --- ComfyQM Standalone.csproj | 39 ++++++++++++---------- ComfyQM.cs | 68 +++++++++++++++----------------------- Properties/AssemblyInfo.cs | 40 ---------------------- 3 files changed, 47 insertions(+), 100 deletions(-) delete mode 100644 Properties/AssemblyInfo.cs diff --git a/ComfyQM Standalone.csproj b/ComfyQM Standalone.csproj index f65c734..9f4955c 100644 --- a/ComfyQM Standalone.csproj +++ b/ComfyQM Standalone.csproj @@ -17,7 +17,7 @@ true full false - C:\Users\Chris\source\repos\ + bin\Debug\ DEBUG;TRACE prompt 4 @@ -30,55 +30,58 @@ prompt 4 + + OnOutputUpdated + - D:\SteamLibrary\steamapps\common\VRChat\MelonLoader\Managed\Assembly-CSharp.dll + C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\Assembly-CSharp.dll - D:\SteamLibrary\steamapps\common\VRChat\MelonLoader\Managed\Il2Cppmscorlib.dll + C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\Il2Cppmscorlib.dll - D:\SteamLibrary\steamapps\common\VRChat\MelonLoader\MelonLoader.dll + C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\MelonLoader.dll - - - - - - D:\SteamLibrary\steamapps\common\VRChat\Mods\UIExpansionKit.dll + C:\Program Files (x86)\Steam\steamapps\common\VRChat\Mods\UIExpansionKit.dll - D:\SteamLibrary\steamapps\common\VRChat\MelonLoader\Managed\UnhollowerBaseLib.dll + C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\UnhollowerBaseLib.dll - D:\SteamLibrary\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.dll + C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.dll - D:\SteamLibrary\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.CoreModule.dll + C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.CoreModule.dll False - D:\SteamLibrary\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.VRModule.dll + C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.VRModule.dll False - D:\SteamLibrary\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.XRModule.dll + C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.XRModule.dll False - D:\SteamLibrary\steamapps\common\VRChat\MelonLoader\Managed\VRC.UI.Core.dll + C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\VRC.UI.Core.dll - D:\SteamLibrary\steamapps\common\VRChat\MelonLoader\Managed\VRC.UI.Elements.dll + C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\VRC.UI.Elements.dll - + + + + + COPY "$(TargetPath)" "C:\Program Files (x86)\Steam\steamapps\common\VRChat\Mods\$(TargetFileName)" + \ No newline at end of file diff --git a/ComfyQM.cs b/ComfyQM.cs index 7017ff7..ed8fc09 100644 --- a/ComfyQM.cs +++ b/ComfyQM.cs @@ -5,6 +5,9 @@ using UnityEngine.XR; using VRC.UI.Core; +[assembly: MelonInfo(typeof(ComfyQM_Standalone.ComfyQM), "ComfyQM", "1.2.0", "xaiver")] +[assembly: MelonGame("VRChat", "VRChat")] + namespace ComfyQM_Standalone { public class ComfyQM : MelonMod @@ -17,65 +20,46 @@ public class ComfyQM : MelonMod public IEnumerator WaitForUIMan() { - while (VRCUiManager.field_Private_Static_VRCUiManager_0 == null) yield return null; - while (UIManager.field_Private_Static_UIManager_0 == null) yield return null; + while (VRCUiManager.field_Private_Static_VRCUiManager_0 is null) yield return null; + while (UIManager.field_Private_Static_UIManager_0 is null) yield return null; while (GameObject.Find("UserInterface").GetComponentInChildren(true) == null) yield return null; + QuickMenuObject = GameObject.Find("UserInterface").GetComponentInChildren(true).gameObject; - OnUIManInit(); + LeftHand = VRCUiCursorManager.field_Private_Static_VRCUiCursorManager_0.transform.Find("DotLeftHand").gameObject; + RightHand = VRCUiCursorManager.field_Private_Static_VRCUiCursorManager_0.transform.Find("DotRightHand").gameObject; } - public override void OnApplicationStart() { ComfyQuickMenu = MelonPreferences.CreateCategory("ComfyQM"); ComfyToggle = ComfyQuickMenu.CreateEntry("ComfyQM Toggle", false); + if (!XRDevice.isPresent) return; + MelonCoroutines.Start(WaitForUIMan()); - - HarmonyInstance.Patch(typeof(VRC.UI.Elements.QuickMenu).GetMethod(nameof(VRC.UI.Elements.QuickMenu.Method_Private_Boolean_0)), - typeof(ComfyQM).GetMethod(nameof(IsAttachedToHandPatch), BindingFlags.NonPublic | BindingFlags.Static).ToNewHarmonyMethod()); - HarmonyInstance.Patch(typeof(VRC.UI.Elements.QuickMenu).GetMethod(nameof(VRC.UI.Elements.QuickMenu.Method_Private_Boolean_1)), - typeof(ComfyQM).GetMethod(nameof(IsAttachedToHandPatch), BindingFlags.NonPublic | BindingFlags.Static).ToNewHarmonyMethod()); - } + HarmonyInstance.Patch( + typeof(VRC.UI.Elements.QuickMenu).GetMethod(nameof(VRC.UI.Elements.QuickMenu.Method_Private_Boolean_0)), + typeof(ComfyQM).GetMethod(nameof(IsAttachedToHandPatch), BindingFlags.NonPublic | BindingFlags.Static).ToNewHarmonyMethod() + ); - public void OnUIManInit() - { - LeftHand = VRCUiCursorManager.field_Private_Static_VRCUiCursorManager_0.transform.Find("DotLeftHand").gameObject; - RightHand = VRCUiCursorManager.field_Private_Static_VRCUiCursorManager_0.transform.Find("DotRightHand").gameObject; + HarmonyInstance.Patch( + typeof(VRC.UI.Elements.QuickMenu).GetMethod(nameof(VRC.UI.Elements.QuickMenu.Method_Private_Boolean_1)), + typeof(ComfyQM).GetMethod(nameof(IsAttachedToHandPatch), BindingFlags.NonPublic | BindingFlags.Static).ToNewHarmonyMethod() + ); } public override void OnUpdate() - { - if (LeftHand == null || RightHand == null) - { - return; - } - if (!QuickMenuObject.active) - { + { + if (!QuickMenuObject.active || !ComfyToggle.Value) return; - } - if (ComfyToggle.Value == true) - { - LeftHand.SetActive(true); - RightHand.SetActive(true); - VRCUiCursorManager.field_Private_Static_VRCUiCursorManager_0.field_Private_Boolean_2 = false; - VRCUiCursorManager.field_Private_Static_VRCUiCursorManager_0.field_Private_Boolean_7 = false; - } - } - private static bool IsAttachedToHandPatch(ref bool __result) - { - if (XRDevice.isPresent == false) - { - return true; - } - if (ComfyToggle.Value) - { - __result = false; - return false; - } - return true; + LeftHand?.SetActive(true); + RightHand?.SetActive(true); + VRCUiCursorManager.field_Private_Static_VRCUiCursorManager_0.field_Private_Boolean_2 = false; + VRCUiCursorManager.field_Private_Static_VRCUiCursorManager_0.field_Private_Boolean_7 = false; } + + private static bool IsAttachedToHandPatch(ref bool __result) => !ComfyToggle.Value || (__result = false); } } \ No newline at end of file diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs deleted file mode 100644 index a974d30..0000000 --- a/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using MelonLoader; -using ComfyQM_Standalone; - - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("ComfyQM Standalone")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ComfyQM Standalone")] -[assembly: AssemblyCopyright("Copyright © 2021")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -[assembly: MelonInfo(typeof(ComfyQM), "ComfyQM", "1.2.0", "xaiver")] -[assembly: MelonGame("VRChat", "VRChat")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("2a5d53cb-8b0e-4fa6-b800-1204e11f0589")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] From c5f0303db869eb3a8bfedd159fdf573f697d7f3d Mon Sep 17 00:00:00 2001 From: xMiraiChan Date: Sun, 28 Nov 2021 16:09:35 -0500 Subject: [PATCH 2/3] minor optimization --- ComfyQM.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ComfyQM.cs b/ComfyQM.cs index ed8fc09..d2a4596 100644 --- a/ComfyQM.cs +++ b/ComfyQM.cs @@ -22,9 +22,8 @@ public IEnumerator WaitForUIMan() { while (VRCUiManager.field_Private_Static_VRCUiManager_0 is null) yield return null; while (UIManager.field_Private_Static_UIManager_0 is null) yield return null; - while (GameObject.Find("UserInterface").GetComponentInChildren(true) == null) yield return null; + while ((QuickMenuObject = GameObject.Find("UserInterface").GetComponentInChildren(true)?.gameObject) is null) yield return null; - QuickMenuObject = GameObject.Find("UserInterface").GetComponentInChildren(true).gameObject; LeftHand = VRCUiCursorManager.field_Private_Static_VRCUiCursorManager_0.transform.Find("DotLeftHand").gameObject; RightHand = VRCUiCursorManager.field_Private_Static_VRCUiCursorManager_0.transform.Find("DotRightHand").gameObject; } From 4cfcb24f659cb9507ce8babd4f294a93ac009e85 Mon Sep 17 00:00:00 2001 From: xMiraiChan Date: Sun, 28 Nov 2021 20:16:40 -0500 Subject: [PATCH 3/3] bug fix --- ComfyQM.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ComfyQM.cs b/ComfyQM.cs index d2a4596..894fdc3 100644 --- a/ComfyQM.cs +++ b/ComfyQM.cs @@ -50,7 +50,7 @@ public override void OnApplicationStart() public override void OnUpdate() { - if (!QuickMenuObject.active || !ComfyToggle.Value) + if (QuickMenuObject is null || !QuickMenuObject.active || !ComfyToggle.Value) return; LeftHand?.SetActive(true);