Skip to content

Commit

Permalink
Added pages for mods section to stop overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
gompocp committed May 6, 2021
1 parent c26423f commit cfc233c
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 22 deletions.
2 changes: 1 addition & 1 deletion ActionMenuApi/ActionMenuApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal static class ModInfo
public const string Name = "ActionMenuApi";
public const string Author = "gompo";
public const string Version = "0.1.1";
public const string DownloadLink = null;
public const string DownloadLink = "https://github.com/gompocp/ActionMenuApi/releases";
}

public class ActionMenuApi : MelonMod
Expand Down
4 changes: 2 additions & 2 deletions ActionMenuApi/ActionMenuApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>none</DebugType>
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp, Version=3.7.1.6, Culture=neutral, PublicKeyToken=null">
Expand Down Expand Up @@ -79,7 +80,6 @@
<Compile Include="Managers\FourAxisPuppetManager.cs" />
<Compile Include="Managers\RadialPuppetManager.cs" />
<Compile Include="ModMenu\ModsFolder.cs" />
<Compile Include="ModMenu\Page.cs" />
<Compile Include="Pedals\PedalFourAxis.cs" />
<Compile Include="Pedals\PedalToggle.cs" />
<Compile Include="AMAPI.cs" />
Expand Down
4 changes: 1 addition & 3 deletions ActionMenuApi/Managers/RadialPuppetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ public static void OpenRadialMenu(float startingValue, Action<float> onUpdate, s
current.GetTitle().text = title;
current.GetCenterText().text = (Math.Round(startingValue*100f)) + "%";
current.GetFill().UpdateGeometry(); ;
//MelonLogger.Msg($"Button Pos: {pedalOption.field_Public_ActionButton_0.transform.position.ToString()}");
//MelonLogger.Msg($"Local Button Pos: {pedalOption.field_Public_ActionButton_0.transform.localPosition.ToString()}");
current.transform.localPosition = pedalOption.GetActionButton().transform.localPosition; //new Vector3(-256f, 0, 0);
double angleOriginal = Utilities.ConvertFromEuler(startingValue*360);
double eulerAngle = Utilities.ConvertFromDegToEuler(angleOriginal);
Expand Down Expand Up @@ -119,7 +117,7 @@ private static void UpdateMathStuff()

if (Vector2.Distance(mousePos, Vector2.zero) > 12)
{
double angleOriginal = Math.Round(((float)Math.Atan2(mousePos.y, mousePos.x)) * Constants.radToDeg);
double angleOriginal = Math.Round(((float)Math.Atan2(mousePos.y, mousePos.x)) * Constants.RAD_TO_DEG);
double eulerAngle = Utilities.ConvertFromDegToEuler(angleOriginal);
current.SetAngle((float)eulerAngle);
current.UpdateArrow(angleOriginal, eulerAngle);
Expand Down
67 changes: 64 additions & 3 deletions ActionMenuApi/ModMenu/ModsFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace ActionMenuApi.ModMenu
internal class ModsFolder
{
public List<Action> mods = new ();
public List<List<Action>> splitMods;
public static ModsFolder instance;
private string text;
private Texture2D icon;
Expand All @@ -22,7 +23,22 @@ public ModsFolder(string text, Texture2D icon = null)
this.icon = icon;
instance = this;
openFunc = () => {
foreach (var action in mods) action.Invoke();
if (mods.Count <= Constants.MAX_PEDALS_PER_PAGE)
{
foreach (var action in mods) action.Invoke();
}
else
{
if(splitMods == null) splitMods = mods.Split((int)Constants.MAX_PEDALS_PER_PAGE);
for (int i = 0; i < splitMods.Count && i < Constants.MAX_PEDALS_PER_PAGE; i++)
{
int index = i;
AMAPI.AddSubMenuToSubMenu($"Page {i+1}", () =>
{
foreach (var action in splitMods[index]) action.Invoke();
}, GetPageIcon(i+1));
}
}
};
}

Expand All @@ -31,10 +47,10 @@ public void AddMod(Action openingAction)
mods.Add(openingAction);
}

public void RemoveMod(Action openingAction)
/*public void RemoveMod(Action openingAction)
{
mods.Remove(openingAction);
}
}*/

public void AddMainPageButton()
{
Expand All @@ -55,7 +71,52 @@ public static void CreateInstance()
}
Texture2D modsSectionIcon = iconsAssetBundle.LoadAsset_Internal("Assets/ActionMenuApi/vrcmg.png", Il2CppType.Of<Texture2D>()).Cast<Texture2D>();
modsSectionIcon.hideFlags |= HideFlags.DontUnloadUnusedAsset;
pageOne = iconsAssetBundle.LoadAsset_Internal("Assets/ActionMenuApi/1.png", Il2CppType.Of<Texture2D>()).Cast<Texture2D>();
pageOne.hideFlags |= HideFlags.DontUnloadUnusedAsset;
pageTwo = iconsAssetBundle.LoadAsset_Internal("Assets/ActionMenuApi/2.png", Il2CppType.Of<Texture2D>()).Cast<Texture2D>();
pageTwo.hideFlags |= HideFlags.DontUnloadUnusedAsset;
pageThree = iconsAssetBundle.LoadAsset_Internal("Assets/ActionMenuApi/3.png", Il2CppType.Of<Texture2D>()).Cast<Texture2D>();
pageThree.hideFlags |= HideFlags.DontUnloadUnusedAsset;
pageFour = iconsAssetBundle.LoadAsset_Internal("Assets/ActionMenuApi/4.png", Il2CppType.Of<Texture2D>()).Cast<Texture2D>();
pageFour.hideFlags |= HideFlags.DontUnloadUnusedAsset;
pageFive = iconsAssetBundle.LoadAsset_Internal("Assets/ActionMenuApi/5.png", Il2CppType.Of<Texture2D>()).Cast<Texture2D>();
pageFive.hideFlags |= HideFlags.DontUnloadUnusedAsset;
pageSix = iconsAssetBundle.LoadAsset_Internal("Assets/ActionMenuApi/6.png", Il2CppType.Of<Texture2D>()).Cast<Texture2D>();
pageSix.hideFlags |= HideFlags.DontUnloadUnusedAsset;
pageSeven = iconsAssetBundle.LoadAsset_Internal("Assets/ActionMenuApi/7.png", Il2CppType.Of<Texture2D>()).Cast<Texture2D>();
pageSeven.hideFlags |= HideFlags.DontUnloadUnusedAsset;
new ModsFolder("Mods", modsSectionIcon); //TEMP Texture //TODO: Swap to a different texture
}

private static Texture2D GetPageIcon(int pageIndex)
{
switch (pageIndex)
{
case 1:
return pageOne;
case 2:
return pageTwo;
case 3:
return pageThree;
case 4:
return pageFour;
case 5:
return pageFive;
case 6:
return pageSix;
case 7:
return pageSeven;
default:
return null;
}
}

private static Texture2D pageOne;
private static Texture2D pageTwo;
private static Texture2D pageThree;
private static Texture2D pageFour;
private static Texture2D pageFive;
private static Texture2D pageSix;
private static Texture2D pageSeven;
}
}
11 changes: 0 additions & 11 deletions ActionMenuApi/ModMenu/Page.cs

This file was deleted.

3 changes: 2 additions & 1 deletion ActionMenuApi/Stuff/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace ActionMenuApi
{
internal class Constants
{
public const float radToDeg = (float)(180 / Math.PI);
public const float RAD_TO_DEG = (float)(180 / Math.PI);
public const float MAX_PEDALS_PER_PAGE = 7f;
}
}
13 changes: 12 additions & 1 deletion ActionMenuApi/Stuff/ExtensionMethods.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using MelonLoader;
Expand Down Expand Up @@ -265,10 +266,20 @@ public static void UpdateDisplay(this RadialPuppetMenu radialPuppet)
public static void UpdateArrow(this RadialPuppetMenu radialPuppet, double angleOriginal, double eulerAngle)
{
//MelonLogger.Msg($"Original: {angleOriginal}, Euler Angle:{eulerAngle}");
radialPuppet.GetArrow().transform.localPosition = new Vector3((float)(120 * Math.Cos(angleOriginal / Constants.radToDeg)), (float)(120 * Math.Sin(angleOriginal / Constants.radToDeg)), radialPuppet.GetArrow().transform.localPosition.z);
radialPuppet.GetArrow().transform.localPosition = new Vector3((float)(120 * Math.Cos(angleOriginal / Constants.RAD_TO_DEG)), (float)(120 * Math.Sin(angleOriginal / Constants.RAD_TO_DEG)), radialPuppet.GetArrow().transform.localPosition.z);
radialPuppet.GetArrow().transform.localEulerAngles = new Vector3(radialPuppet.GetArrow().transform.localEulerAngles.x, radialPuppet.GetArrow().transform.localEulerAngles.y, (float)(180 - eulerAngle));
}

public static List<List<Action>> Split(this List<Action> mods, int chunkSize)
{
var list = new List<List<Action>>();
for (int i = 0; i < mods.Count; i += chunkSize)
{
list.Add(mods.GetRange(i, Math.Min(chunkSize, mods.Count - i)));
}
return list;
}

//These things might change, just a bit tricky to identify the correct ones using reflection
public static void SetFillAngle(this PedalGraphic pedalGraphic, float angle) => pedalGraphic.field_Public_Single_3 = angle;
public static float GetFillAngle(this PedalGraphic pedalGraphic) => pedalGraphic.field_Public_Single_3;
Expand Down
Binary file modified ActionMenuApi/actionmenuapi.icons
Binary file not shown.
4 changes: 4 additions & 0 deletions ActionMenuTestMod/ActionMenuTestMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public override void OnApplicationStart()
},
subMenuIcon
);
for (int i = 0; i < 20; i++) //Set to a high number if you want to test the page functionality
{
AMAPI.AddModFolder($"Example Mod {i+2}", () => {}, subMenuIcon);
}
}

private static void CreateCube()
Expand Down

0 comments on commit cfc233c

Please sign in to comment.