Skip to content

Commit

Permalink
Added a way to disable pedals added to vrc menus
Browse files Browse the repository at this point in the history
  • Loading branch information
gompocp committed May 14, 2021
1 parent 7113bba commit 80a48a5
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
10 changes: 5 additions & 5 deletions ActionMenuApi/AMAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void AddButtonPedalToMenu(ActionMenuPageType pageType, string text
[Obsolete("This method is only here for compatibility reasons! Please use CustomSubMenu.AddButton()", false)]
public static PedalOption AddButtonPedalToSubMenu(string text, Action triggerEvent, Texture2D icon = null)
{
return CustomSubMenu.AddButton(text, triggerEvent, false, icon);
return CustomSubMenu.AddButton(text, triggerEvent, icon, false);
}

[Obsolete("This method is only here for compatibility reasons! Please use VRCActionMenuPage.AddRadialPuppet()", false)]
Expand All @@ -38,7 +38,7 @@ public static void AddRadialPedalToMenu(ActionMenuPageType pageType, string text
[Obsolete("This method is only here for compatibility reasons! Please use CustomSubMenu.AddRadialPuppet()", false)]
public static PedalOption AddRadialPedalToSubMenu(string text, Action<float> onUpdate, float startingValue = 0, Texture2D icon = null)
{
return CustomSubMenu.AddRadialPuppet(text, onUpdate, false, startingValue, icon);
return CustomSubMenu.AddRadialPuppet(text, onUpdate, startingValue, icon, false);
}

[Obsolete("This method is only here for compatibility reasons! Please use VRCActionMenuPage.AddFourAxisPuppet()", false)]
Expand All @@ -52,7 +52,7 @@ public static void AddFourAxisPedalToMenu(ActionMenuPageType pageType, string te
public static PedalOption AddFourAxisPedalToSubMenu(string text, Action<Vector2> onUpdate,Texture2D icon = null, string topButtonText = "Up",
string rightButtonText = "Right", string downButtonText = "Down", string leftButtonText = "Left")
{
return CustomSubMenu.AddFourAxisPuppet(text, onUpdate, false, icon, topButtonText, rightButtonText, downButtonText, leftButtonText);
return CustomSubMenu.AddFourAxisPuppet(text, onUpdate, icon, false, topButtonText, rightButtonText, downButtonText, leftButtonText);
}

[Obsolete("This method is only here for compatibility reasons! Please use VRCActionMenuPage.AddSubMenu()", false)]
Expand All @@ -64,7 +64,7 @@ public static void AddSubMenuToMenu(ActionMenuPageType pageType, string text, Ac
[Obsolete("This method is only here for compatibility reasons! Please use CustomSubMenu.AddSubMenu()", false)]
public static PedalOption AddSubMenuToSubMenu(string text, Action openFunc, Texture2D icon = null, Action closeFunc = null)
{
return CustomSubMenu.AddSubMenu(text, openFunc, false, icon, closeFunc);
return CustomSubMenu.AddSubMenu(text, openFunc, icon, false, closeFunc);
}

[Obsolete("This method is only here for compatibility reasons! Please use VRCActionMenuPage.AddToggle()", false)]
Expand All @@ -76,7 +76,7 @@ public static void AddTogglePedalToMenu(ActionMenuPageType pageType, string text
[Obsolete("This method is only here for compatibility reasons! Please use CustomSubMenu.AddToggle()", false)]
public static PedalOption AddTogglePedalToSubMenu(string text, bool startingState, Action<bool> onToggle, Texture2D icon = null)
{
return CustomSubMenu.AddToggle(text, startingState, onToggle, false, icon);
return CustomSubMenu.AddToggle(text, startingState, onToggle, icon, false);
}

[Obsolete("This method is only here for compatibility reasons! Please use AMUtils.AddToModsFolder()", false)]
Expand Down
4 changes: 2 additions & 2 deletions ActionMenuApi/Api/AMUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public static void RefreshActionMenu()
/// <param name="text">Button text</param>
/// <param name="openFunc">Function called when your mod page is opened. Add your methods calls to other AMAPI methods such AddRadialPedalToSubMenu to add buttons to the submenu it creates when clicked</param>
/// <param name="icon">(optional) The Button Icon</param>
public static void AddToModsFolder(string text, Action openFunc, Texture2D icon = null)
public static void AddToModsFolder(string text, Action openFunc, Texture2D icon = null, bool locked = false)
{
ModsFolderManager.AddMod(() =>
{
CustomSubMenu.AddSubMenu(text, openFunc, icon, null);
CustomSubMenu.AddSubMenu(text, openFunc, icon, locked);
});
}
}
Expand Down
10 changes: 5 additions & 5 deletions ActionMenuApi/Api/CustomSubMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static class CustomSubMenu
/// <param name="locked">The starting state for the lockable pedal, true = locked, false = unlocked</param>
/// <param name="icon">(optional) The Button Icon</param>
/// <returns> PedalOption Instance (Note: 1. can be null if both action menus are open 2. The gameobject that it is attached to is destroyed when you change page on the action menu)</returns>
public static PedalOption AddButton(string text, Action triggerEvent, bool locked, Texture2D icon = null)
public static PedalOption AddButton(string text, Action triggerEvent, Texture2D icon = null, bool locked = false)
{
ActionMenuOpener actionMenuOpener = Utilities.GetActionMenuOpener();
if (actionMenuOpener == null) return null;
Expand All @@ -43,7 +43,7 @@ public static PedalOption AddButton(string text, Action triggerEvent, bool locke
/// <param name="startingValue">(optional) Starting value for radial puppet 0-1</param>
/// <param name="icon">(optional) The Button Icon</param>
/// <returns> PedalOption Instance (Note: the gameobject that it is attached to is destroyed when you change page on the action menu</returns>
public static PedalOption AddRadialPuppet(string text, Action<float> onUpdate, bool locked, float startingValue = 0, Texture2D icon = null)
public static PedalOption AddRadialPuppet(string text, Action<float> onUpdate, float startingValue = 0, Texture2D icon = null, bool locked = false)
{
ActionMenuOpener actionMenuOpener = Utilities.GetActionMenuOpener();
if (actionMenuOpener == null) return null;
Expand Down Expand Up @@ -79,7 +79,7 @@ public static PedalOption AddRadialPuppet(string text, Action<float> onUpdate, b
/// <param name="downButtonText">(optional) Bottom Button Button text On Four Axis Puppet</param>
/// <param name="leftButtonText">(optional) Left Button Button text On Four Axis Puppet</param>
/// <returns> PedalOption Instance (Note: the gameobject that it is attached to is destroyed when you change page on the action menu</returns>
public static PedalOption AddFourAxisPuppet(string text, Action<Vector2> onUpdate, bool locked, Texture2D icon = null, string topButtonText = "Up",
public static PedalOption AddFourAxisPuppet(string text, Action<Vector2> onUpdate, Texture2D icon = null, bool locked = false, string topButtonText = "Up",
string rightButtonText = "Right", string downButtonText = "Down", string leftButtonText = "Left")
{
ActionMenuOpener actionMenuOpener = Utilities.GetActionMenuOpener();
Expand Down Expand Up @@ -111,7 +111,7 @@ public static PedalOption AddFourAxisPuppet(string text, Action<Vector2> onUpdat
/// <param name="icon">(optional) The Button Icon</param>
/// <param name="closeFunc">(optional) Function called when page closes</param>
/// <returns> PedalOption Instance (Note: the gameobject that it is attached to is destroyed when you change page on the action menu</returns>
public static PedalOption AddSubMenu(string text, Action openFunc, bool locked, Texture2D icon = null, Action closeFunc = null)
public static PedalOption AddSubMenu(string text, Action openFunc, Texture2D icon = null, bool locked = false, Action closeFunc = null)
{
ActionMenuOpener actionMenuOpener = Utilities.GetActionMenuOpener();
if (actionMenuOpener == null) return null;
Expand All @@ -138,7 +138,7 @@ public static PedalOption AddSubMenu(string text, Action openFunc, bool locked,
/// <param name="locked">The starting state for the lockable pedal, true = locked, false = unlocked</param>
/// <param name="icon">(optional) The Button Icon</param>
/// <returns> PedalOption Instance (Note: the gameobject that it is attached to is destroyed when you change page on the action menu</returns>
public static PedalOption AddToggle(string text, bool startingState, Action<bool> onToggle, bool locked, Texture2D icon = null)
public static PedalOption AddToggle(string text, bool startingState, Action<bool> onToggle, Texture2D icon = null, bool locked = false)
{

ActionMenuOpener actionMenuOpener = Utilities.GetActionMenuOpener();
Expand Down
4 changes: 2 additions & 2 deletions ActionMenuApi/Managers/ModsFolderManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal static class ModsFolderManager
CustomSubMenu.AddSubMenu($"Page {i+1}", () =>
{
foreach (var action in splitMods[index]) action.Invoke();
}, false, ResourcesManager.GetPageIcon(i+1));
}, ResourcesManager.GetPageIcon(i+1), false);
}
}
};
Expand All @@ -41,7 +41,7 @@ public static void AddMod(Action openingAction)

public static void AddMainPageButton()
{
CustomSubMenu.AddSubMenu(Constants.MODS_FOLDER_NAME, openFunc, false, ResourcesManager.GetModsSectionIcon());
CustomSubMenu.AddSubMenu(Constants.MODS_FOLDER_NAME, openFunc, ResourcesManager.GetModsSectionIcon(),false);
}
}
}
1 change: 1 addition & 0 deletions ActionMenuApi/Stuff/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public static void AddPedalsInList(List<PedalStruct> list, ActionMenu instance)
{
foreach (var pedalStruct in list)
{
if(!pedalStruct.shouldAdd) continue;
PedalOption pedalOption = instance.AddOption();
pedalOption.SetText(pedalStruct.text);
pedalOption.SetIcon(pedalStruct.icon);
Expand Down
11 changes: 6 additions & 5 deletions ActionMenuTestMod/ActionMenuTestMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ public override void OnApplicationStart()
AMUtils.RefreshActionMenu();
});
//No properties here are saved because I'm lazy af
CustomSubMenu.AddToggle("Enable Hax", false, b => { }, riskyFunctionsAllowed);
CustomSubMenu.AddRadialPuppet("Volume", f => { }, riskyFunctionsAllowed);
CustomSubMenu.AddSubMenu("Whatever", () => { }, riskyFunctionsAllowed);
CustomSubMenu.AddToggle("Enable Hax", false, b => { }, null,riskyFunctionsAllowed);
CustomSubMenu.AddRadialPuppet("Volume", f => { }, 0, null, riskyFunctionsAllowed);
CustomSubMenu.AddSubMenu("Whatever", () => { }, null, riskyFunctionsAllowed);
CustomSubMenu.AddButton("Risky Function", () =>
{
MelonLogger.Msg("Locked Pedal Func ran");
}, riskyFunctionsAllowed, buttonIcon);
CustomSubMenu.AddFourAxisPuppet("Move", vector2 => { }, riskyFunctionsAllowed);
}, buttonIcon, riskyFunctionsAllowed);
CustomSubMenu.AddFourAxisPuppet("Move", vector2 => { }, null, riskyFunctionsAllowed);
},
subMenuIcon
);
Expand Down Expand Up @@ -131,6 +131,7 @@ private static void RePositionCubeXZ(Vector2 v)

private static void RotateCubeX(float rotation)
{
//This is the incorrect way of rotating the gameobject and it breaks from 90-270 as quaternions and euler angle conversions are a bit fucky
Vector3 old = controllingGameObject.transform.eulerAngles;
controllingGameObject.transform.eulerAngles = new Vector3((rotation)*360, old.y, old.z);
x = rotation;
Expand Down

0 comments on commit 80a48a5

Please sign in to comment.