[MoreMenuOptions] Initial Release

This commit is contained in:
NotAKidoS 2024-04-23 18:37:07 -05:00
parent f12fb89fc0
commit 9cfe74276d
7 changed files with 217 additions and 0 deletions

106
MoreMenuOptions/Main.cs Normal file
View file

@ -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
}

View file

@ -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<MoreMenuOptions.MainMenuModifierUsage> EntryMainMenuModiferUsage =
Category.CreateEntry("Main Menu Modifier Usage", MoreMenuOptions.MainMenuModifierUsage.Both, description: "The usage of the main menu modifier.");
internal static readonly MelonPreferences_Entry<float> EntryMMScaleModifier =
Category.CreateEntry("Main Menu Scale Modifier", 0.75f, description: "The scale of the main menu.");
internal static readonly MelonPreferences_Entry<float> 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<bool> EntryQMWorldAnchorInVR =
Category.CreateEntry("Quick Menu World Anchor In VR", false, description: "Toggle the quick menu world anchor in VR.");
}

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk"/>

View file

@ -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";
}

21
MoreMenuOptions/README.md Normal file
View file

@ -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.

View file

@ -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"
}

View file

@ -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