From 9cfe74276d3f8a4a1f0bb6624c37aad762c300a7 Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com> Date: Tue, 23 Apr 2024 18:37:07 -0500 Subject: [PATCH] [MoreMenuOptions] Initial Release --- MoreMenuOptions/Main.cs | 106 +++++++++++++++++++++ MoreMenuOptions/ModSettings.cs | 27 ++++++ MoreMenuOptions/MoreMenuOptions.csproj | 2 + MoreMenuOptions/Properties/AssemblyInfo.cs | 32 +++++++ MoreMenuOptions/README.md | 21 ++++ MoreMenuOptions/format.json | 23 +++++ NAK_CVR_Mods.sln | 6 ++ 7 files changed, 217 insertions(+) create mode 100644 MoreMenuOptions/Main.cs create mode 100644 MoreMenuOptions/ModSettings.cs create mode 100644 MoreMenuOptions/MoreMenuOptions.csproj create mode 100644 MoreMenuOptions/Properties/AssemblyInfo.cs create mode 100644 MoreMenuOptions/README.md create mode 100644 MoreMenuOptions/format.json diff --git a/MoreMenuOptions/Main.cs b/MoreMenuOptions/Main.cs new file mode 100644 index 0000000..b086c33 --- /dev/null +++ b/MoreMenuOptions/Main.cs @@ -0,0 +1,106 @@ +using System.Reflection; +using ABI_RC.Core.InteractionSystem; +using ABI_RC.Core.Player; +using ABI_RC.Core.Savior; +using ABI_RC.Systems.GameEventSystem; +using ABI_RC.Systems.VRModeSwitch; +using MelonLoader; +using UnityEngine; + +namespace NAK.MoreMenuOptions; + +public class MoreMenuOptions : MelonMod +{ + // very lazy mod lol + + public override void OnInitializeMelon() + { + // Main Menu Scale & Distance Modifier Settings + ModSettings.EntryMainMenuModiferUsage.OnEntryValueChanged.Subscribe(OnMMUsageTypeChanged); + ModSettings.EntryMMScaleModifier.OnEntryValueChanged.Subscribe(OnMMFloatModifierChanged); + ModSettings.EntryMMDistanceModifier.OnEntryValueChanged.Subscribe(OnMMFloatModifierChanged); + + // Quick Menu World Anchor In VR Setting + ModSettings.EntryQMWorldAnchorInVR.OnEntryValueChanged.Subscribe(OnQMWorldAnchorInVRChanged); + + // Game Event Subscriptions + CVRGameEventSystem.World.OnLoad.AddListener(OnGameStart); + VRModeSwitchEvents.OnPostVRModeSwitch.AddListener(OnVRModeSwitched); + } + + #region Game Events + + private void OnGameStart(string _) + { + UpdateMenuSettings(); + CVRGameEventSystem.World.OnLoad.RemoveListener(OnGameStart); // only need to run once + } + + private void OnVRModeSwitched(bool switchToVr) + => UpdateMenuSettings(); + + private void UpdateMenuSettings() + { + UpdateMainMenuModifierSettings(); + UpdateQuickMenuModifierSettings(); + } + + #endregion Game Events + + #region Main Menu Scale & Distance Modifier Settings + + internal enum MainMenuModifierUsage + { + None, + Desktop, + VR, + Both + } + + private void OnMMUsageTypeChanged(MainMenuModifierUsage _, MainMenuModifierUsage __) + => UpdateMainMenuModifierSettings(); + + private void OnMMFloatModifierChanged(float _, float __) + => UpdateMainMenuModifierSettings(); + + private void UpdateMainMenuModifierSettings() + { + if (CVRMainMenuPositionHelper.Instance == null) + return; + + MainMenuModifierUsage usage = ModSettings.EntryMainMenuModiferUsage.Value; + + bool isVrActive = MetaPort.Instance.isUsingVr; + bool applyVrModifier = (isVrActive && usage is MainMenuModifierUsage.VR or MainMenuModifierUsage.Both); + bool applyDesktopModifier = (!isVrActive && usage is MainMenuModifierUsage.Desktop or MainMenuModifierUsage.Both); + + if (applyVrModifier || applyDesktopModifier) + { + CVRMainMenuPositionHelper.Instance.menuTransform.localPosition = new Vector3(0f, 0f, ModSettings.EntryMMDistanceModifier.Value); + CVRMainMenuPositionHelper.Instance.menuTransform.parent.localScale = Vector3.one * ModSettings.EntryMMScaleModifier.Value; + } + else // None or invalid usage + { + CVRMainMenuPositionHelper.Instance.menuTransform.localPosition = Vector3.zero; + CVRMainMenuPositionHelper.Instance.menuTransform.parent.localScale = Vector3.one; + } + } + + #endregion Main Menu Scale & Distance Modifier Settings + + #region Quick Menu World Anchor In VR Setting + + private void OnQMWorldAnchorInVRChanged(bool _, bool __) + => UpdateQuickMenuModifierSettings(); + + private void UpdateQuickMenuModifierSettings() + { + if (CVRQuickMenuPositionHelper.Instance == null) + return; + + CVRQuickMenuPositionHelper.Instance.worldAnchorMenu = + ModSettings.EntryQMWorldAnchorInVR.Value && MetaPort.Instance.isUsingVr; + } + + #endregion Quick Menu World Anchor In VR Setting +} \ No newline at end of file diff --git a/MoreMenuOptions/ModSettings.cs b/MoreMenuOptions/ModSettings.cs new file mode 100644 index 0000000..40ed605 --- /dev/null +++ b/MoreMenuOptions/ModSettings.cs @@ -0,0 +1,27 @@ +using MelonLoader; + +namespace NAK.MoreMenuOptions; + +public static class ModSettings +{ + private const string SettingsCategory = nameof(MoreMenuOptions); + + private static readonly MelonPreferences_Category Category = + MelonPreferences.CreateCategory(SettingsCategory); + + // main menu options + + internal static readonly MelonPreferences_Entry EntryMainMenuModiferUsage = + Category.CreateEntry("Main Menu Modifier Usage", MoreMenuOptions.MainMenuModifierUsage.Both, description: "The usage of the main menu modifier."); + + internal static readonly MelonPreferences_Entry EntryMMScaleModifier = + Category.CreateEntry("Main Menu Scale Modifier", 0.75f, description: "The scale of the main menu."); + + internal static readonly MelonPreferences_Entry EntryMMDistanceModifier = + Category.CreateEntry("Main Menu Distance Modifier", 0.1f, description: "The distance of the main menu from the camera."); + + // quick menu options + + internal static readonly MelonPreferences_Entry EntryQMWorldAnchorInVR = + Category.CreateEntry("Quick Menu World Anchor In VR", false, description: "Toggle the quick menu world anchor in VR."); +} \ No newline at end of file diff --git a/MoreMenuOptions/MoreMenuOptions.csproj b/MoreMenuOptions/MoreMenuOptions.csproj new file mode 100644 index 0000000..66a50a8 --- /dev/null +++ b/MoreMenuOptions/MoreMenuOptions.csproj @@ -0,0 +1,2 @@ + + diff --git a/MoreMenuOptions/Properties/AssemblyInfo.cs b/MoreMenuOptions/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c0b5125 --- /dev/null +++ b/MoreMenuOptions/Properties/AssemblyInfo.cs @@ -0,0 +1,32 @@ +using NAK.MoreMenuOptions.Properties; +using MelonLoader; +using System.Reflection; + +[assembly: AssemblyVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyTitle(nameof(NAK.MoreMenuOptions))] +[assembly: AssemblyCompany(AssemblyInfoParams.Author)] +[assembly: AssemblyProduct(nameof(NAK.MoreMenuOptions))] + +[assembly: MelonInfo( + typeof(NAK.MoreMenuOptions.MoreMenuOptions), + nameof(NAK.MoreMenuOptions), + AssemblyInfoParams.Version, + AssemblyInfoParams.Author, + downloadLink: "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/MoreMenuOptions" +)] + +[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")] +[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] +[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)] +[assembly: MelonColor(255, 137, 183, 217)] +[assembly: MelonAuthorColor(255, 158, 21, 32)] +[assembly: HarmonyDontPatchAll] + +namespace NAK.MoreMenuOptions.Properties; +internal static class AssemblyInfoParams +{ + public const string Version = "1.0.0"; + public const string Author = "NotAKidoS"; +} \ No newline at end of file diff --git a/MoreMenuOptions/README.md b/MoreMenuOptions/README.md new file mode 100644 index 0000000..1c9267c --- /dev/null +++ b/MoreMenuOptions/README.md @@ -0,0 +1,21 @@ +# MoreMenuOptions + +Exposes some menu options: +- Main Menu Scale Modifier +- Main Menu Distance Modifier +- Quick Menu World Anchor in VR + +By default, the menu is adjusted to a more comfortable scale for VR only, but can be configured in the mod settings. + +The mod is very slapped together and messy lol. + +--- + +Here is the block of text where I tell you this mod is not affiliated with or endorsed by ABI. +https://documentation.abinteractive.net/official/legal/tos/#7-modding-our-games + +> This mod is an independent creation not affiliated with, supported by, or approved by Alpha Blend Interactive. + +> Use of this mod is done so at the user's own risk and the creator cannot be held responsible for any issues arising from its use. + +> To the best of my knowledge, I have adhered to the Modding Guidelines established by Alpha Blend Interactive. diff --git a/MoreMenuOptions/format.json b/MoreMenuOptions/format.json new file mode 100644 index 0000000..8abeaaf --- /dev/null +++ b/MoreMenuOptions/format.json @@ -0,0 +1,23 @@ +{ + "_id": -1, + "name": "MoreMenuOptions", + "modversion": "1.0.0", + "gameversion": "2024r175", + "loaderversion": "0.6.1", + "modtype": "Mod", + "author": "NotAKidoS", + "description": "Exposes some menu options:\n- Main Menu Scale Modifier\n- Main Menu Distance Modifier\n- Quick Menu World Anchor in VR\n\nBy default, the menu is adjusted to a more comfortable scale, but can be configured in the mod settings.", + "searchtags": [ + "menu", + "scale", + "distance", + "anchor" + ], + "requirements": [ + "None" + ], + "downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r26/MoreMenuOptions.dll", + "sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/MoreMenuOptions/", + "changelog": "- Initial Release", + "embedcolor": "#89b7d9" +} \ No newline at end of file diff --git a/NAK_CVR_Mods.sln b/NAK_CVR_Mods.sln index 0e7f92a..cd698b8 100644 --- a/NAK_CVR_Mods.sln +++ b/NAK_CVR_Mods.sln @@ -45,6 +45,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StopClosingMyMenuOnWorldLoa EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SwitchToDesktopOnSteamVRExit", "SwitchToDesktopOnSteamVRExit\SwitchToDesktopOnSteamVRExit.csproj", "{F7F4B840-6FF5-46C4-AAFD-95362D1D666C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoreMenuOptions", "MoreMenuOptions\MoreMenuOptions.csproj", "{AB07B31E-A930-4CCC-8E02-F2A4D6C52C8F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -135,6 +137,10 @@ Global {F7F4B840-6FF5-46C4-AAFD-95362D1D666C}.Debug|Any CPU.Build.0 = Debug|Any CPU {F7F4B840-6FF5-46C4-AAFD-95362D1D666C}.Release|Any CPU.ActiveCfg = Release|Any CPU {F7F4B840-6FF5-46C4-AAFD-95362D1D666C}.Release|Any CPU.Build.0 = Release|Any CPU + {AB07B31E-A930-4CCC-8E02-F2A4D6C52C8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AB07B31E-A930-4CCC-8E02-F2A4D6C52C8F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AB07B31E-A930-4CCC-8E02-F2A4D6C52C8F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AB07B31E-A930-4CCC-8E02-F2A4D6C52C8F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE