mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
[FOVAdjustment] Initial release
This commit is contained in:
parent
c7ca08cd4d
commit
6e447c5cff
5 changed files with 136 additions and 0 deletions
2
FOVAdjustment/FOVAdjustment.csproj
Normal file
2
FOVAdjustment/FOVAdjustment.csproj
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk"/>
|
64
FOVAdjustment/Main.cs
Normal file
64
FOVAdjustment/Main.cs
Normal file
|
@ -0,0 +1,64 @@
|
|||
using ABI.CCK.Components;
|
||||
using ABI_RC.Core.Player;
|
||||
using MelonLoader;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.FOVAdjustment;
|
||||
|
||||
public class FOVAdjustment : MelonMod
|
||||
{
|
||||
internal const string SettingsCategory = nameof(FOVAdjustment);
|
||||
|
||||
public static readonly MelonPreferences_Category Category =
|
||||
MelonPreferences.CreateCategory(SettingsCategory);
|
||||
|
||||
public static readonly MelonPreferences_Entry<bool> EntryEnabled =
|
||||
Category.CreateEntry("Enabled", true, description: "Toggle FOVAdjustment entirely.");
|
||||
|
||||
public static readonly MelonPreferences_Entry<float> EntryFOV =
|
||||
Category.CreateEntry("FOV", 60f, description: "Target Desktop FOV. This is ignored if the world specifies a custom FOV!");
|
||||
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
HarmonyInstance.Patch(
|
||||
typeof(CVR_DesktopCameraController).GetMethod(nameof(CVR_DesktopCameraController.UpdateFov)),
|
||||
prefix: new HarmonyLib.HarmonyMethod(typeof(FOVAdjustment).GetMethod(nameof(OnUpdateFov_Prefix), BindingFlags.NonPublic | BindingFlags.Static))
|
||||
);
|
||||
|
||||
EntryEnabled.OnEntryValueChanged.Subscribe(OnEntryEnabledChanged);
|
||||
EntryFOV.OnEntryValueChanged.Subscribe(OnEntryFovChanged);
|
||||
}
|
||||
|
||||
private void OnEntryEnabledChanged(bool oldValue, bool newValue)
|
||||
{
|
||||
UpdateDesktopCameraControllerFov(newValue ? EntryFOV.Value : 60f);
|
||||
CVR_DesktopCameraController.UpdateFov();
|
||||
}
|
||||
|
||||
private void OnEntryFovChanged(float oldValue, float newValue)
|
||||
{
|
||||
if (!EntryEnabled.Value)
|
||||
return;
|
||||
|
||||
UpdateDesktopCameraControllerFov(newValue);
|
||||
CVR_DesktopCameraController.UpdateFov();
|
||||
}
|
||||
|
||||
private static void OnUpdateFov_Prefix()
|
||||
{
|
||||
if (!EntryEnabled.Value)
|
||||
return;
|
||||
|
||||
UpdateDesktopCameraControllerFov(EntryFOV.Value);
|
||||
}
|
||||
|
||||
private static void UpdateDesktopCameraControllerFov(float value)
|
||||
{
|
||||
if (CVRWorld.Instance != null && Mathf.Approximately(CVRWorld.Instance.fov, 60f))
|
||||
{
|
||||
CVR_DesktopCameraController.defaultFov = Mathf.Clamp(value, 60f, 120f);
|
||||
CVR_DesktopCameraController.zoomFov = CVR_DesktopCameraController.defaultFov * 0.5f;
|
||||
}
|
||||
}
|
||||
}
|
29
FOVAdjustment/Properties/AssemblyInfo.cs
Normal file
29
FOVAdjustment/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using MelonLoader;
|
||||
using NAK.FOVAdjustment.Properties;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyTitle(nameof(NAK.FOVAdjustment))]
|
||||
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
|
||||
[assembly: AssemblyProduct(nameof(NAK.FOVAdjustment))]
|
||||
|
||||
[assembly: MelonInfo(
|
||||
typeof(NAK.FOVAdjustment.FOVAdjustment),
|
||||
nameof(NAK.FOVAdjustment),
|
||||
AssemblyInfoParams.Version,
|
||||
AssemblyInfoParams.Author,
|
||||
downloadLink: "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/FOVAdjustment"
|
||||
)]
|
||||
|
||||
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
||||
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
||||
|
||||
namespace NAK.FOVAdjustment.Properties;
|
||||
internal static class AssemblyInfoParams
|
||||
{
|
||||
public const string Version = "1.0.0";
|
||||
public const string Author = "NotAKidoS";
|
||||
}
|
18
FOVAdjustment/README.md
Normal file
18
FOVAdjustment/README.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
# FOVAdjustment
|
||||
|
||||
A simple mod that makes the CVR_DesktopCameraController defaultFov adjustable.
|
||||
|
||||
The custom FOV setting is ignored if a world author specified a FOV other than 60f.
|
||||
|
||||
It is limited between 60f and 120f to match the limitations world creators have with setting custom FOV.
|
||||
|
||||
---
|
||||
|
||||
Here is the block of text where I tell you this mod is not affiliated or endorsed by ABI.
|
||||
https://documentation.abinteractive.net/official/legal/tos/#7-modding-our-games
|
||||
|
||||
> This mod is an independent creation and is 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.
|
23
FOVAdjustment/format.json
Normal file
23
FOVAdjustment/format.json
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"_id": -1,
|
||||
"name": "FOVAdjustment",
|
||||
"modversion": "1.0.0",
|
||||
"gameversion": "2022r170p1",
|
||||
"loaderversion": "0.6.1",
|
||||
"modtype": "Mod",
|
||||
"author": "NotAKidoS",
|
||||
"description": "A simple mod that makes CVR_DesktopCameraController defaultFov configurable by the user if the world author didn't specify a custom world FOV.\n\nCustom FOV values are limited between 60f and 120f to match the limitations imposed on world creators.",
|
||||
"searchtags": [
|
||||
"aas",
|
||||
"sync",
|
||||
"naked",
|
||||
"buffer"
|
||||
],
|
||||
"requirements": [
|
||||
"UIExpansionKit"
|
||||
],
|
||||
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r13/FOVAdjustment.dll",
|
||||
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/FOVAdjustment/",
|
||||
"changelog": "- Initial CVRMG release",
|
||||
"embedcolor": "7d7d7d"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue