diff --git a/ActionMenuApi/Tools.cs b/ActionMenuApi/AMAPI.cs similarity index 98% rename from ActionMenuApi/Tools.cs rename to ActionMenuApi/AMAPI.cs index f0f1f5e..ff3b7e0 100644 --- a/ActionMenuApi/Tools.cs +++ b/ActionMenuApi/AMAPI.cs @@ -1,224 +1,225 @@ -using System; -using ActionMenuApi.Pedals; -using UnhollowerRuntimeLib; -using UnityEngine; -using PedalOptionTriggerEvent = PedalOption.MulticastDelegateNPublicSealedBoUnique; //Will this change?, ¯\_(ツ)_/¯ -using ActionMenuPage = ActionMenu.ObjectNPublicAcTeAcStGaUnique; //Will this change?, ¯\_(ツ)_/¯x2 - -namespace ActionMenuApi -{ - public static class AMAPI - { - - public static void AddButtonPedalToMenu(ActionMenuPageType pageType, Action triggerEvent, string text = "Button Text", Texture2D icon = null, Insertion insertion = Insertion.Post) - { - AddPedalToList( - pageType, - new PedalButton( - text, - icon, - triggerEvent - ), - insertion - ); - } - - public static PedalOption AddButtonPedalToSubMenu(Action triggerEvent, string text = "Button Text", Texture2D icon = null) - { - ActionMenuOpener actionMenuOpener = Utilities.GetActionMenuOpener(); - if (actionMenuOpener == null) return null; - PedalOption pedalOption = actionMenuOpener.GetActionMenu().AddOption(); - pedalOption.setText(text); - pedalOption.setIcon(icon); - pedalOption.field_Public_MulticastDelegateNPublicSealedBoUnique_0 = DelegateSupport.ConvertDelegate(triggerEvent); - return pedalOption; - } - - public static void AddRadialPedalToMenu(ActionMenuPageType pageType, Action onUpdate, string text = "Button Text", float startingValue = 0, Texture2D icon = null, Insertion insertion = Insertion.Post) - { - AddPedalToList( - pageType, - new PedalRadial( - text, - startingValue, - icon, - onUpdate - ), - insertion - ); - } - - public static PedalOption AddRadialPedalToSubMenu(Action onUpdate, string text = "Button Text", float startingValue = 0, Texture2D icon = null) - { - ActionMenuOpener actionMenuOpener = Utilities.GetActionMenuOpener(); - if (actionMenuOpener == null) return null; - PedalOption pedalOption = actionMenuOpener.GetActionMenu().AddOption(); - pedalOption.setText(text); - pedalOption.setIcon(icon); - pedalOption.field_Public_ActionButton_0.prop_String_1 = $"{Math.Round(startingValue)}%"; - pedalOption.field_Public_ActionButton_0.prop_Texture2D_2 = Utilities.GetExpressionsIcons().typeRadial; - pedalOption.field_Public_MulticastDelegateNPublicSealedBoUnique_0 = DelegateSupport.ConvertDelegate(new Action(delegate - { - Action combinedAction = (System.Action)Delegate.Combine(new Action(delegate(float f) - { - startingValue = f; - - pedalOption.field_Public_ActionButton_0.prop_String_1 = $"{Math.Round(startingValue)}%"; - }), onUpdate); - RadialPuppetManager.OpenRadialMenu(startingValue, combinedAction, text); - })); - return pedalOption; - } - - public static void AddFourAxisPedalToMenu(ActionMenuPageType pageType, string text, Vector2 startingValue, Action onUpdate,Texture2D icon = null, Insertion insertion = Insertion.Post, string topButtonText = "Up", - string rightButtonText = "Right", string downButtonText = "Down", string leftButtonText = "Left") - { - AddPedalToList( - pageType, - new PedalFourAxis( - text, - startingValue, - icon, - onUpdate, - topButtonText, - rightButtonText, - downButtonText, - leftButtonText - ), - insertion - ); - } - - public static PedalOption AddFourAxisPedalToSubMenu(string text, Vector2 startingValue, Action onUpdate,Texture2D icon = null, string topButtonText = "Up", - string rightButtonText = "Right", string downButtonText = "Down", string leftButtonText = "Left") - { - ActionMenuOpener actionMenuOpener = Utilities.GetActionMenuOpener(); - if (actionMenuOpener == null) return null; - PedalOption pedalOption = actionMenuOpener.GetActionMenu().AddOption(); - pedalOption.setText(text); - pedalOption.setIcon(icon); - pedalOption.field_Public_ActionButton_0.prop_Texture2D_2 = Utilities.GetExpressionsIcons().typeAxis; - pedalOption.field_Public_MulticastDelegateNPublicSealedBoUnique_0 = DelegateSupport.ConvertDelegate(new Action(delegate - { - FourAxisPuppetManager.OpenFourAxisMenu(startingValue, v => startingValue = v, text, onUpdate); - FourAxisPuppetManager.current.GetButtonUp().SetButtonText(topButtonText); - FourAxisPuppetManager.current.GetButtonRight().SetButtonText(rightButtonText); - FourAxisPuppetManager.current.GetButtonDown().SetButtonText(downButtonText); - FourAxisPuppetManager.current.GetButtonLeft().SetButtonText(leftButtonText); - })); - return pedalOption; - } - - public static void AddSubMenuToMenu(ActionMenuPageType pageType, Action openFunc, string text = null, - Texture2D icon = null, Action closeFunc = null, Insertion insertion = Insertion.Post) - { - AddPedalToList( - pageType, - new PedalSubMenu( - openFunc, - text, - icon, - closeFunc - ), - insertion - ); - } - - public static void AddTogglePedalToMenu(ActionMenuPageType pageType,bool startingState, System.Action onToggle, string text, Texture2D icon = null, Insertion insertion = Insertion.Post) - { - AddPedalToList( - pageType, - new PedalToggle( - text, - onToggle, - startingState, - icon - ), - insertion - ); - } - - - public static PedalOption AddTogglePedalToSubMenu(Action onToggle, bool startingState, string text, Texture2D icon = null) - { - - ActionMenuOpener actionMenuOpener = Utilities.GetActionMenuOpener(); - if (actionMenuOpener == null) return null; - PedalOption pedalOption = actionMenuOpener.GetActionMenu().AddOption(); - pedalOption.setText(text); - pedalOption.setIcon(icon); - if (startingState) pedalOption.field_Public_ActionButton_0.prop_Texture2D_2 = Utilities.GetExpressionsIcons().typeToggleOn; - else pedalOption.field_Public_ActionButton_0.prop_Texture2D_2 = Utilities.GetExpressionsIcons().typeToggleOff; - pedalOption.field_Public_MulticastDelegateNPublicSealedBoUnique_0 = DelegateSupport.ConvertDelegate(new Action(delegate - { - startingState = !startingState; - if (startingState) - pedalOption.field_Public_ActionButton_0.prop_Texture2D_2 = Utilities.GetExpressionsIcons().typeToggleOn; - else - pedalOption.field_Public_ActionButton_0.prop_Texture2D_2 = Utilities.GetExpressionsIcons().typeToggleOff; - onToggle.Invoke(startingState); - })); - return pedalOption; - } - - - - - private static void AddPedalToList(ActionMenuPageType pageType, PedalStruct customPedal, Insertion insertion) - { - switch (pageType) - { - case ActionMenuPageType.SDK2Expression: - if(insertion == Insertion.Pre) Patches.sdk2ExpressionPagePre.Add(customPedal); - else if(insertion == Insertion.Post) Patches.sdk2ExpressionPagePost.Add(customPedal); - break; - case ActionMenuPageType.Config: - if (insertion == Insertion.Pre) Patches.configPagePre.Add(customPedal); - else if (insertion == Insertion.Post) Patches.configPagePost.Add(customPedal); - break; - case ActionMenuPageType.Emojis: - if (insertion == Insertion.Pre) Patches.emojisPagePre.Add(customPedal); - else if (insertion == Insertion.Post) Patches.emojisPagePost.Add(customPedal); - break; - case ActionMenuPageType.Expression: - if (insertion == Insertion.Pre) Patches.expressionPagePre.Add(customPedal); - else if (insertion == Insertion.Post) Patches.expressionPagePost.Add(customPedal); - break; - case ActionMenuPageType.Main: - if (insertion == Insertion.Pre) Patches.mainPagePre.Add(customPedal); - else if (insertion == Insertion.Post) Patches.mainPagePost.Add(customPedal); - break; - case ActionMenuPageType.MenuOpacity: - if (insertion == Insertion.Pre) Patches.menuOpacityPagePre.Add(customPedal); - else if (insertion == Insertion.Post) Patches.menuOpacityPagePost.Add(customPedal); - break; - case ActionMenuPageType.MenuSize: - if (insertion == Insertion.Pre) Patches.menuSizePagePre.Add(customPedal); - else if (insertion == Insertion.Post) Patches.menuSizePagePost.Add(customPedal); - break; - case ActionMenuPageType.Nameplates: - if (insertion == Insertion.Pre) Patches.nameplatesPagePre.Add(customPedal); - else if (insertion == Insertion.Post) Patches.nameplatesPagePost.Add(customPedal); - break; - case ActionMenuPageType.NameplatesOpacity: - if (insertion == Insertion.Pre) Patches.nameplatesOpacityPagePre.Add(customPedal); - else if (insertion == Insertion.Post) Patches.nameplatesOpacityPagePost.Add(customPedal); - break; - case ActionMenuPageType.NameplatesSize: - if (insertion == Insertion.Pre) Patches.nameplatesSizePagePre.Add(customPedal); - else if (insertion == Insertion.Post) Patches.nameplatesSizePagePost.Add(customPedal); - break; - case ActionMenuPageType.NameplatesVisibilty: - if (insertion == Insertion.Pre) Patches.nameplatesVisibilityPagePre.Add(customPedal); - else if (insertion == Insertion.Post) Patches.nameplatesVisibilityPagePost.Add(customPedal); - break; - case ActionMenuPageType.Options: - if (insertion == Insertion.Pre) Patches.optionsPagePre.Add(customPedal); - else if (insertion == Insertion.Post) Patches.optionsPagePost.Add(customPedal); - break; - } - } - - - } +using System; +using ActionMenuApi.Pedals; +using ActionMenuApi.Managers; +using UnhollowerRuntimeLib; +using UnityEngine; +using PedalOptionTriggerEvent = PedalOption.MulticastDelegateNPublicSealedBoUnique; //Will this change?, ¯\_(ツ)_/¯ +using ActionMenuPage = ActionMenu.ObjectNPublicAcTeAcStGaUnique; //Will this change?, ¯\_(ツ)_/¯x2 + +namespace ActionMenuApi +{ + public static class AMAPI + { + + public static void AddButtonPedalToMenu(ActionMenuPageType pageType, Action triggerEvent, string text = "Button Text", Texture2D icon = null, Insertion insertion = Insertion.Post) + { + AddPedalToList( + pageType, + new PedalButton( + text, + icon, + triggerEvent + ), + insertion + ); + } + + public static PedalOption AddButtonPedalToSubMenu(Action triggerEvent, string text = "Button Text", Texture2D icon = null) + { + ActionMenuOpener actionMenuOpener = Utilities.GetActionMenuOpener(); + if (actionMenuOpener == null) return null; + PedalOption pedalOption = actionMenuOpener.GetActionMenu().AddOption(); + pedalOption.setText(text); + pedalOption.setIcon(icon); + pedalOption.field_Public_MulticastDelegateNPublicSealedBoUnique_0 = DelegateSupport.ConvertDelegate(triggerEvent); + return pedalOption; + } + + public static void AddRadialPedalToMenu(ActionMenuPageType pageType, Action onUpdate, string text = "Button Text", float startingValue = 0, Texture2D icon = null, Insertion insertion = Insertion.Post) + { + AddPedalToList( + pageType, + new PedalRadial( + text, + startingValue, + icon, + onUpdate + ), + insertion + ); + } + + public static PedalOption AddRadialPedalToSubMenu(Action onUpdate, string text = "Button Text", float startingValue = 0, Texture2D icon = null) + { + ActionMenuOpener actionMenuOpener = Utilities.GetActionMenuOpener(); + if (actionMenuOpener == null) return null; + PedalOption pedalOption = actionMenuOpener.GetActionMenu().AddOption(); + pedalOption.setText(text); + pedalOption.setIcon(icon); + pedalOption.field_Public_ActionButton_0.prop_String_1 = $"{Math.Round(startingValue)}%"; + pedalOption.field_Public_ActionButton_0.prop_Texture2D_2 = Utilities.GetExpressionsIcons().typeRadial; + pedalOption.field_Public_MulticastDelegateNPublicSealedBoUnique_0 = DelegateSupport.ConvertDelegate(new Action(delegate + { + Action combinedAction = (System.Action)Delegate.Combine(new Action(delegate(float f) + { + startingValue = f; + + pedalOption.field_Public_ActionButton_0.prop_String_1 = $"{Math.Round(startingValue)}%"; + }), onUpdate); + RadialPuppetManager.OpenRadialMenu(startingValue, combinedAction, text); + })); + return pedalOption; + } + + public static void AddFourAxisPedalToMenu(ActionMenuPageType pageType, string text, Vector2 startingValue, Action onUpdate,Texture2D icon = null, Insertion insertion = Insertion.Post, string topButtonText = "Up", + string rightButtonText = "Right", string downButtonText = "Down", string leftButtonText = "Left") + { + AddPedalToList( + pageType, + new PedalFourAxis( + text, + startingValue, + icon, + onUpdate, + topButtonText, + rightButtonText, + downButtonText, + leftButtonText + ), + insertion + ); + } + + public static PedalOption AddFourAxisPedalToSubMenu(string text, Vector2 startingValue, Action onUpdate,Texture2D icon = null, string topButtonText = "Up", + string rightButtonText = "Right", string downButtonText = "Down", string leftButtonText = "Left") + { + ActionMenuOpener actionMenuOpener = Utilities.GetActionMenuOpener(); + if (actionMenuOpener == null) return null; + PedalOption pedalOption = actionMenuOpener.GetActionMenu().AddOption(); + pedalOption.setText(text); + pedalOption.setIcon(icon); + pedalOption.field_Public_ActionButton_0.prop_Texture2D_2 = Utilities.GetExpressionsIcons().typeAxis; + pedalOption.field_Public_MulticastDelegateNPublicSealedBoUnique_0 = DelegateSupport.ConvertDelegate(new Action(delegate + { + FourAxisPuppetManager.OpenFourAxisMenu(startingValue, v => startingValue = v, text, onUpdate); + FourAxisPuppetManager.current.GetButtonUp().SetButtonText(topButtonText); + FourAxisPuppetManager.current.GetButtonRight().SetButtonText(rightButtonText); + FourAxisPuppetManager.current.GetButtonDown().SetButtonText(downButtonText); + FourAxisPuppetManager.current.GetButtonLeft().SetButtonText(leftButtonText); + })); + return pedalOption; + } + + public static void AddSubMenuToMenu(ActionMenuPageType pageType, Action openFunc, string text = null, + Texture2D icon = null, Action closeFunc = null, Insertion insertion = Insertion.Post) + { + AddPedalToList( + pageType, + new PedalSubMenu( + openFunc, + text, + icon, + closeFunc + ), + insertion + ); + } + + public static void AddTogglePedalToMenu(ActionMenuPageType pageType,bool startingState, System.Action onToggle, string text, Texture2D icon = null, Insertion insertion = Insertion.Post) + { + AddPedalToList( + pageType, + new PedalToggle( + text, + onToggle, + startingState, + icon + ), + insertion + ); + } + + + public static PedalOption AddTogglePedalToSubMenu(Action onToggle, bool startingState, string text, Texture2D icon = null) + { + + ActionMenuOpener actionMenuOpener = Utilities.GetActionMenuOpener(); + if (actionMenuOpener == null) return null; + PedalOption pedalOption = actionMenuOpener.GetActionMenu().AddOption(); + pedalOption.setText(text); + pedalOption.setIcon(icon); + if (startingState) pedalOption.field_Public_ActionButton_0.prop_Texture2D_2 = Utilities.GetExpressionsIcons().typeToggleOn; + else pedalOption.field_Public_ActionButton_0.prop_Texture2D_2 = Utilities.GetExpressionsIcons().typeToggleOff; + pedalOption.field_Public_MulticastDelegateNPublicSealedBoUnique_0 = DelegateSupport.ConvertDelegate(new Action(delegate + { + startingState = !startingState; + if (startingState) + pedalOption.field_Public_ActionButton_0.prop_Texture2D_2 = Utilities.GetExpressionsIcons().typeToggleOn; + else + pedalOption.field_Public_ActionButton_0.prop_Texture2D_2 = Utilities.GetExpressionsIcons().typeToggleOff; + onToggle.Invoke(startingState); + })); + return pedalOption; + } + + + + + private static void AddPedalToList(ActionMenuPageType pageType, PedalStruct customPedal, Insertion insertion) + { + switch (pageType) + { + case ActionMenuPageType.SDK2Expression: + if(insertion == Insertion.Pre) Patches.sdk2ExpressionPagePre.Add(customPedal); + else if(insertion == Insertion.Post) Patches.sdk2ExpressionPagePost.Add(customPedal); + break; + case ActionMenuPageType.Config: + if (insertion == Insertion.Pre) Patches.configPagePre.Add(customPedal); + else if (insertion == Insertion.Post) Patches.configPagePost.Add(customPedal); + break; + case ActionMenuPageType.Emojis: + if (insertion == Insertion.Pre) Patches.emojisPagePre.Add(customPedal); + else if (insertion == Insertion.Post) Patches.emojisPagePost.Add(customPedal); + break; + case ActionMenuPageType.Expression: + if (insertion == Insertion.Pre) Patches.expressionPagePre.Add(customPedal); + else if (insertion == Insertion.Post) Patches.expressionPagePost.Add(customPedal); + break; + case ActionMenuPageType.Main: + if (insertion == Insertion.Pre) Patches.mainPagePre.Add(customPedal); + else if (insertion == Insertion.Post) Patches.mainPagePost.Add(customPedal); + break; + case ActionMenuPageType.MenuOpacity: + if (insertion == Insertion.Pre) Patches.menuOpacityPagePre.Add(customPedal); + else if (insertion == Insertion.Post) Patches.menuOpacityPagePost.Add(customPedal); + break; + case ActionMenuPageType.MenuSize: + if (insertion == Insertion.Pre) Patches.menuSizePagePre.Add(customPedal); + else if (insertion == Insertion.Post) Patches.menuSizePagePost.Add(customPedal); + break; + case ActionMenuPageType.Nameplates: + if (insertion == Insertion.Pre) Patches.nameplatesPagePre.Add(customPedal); + else if (insertion == Insertion.Post) Patches.nameplatesPagePost.Add(customPedal); + break; + case ActionMenuPageType.NameplatesOpacity: + if (insertion == Insertion.Pre) Patches.nameplatesOpacityPagePre.Add(customPedal); + else if (insertion == Insertion.Post) Patches.nameplatesOpacityPagePost.Add(customPedal); + break; + case ActionMenuPageType.NameplatesSize: + if (insertion == Insertion.Pre) Patches.nameplatesSizePagePre.Add(customPedal); + else if (insertion == Insertion.Post) Patches.nameplatesSizePagePost.Add(customPedal); + break; + case ActionMenuPageType.NameplatesVisibilty: + if (insertion == Insertion.Pre) Patches.nameplatesVisibilityPagePre.Add(customPedal); + else if (insertion == Insertion.Post) Patches.nameplatesVisibilityPagePost.Add(customPedal); + break; + case ActionMenuPageType.Options: + if (insertion == Insertion.Pre) Patches.optionsPagePre.Add(customPedal); + else if (insertion == Insertion.Post) Patches.optionsPagePost.Add(customPedal); + break; + } + } + + + } } \ No newline at end of file diff --git a/ActionMenuApi/ActionMenuApi.cs b/ActionMenuApi/ActionMenuApi.cs index cbf126d..51e1b84 100644 --- a/ActionMenuApi/ActionMenuApi.cs +++ b/ActionMenuApi/ActionMenuApi.cs @@ -1,25 +1,21 @@ -using System.Diagnostics; -using Harmony; -using MelonLoader; - +using MelonLoader; +using ActionMenuApi.Managers; +using UnityEngine; namespace ActionMenuApi { internal static class ModInfo { public const string Name = "ActionMenuApi"; - public const string Author = "gompo#6956"; - public const string Version = "1.0.0"; + public const string Author = "gompo"; + public const string Version = "0.1.0"; public const string DownloadLink = null; } public class ActionMenuApi : MelonMod { - private static MelonMod Instance; - public static HarmonyInstance HarmonyInstance => Instance.Harmony; public override void OnApplicationStart() { - Instance = this; Patches.PatchAll(); RadialPuppetManager.Setup(); FourAxisPuppetManager.Setup(); @@ -29,6 +25,10 @@ public override void OnUpdate() { RadialPuppetManager.OnUpdate(); FourAxisPuppetManager.OnUpdate(); + if (Input.GetKey(KeyCode.P)) + { + MelonLogger.Msg(Utilities.GetCursorPosRight().ToString()); + } } } } \ No newline at end of file diff --git a/ActionMenuApi/ActionMenuApi.csproj b/ActionMenuApi/ActionMenuApi.csproj index 57c409e..51607ab 100644 --- a/ActionMenuApi/ActionMenuApi.csproj +++ b/ActionMenuApi/ActionMenuApi.csproj @@ -77,7 +77,7 @@ - + diff --git a/ActionMenuApi/Managers/FourAxisPuppetManager.cs b/ActionMenuApi/Managers/FourAxisPuppetManager.cs index ae4e1ca..3866fc3 100644 --- a/ActionMenuApi/Managers/FourAxisPuppetManager.cs +++ b/ActionMenuApi/Managers/FourAxisPuppetManager.cs @@ -2,7 +2,7 @@ using MelonLoader; using UnityEngine; -namespace ActionMenuApi +namespace ActionMenuApi.Managers { public static class FourAxisPuppetManager { @@ -40,49 +40,50 @@ public static void OnUpdate() { if (hand == ActionMenuHand.Right) { - if (Input.GetKeyUp(InputAxes.RightTrigger)) + if (Input.GetAxis(InputAxes.RightTrigger) >= 0.4) { CloseFourAxisMenu(); + return; } } else if (hand == ActionMenuHand.Left) { - if (Input.GetKeyUp(InputAxes.LeftTrigger)) + if (Input.GetAxis(InputAxes.LeftTrigger) >= 0.4) { CloseFourAxisMenu(); + return; } } } else if (Input.GetMouseButton(0)) { CloseFourAxisMenu(); + return; } - else + + try { - try - { - current.Method_Private_Void_Vector2_Boolean_1(fourAxisPuppetValue, false); - }catch {} - fourAxisPuppetValue = ((hand == ActionMenuHand.Left) ? Utilities.GetCursorPosLeft() : Utilities.GetCursorPosRight())/ 16; - float x = fourAxisPuppetValue.x; - float y = fourAxisPuppetValue.y; - if (x >= 0) { - current.GetFillLeft().SetAlpha(0); - current.GetFillRight().SetAlpha(x); - }else { - current.GetFillLeft().SetAlpha(Math.Abs(x)); - current.GetFillRight().SetAlpha(0); - } - if (y >= 0) { - current.GetFillDown().SetAlpha(0); - current.GetFillUp().SetAlpha(y); - }else { - current.GetFillDown().SetAlpha(Math.Abs(y)); - current.GetFillUp().SetAlpha(0); - } - UpdateMathStuff(); - onUpdate.Invoke(fourAxisPuppetValue); + current.Method_Private_Void_Vector2_Boolean_1(fourAxisPuppetValue, false); + }catch {} + fourAxisPuppetValue = ((hand == ActionMenuHand.Left) ? Utilities.GetCursorPosLeft() : Utilities.GetCursorPosRight())/ 16; + float x = fourAxisPuppetValue.x; + float y = fourAxisPuppetValue.y; + if (x >= 0) { + current.GetFillLeft().SetAlpha(0); + current.GetFillRight().SetAlpha(x); + }else { + current.GetFillLeft().SetAlpha(Math.Abs(x)); + current.GetFillRight().SetAlpha(0); + } + if (y >= 0) { + current.GetFillDown().SetAlpha(0); + current.GetFillUp().SetAlpha(y); + }else { + current.GetFillDown().SetAlpha(Math.Abs(y)); + current.GetFillUp().SetAlpha(0); } + UpdateMathStuff(); + onUpdate.Invoke(fourAxisPuppetValue); } } public static void OpenFourAxisMenu(Vector2 startingValue, Action close, string title, Action update) diff --git a/ActionMenuApi/Managers/RadialPuppetManager.cs b/ActionMenuApi/Managers/RadialPuppetManager.cs index 18eb869..59ac7be 100644 --- a/ActionMenuApi/Managers/RadialPuppetManager.cs +++ b/ActionMenuApi/Managers/RadialPuppetManager.cs @@ -2,7 +2,7 @@ using MelonLoader; using UnityEngine; -namespace ActionMenuApi +namespace ActionMenuApi.Managers { internal static class RadialPuppetManager { @@ -42,29 +42,30 @@ public static void OnUpdate() { if (hand == ActionMenuHand.Right) { - if (Input.GetKeyUp(InputAxes.RightTrigger)) + if (Input.GetAxis(InputAxes.RightTrigger) >= 0.4) { CloseRadialMenu(); + return; } } else if (hand == ActionMenuHand.Left) { - if (Input.GetKeyUp(InputAxes.LeftTrigger)) + if (Input.GetAxis(InputAxes.LeftTrigger) >= 0.4) { CloseRadialMenu(); + return; } } } else if (Input.GetMouseButton(0)) { CloseRadialMenu(); + return; } - else - { - UpdateMathStuff(); - radialPuppetValue = (current.GetFill().field_Public_Single_3 / 360) * 100; - if(onUpdate != null) onUpdate.Invoke(radialPuppetValue); - } + + UpdateMathStuff(); + radialPuppetValue = (current.GetFill().field_Public_Single_3 / 360) * 100; + if(onUpdate != null) onUpdate.Invoke(radialPuppetValue); } } diff --git a/ActionMenuApi/Patches.cs b/ActionMenuApi/Patches.cs index 42c555a..d4161d1 100644 --- a/ActionMenuApi/Patches.cs +++ b/ActionMenuApi/Patches.cs @@ -39,9 +39,23 @@ public static List private static readonly List openNameplatesVisibilityPageKeyWords = new (new [] { "Nameplates Shown", "Icons Only", "Nameplates Hidden" }); private static readonly List openNameplatesSizePageKeyWords = new (new [] { "Large", "Medium", "Normal", "Small", "Tiny" }); private static readonly List openMenuSizePageKeyWords = new (new [] { "XXXXXXXXX" }); // No strings found :( Unusable for now. Scanning for methods doesnt help either as there are other functions that yield similar results + unsafe static private void ApplyPatches() + { + var CollideTarget = *(IntPtr*)(IntPtr)typeof(DynamicBoneCollider).GetField("NativeMethodInfoPtr_Method_Public_Void_byref_Vector3_Single_0", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null); + MelonUtils.NativeHookAttach((IntPtr)(&CollideTarget), Marshal.GetFunctionPointerForDelegate(new Action(OnCollide))); + collideDelegate = Marshal.GetDelegateForFunctionPointer(CollideTarget); + } + + public delegate void CollideDelegate(IntPtr instance, IntPtr particlePosition, IntPtr particleRadius); + public static CollideDelegate collideDelegate; + unsafe static private void OnCollide(IntPtr instance, IntPtr particlePosition, IntPtr particleRadius) + { + collideDelegate(instance, particlePosition, particleRadius); // Error happens here + } public static void PatchAll() { + ApplyPatches(); try { unsafe { diff --git a/ActionMenuApi/Pedals/PedalFourAxis.cs b/ActionMenuApi/Pedals/PedalFourAxis.cs index e7d06cb..3e6262c 100644 --- a/ActionMenuApi/Pedals/PedalFourAxis.cs +++ b/ActionMenuApi/Pedals/PedalFourAxis.cs @@ -1,5 +1,5 @@ using System; -using MelonLoader; +using ActionMenuApi.Managers; using UnityEngine; namespace ActionMenuApi.Pedals diff --git a/ActionMenuApi/Pedals/PedalRadial.cs b/ActionMenuApi/Pedals/PedalRadial.cs index 7810d0f..8d1a0b9 100644 --- a/ActionMenuApi/Pedals/PedalRadial.cs +++ b/ActionMenuApi/Pedals/PedalRadial.cs @@ -1,6 +1,6 @@ using System; using UnityEngine; -using UnityEngine.Experimental.PlayerLoop; +using ActionMenuApi.Managers; namespace ActionMenuApi.Pedals { diff --git a/ActionMenuApi/Stuff/Utilities.cs b/ActionMenuApi/Stuff/Utilities.cs index f7d8e7c..d17ae40 100644 --- a/ActionMenuApi/Stuff/Utilities.cs +++ b/ActionMenuApi/Stuff/Utilities.cs @@ -103,6 +103,7 @@ public static void AddPedalsInList(List list, ActionMenu instance) public static double ConvertFromDegToEuler(double angle) { + //TODO: Rewrite/Remove Unnecessary Addition/Subtraction if (angle >= 0 && angle <= 90) return 90 - angle; if (angle > 90 && angle <= 180) return 360 - (angle - 90); if (angle <= -90 && angle >= -180) return 270 - (angle + 180); diff --git a/ActionMenuApi/Types/ActionMenuPageType.cs b/ActionMenuApi/Types/ActionMenuPageType.cs index 01c4c55..d6816ed 100644 --- a/ActionMenuApi/Types/ActionMenuPageType.cs +++ b/ActionMenuApi/Types/ActionMenuPageType.cs @@ -8,7 +8,7 @@ public enum ActionMenuPageType SDK2Expression, Main, MenuOpacity, - MenuSize, + MenuSize, //Not Implemented Nameplates, NameplatesOpacity, NameplatesVisibilty,