Add project files.

This commit is contained in:
notGreg 2022-09-08 21:29:16 +02:00
parent 6a3cfe1591
commit 364f313e79
5 changed files with 236 additions and 0 deletions

25
CameraResolutionScale.sln Normal file
View File

@ -0,0 +1,25 @@

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}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
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}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41D9C9BC-1D1B-4A90-8543-DD303712A766}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D4D1124D-EE96-4A87-9DC9-879ED5AC1122}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{41D9C9BC-1D1B-4A90-8543-DD303712A766}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CameraResolutionScale</RootNamespace>
<AssemblyName>CameraResolutionScale</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>E:\SPT-AKI\SPT-AKI 3.2.1\EscapeFromTarkov_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="BepInEx">
<HintPath>E:\SPT-AKI\SPT-AKI 3.2.1\BepInEx\core\BepInEx.dll</HintPath>
</Reference>
<Reference Include="Comfort">
<HintPath>E:\SPT-AKI\SPT-AKI 3.2.1\EscapeFromTarkov_Data\Managed\Comfort.dll</HintPath>
</Reference>
<Reference Include="ItemComponent.Types, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>E:\SPT-AKI\SPT-AKI 3.2.1\EscapeFromTarkov_Data\Managed\ItemComponent.Types.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Unity.Postprocessing.Runtime">
<HintPath>E:\SPT-AKI\SPT-AKI 3.2.1\EscapeFromTarkov_Data\Managed\Unity.Postprocessing.Runtime.dll</HintPath>
</Reference>
<Reference Include="UnityEngine">
<HintPath>E:\SPT-AKI\SPT-AKI 3.2.1\EscapeFromTarkov_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>E:\SPT-AKI\SPT-AKI 3.2.1\EscapeFromTarkov_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Plugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,83 @@
using BepInEx;
using BepInEx.Configuration;
using EFT;
using UnityEngine;
using Comfort.Common;
namespace CameraResolutionScale
{
[BepInPlugin("com.notGreg.cameraScaleControl", "notGreg's Camera Resolution Settings", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
ConfigEntry<int> cameraResolutionScale;
ConfigEntry<int> scopeCameraResolutionScale;
void Awake()
{
cameraResolutionScale = Config.Bind("General", "Main camera scale %", 50, new ConfigDescription("Main camera resulution scae", new AcceptableValueRange<int>(10,200)));
scopeCameraResolutionScale = Config.Bind("General", "Scope camera scale %", 33, new ConfigDescription("Scope camera resulution scae", new AcceptableValueRange<int>(10, 200)));
}
Rect defaultMainCameraRect;
float rectScale;
bool setupDone = false;
Camera scopeCamera = null;
bool isAiming = false;
Utils utils = new Utils();
void Update()
{
if (!utils.gameIsReady())
{
return;
}
if (Camera.allCamerasCount < 1) return;
if (Camera.main == null || Camera.main.isActiveAndEnabled == false)
{
setupDone = false;
return;
}
var handsController = ((Singleton<GameWorld>.Instance.RegisteredPlayers[0].HandsController));
isAiming = handsController.IsAiming;
if (isAiming)
{
if (Camera.main == null || Camera.allCamerasCount <= 1) return;
if (!setupDone)
{
Logger.LogInfo("Storing default Camera.main.rect");
defaultMainCameraRect = Camera.main.rect;
rectScale = defaultMainCameraRect.width;
Logger.LogInfo($"Rect: {defaultMainCameraRect}");
setupDone = true;
}
if (scopeCamera == null) scopeCamera = Camera.allCameras[1];
scopeCamera.GetComponent<SSAAOptic>().OpticCameraToMainCameraResolutionRatio = (float)(scopeCameraResolutionScale.Value / 100f);
float scale = (float)cameraResolutionScale.Value / 100f;
Camera.main.rect = new Rect(0, 0, rectScale * scale, rectScale * scale);
//Logger.LogInfo($"Updating render resolutions: Main Camera: {cameraResolutionScale.Value}% Scope Camera: {scopeCameraResolutionScale.Value}%");
return;
}
if (Camera.main.rect != defaultMainCameraRect && setupDone)
{
Logger.LogInfo("Restoring default render resolution");
Camera.main.rect = defaultMainCameraRect;
}
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("CameraResolutionScale")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CameraResolutionScale")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("41d9c9bc-1d1b-4a90-8543-dd303712a766")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,21 @@
using Comfort.Common;
using EFT;
namespace CameraResolutionScale
{
public class Utils
{
public bool gameIsReady()
{
var gameWorld = Singleton<GameWorld>.Instance;
var sessionResultPanel = Singleton<SessionResultPanel>.Instance;
if (gameWorld == null
|| gameWorld.AllPlayers == null
|| gameWorld.AllPlayers.Count <= 0
|| sessionResultPanel != null)
{ return false; }
return true;
}
}
}