From b6c284857bcf19cc0b046c149bd5758081a6c5f3 Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com> Date: Thu, 6 Jul 2023 14:54:40 -0500 Subject: [PATCH] [MenuScalePatch] Added FOV adjustment handling. --- MenuScalePatch/HarmonyPatches.cs | 16 ++++++++++++++++ MenuScalePatch/Helpers/MainMenuHelper.cs | 2 +- MenuScalePatch/Helpers/QuickMenuHelper.cs | 2 +- MenuScalePatch/MSP_Menus.cs | 1 + MenuScalePatch/Main.cs | 3 +++ MenuScalePatch/Properties/AssemblyInfo.cs | 2 +- MenuScalePatch/format.json | 6 +++--- NAK_CVR_Mods.sln | 6 ++++++ 8 files changed, 32 insertions(+), 6 deletions(-) diff --git a/MenuScalePatch/HarmonyPatches.cs b/MenuScalePatch/HarmonyPatches.cs index 32c8ceb..5ab08f2 100644 --- a/MenuScalePatch/HarmonyPatches.cs +++ b/MenuScalePatch/HarmonyPatches.cs @@ -184,4 +184,20 @@ internal class HarmonyPatches return patchedInstructions; } + + [HarmonyPostfix] + [HarmonyPatch(typeof(CVR_DesktopCameraController), nameof(CVR_DesktopCameraController.UpdateFov))] + private static void Postfix_CVR_DesktopCameraController_UpdateFov() + { + if (!MenuScalePatch.EntryUseFOVAdjustment.Value) + { + MSP_MenuInfo.FOVAdjustment = 1f; + return; + } + + const float minFovValue = 60f; + const float maxFovValue = 120f; + MSP_MenuInfo.FOVAdjustment = + 1f + (2f * Mathf.Clamp01((CVR_DesktopCameraController.defaultFov - minFovValue) / (maxFovValue - minFovValue))); + } } \ No newline at end of file diff --git a/MenuScalePatch/Helpers/MainMenuHelper.cs b/MenuScalePatch/Helpers/MainMenuHelper.cs index 0849ba5..0cc2099 100644 --- a/MenuScalePatch/Helpers/MainMenuHelper.cs +++ b/MenuScalePatch/Helpers/MainMenuHelper.cs @@ -95,7 +95,7 @@ public class MainMenuHelper : MonoBehaviour if (MSP_MenuInfo.CameraTransform == null || MSP_MenuInfo.DisableMMHelper) return; Transform activeAnchor = MSP_MenuInfo.isIndependentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform; - transform.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor, 0.9f * MSP_MenuInfo.ScaleFactor, 1f); + transform.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor * MSP_MenuInfo.FOVAdjustment, 0.9f * MSP_MenuInfo.ScaleFactor * MSP_MenuInfo.FOVAdjustment, 1f); transform.position = activeAnchor.position + activeAnchor.forward * 1f * MSP_MenuInfo.ScaleFactor * MSP_MenuInfo.AspectRatio; transform.rotation = activeAnchor.rotation; } diff --git a/MenuScalePatch/Helpers/QuickMenuHelper.cs b/MenuScalePatch/Helpers/QuickMenuHelper.cs index 7404ec8..6c01f95 100644 --- a/MenuScalePatch/Helpers/QuickMenuHelper.cs +++ b/MenuScalePatch/Helpers/QuickMenuHelper.cs @@ -76,7 +76,7 @@ public class QuickMenuHelper : MonoBehaviour if (MSP_MenuInfo.CameraTransform == null || MSP_MenuInfo.DisableQMHelper) return; Transform activeAnchor = MSP_MenuInfo.isIndependentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform; - transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f); + transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor * MSP_MenuInfo.FOVAdjustment, 1f * MSP_MenuInfo.ScaleFactor * MSP_MenuInfo.FOVAdjustment, 1f); transform.rotation = activeAnchor.rotation; transform.position = activeAnchor.position + activeAnchor.transform.forward * 1f * MSP_MenuInfo.ScaleFactor; } diff --git a/MenuScalePatch/MSP_Menus.cs b/MenuScalePatch/MSP_Menus.cs index a20dcde..b6d887a 100644 --- a/MenuScalePatch/MSP_Menus.cs +++ b/MenuScalePatch/MSP_Menus.cs @@ -11,6 +11,7 @@ public class MSP_MenuInfo //Shared Info internal static float ScaleFactor = 1f; internal static float AspectRatio = 1f; + internal static float FOVAdjustment = 1f; internal static Transform CameraTransform; //Settings...? diff --git a/MenuScalePatch/Main.cs b/MenuScalePatch/Main.cs index 21b168d..bc8298b 100644 --- a/MenuScalePatch/Main.cs +++ b/MenuScalePatch/Main.cs @@ -12,6 +12,9 @@ public class MenuScalePatch : MelonMod public static MelonPreferences_Entry EntryPlayerAnchorMenus = Category.CreateEntry("Player Anchor Menus", true, description: "Should the menus be anchored to & constantly follow the player?"); + + public static MelonPreferences_Entry EntryUseFOVAdjustment = + Category.CreateEntry("Use FOV Adjustment", true, description: "Should the menus adjust to your changed FOV?"); public override void OnInitializeMelon() { diff --git a/MenuScalePatch/Properties/AssemblyInfo.cs b/MenuScalePatch/Properties/AssemblyInfo.cs index d42bda8..9399df6 100644 --- a/MenuScalePatch/Properties/AssemblyInfo.cs +++ b/MenuScalePatch/Properties/AssemblyInfo.cs @@ -24,6 +24,6 @@ using System.Reflection; namespace NAK.MenuScalePatch.Properties; internal static class AssemblyInfoParams { - public const string Version = "4.2.7"; + public const string Version = "4.2.8"; public const string Author = "NotAKidoS"; } \ No newline at end of file diff --git a/MenuScalePatch/format.json b/MenuScalePatch/format.json index 78fc27f..462be0b 100644 --- a/MenuScalePatch/format.json +++ b/MenuScalePatch/format.json @@ -1,7 +1,7 @@ { "_id": 95, "name": "MenuScalePatch", - "modversion": "4.2.7", + "modversion": "4.2.8", "gameversion": "2022r170p1", "loaderversion": "0.6.1", "modtype": "Mod", @@ -16,8 +16,8 @@ "requirements": [ "None" ], - "downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r3/MenuScalePatch.dll", + "downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r13/MenuScalePatch.dll", "sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/MenuScalePatch/", - "changelog": "- Menus are no longer forced closed on world load.", + "changelog": "- Added FOV handling to menu scaling. The menu will scale with changes to your FOV.", "embedcolor": "363020" } \ No newline at end of file diff --git a/NAK_CVR_Mods.sln b/NAK_CVR_Mods.sln index a6ad22d..62b3786 100644 --- a/NAK_CVR_Mods.sln +++ b/NAK_CVR_Mods.sln @@ -69,6 +69,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FuckCohtmlResourceHandler", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlaySpaceScaleFix", "PlaySpaceScaleFix\PlaySpaceScaleFix.csproj", "{61368493-5B0E-489B-828C-DE10428AB81A}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FOVAdjustment", "FOVAdjustment\FOVAdjustment.csproj", "{EE552804-30B1-49CF-BBDE-3B312895AFF7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -207,6 +209,10 @@ Global {61368493-5B0E-489B-828C-DE10428AB81A}.Debug|Any CPU.Build.0 = Debug|Any CPU {61368493-5B0E-489B-828C-DE10428AB81A}.Release|Any CPU.ActiveCfg = Release|Any CPU {61368493-5B0E-489B-828C-DE10428AB81A}.Release|Any CPU.Build.0 = Release|Any CPU + {EE552804-30B1-49CF-BBDE-3B312895AFF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EE552804-30B1-49CF-BBDE-3B312895AFF7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EE552804-30B1-49CF-BBDE-3B312895AFF7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EE552804-30B1-49CF-BBDE-3B312895AFF7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE