This commit is contained in:
notGreg 2022-09-17 20:08:36 +02:00
parent 963699710b
commit c8728e5769
6 changed files with 39 additions and 64 deletions

View File

@ -1,21 +0,0 @@

using EFT.UI;
using UnityEngine;
namespace CameraResolutionScale
{
public class DisableFOVScaling
{
public SelectSlider getFOVSelectSlider()
{
string rootObjectPath = "Common UI/Common UI/SettingsScreen";
GameObject rootObject = GameObject.Find(rootObjectPath);
string fovObjectPath = "Game Settings/Image/Other Settings/FOV/FOV";
GameObject fovObject = rootObject.transform.Find(fovObjectPath).gameObject;
return fovObject.GetComponent<SelectSlider>();
}
}
}

View File

@ -7,18 +7,17 @@ using System.Reflection;
using System.Collections;
namespace CameraResolutionScale
namespace ScopeTweaks
{
[BepInPlugin("com.notGreg.cameraScaleControl", "notGreg's Camera Resolution Settings", "1.0.0")]
[BepInPlugin("com.notGreg.scopeTweaks", "notGreg's Scope Tweaks", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
Utils utils = new Utils();
DisableFOVScaling fovScaling = new DisableFOVScaling();
UpdateScopeResolution scopeRes = new UpdateScopeResolution();
CameraUtils scopeRes = new CameraUtils();
ConfigEntry<int> cameraResolutionScale;
ConfigEntry<int> scopeCameraResolutionScale;
ConfigEntry<int> fovCompDistScale;
ConfigEntry<bool> fovCompDistScale;
enum fovScalingMode
{
@ -41,10 +40,10 @@ namespace CameraResolutionScale
new ConfigDescription("Scope camera resolution scale", new AcceptableValueRange<int>(25, 100)));
fovCompDistScale = Config.Bind(
"Experimental",
"FOV Compensation Dist. Scale",
0,
new ConfigDescription("Adjusts _fovCompensatoryDistance variable, makes scopes more useable at high FOV values", new AcceptableValueRange<int>(0, 100)));
"Fixes",
"High FOV scope fix",
true,
new ConfigDescription("Makes scopes more useable at high FOV values"));
}
@ -63,12 +62,12 @@ namespace CameraResolutionScale
void setUpCameras()
{
Logger.LogInfo("Game started!");
//Logger.LogInfo("Game started!");
Logger.LogInfo("Get FPS Camera");
//Logger.LogInfo("Get FPS Camera");
StartCoroutine(tryGetMainCamera());
Logger.LogInfo("Get Scope Camera");
//Logger.LogInfo("Get Scope Camera");
StartCoroutine(tryGetScopeCamera());
}
@ -83,14 +82,14 @@ namespace CameraResolutionScale
}
FPSCamera = scopeRes.getMainCamera();
Logger.LogInfo("Get SSAAInstance (Camera)");
//Logger.LogInfo("Get SSAAInstance (Camera)");
ssaaInstance = scopeRes.getSSAAInstance(FPSCamera);
Logger.LogInfo("Set SSRatios");
//Logger.LogInfo("Set SSRatios");
_nextSSRation = scopeRes.getFieldInfo("_nextSSRation");
_currentSSRatio = scopeRes.getFieldInfo("_currentSSRatio");
Logger.LogInfo($"Updating defaultSSRatio to {_nextSSRation.GetValue(ssaaInstance)}");
//Logger.LogInfo($"Updating defaultSSRatio to {_nextSSRation.GetValue(ssaaInstance)}");
defaultSSRatio = (float)_nextSSRation.GetValue(ssaaInstance);
}
@ -98,7 +97,7 @@ namespace CameraResolutionScale
{
if (scopeRes.getScopeCamera() == null)
{
Logger.LogInfo("ScopeCamera not found! Restarting...");
//Logger.LogInfo("ScopeCamera not found! Restarting...");
yield return myDelaySec;
StartCoroutine(tryGetScopeCamera());
yield break;
@ -106,21 +105,18 @@ namespace CameraResolutionScale
}
Logger.LogInfo("Assigning scopeCamera");
//Logger.LogInfo("Assigning scopeCamera");
scopeCamera = scopeRes.getScopeCamera();
}
void subscribeToOnAimingChanged()
{
Logger.LogInfo($"subscribeToOnAimingChanged: player = {mainPlayer}");
//Logger.LogInfo($"subscribeToOnAimingChanged: player = {mainPlayer}");
mainPlayer.HandsController.OnAimingChanged += (args) =>
{
Logger.LogInfo("Changing fovCompDist");
mainPlayer.ProceduralWeaponAnimation._fovCompensatoryDistance = -0.03f * fovCompDistScale.Value / 100f;
if (mainPlayer.HandsController.IsAiming)
{
Logger.LogInfo("Updating camera resolutions");
//Logger.LogInfo("Updating camera resolutions");
_nextSSRation.SetValue(ssaaInstance, (float)(defaultSSRatio * cameraResolutionScale.Value / 100f));
if (scopeCamera != null && scopeCamera.isActiveAndEnabled)
@ -132,7 +128,7 @@ namespace CameraResolutionScale
if (!mainPlayer.HandsController.IsAiming)
{
Logger.LogInfo("Restoring camera resolutions");
//Logger.LogInfo("Restoring camera resolutions");
_nextSSRation.SetValue(ssaaInstance, (float)(defaultSSRatio));
return;
@ -146,7 +142,7 @@ namespace CameraResolutionScale
if (lastGameState != currentState)
{
lastGameState = currentState;
Logger.LogInfo($"GameState changed! {currentState}");
//Logger.LogInfo($"GameState changed! {currentState}");
return true;
}
//Logger.LogInfo("GameState unchanged.");
@ -165,7 +161,8 @@ namespace CameraResolutionScale
{
if (mainPlayer.HandsController.IsAiming)
{
mainPlayer.ProceduralWeaponAnimation._fovCompensatoryDistance = -0.03f * fovCompDistScale.Value / 100f;
//Logger.LogInfo("Changing fovCompDist");
if (fovCompDistScale.Value) { mainPlayer.ProceduralWeaponAnimation._fovCompensatoryDistance = 0; }
}
}
@ -173,29 +170,29 @@ namespace CameraResolutionScale
if ((currentGameState == GameStatus.SoftStopping || currentGameState == GameStatus.Stopped))
{
Logger.LogInfo("Game is stopping, resetting stuffs for the next raid");
//Logger.LogInfo("Game is stopping, resetting stuffs for the next raid");
mainPlayer = null;
return;
}
if (currentGameState == GameStatus.Started)
{
Logger.LogInfo("Getting local player");
//Logger.LogInfo("Getting local player");
mainPlayer = utils.getLocalPlayer();
Logger.LogInfo($"Returned: {mainPlayer.GetType()}");
//Logger.LogInfo($"Returned: {mainPlayer.GetType()}");
Logger.LogInfo("Updating default FOV value");
//Logger.LogInfo("Updating default FOV value");
if (defaultFOVValue != Camera.main.fieldOfView) { defaultFOVValue = (int)Camera.main.fieldOfView; }
Logger.LogInfo("setUpCameras()");
//Logger.LogInfo("setUpCameras()");
setUpCameras();
Logger.LogInfo("UpdateSSRatio()");
//Logger.LogInfo("UpdateSSRatio()");
defaultSSRatio = (float)_nextSSRation.GetValue(ssaaInstance);
Logger.LogInfo($"Updating defaultSSRatio to {defaultSSRatio}");
//Logger.LogInfo($"Updating defaultSSRatio to {defaultSSRatio}");
//updateSSRatio();
Logger.LogInfo("subscibeToOnAimingChanged()");
//Logger.LogInfo("subscibeToOnAimingChanged()");
subscribeToOnAimingChanged();
return;
@ -207,7 +204,7 @@ namespace CameraResolutionScale
// if (!isAiming && FPSCamera != null)
// {
// defaultSSRatio = (float)_nextSSRation.GetValue(ssaaInstance);
// Logger.LogInfo($"Updating defaultSSRatio to {defaultSSRatio}");
// //Logger.LogInfo($"Updating defaultSSRatio to {defaultSSRatio}");
// }
//}
}

View File

@ -1,9 +1,9 @@
using System.Reflection;
using UnityEngine;
namespace CameraResolutionScale
namespace ScopeTweaks
{
public class UpdateScopeResolution
public class CameraUtils
{
public Camera getMainCamera()
{

View File

@ -1,7 +1,7 @@
using Comfort.Common;
using EFT;
namespace CameraResolutionScale
namespace ScopeTweaks
{
public class Utils
{

View File

@ -7,8 +7,8 @@
<ProjectGuid>{41D9C9BC-1D1B-4A90-8543-DD303712A766}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CameraResolutionScale</RootNamespace>
<AssemblyName>CameraResolutionScale</AssemblyName>
<RootNamespace>ScopeTweaks</RootNamespace>
<AssemblyName>notGreg.ScopeTweaks</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
@ -67,7 +67,6 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="DisableFOVScaling.cs" />
<Compile Include="Plugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UpdateScopeResolution.cs" />

View File

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32825.248
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CameraResolutionScale", "CameraResolutionScale\CameraResolutionScale.csproj", "{41D9C9BC-1D1B-4A90-8543-DD303712A766}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "notGreg.ScopeTweaks", "CameraResolutionScale\notGreg.ScopeTweaks.csproj", "{41D9C9BC-1D1B-4A90-8543-DD303712A766}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -11,8 +11,8 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{41D9C9BC-1D1B-4A90-8543-DD303712A766}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41D9C9BC-1D1B-4A90-8543-DD303712A766}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41D9C9BC-1D1B-4A90-8543-DD303712A766}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{41D9C9BC-1D1B-4A90-8543-DD303712A766}.Debug|Any CPU.Build.0 = Release|Any CPU
{41D9C9BC-1D1B-4A90-8543-DD303712A766}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41D9C9BC-1D1B-4A90-8543-DD303712A766}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection