Skip to content

Commit

Permalink
Big Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gompocp committed Jun 16, 2021
1 parent b4338cc commit b831edb
Show file tree
Hide file tree
Showing 25 changed files with 1,067 additions and 729 deletions.
103 changes: 62 additions & 41 deletions ActionMenuApi/AMAPI.cs
Original file line number Diff line number Diff line change
@@ -1,84 +1,105 @@
using System;
using ActionMenuApi.Api;
using ActionMenuApi.Managers;
using ActionMenuApi.Pedals;
using ActionMenuApi.Types;
using MelonLoader;
using UnhollowerRuntimeLib;
using UnityEngine;
using UnityEngine.UI;
using PedalOptionTriggerEvent = PedalOption.MulticastDelegateNPublicSealedBoUnique; //Will this change?, ¯\_(ツ)_/¯
// ReSharper disable HeuristicUnreachableCode
#pragma warning disable 1591

namespace ActionMenuApi
{
[Obsolete("This class is only here for compatibility reasons! Please use ActionMenuApi.Api.CustomSubMenu/VRCActionMenuPage/AMUtils for new updated methods to integrate with the action menu", false)]
[Obsolete(
"This class is only here for compatibility reasons! Please use ActionMenuApi.Api.CustomSubMenu/VRCActionMenuPage/AMUtils for new updated methods to integrate with the action menu",
false)]
public static class AMAPI
{

[Obsolete("This method is only here for compatibility reasons! Please use VRCActionMenuPage.AddButton()", false)]
public static void AddButtonPedalToMenu(ActionMenuPageType pageType, string text, Action triggerEvent, Texture2D icon = null, Insertion insertion = Insertion.Post)
[Obsolete("This method is only here for compatibility reasons! Please use VRCActionMenuPage.AddButton()",
false)]
public static void AddButtonPedalToMenu(ActionMenuPageType pageType, string text, Action triggerEvent,
Texture2D icon = null, Insertion insertion = Insertion.Post)
{
VRCActionMenuPage.AddPedalToList((ActionMenuPage)pageType, new PedalButton(text, icon, triggerEvent), insertion);
VRCActionMenuPage.AddPedalToList((ActionMenuPage) pageType, new PedalButton(text, icon, triggerEvent),
insertion);
}

[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, icon, false);
return CustomSubMenu.AddButton(text, triggerEvent, icon);
}

[Obsolete("This method is only here for compatibility reasons! Please use VRCActionMenuPage.AddRadialPuppet()", false)]
public static void AddRadialPedalToMenu(ActionMenuPageType pageType, string text, Action<float> onUpdate, float startingValue = 0, Texture2D icon = null, Insertion insertion = Insertion.Post)

[Obsolete("This method is only here for compatibility reasons! Please use VRCActionMenuPage.AddRadialPuppet()",
false)]
public static void AddRadialPedalToMenu(ActionMenuPageType pageType, string text, Action<float> onUpdate,
float startingValue = 0, Texture2D icon = null, Insertion insertion = Insertion.Post)
{
VRCActionMenuPage.AddPedalToList((ActionMenuPage)pageType, new PedalRadial(text, startingValue, icon, onUpdate), insertion);
VRCActionMenuPage.AddPedalToList((ActionMenuPage) pageType,
new PedalRadial(text, startingValue, icon, onUpdate), insertion);
}

[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)
[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, startingValue, icon, false);
return CustomSubMenu.AddRadialPuppet(text, onUpdate, startingValue, icon);
}

[Obsolete("This method is only here for compatibility reasons! Please use VRCActionMenuPage.AddFourAxisPuppet()", false)]
public static void AddFourAxisPedalToMenu(ActionMenuPageType pageType, string text, Action<Vector2> onUpdate,Texture2D icon = null, Insertion insertion = Insertion.Post, string topButtonText = "Up",

[Obsolete(
"This method is only here for compatibility reasons! Please use VRCActionMenuPage.AddFourAxisPuppet()",
false)]
public static void AddFourAxisPedalToMenu(ActionMenuPageType pageType, string text, Action<Vector2> onUpdate,
Texture2D icon = null, Insertion insertion = Insertion.Post, string topButtonText = "Up",
string rightButtonText = "Right", string downButtonText = "Down", string leftButtonText = "Left")
{
VRCActionMenuPage.AddPedalToList((ActionMenuPage)pageType, new PedalFourAxis(text, icon, onUpdate, topButtonText, rightButtonText, downButtonText, leftButtonText), insertion);
VRCActionMenuPage.AddPedalToList((ActionMenuPage) pageType,
new PedalFourAxis(text, icon, onUpdate, topButtonText, rightButtonText, downButtonText, leftButtonText),
insertion);
}

[Obsolete("This method is only here for compatibility reasons! Please use CustomSubMenu.AddFourAxisPuppet()", false)]
public static PedalOption AddFourAxisPedalToSubMenu(string text, Action<Vector2> onUpdate,Texture2D icon = null, string topButtonText = "Up",

[Obsolete("This method is only here for compatibility reasons! Please use CustomSubMenu.AddFourAxisPuppet()",
false)]
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, icon, false, 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)]
public static void AddSubMenuToMenu(ActionMenuPageType pageType, string text, Action openFunc, Texture2D icon = null, Action closeFunc = null, Insertion insertion = Insertion.Post)

[Obsolete("This method is only here for compatibility reasons! Please use VRCActionMenuPage.AddSubMenu()",
false)]
public static void AddSubMenuToMenu(ActionMenuPageType pageType, string text, Action openFunc,
Texture2D icon = null, Action closeFunc = null, Insertion insertion = Insertion.Post)
{
VRCActionMenuPage.AddPedalToList((ActionMenuPage)pageType, new PedalSubMenu(openFunc, text, icon, closeFunc), insertion);
VRCActionMenuPage.AddPedalToList((ActionMenuPage) pageType,
new PedalSubMenu(openFunc, text, icon, closeFunc), insertion);
}

[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)
public static PedalOption AddSubMenuToSubMenu(string text, Action openFunc, Texture2D icon = null,
Action closeFunc = null)
{
return CustomSubMenu.AddSubMenu(text, openFunc, icon, false, closeFunc);
return CustomSubMenu.AddSubMenu(text, openFunc, icon, false, closeFunc);
}

[Obsolete("This method is only here for compatibility reasons! Please use VRCActionMenuPage.AddToggle()", false)]
public static void AddTogglePedalToMenu(ActionMenuPageType pageType, string text, bool startingState, Action<bool> onToggle, Texture2D icon = null, Insertion insertion = Insertion.Post)

[Obsolete("This method is only here for compatibility reasons! Please use VRCActionMenuPage.AddToggle()",
false)]
public static void AddTogglePedalToMenu(ActionMenuPageType pageType, string text, bool startingState,
Action<bool> onToggle, Texture2D icon = null, Insertion insertion = Insertion.Post)
{
VRCActionMenuPage.AddPedalToList((ActionMenuPage)pageType, new PedalToggle(text, onToggle, startingState, icon), insertion);
VRCActionMenuPage.AddPedalToList((ActionMenuPage) pageType,
new PedalToggle(text, onToggle, startingState, icon), insertion);
}

[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)
public static PedalOption AddTogglePedalToSubMenu(string text, bool startingState, Action<bool> onToggle,
Texture2D icon = null)
{
return CustomSubMenu.AddToggle(text, startingState, onToggle, icon, false);
return CustomSubMenu.AddToggle(text, startingState, onToggle, icon);
}

[Obsolete("This method is only here for compatibility reasons! Please use AMUtils.AddToModsFolder()", false)]
public static void AddModFolder(string text, Action openFunc, Texture2D icon = null)
{
Expand Down
21 changes: 12 additions & 9 deletions ActionMenuApi/ActionMenuApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@
using System.Collections;
using ActionMenuApi.Managers;
using MelonLoader;

#pragma warning disable 1591
[assembly: MelonInfo(typeof(ActionMenuApi.ActionMenuApi), "ActionMenuApi", "0.3.0", "gompo", "https://github.com/gompocp/ActionMenuApi/releases")]
[assembly:
MelonInfo(typeof(ActionMenuApi.ActionMenuApi), "ActionMenuApi", "0.3.0", "gompo",
"https://github.com/gompocp/ActionMenuApi/releases")]
[assembly: MelonGame("VRChat", "VRChat")]
[assembly: VerifyLoaderVersion(0, 4, 0, true)]

namespace ActionMenuApi
{
public class ActionMenuApi : MelonMod
{
public ActionMenuApi()
{
LoaderIntegrityCheck.VibeCheck();
}

public override void OnApplicationStart()
{
ResourcesManager.LoadTextures();
Expand All @@ -24,8 +32,8 @@ public override void OnApplicationStart()
MelonLogger.Error($"Patching failed with exception: {e.Message}");
}
}
IEnumerator WaitForActionMenuInit()

private IEnumerator WaitForActionMenuInit()
{
while (ActionMenuDriver.prop_ActionMenuDriver_0 == null) //VRCUIManager Init is too early
yield return null;
Expand All @@ -34,17 +42,12 @@ IEnumerator WaitForActionMenuInit()
RadialPuppetManager.Setup();
FourAxisPuppetManager.Setup();
}


public override void OnUpdate()
{
RadialPuppetManager.OnUpdate();
FourAxisPuppetManager.OnUpdate();
}

public ActionMenuApi()
{
LoaderIntegrityCheck.VibeCheck();
}
}
}
23 changes: 12 additions & 11 deletions ActionMenuApi/Api/AMUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,44 @@ namespace ActionMenuApi.Api
public static class AMUtils
{
/// <summary>
/// Trigger a refresh for the action menus
/// Trigger a refresh for the action menus
/// </summary>
public static void RefreshActionMenu()
{
try
{
Utilities.RefreshAM();
}
catch(Exception e)
catch (Exception e)
{
MelonLogger.Warning($"Refresh failed (oops). This may or may not be an oof if another exception immediately follows after this exception: {e}");
MelonLogger.Warning(
$"Refresh failed (oops). This may or may not be an oof if another exception immediately follows after this exception: {e}");
//This is semi-abusable if this fails so its probably a good idea to have a fail-safe to protect sensitive functions that are meant to be locked
Utilities.ResetMenu();
}
}

/// <summary>
/// Trigger a complete reset for the action menus
/// Trigger a complete reset for the action menus
/// </summary>
public static void ResetMenu()
{
Utilities.ResetMenu();
}

/// <summary>
/// Add a mod to a dedicated section of the action menu with other mods
/// Add a mod to a dedicated section of the action menu with other mods
/// </summary>
/// <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="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>
/// <param name="locked">(optional) Starting state of pedal</param>
public static void AddToModsFolder(string text, Action openFunc, Texture2D icon = null, bool locked = false)
{
ModsFolderManager.AddMod(() =>
{
CustomSubMenu.AddSubMenu(text, openFunc, icon, locked);
});
ModsFolderManager.AddMod(() => { CustomSubMenu.AddSubMenu(text, openFunc, icon, locked); });
}
}
}
50 changes: 25 additions & 25 deletions ActionMenuApi/Api/ActionMenuPage.cs
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
namespace ActionMenuApi.Api
{
{
/// <summary>
/// Supported existing vrchat pages that you can add pedals to
/// Supported existing vrchat pages that you can add pedals to
/// </summary>
public enum ActionMenuPage
{
/// <summary>
/// The more "advanced" options in the action menu. Can change menu opacity, size, position etc. here
/// The more "advanced" options in the action menu. Can change menu opacity, size, position etc. here
/// </summary>
Config,

/// <summary>
/// The page that shows when you open the emojis page of the action menu
/// The page that shows when you open the emojis page of the action menu
/// </summary>
Emojis,

/// <summary>
/// The page that shows when you open the expression page of the action menu using an sdk3 avatar
/// The page that shows when you open the expression page of the action menu using an sdk3 avatar
/// </summary>
Expression,

/// <summary>
/// The page that shows when you open the expression page of the action menu using an sdk2 avatar. Has emotes 1-8
/// The page that shows when you open the expression page of the action menu using an sdk2 avatar. Has emotes 1-8
/// </summary>
SDK2Expression,

/// <summary>
/// The default page that shows when you open the action menu
/// The default page that shows when you open the action menu
/// </summary>
Main,

/// <summary>
/// The menu opacity page. Has 25%, 50%, 75%, 100%
/// The menu opacity page. Has 25%, 50%, 75%, 100%
/// </summary>
MenuOpacity,

/// <summary>
/// The menu size page. Has Small, Medium, Large
/// The menu size page. Has Small, Medium, Large
/// </summary>
MenuSize, //Not Implemented

/// <summary>
/// The nameplates config page of the action menu
/// The nameplates config page of the action menu
/// </summary>
Nameplates,

/// <summary>
/// The nameplates opacity page 0%,20%,40%,60%,80%,100%
/// The nameplates opacity page 0%,20%,40%,60%,80%,100%
/// </summary>
NameplatesOpacity,

/// <summary>
/// The nameplates visibility page shown,icons only,hidden
/// The nameplates visibility page shown,icons only,hidden
/// </summary>
NameplatesVisibilty,

/// <summary>
/// The nameplates size page tiny,small,normal,medium,large
/// The nameplates size page tiny,small,normal,medium,large
/// </summary>
NameplatesSize,

/// <summary>
/// The options page, toggle mic, close menu etc.
/// The options page, toggle mic, close menu etc.
/// </summary>
Options
}
Expand Down
Loading

0 comments on commit b831edb

Please sign in to comment.