using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Big_Visuals.Configuration;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Rewired;
using UnityEngine;
using UnityEngine.Rendering.Universal;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Big_Visuals")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+56a6a1787d783cbd674f69501bfa6a3e7a93065d")]
[assembly: AssemblyProduct("Big Visuals")]
[assembly: AssemblyTitle("Big_Visuals")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Big_Visuals
{
[BepInPlugin("Big_Visuals", "Big Visuals", "1.0.0")]
public class Plugin : BasePlugin
{
private readonly Harmony _harmony = new Harmony("Big_Visuals");
private ModConfigurationUI _ui;
internal static ManualLogSource Log { get; private set; }
public static Plugin Instance { get; private set; }
public ConfigurationHandler ConfigurationHandler { get; private set; } = null;
public Settings Settings { get; private set; } = null;
public override void Load()
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Expected O, but got Unknown
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
Log = ((BasePlugin)this).Log;
if (Instance == null)
{
Instance = this;
}
ClassInjector.RegisterTypeInIl2Cpp<ModConfigurationUI>();
ClassInjector.RegisterTypeInIl2Cpp<SettingsRetry>();
ConfigurationHandler = new ConfigurationHandler(((BasePlugin)this).Config);
Settings = new Settings();
_harmony.PatchAll();
GameObject val = new GameObject("BigVisualsUI");
Object.DontDestroyOnLoad((Object)(object)val);
_ui = val.AddComponent<ModConfigurationUI>();
_ui.Init();
SettingsRetry settingsRetry = val.AddComponent<SettingsRetry>();
((Behaviour)settingsRetry).enabled = false;
SettingsRetry.SetInstance(settingsRetry);
ManualLogSource log = Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Plugin ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("Big Visuals");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" is loaded!");
}
log.LogInfo(val2);
}
}
public class Settings
{
private static readonly BindingFlags PipelineMemberFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
private ConfigurationHandler _configurationHandler = Plugin.Instance.ConfigurationHandler;
public void SetAllSettings()
{
SetResolutionScale();
SetUpscaler();
SetLODQuality();
SetShadowCascades();
SetAnisotropicFiltering();
SetSoftShadows();
SetShadowmapResolution();
}
public void SetAllCameraSettings()
{
SetPostProcessAA();
SetFOV();
}
public void SetAllCameraSettings(PlayerCameraMinder cameraMinder)
{
SetPostProcessAA(cameraMinder);
SetFOV();
}
public void SetSoftShadows()
{
ApplyToRenderPipelines("Soft Shadows", delegate(UniversalRenderPipelineAsset pipeline)
{
SetPipelineMember(pipeline, "supportsSoftShadows", _configurationHandler.SoftShadows);
SetPipelineMember(pipeline, "m_SoftShadowsSupported", _configurationHandler.SoftShadows);
}, (UniversalRenderPipelineAsset pipeline) => pipeline.supportsSoftShadows.ToString());
}
public void SetShadowmapResolution()
{
ApplyToRenderPipelines("Shadowmap Resolution", delegate(UniversalRenderPipelineAsset pipeline)
{
pipeline.mainLightShadowmapResolution = _configurationHandler.ShadowmapResolution;
SetPipelineMember(pipeline, "m_MainLightShadowmapResolution", (object)(ShadowResolution)_configurationHandler.ShadowmapResolution);
}, (UniversalRenderPipelineAsset pipeline) => pipeline.mainLightShadowmapResolution.ToString());
}
public void SetAnisotropicFiltering()
{
QualitySettings.anisotropicFiltering = (AnisotropicFiltering)(_configurationHandler.AnisotropicFiltering ? 2 : 0);
Plugin.Log.LogInfo((object)("Anisotropic Filtering applied: " + _configurationHandler.AnisotropicFiltering));
}
public void SetPostProcessAA()
{
ApplyPostProcessAA(Camera.main, "main camera");
}
public void SetPostProcessAA(PlayerCameraMinder cameraMinder)
{
Camera val = null;
if (cameraMinder != null && (Object)(object)cameraMinder.playerCameraReferences != (Object)null && (Object)(object)cameraMinder.playerCameraReferences.playerCamera != (Object)null)
{
val = cameraMinder.playerCameraReferences.playerCamera;
}
if ((Object)(object)val == (Object)null)
{
val = Camera.main;
}
ApplyPostProcessAA(val, "player camera");
}
public void SetFOV()
{
PlayerCameraMinder.fovFromSettings = _configurationHandler.FOV;
Plugin.Log.LogInfo((object)("FOV applied: " + _configurationHandler.FOV));
}
public void SetResolutionScale()
{
ApplyToRenderPipelines("Render Scale", delegate(UniversalRenderPipelineAsset pipeline)
{
pipeline.renderScale = _configurationHandler.RenderScale;
SetPipelineMember(pipeline, "m_RenderScale", _configurationHandler.RenderScale);
}, (UniversalRenderPipelineAsset pipeline) => pipeline.renderScale.ToString("F3"));
}
public void SetUpscaler()
{
ApplyToRenderPipelines("Upscaling Filter", delegate(UniversalRenderPipelineAsset pipeline)
{
pipeline.upscalingFilter = (UpscalingFilterSelection)_configurationHandler.UpscalingFilter;
SetPipelineMember(pipeline, "m_UpscalingFilter", (object)(UpscalingFilterSelection)_configurationHandler.UpscalingFilter);
}, (UniversalRenderPipelineAsset pipeline) => ((object)pipeline.upscalingFilter/*cast due to .constrained prefix*/).ToString());
}
public void SetLODQuality()
{
QualitySettings.lodBias = _configurationHandler.LodQuality;
Plugin.Log.LogInfo((object)("LOD Bias applied: " + _configurationHandler.LodQuality));
}
public void SetShadowCascades()
{
ApplyToRenderPipelines("Shadow Cascades", delegate(UniversalRenderPipelineAsset pipeline)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
pipeline.shadowCascadeCount = _configurationHandler.ShadowCascades;
SetPipelineMember(pipeline, "m_ShadowCascadeCount", _configurationHandler.ShadowCascades);
SetPipelineMember(pipeline, "m_ShadowCascades", GetShadowCascadeOption(_configurationHandler.ShadowCascades));
}, (UniversalRenderPipelineAsset pipeline) => pipeline.shadowCascadeCount.ToString());
}
private void ApplyToRenderPipelines(string settingName, Action<UniversalRenderPipelineAsset> apply, Func<UniversalRenderPipelineAsset, string> readBack)
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Expected O, but got Unknown
List<UniversalRenderPipelineAsset> list = new List<UniversalRenderPipelineAsset>();
foreach (UniversalRenderPipelineAsset item in Resources.FindObjectsOfTypeAll<UniversalRenderPipelineAsset>())
{
list.Add(item);
}
bool flag = default(bool);
if (list.Count == 0)
{
ManualLogSource log = Plugin.Log;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(65, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(settingName);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" not applied: no UniversalRenderPipelineAsset is active or loaded");
}
log.LogWarning(val);
return;
}
foreach (UniversalRenderPipelineAsset item2 in list)
{
apply(item2);
}
ManualLogSource log2 = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(41, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(settingName);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" applied to ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(list.Count);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" URP asset(s), active value: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(readBack(list[0]));
}
log2.LogInfo(val2);
}
private static void SetPipelineMember(UniversalRenderPipelineAsset pipeline, string memberName, object value)
{
PropertyInfo property = ((object)pipeline).GetType().GetProperty(memberName, PipelineMemberFlags);
if (property != null && property.CanWrite)
{
property.SetValue(pipeline, value);
return;
}
FieldInfo field = ((object)pipeline).GetType().GetField(memberName, PipelineMemberFlags);
if (field != null)
{
field.SetValue(pipeline, value);
}
}
private static ShadowCascadesOption GetShadowCascadeOption(int cascadeCount)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
if (cascadeCount <= 1)
{
return (ShadowCascadesOption)0;
}
if (cascadeCount <= 2)
{
return (ShadowCascadesOption)1;
}
return (ShadowCascadesOption)2;
}
private void ApplyPostProcessAA(Camera camera, string sourceName)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
bool flag = default(bool);
if ((Object)(object)camera == (Object)null)
{
ManualLogSource log = Plugin.Log;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(41, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Camera AA not applied: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(sourceName);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" was not available");
}
log.LogWarning(val);
return;
}
UniversalAdditionalCameraData component = ((Component)camera).GetComponent<UniversalAdditionalCameraData>();
if ((Object)(object)component == (Object)null)
{
ManualLogSource log2 = Plugin.Log;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(60, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Camera AA not applied: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(sourceName);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" has no UniversalAdditionalCameraData");
}
log2.LogWarning(val);
}
else
{
component.antialiasing = (AntialiasingMode)Plugin.Instance.ConfigurationHandler.CameraAA;
Plugin.Log.LogInfo((object)("Camera AA applied: " + _configurationHandler.CameraAA));
}
}
}
public class SettingsRetry : MonoBehaviour
{
private const int MaxAttempts = 300;
private static SettingsRetry _instance;
private static int _remainingAttempts;
public SettingsRetry(IntPtr ptr)
: base(ptr)
{
}
internal static void SetInstance(SettingsRetry instance)
{
_instance = instance;
}
internal static void Request()
{
_remainingAttempts = 300;
if ((Object)(object)_instance == (Object)null)
{
Plugin.Log.LogWarning((object)"Camera settings retry requested before retry component was ready");
}
else
{
((Behaviour)_instance).enabled = true;
}
}
private void Update()
{
if (_remainingAttempts <= 0)
{
((Behaviour)this).enabled = false;
Plugin.Log.LogWarning((object)"Camera settings retry timed out before a URP camera was available");
return;
}
_remainingAttempts--;
if (CameraSettingsTargetIsReady())
{
Plugin.Instance.Settings.SetAllCameraSettings();
Plugin.Instance.Settings.SetAllSettings();
((Behaviour)this).enabled = false;
Plugin.Log.LogInfo((object)"Camera settings applied after player camera became available");
}
}
private static bool CameraSettingsTargetIsReady()
{
Camera main = Camera.main;
return (Object)(object)main != (Object)null && (Object)(object)((Component)main).GetComponent<UniversalAdditionalCameraData>() != (Object)null;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "Big_Visuals";
public const string PLUGIN_NAME = "Big Visuals";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace Big_Visuals.Patches
{
public static class PlayerLoadPatches
{
[HarmonyPatch(typeof(WorldManager), "OnLocalPlayerCharcterStart")]
private static class LocalPlayerStartPatch
{
[HarmonyPostfix]
private static void Postfix()
{
Plugin.Log.LogInfo((object)"Local player loaded, applying Big Visuals settings");
SettingsRetry.Request();
}
}
}
public static class SettingsHandlerPatches
{
[HarmonyPatch(typeof(SettingsMenu))]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
private class ConstructorPatch
{
[HarmonyPostfix]
private static void Postfix(SettingsMenu __instance)
{
Plugin.Instance.Settings.SetAllSettings();
}
}
[HarmonyPatch(typeof(SettingsMenu), "ActionResetGraphics")]
private class SaveSettingPatch
{
[HarmonyPostfix]
private static void Postfix(SettingsMenu __instance)
{
Plugin.Instance.Settings.SetAllSettings();
}
}
}
}
namespace Big_Visuals.Configuration
{
public class ConfigurationHandler
{
private sealed class ConfigChangeListener<T>
{
private readonly ConfigEntry<T> _entry;
private readonly Action _onChanged;
private readonly Func<T, T> _clamp;
public ConfigChangeListener(ConfigEntry<T> entry, Action onChanged, Func<T, T> clamp)
{
_entry = entry;
_onChanged = onChanged;
_clamp = clamp;
}
public void OnSettingChanged(object sender, EventArgs args)
{
if (_clamp != null)
{
_entry.Value = _clamp(_entry.Value);
}
_onChanged();
}
}
private ConfigFile _config;
public ConfigEntry<float> ConfigRenderScale;
public ConfigEntry<int> ConfigUpscalingFilter;
public ConfigEntry<float> ConfigLODQuality;
public ConfigEntry<string> ConfigMenuKey;
public ConfigEntry<int> ConfigShadowCascades;
public ConfigEntry<int> ConfigShadowmapResolution;
public ConfigEntry<bool> ConfigSoftShadows;
public ConfigEntry<bool> ConfigAnisotropicFiltering;
public ConfigEntry<int> ConfigCameraAA;
public ConfigEntry<int> ConfigFOV;
public KeyCode MenuKey { get; private set; }
public float RenderScale => ConfigRenderScale.Value;
public int UpscalingFilter => ConfigUpscalingFilter.Value;
public float LodQuality => ConfigLODQuality.Value;
public int ShadowCascades => ConfigShadowCascades.Value;
public int ShadowmapResolution => ConfigShadowmapResolution.Value;
public bool SoftShadows => ConfigSoftShadows.Value;
public bool AnisotropicFiltering => ConfigAnisotropicFiltering.Value;
public int CameraAA => ConfigCameraAA.Value;
public int FOV => ConfigFOV.Value;
public ConfigurationHandler(ConfigFile configFile)
{
_config = configFile;
Plugin.Log.LogInfo((object)"ConfigurationHandler initialising");
ConfigRenderScale = Bind("Scaling", "RenderScale", 1.4f, "Controls the render scale of the game. Native is 1.0 (100%). Range 0.1-2.0", delegate
{
Plugin.Instance.Settings.SetResolutionScale();
}, (float v) => Mathf.Clamp(v, 0.1f, 2f));
ConfigUpscalingFilter = Bind("Scaling", "UpscalingFilter", 1, "Controls what filter the game uses to scale to your monitor resolution. 0 = auto, 1 = linear, 2 = point, 3 = FSR 1.0", delegate
{
Plugin.Instance.Settings.SetUpscaler();
}, (int v) => Mathf.Clamp(v, 0, 4));
ConfigLODQuality = Bind("LOD", "LODQuality", 4f, "Controls the LOD bias of the game. Higher values increase detail distance. Range 0.1-10", delegate
{
Plugin.Instance.Settings.SetLODQuality();
}, (float v) => Mathf.Clamp(v, 0.1f, 10f));
ConfigShadowCascades = Bind("Shadows", "ShadowCascades", 4, "Controls the number of shadow cascades used by the directional light. Higher values improve shadow stability. Range 1-4", delegate
{
Plugin.Instance.Settings.SetShadowCascades();
}, ClampShadowCascades);
ConfigShadowmapResolution = Bind("Shadows", "ShadowmapResolution", 8192, "Controls the quality of the shadows, can reduce performance so turn it down if you're having issues. Makes the trees less wobbly", delegate
{
Plugin.Instance.Settings.SetShadowmapResolution();
}, ClampShadowmapResolution);
ConfigSoftShadows = Bind("Shadows", "SoftShadows", defaultValue: true, "Allows shadows to be soft, if your PC is too low spec for a high shadowmap setting this to false can stop the wobblyness of the shadows (but will result in a pixelly effect if the shadowmap res is low)", delegate
{
Plugin.Instance.Settings.SetSoftShadows();
});
ConfigAnisotropicFiltering = Bind("Quality", "AnisotropicFiltering", defaultValue: true, "Helps texture sharpness at angles (set to on)", delegate
{
Plugin.Instance.Settings.SetAnisotropicFiltering();
});
ConfigCameraAA = Bind("AntiAliasing", "CameraAA", 0, "Controls what type of AA the Camera uses. All of these options are essentially clever blur filters and sometimes people find them unpleasant. 0 = None, 1 = FXAA, 2 = SMAA, 3 = TAA.", delegate
{
Plugin.Instance.Settings.SetPostProcessAA();
}, (int v) => Mathf.Clamp(v, 0, 3));
ConfigFOV = Bind("Camera", "FOV", 90, "Controls the camera field of view. Range 60-150. Will override the option in the game's menu.", delegate
{
Plugin.Instance.Settings.SetFOV();
}, (int v) => Mathf.Clamp(v, 60, 150));
ConfigMenuKey = Bind("General", "Config Menu Key", "F11", "Keyboard key for opening the mod configuration menu", SetupInputKey);
SetupInputKey();
Plugin.Log.LogInfo((object)"ConfigurationHandler initialised");
}
private ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, string description, Action onChanged = null, Func<T, T> clamp = null)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
ConfigEntry<T> val = _config.Bind<T>(section, key, defaultValue, description);
if (clamp != null)
{
val.Value = clamp(val.Value);
}
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(9, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(key);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" set to: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<T>(val.Value);
}
log.LogInfo(val2);
if (onChanged != null)
{
AddSettingChangedHandler(val, onChanged, clamp);
}
return val;
}
private static int ClampMsaa(int value)
{
if (value <= 0)
{
return 0;
}
if (value <= 2)
{
return 2;
}
if (value <= 4)
{
return 4;
}
return 8;
}
private static int ClampShadowCascades(int value)
{
if (value <= 1)
{
return 1;
}
if (value <= 2)
{
return 2;
}
return 4;
}
private static int ClampShadowmapResolution(int value)
{
if (value <= 1024)
{
return 1024;
}
if (value <= 2048)
{
return 2048;
}
if (value <= 4096)
{
return 4096;
}
return 8192;
}
private static void AddSettingChangedHandler<T>(ConfigEntry<T> entry, Action onChanged, Func<T, T> clamp)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
EventInfo eventInfo = typeof(ConfigEntry<T>).GetEvent("SettingChanged");
if (eventInfo == null)
{
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(42, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not subscribe to SettingChanged for ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((ConfigEntryBase)entry).Definition.Key);
}
log.LogWarning(val);
}
else
{
ConfigChangeListener<T> firstArgument = new ConfigChangeListener<T>(entry, onChanged, clamp);
MethodInfo method = typeof(ConfigChangeListener<T>).GetMethod("OnSettingChanged", BindingFlags.Instance | BindingFlags.Public);
Delegate handler = Delegate.CreateDelegate(eventInfo.EventHandlerType, firstArgument, method);
eventInfo.AddEventHandler(entry, handler);
}
}
private void SetupInputKey()
{
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected O, but got Unknown
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
bool flag = default(bool);
if (Enum.TryParse<KeyCode>(ConfigMenuKey.Value, out KeyCode result))
{
MenuKey = result;
ManualLogSource log = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(16, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Menu key set to ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<KeyCode>(MenuKey);
}
log.LogInfo(val);
return;
}
MenuKey = (KeyCode)292;
ManualLogSource log2 = Plugin.Log;
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(28, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Invalid menu key ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ConfigMenuKey.Value);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", using F11");
}
log2.LogWarning(val2);
}
}
public class ModConfigurationUI : MonoBehaviour
{
private const int MouseWheelAxis = 2;
private List<Option> _options;
private bool _visible;
private int _selectedIndex;
private bool _prevCursorVisible;
private CursorLockMode _prevCursorLock;
private bool _waitingForBinding = false;
private Option _bindingTarget;
private Texture2D _whiteTex;
private GUIStyle _titleStyle;
private GUIStyle _rowStyle;
private GUIStyle _hintStyle;
private string titleText = "Big Visuals Settings | v 1.0.0";
private string hintText = "F2: Open/Close • Tab or ↑/↓: Move • Enter/Click: Change • Scroll Wheel or ←/→ Arrows: Adjust Numerical Values • +/-: Scale Menu";
private int RowHeight = 32;
private int PanelWidth = 460;
private int Pad = 12;
private int TitleFontSize = 22;
private int OptionFontSize = 16;
private int HintFontSize = 14;
private Player _player;
private Keyboard _keyboard;
private Mouse _mouse;
public ModConfigurationUI(IntPtr ptr)
: base(ptr)
{
}
private Color GetColor(Color c)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
if ((int)SystemInfo.graphicsDeviceType == 21)
{
return ((Color)(ref c)).linear;
}
return c;
}
private void CalculatePanelWidth()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
float num = _titleStyle.CalcSize(new GUIContent(titleText)).x;
foreach (Option option in _options)
{
float x = _rowStyle.CalcSize(new GUIContent(option.Label + ": " + option.DisplayValue())).x;
if (x > num)
{
num = x;
}
}
int num2 = CalculateHintWidth();
num = Mathf.Max(num, (float)num2);
PanelWidth = Mathf.Clamp((int)num + Pad * 2, 460, Screen.width - Pad * 2);
}
private int CalculateHintWidth()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
float num = _hintStyle.CalcHeight(new GUIContent("Test"), 9999f);
float num2 = num * 2f;
for (int i = 200; i < Screen.width - Pad * 2; i += 20)
{
float num3 = _hintStyle.CalcHeight(new GUIContent(hintText), (float)i);
if (num3 <= num2)
{
return i;
}
}
return Screen.width - Pad * 2;
}
private void Scale(int scale)
{
if (scale >= 0 || HintFontSize >= 2)
{
TitleFontSize += scale * 2;
OptionFontSize += scale * 2;
HintFontSize += scale * 2;
RowHeight = OptionFontSize + 16;
CalculatePanelWidth();
}
}
public void Init()
{
ConfigurationHandler configurationHandler = Plugin.Instance.ConfigurationHandler;
_options = new List<Option>
{
Option.Int("FOV", configurationHandler.ConfigFOV, 60, 150),
Option.Float("Render Scale", configurationHandler.ConfigRenderScale, 0.1f, 2f, 0.1f),
Option.Int("Upscaling Filter", configurationHandler.ConfigUpscalingFilter, 0, 3, 1, null, delegate
{
int value = configurationHandler.ConfigUpscalingFilter.Value;
if (1 == 0)
{
}
string result = value switch
{
0 => "Auto",
1 => "Linear",
2 => "Nearest Neighbor",
3 => "FSR 1.0",
_ => "Invalid Value",
};
if (1 == 0)
{
}
return result;
}),
Option.Bool("Anisotropic Filtering", configurationHandler.ConfigAnisotropicFiltering),
Option.Float("LOD Quality", configurationHandler.ConfigLODQuality, 0.1f, 10f, 0.1f),
Option.Int("Shadowmap Resolution", configurationHandler.ConfigShadowmapResolution, 1024, 8192, 1024),
Option.Int("Shadow Cascades", configurationHandler.ConfigShadowCascades, 1, 10),
Option.Bool("Soft Shadows", configurationHandler.ConfigSoftShadows),
Option.Int("Camera Antialiasing", configurationHandler.ConfigCameraAA, 0, 3, 1, null, delegate
{
int value = configurationHandler.ConfigCameraAA.Value;
if (1 == 0)
{
}
string result = value switch
{
0 => "None",
1 => "FXAA",
2 => "SMAA",
3 => "TAA",
_ => "???",
};
if (1 == 0)
{
}
return result;
}),
Option.InputAction("Menu Key", configurationHandler.ConfigMenuKey)
};
_selectedIndex = 0;
hintText = configurationHandler.ConfigMenuKey.Value.Split("/")[^1].ToUpper() + ": Open/Close • Tab or ↑/↓: Move • Enter/Click: Change • Scroll Wheel or ←/→ Arrows: Adjust Numerical Values • +/-: Scale Menu";
}
private void EnsureStyles()
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected O, but got Unknown
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Expected O, but got Unknown
//IL_00b5: Expected O, but got Unknown
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Expected O, but got Unknown
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_whiteTex == (Object)null)
{
_whiteTex = new Texture2D(1, 1, (TextureFormat)4, false);
_whiteTex.SetPixel(0, 0, GetColor(Color.white));
_whiteTex.Apply();
}
_titleStyle = new GUIStyle(GUI.skin.label)
{
fontSize = TitleFontSize,
alignment = (TextAnchor)3,
fontStyle = (FontStyle)1
};
_rowStyle = new GUIStyle(GUI.skin.button)
{
alignment = (TextAnchor)3,
fontSize = OptionFontSize,
padding = new RectOffset(10, 10, 4, 4)
};
_hintStyle = new GUIStyle(GUI.skin.label)
{
fontSize = HintFontSize,
alignment = (TextAnchor)3,
wordWrap = true
};
}
private void Update()
{
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Expected O, but got Unknown
if (!ReInput.isReady)
{
return;
}
if (_player == null)
{
_player = ReInput.players.GetPlayer(0);
_keyboard = ReInput.controllers.Keyboard;
_mouse = ReInput.controllers.Mouse;
}
if (_waitingForBinding)
{
bool flag = default(bool);
foreach (KeyCode value in Enum.GetValues(typeof(KeyCode)))
{
if (_keyboard.GetKeyDown(value))
{
string text = ((object)value/*cast due to .constrained prefix*/).ToString();
_bindingTarget.StringEntry.Value = text;
ManualLogSource log = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(12, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Rebound ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(_bindingTarget.Label);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" to ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
}
log.LogInfo(val2);
_waitingForBinding = false;
hintText = _bindingTarget.DisplayValue() + ": Open/Close • Tab or ↑/↓: Move • Enter/Click: Change • Scroll Wheel or ←/→ Arrows: Adjust Numerical Values • +/-: Scale Menu";
_bindingTarget = null;
break;
}
}
return;
}
if (_keyboard.GetKeyDown(Plugin.Instance.ConfigurationHandler.MenuKey))
{
_visible = !_visible;
if (_visible)
{
OnOpened();
}
else
{
OnClosed();
}
}
if (_visible && _options.Count != 0)
{
if (_keyboard.GetKeyDown((KeyCode)9))
{
bool flag2 = _keyboard.GetKey((KeyCode)304) || _keyboard.GetKey((KeyCode)303);
CycleSelection((!flag2) ? 1 : (-1));
}
if (_keyboard.GetKeyDown((KeyCode)61) || _keyboard.GetKeyDown((KeyCode)43))
{
Scale(1);
}
if (_keyboard.GetKeyDown((KeyCode)45))
{
Scale(-1);
}
if (_keyboard.GetKeyDown((KeyCode)273))
{
CycleSelection(-1);
}
if (_keyboard.GetKeyDown((KeyCode)274))
{
CycleSelection(1);
}
if (_keyboard.GetKeyDown((KeyCode)13) || _keyboard.GetKeyDown((KeyCode)271))
{
ToggleSelected();
}
if (_keyboard.GetKeyDown((KeyCode)276))
{
AdjustNumerical(-1);
}
if (_keyboard.GetKeyDown((KeyCode)275))
{
AdjustNumerical(1);
}
float axis = ((ControllerWithAxes)_mouse).GetAxis(2);
if (axis > 0f)
{
AdjustNumerical(1);
}
else if (axis < 0f)
{
AdjustNumerical(-1);
}
}
}
private void ToggleSelected()
{
Option option = _options[_selectedIndex];
if (option.IsDisabled())
{
return;
}
switch (option.Type)
{
case Option.OptionType.Bool:
option.BoolEntry.Value = !option.BoolEntry.Value;
break;
case Option.OptionType.Int:
{
int num2 = option.IntEntry.Value + option.Step;
if (num2 > option.MaxInt)
{
num2 = option.MinInt;
}
option.IntEntry.Value = num2;
break;
}
case Option.OptionType.Float:
{
float num = option.FloatEntry.Value + option.FloatStep;
if (num > option.MaxFloat)
{
num = option.MinFloat;
}
option.FloatEntry.Value = num;
break;
}
case Option.OptionType.InputAction:
_waitingForBinding = true;
_bindingTarget = option;
break;
case Option.OptionType.String:
break;
}
}
private void AdjustNumerical(int delta)
{
Option option = _options[_selectedIndex];
if (!option.IsDisabled())
{
if (option.Type == Option.OptionType.Bool)
{
option.BoolEntry.Value = delta > 0;
}
else if (option.Type == Option.OptionType.Int)
{
AdjustInt(option, delta);
}
else if (option.Type == Option.OptionType.Float)
{
AdjustFloat(option, delta);
}
}
}
private static void AdjustInt(Option option, int delta)
{
int value = option.IntEntry.Value;
int num = value;
int num2 = Mathf.Max(1, Mathf.CeilToInt((float)(option.MaxInt - option.MinInt) / (float)option.Step) + 1);
for (int i = 0; i < num2; i++)
{
int num3 = Mathf.Clamp(num + delta * option.Step, option.MinInt, option.MaxInt);
if (num3 == num)
{
break;
}
option.IntEntry.Value = num3;
if (option.IntEntry.Value != value)
{
break;
}
num = num3;
}
}
private static void AdjustFloat(Option option, int delta)
{
float value = option.FloatEntry.Value;
float num = value;
int num2 = Mathf.Max(1, Mathf.CeilToInt((option.MaxFloat - option.MinFloat) / option.FloatStep) + 1);
for (int i = 0; i < num2; i++)
{
float num3 = Mathf.Clamp(num + (float)delta * option.FloatStep, option.MinFloat, option.MaxFloat);
if (Mathf.Approximately(num3, num))
{
break;
}
option.FloatEntry.Value = num3;
if (!Mathf.Approximately(option.FloatEntry.Value, value))
{
break;
}
num = num3;
}
}
private void OnOpened()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
_prevCursorVisible = Cursor.visible;
_prevCursorLock = Cursor.lockState;
Cursor.visible = true;
Cursor.lockState = (CursorLockMode)0;
if (_options.Count > 0 && _options[_selectedIndex].IsDisabled())
{
CycleSelection(1);
}
}
private void OnClosed()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
Cursor.visible = _prevCursorVisible;
Cursor.lockState = _prevCursorLock;
}
private void CycleSelection(int delta)
{
if (_options.Count == 0)
{
return;
}
int selectedIndex = _selectedIndex;
do
{
_selectedIndex = (_selectedIndex + delta) % _options.Count;
if (_selectedIndex < 0)
{
_selectedIndex += _options.Count;
}
}
while (_options[_selectedIndex].IsDisabled() && _selectedIndex != selectedIndex);
}
private void OnGUI()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected O, but got Unknown
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_0378: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
if (!_visible)
{
return;
}
EnsureStyles();
CalculatePanelWidth();
float num = _titleStyle.CalcHeight(new GUIContent(titleText), (float)(PanelWidth - Pad * 2));
float num2 = _options.Count * (RowHeight + 4);
float num3 = _hintStyle.CalcHeight(new GUIContent("Test"), 9999f);
float num4 = num3 * 2f;
int num5 = Pad + (int)num + 8 + (int)num2 + Pad + (int)num4;
Rect val = default(Rect);
((Rect)(ref val))..ctor(20f, 20f, (float)PanelWidth, (float)num5);
GUI.color = GetColor(new Color(0f, 0f, 0f, 0.75f));
GUI.DrawTexture(val, (Texture)(object)_whiteTex);
GUI.color = Color.white;
Rect val2 = default(Rect);
((Rect)(ref val2))..ctor(((Rect)(ref val)).x + (float)Pad, ((Rect)(ref val)).y + (float)Pad, ((Rect)(ref val)).width - (float)(Pad * 2), num);
GUI.Label(val2, titleText, _titleStyle);
float num6 = ((Rect)(ref val2)).yMax + 8f;
Rect val3 = default(Rect);
for (int i = 0; i < _options.Count; i++)
{
((Rect)(ref val3))..ctor(((Rect)(ref val)).x + (float)Pad, num6, ((Rect)(ref val)).width - (float)(Pad * 2), (float)RowHeight);
Option option = _options[i];
if (((Rect)(ref val3)).Contains(Event.current.mousePosition) && !option.IsDisabled())
{
_selectedIndex = i;
}
if (i == _selectedIndex && !option.IsDisabled())
{
GUI.color = GetColor(new Color(1f, 1f, 1f, 0.24f));
GUI.DrawTexture(val3, (Texture)(object)_whiteTex);
GUI.color = Color.white;
}
GUI.enabled = !option.IsDisabled();
if (option.Label == "Menu Key" && _waitingForBinding)
{
GUI.color = GetColor(new Color(0f, 0f, 0f, 0.6f));
GUI.DrawTexture(val3, (Texture)(object)_whiteTex);
GUI.color = Color.white;
GUI.Button(val3, "Press any key...", _rowStyle);
}
else if (GUI.Button(val3, option.Label + ": " + option.DisplayValue(), _rowStyle) && !option.IsDisabled())
{
ToggleSelected();
}
GUI.enabled = true;
num6 += (float)(RowHeight + 4);
}
Rect val4 = default(Rect);
((Rect)(ref val4))..ctor(((Rect)(ref val)).x + (float)Pad, ((Rect)(ref val)).yMax - (float)Pad - num4, ((Rect)(ref val)).width - (float)(Pad * 2), num4);
GUI.Label(val4, hintText, _hintStyle);
}
private void OnDestroy()
{
if ((Object)(object)_whiteTex != (Object)null)
{
Object.Destroy((Object)(object)_whiteTex);
_whiteTex = null;
}
}
}
public class Option
{
public enum OptionType
{
Bool,
Int,
String,
InputAction,
Float
}
public string Label { get; set; }
public OptionType Type { get; set; }
public ConfigEntry<bool> BoolEntry { get; set; }
public ConfigEntry<int> IntEntry { get; set; }
public ConfigEntry<string> StringEntry { get; set; }
public int MinInt { get; set; }
public int MaxInt { get; set; }
public int Step { get; set; }
public Func<bool> IsDisabled { get; set; } = () => false;
public Func<string> DisplayValue { get; set; } = () => "";
public ConfigEntry<float> FloatEntry { get; set; }
public float MinFloat { get; set; }
public float MaxFloat { get; set; }
public float FloatStep { get; set; }
private Option(string label, OptionType type)
{
Label = label;
Type = type;
}
public static Option Float(string label, ConfigEntry<float> entry, float min, float max, float step = 0.05f, Func<bool> isDisabled = null)
{
return new Option(label, OptionType.Float)
{
FloatEntry = entry,
MinFloat = min,
MaxFloat = max,
FloatStep = step,
IsDisabled = (isDisabled ?? ((Func<bool>)(() => false))),
DisplayValue = () => entry.Value.ToString("F3")
};
}
public static Option Bool(string label, ConfigEntry<bool> entry, Func<bool> isDisabled = null)
{
return new Option(label, OptionType.Bool)
{
BoolEntry = entry,
IsDisabled = (isDisabled ?? ((Func<bool>)(() => false))),
DisplayValue = () => entry.Value ? "ON" : "OFF"
};
}
public static Option InputAction(string label, ConfigEntry<string> entry, Func<bool> isDisabled = null)
{
return new Option(label, OptionType.InputAction)
{
StringEntry = entry,
IsDisabled = (isDisabled ?? ((Func<bool>)(() => false))),
DisplayValue = delegate
{
string[] array = entry.Value.Split("/");
return (array.Length > 1) ? array[^1].ToUpper() : entry.Value;
}
};
}
public static Option Int(string label, ConfigEntry<int> entry, int min, int max, int step = 1, Func<bool> isDisabled = null, Func<string> displayValue = null)
{
return new Option(label, OptionType.Int)
{
IntEntry = entry,
MinInt = min,
MaxInt = max,
Step = step,
IsDisabled = (isDisabled ?? ((Func<bool>)(() => false))),
DisplayValue = (displayValue ?? ((Func<string>)(() => entry.Value.ToString())))
};
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}