Skip to content

Commit

Permalink
New graphical options!
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsteyk committed Mar 22, 2023
1 parent 0053a3b commit 91149a3
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 7 deletions.
30 changes: 30 additions & 0 deletions Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class Plugin : BasePlugin
internal static Harmony Harmony { get; } = new Harmony(MyPluginInfo.PLUGIN_GUID);

private static ConfigEntry<bool> HighMSAA;
private static ConfigEntry<bool> NoVSync;
private static ConfigEntry<int> Aniso;
private static ConfigEntry<int> DesiredResolutionX;
private static ConfigEntry<int> DesiredResolutionY;
private static ConfigEntry<bool> Fullscreen;
Expand All @@ -32,6 +34,8 @@ public override void Load()
Log.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!");

HighMSAA = Config.Bind("Quality", "HighMSAA", true, "Enable High Quality MSAA on all cameras");
NoVSync = Config.Bind("Quality", "NoVSync", false, "Force NoVSync setting");
Aniso = Config.Bind("Quality", "ForceAniso", -1, "Force this anisoLevel");

DesiredResolutionX = Config.Bind("Resolution", "X", Display.main.systemWidth);
DesiredResolutionY = Config.Bind("Resolution", "Y", Display.main.systemHeight);
Expand All @@ -55,7 +59,15 @@ public static void CameraQualityFix(Game.CameraController __instance) {
}
}

[HarmonyPatch(typeof(UnityEngine.Texture), "get_anisoLevel")]
[HarmonyPrefix]
public static void Texture2Dctor(UnityEngine.Texture __instance) {
if (Aniso.Value >= 0)
__instance.anisoLevel = Aniso.Value;
}

[HarmonyPatch(typeof(Game.LauncherArgs), nameof(Game.LauncherArgs.OnRuntimeMethodLoad))]
[HarmonyPostfix]
public static void SetResolution() {
if (ResolutionOverride.Value) {
logger.LogInfo("Overriding resolution");
Expand All @@ -67,6 +79,24 @@ public static void SetResolution() {
logger.LogInfo("Override to windowed");
}
}
logger.LogInfo("Applying stuff!");
// Get's set to 8 :pensive:
// Get's set to 0 if I do it here :face_melt:
if (HighMSAA.Value)
UnityEngine.QualitySettings.antiAliasing = 16;
// UnityEngine.QualitySettings.anisotropicFiltering = UnityEngine.AnisotropicFiltering.ForceEnable;
// foreach(var name in UnityEngine.QualitySettings.names) {
// logger.LogInfo(name);
// }
// There's only one quality level 0 - Fastest named "High"???
UnityEngine.QualitySettings.SetQualityLevel((int)UnityEngine.QualityLevel.Fantastic, true);
// Clamps to 9-16
UnityEngine.QualitySettings.anisotropicFiltering = UnityEngine.AnisotropicFiltering.ForceEnable;
UnityEngine.QualitySettings.shadowResolution = UnityEngine.ShadowResolution.VeryHigh;
UnityEngine.QualitySettings.skinWeights = UnityEngine.SkinWeights.Unlimited;
UnityEngine.QualitySettings.softParticles = true;
if (NoVSync.Value)
UnityEngine.QualitySettings.vSyncCount = 0;
}

// [HarmonyPatch(typeof(Develop.DevelopManager), "get_UserName")]
Expand Down
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Fixes done:

## Configuration

Example config with defaults:

```ini
## Settings file was created by plugin aitsf2fix v1.0.0
## Plugin GUID: aitsf2fix
Expand All @@ -22,15 +24,25 @@ Fixes done:
# Default value: true
HighMSAA = true

## Force NoVSync setting
# Setting type: Boolean
# Default value: false
NoVSync = true

## Force this anisoLevel
# Setting type: Int32
# Default value: -1
ForceAniso = 16

[Resolution]

# Setting type: Int32
# Default value: Main Display Width
X = 1920
# Default value: 1920
X = 1366

# Setting type: Int32
# Default value: Main Display Height
Y = 1080
# Default value: 1080
Y = 768

# Setting type: Boolean
# Default value: false
Expand All @@ -42,5 +54,5 @@ Fullscreen = false

# Setting type: Boolean
# Default value: true
UIFix = true # doesn't do anything as of rn
UIFix = true
```
4 changes: 2 additions & 2 deletions aitsf2fix.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>aitsf2fix</AssemblyName>
<Description>My first plugin</Description>
<Version>1.0.0</Version>
<Description>Various AITSF2 fixes...</Description>
<Version>2.0.0</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<RestoreAdditionalProjectSources>
Expand Down

0 comments on commit 91149a3

Please sign in to comment.