wip
This commit is contained in:
parent
19c13e03cd
commit
f4a7536862
@ -3,8 +3,8 @@ using BepInEx.Configuration;
|
||||
using EFT;
|
||||
using UnityEngine;
|
||||
using Comfort.Common;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using System;
|
||||
|
||||
namespace CameraResolutionScale
|
||||
{
|
||||
@ -14,10 +14,31 @@ namespace CameraResolutionScale
|
||||
ConfigEntry<int> cameraResolutionScale;
|
||||
ConfigEntry<int> scopeCameraResolutionScale;
|
||||
|
||||
public event EventHandler SettingChanged;
|
||||
void Awake()
|
||||
{
|
||||
cameraResolutionScale = Config.Bind("General", "Main camera scale %", 80, new ConfigDescription("Main camera resulution sclae", new AcceptableValueRange<int>(50, 100)));
|
||||
scopeCameraResolutionScale = Config.Bind("General", "Scope camera scale %", 40, new ConfigDescription("Scope camera resulution scale", new AcceptableValueRange<int>(25, 100)));
|
||||
|
||||
|
||||
cameraResolutionScale.SettingChanged += (s, args) =>
|
||||
{
|
||||
updateSSRatio();
|
||||
};
|
||||
|
||||
scopeCameraResolutionScale.SettingChanged += (s, args) =>
|
||||
{
|
||||
updateSSRatio();
|
||||
};
|
||||
}
|
||||
|
||||
void updateSSRatio()
|
||||
{
|
||||
if (!isAiming && FPSCamera != null)
|
||||
{
|
||||
defaultSSRatio = (float)_nextSSRation.GetValue(ssaaInstance);
|
||||
Logger.LogInfo($"Updating defaultSSRatio to {defaultSSRatio}");
|
||||
}
|
||||
}
|
||||
|
||||
float defaultSSRatio = 1.0f;
|
||||
@ -38,30 +59,38 @@ namespace CameraResolutionScale
|
||||
{
|
||||
if (!utils.gameIsReady())
|
||||
{
|
||||
//reset everything ahead of time
|
||||
FPSCamera = null;
|
||||
scopeCamera = null;
|
||||
//Logger.LogInfo("Resetting...");
|
||||
doneOnce = false;
|
||||
FPSCamera = null;
|
||||
ssaaInstance = null;
|
||||
scopeCamera = null;
|
||||
return;
|
||||
}
|
||||
if (Camera.allCamerasCount < 1) return;
|
||||
if (Camera.main == null) return;
|
||||
|
||||
//Logger.LogInfo("Check FPS camera");
|
||||
if (GameObject.Find("FPS Camera") != null && FPSCamera == null)
|
||||
{
|
||||
//Logger.LogInfo("Assigning FPS Camera");
|
||||
FPSCamera = GameObject.Find("FPS Camera").GetComponent<Camera>();
|
||||
}
|
||||
|
||||
//Logger.LogInfo("Check Scope camera");
|
||||
if (GameObject.Find("BaseOpticCamera(Clone)") != null && scopeCamera == null)
|
||||
{
|
||||
//Logger.LogInfo("Assigning Scope Camera");
|
||||
scopeCamera = GameObject.Find("BaseOpticCamera(Clone)").GetComponent<Camera>();
|
||||
}
|
||||
|
||||
var handsController = ((Singleton<GameWorld>.Instance.RegisteredPlayers[0].HandsController));
|
||||
isAiming = handsController.IsAiming;
|
||||
|
||||
//Logger.LogInfo("Checking ssaaInstance");
|
||||
if(ssaaInstance == null)
|
||||
{
|
||||
ssaaInstance = FPSCamera.GetComponent<SSAA>();
|
||||
|
||||
//figure out a way to update it if resolution or reso scale changes
|
||||
_nextSSRation = typeof(SSAA).GetField("_nextSSRation", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
_currentSSRatio = typeof(SSAA).GetField("_currentSSRatio", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
@ -69,6 +98,7 @@ namespace CameraResolutionScale
|
||||
defaultSSRatio = (float)_nextSSRation.GetValue(ssaaInstance);
|
||||
}
|
||||
|
||||
//Logger.LogInfo("Checking if isAiming");
|
||||
if (isAiming && !doneOnce)
|
||||
{
|
||||
if (FPSCamera == null) return;
|
||||
@ -83,6 +113,7 @@ namespace CameraResolutionScale
|
||||
return;
|
||||
}
|
||||
|
||||
//Logger.LogInfo("Checking if not isAiming");
|
||||
if (!isAiming && doneOnce)
|
||||
{
|
||||
Logger.LogInfo($"Restoring default scale: {defaultSSRatio}");
|
||||
|
Loading…
x
Reference in New Issue
Block a user