Expanded ScalingMode to ScopesOnly and AllSights
This commit is contained in:
parent
804e4643f4
commit
9fe689ef13
@ -6,6 +6,7 @@ using Comfort.Common;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using EFT.Settings.Graphics;
|
using EFT.Settings.Graphics;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ScopeTweaks
|
namespace ScopeTweaks
|
||||||
{
|
{
|
||||||
@ -19,7 +20,10 @@ namespace ScopeTweaks
|
|||||||
enum EFOVScalingMode
|
enum EFOVScalingMode
|
||||||
{
|
{
|
||||||
Disabled,
|
Disabled,
|
||||||
Enabled,
|
[Description("Magnified optics")]
|
||||||
|
ScopesOnly,
|
||||||
|
[Description("All sights")]
|
||||||
|
All,
|
||||||
}
|
}
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
@ -36,7 +40,7 @@ namespace ScopeTweaks
|
|||||||
80,
|
80,
|
||||||
new ConfigDescription("Scope camera resolution scale", new AcceptableValueRange<int>(25, 100)));
|
new ConfigDescription("Scope camera resolution scale", new AcceptableValueRange<int>(25, 100)));
|
||||||
|
|
||||||
scopeFixType = Config.Bind("General", "High FOV scope tweak", EFOVScalingMode.Enabled, new ConfigDescription(""));
|
scopeFixType = Config.Bind("General", "High FOV sight tweak", EFOVScalingMode.ScopesOnly, new ConfigDescription(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
Camera FPSCamera = null;
|
Camera FPSCamera = null;
|
||||||
@ -57,12 +61,12 @@ namespace ScopeTweaks
|
|||||||
{
|
{
|
||||||
case GameStatus.Started:
|
case GameStatus.Started:
|
||||||
{
|
{
|
||||||
//Logger.LogInfo("Getting local player");
|
Logger.LogInfo("Getting local player");
|
||||||
mainPlayer = getLocalPlayer();
|
mainPlayer = getLocalPlayer();
|
||||||
|
|
||||||
subscribeHandsChangedEvent();
|
subscribeHandsChangedEvent();
|
||||||
|
|
||||||
//Logger.LogInfo("Assigning cameras...");
|
Logger.LogInfo("Assigning cameras...");
|
||||||
StartCoroutine(tryGetMainCamera());
|
StartCoroutine(tryGetMainCamera());
|
||||||
StartCoroutine(tryGetScopeCamera());
|
StartCoroutine(tryGetScopeCamera());
|
||||||
|
|
||||||
@ -71,7 +75,7 @@ namespace ScopeTweaks
|
|||||||
case GameStatus.SoftStopping:
|
case GameStatus.SoftStopping:
|
||||||
case GameStatus.Stopped:
|
case GameStatus.Stopped:
|
||||||
{
|
{
|
||||||
//Logger.LogInfo("Resetting...");
|
Logger.LogInfo("Resetting...");
|
||||||
FPSCamera = null;
|
FPSCamera = null;
|
||||||
scopeCamera = null;
|
scopeCamera = null;
|
||||||
mainPlayer = null;
|
mainPlayer = null;
|
||||||
@ -107,13 +111,13 @@ namespace ScopeTweaks
|
|||||||
int getInGameFOV()
|
int getInGameFOV()
|
||||||
{
|
{
|
||||||
int fov = Singleton<GClass1642>.Instance.Game.Settings.FieldOfView.Value;
|
int fov = Singleton<GClass1642>.Instance.Game.Settings.FieldOfView.Value;
|
||||||
//Logger.LogInfo($"In-game FOV: {fov}");
|
Logger.LogInfo($"In-game FOV: {fov}");
|
||||||
return fov;
|
return fov;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setInGameFOV(int value)
|
void setInGameFOV(int value)
|
||||||
{
|
{
|
||||||
//Logger.LogInfo($"Setting FOV to {value}");
|
Logger.LogInfo($"setInGameFOV(): Update to {value}");
|
||||||
Singleton<GClass1642>.Instance.Game.Settings.FieldOfView.Value = value;
|
Singleton<GClass1642>.Instance.Game.Settings.FieldOfView.Value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,11 +131,11 @@ namespace ScopeTweaks
|
|||||||
if (GameObject.Find(cameraName) != null)
|
if (GameObject.Find(cameraName) != null)
|
||||||
{
|
{
|
||||||
FPSCamera = GameObject.Find(cameraName).GetComponent<Camera>();
|
FPSCamera = GameObject.Find(cameraName).GetComponent<Camera>();
|
||||||
//Logger.LogInfo($"{FPSCamera.name} found!");
|
Logger.LogInfo($"{FPSCamera.name} found!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Logger.LogMessage($"Camera \"{cameraName}\" not found, rescheduling...");
|
Logger.LogMessage($"Camera \"{cameraName}\" not found, rescheduling...");
|
||||||
yield return myDelaySec;
|
yield return myDelaySec;
|
||||||
StartCoroutine(tryGetMainCamera());
|
StartCoroutine(tryGetMainCamera());
|
||||||
yield break;
|
yield break;
|
||||||
@ -150,14 +154,14 @@ namespace ScopeTweaks
|
|||||||
if (GameObject.Find(cameraName) != null)
|
if (GameObject.Find(cameraName) != null)
|
||||||
{
|
{
|
||||||
scopeCamera = GameObject.Find(cameraName).GetComponent<Camera>();
|
scopeCamera = GameObject.Find(cameraName).GetComponent<Camera>();
|
||||||
//Logger.LogInfo($"Camera \"{scopeCamera.name}\" found!");
|
Logger.LogInfo($"Camera \"{scopeCamera.name}\" found!");
|
||||||
}
|
}
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMainCameraResolutionScale(int value = 100)
|
void setMainCameraResolutionScale(int value = 100)
|
||||||
{
|
{
|
||||||
//Logger.LogInfo($"Setting MainCam res scale to {value}%");
|
Logger.LogInfo($"Setting MainCam res scale to {value}%");
|
||||||
ssaaInstance = FPSCamera.GetComponent<SSAA>();
|
ssaaInstance = FPSCamera.GetComponent<SSAA>();
|
||||||
_nextSSRation = getFieldInfo("_nextSSRation");
|
_nextSSRation = getFieldInfo("_nextSSRation");
|
||||||
_nextSSRation.SetValue(ssaaInstance, (float)(currentScalingFactor * value / 100f));
|
_nextSSRation.SetValue(ssaaInstance, (float)(currentScalingFactor * value / 100f));
|
||||||
@ -166,10 +170,10 @@ namespace ScopeTweaks
|
|||||||
void setScopeCameraResolutionScale(int value)
|
void setScopeCameraResolutionScale(int value)
|
||||||
{
|
{
|
||||||
if(scopeCamera == null || !scopeCamera.isActiveAndEnabled)
|
if(scopeCamera == null || !scopeCamera.isActiveAndEnabled)
|
||||||
{ //Logger.LogInfo("ScopeCam inactive or absent!");
|
{ Logger.LogInfo("ScopeCam inactive or absent!");
|
||||||
return; }
|
return; }
|
||||||
|
|
||||||
//Logger.LogInfo($"Setting Scope res scale to {value}%");
|
Logger.LogInfo($"Setting Scope res scale to {value}%");
|
||||||
scopeCamera.GetComponent<SSAAOptic>().OpticCameraToMainCameraResolutionRatio = (float)(currentScalingFactor * value / 100);
|
scopeCamera.GetComponent<SSAAOptic>().OpticCameraToMainCameraResolutionRatio = (float)(currentScalingFactor * value / 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +182,7 @@ namespace ScopeTweaks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
void subscribeHandsChangedEvent()
|
void subscribeHandsChangedEvent()
|
||||||
{
|
{
|
||||||
//Logger.LogInfo("Subscribing to HandsChanged Event");
|
Logger.LogInfo("Subscribing to HandsChanged Event");
|
||||||
mainPlayer.HandsChangedEvent += (handsArgs) =>
|
mainPlayer.HandsChangedEvent += (handsArgs) =>
|
||||||
{
|
{
|
||||||
subscribeOnAimingChangedEvent();
|
subscribeOnAimingChangedEvent();
|
||||||
@ -187,33 +191,83 @@ namespace ScopeTweaks
|
|||||||
|
|
||||||
void subscribeOnAimingChangedEvent()
|
void subscribeOnAimingChangedEvent()
|
||||||
{
|
{
|
||||||
//Logger.LogInfo("Subscribing to OnAimingChanged Event");
|
Logger.LogInfo("Subscribing to OnAimingChanged Event");
|
||||||
mainPlayer.HandsController.OnAimingChanged += (aimingArgs) =>
|
mainPlayer.HandsController.OnAimingChanged += (aimingArgs) =>
|
||||||
{
|
{
|
||||||
if (scopeFixType.Value != EFOVScalingMode.Enabled) return;
|
|
||||||
if(!mainPlayer.ProceduralWeaponAnimation.IsAiming)
|
|
||||||
{
|
|
||||||
GClass1774.Instance.SetFov(inGameFOV, 0.33f, false);
|
|
||||||
setInGameFOV(inGameFOV);
|
|
||||||
}
|
|
||||||
setMainCameraResolutionScale();
|
|
||||||
|
|
||||||
currentScalingFactor = getCurrentScalingFactor();
|
currentScalingFactor = getCurrentScalingFactor();
|
||||||
StartCoroutine(tryGetScopeCamera());
|
StartCoroutine(tryGetScopeCamera());
|
||||||
if(mainPlayer.HandsController.IsAiming)
|
|
||||||
|
|
||||||
|
Logger.LogInfo("AimingChanged: notAiming");
|
||||||
|
if (!mainPlayer.ProceduralWeaponAnimation.IsAiming)
|
||||||
{
|
{
|
||||||
if(inGameFOV != 50) { inGameFOV = getInGameFOV(); }
|
|
||||||
|
|
||||||
GClass1774.Instance.SetFov(35, 0.25f, false);
|
switch(scopeFixType.Value)
|
||||||
setInGameFOV(50);
|
{
|
||||||
|
case EFOVScalingMode.Disabled:
|
||||||
|
{
|
||||||
|
Logger.LogInfo("Nothing to do!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EFOVScalingMode.ScopesOnly:
|
||||||
|
{
|
||||||
|
setMainCameraResolutionScale();
|
||||||
|
GClass1774.Instance.SetFov(90, 0.33f, false);
|
||||||
|
setInGameFOV(inGameFOV);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EFOVScalingMode.All:
|
||||||
|
{
|
||||||
|
setMainCameraResolutionScale();
|
||||||
|
GClass1774.Instance.SetFov(90, 0.33f, false);
|
||||||
|
setInGameFOV(inGameFOV);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setMainCameraResolutionScale(cameraResolutionScale.Value);
|
Logger.LogInfo("Entering switch()");
|
||||||
setScopeCameraResolutionScale(scopeCameraResolutionScale.Value);
|
if (mainPlayer.ProceduralWeaponAnimation.IsAiming)
|
||||||
return;
|
{
|
||||||
|
if (inGameFOV != 50) { inGameFOV = getInGameFOV(); }
|
||||||
|
switch (scopeFixType.Value)
|
||||||
|
{
|
||||||
|
case EFOVScalingMode.Disabled:
|
||||||
|
{
|
||||||
|
Logger.LogInfo("Plugin is disabled!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EFOVScalingMode.ScopesOnly:
|
||||||
|
{
|
||||||
|
Logger.LogInfo("Only magnified optics!");
|
||||||
|
if(scopeCamera.isActiveAndEnabled)
|
||||||
|
{
|
||||||
|
applyFixesWhileAiming();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EFOVScalingMode.All:
|
||||||
|
{
|
||||||
|
Logger.LogInfo("All sights!");
|
||||||
|
|
||||||
|
applyFixesWhileAiming();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void applyFixesWhileAiming()
|
||||||
|
{
|
||||||
|
GClass1774.Instance.SetFov(35, 0.25f, false);
|
||||||
|
setInGameFOV(50);
|
||||||
|
|
||||||
|
setMainCameraResolutionScale(cameraResolutionScale.Value);
|
||||||
|
setScopeCameraResolutionScale(scopeCameraResolutionScale.Value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// IN-GAME SETTINGS
|
/// IN-GAME SETTINGS
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -222,12 +276,12 @@ namespace ScopeTweaks
|
|||||||
|
|
||||||
float getCurrentScalingFactor()
|
float getCurrentScalingFactor()
|
||||||
{
|
{
|
||||||
//Logger.LogInfo("Getting current scaling factor:");
|
Logger.LogInfo("Getting current scaling factor:");
|
||||||
var graphics = Singleton<GClass1642>.Instance.Graphics.Settings;
|
var graphics = Singleton<GClass1642>.Instance.Graphics.Settings;
|
||||||
|
|
||||||
if (!graphics.DLSSEnabled && !graphics.FSREnabled)
|
if (!graphics.DLSSEnabled && !graphics.FSREnabled)
|
||||||
{
|
{
|
||||||
//Logger.LogInfo($"Supersampling factor: {graphics.SuperSamplingFactor}");
|
Logger.LogInfo($"Supersampling factor: {graphics.SuperSamplingFactor}");
|
||||||
return graphics.SuperSamplingFactor;
|
return graphics.SuperSamplingFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +296,7 @@ namespace ScopeTweaks
|
|||||||
case EDLSSMode.Performance: { DLSSFactor = 0.5f; break; }
|
case EDLSSMode.Performance: { DLSSFactor = 0.5f; break; }
|
||||||
case EDLSSMode.UltraPerformance: { DLSSFactor = 0.33f; break; }
|
case EDLSSMode.UltraPerformance: { DLSSFactor = 0.33f; break; }
|
||||||
}
|
}
|
||||||
//Logger.LogInfo($"DLSS factor: {DLSSFactor}");
|
Logger.LogInfo($"DLSS factor: {DLSSFactor}");
|
||||||
return DLSSFactor;
|
return DLSSFactor;
|
||||||
}
|
}
|
||||||
if (graphics.FSREnabled)
|
if (graphics.FSREnabled)
|
||||||
@ -256,11 +310,11 @@ namespace ScopeTweaks
|
|||||||
case EFSRMode.Balanced: { FSRFactor = 0.59f; break; }
|
case EFSRMode.Balanced: { FSRFactor = 0.59f; break; }
|
||||||
case EFSRMode.Performance: { FSRFactor = 0.5f; break; }
|
case EFSRMode.Performance: { FSRFactor = 0.5f; break; }
|
||||||
}
|
}
|
||||||
//Logger.LogInfo($"FSR factor: {FSRFactor}");
|
Logger.LogInfo($"FSR factor: {FSRFactor}");
|
||||||
return FSRFactor;
|
return FSRFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Logger.LogInfo($"GetCurrentScalingFactor(): Something went wrong. Returning 1.0f");
|
Logger.LogInfo($"GetCurrentScalingFactor(): Something went wrong. Returning 1.0f");
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user