using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using SettingsMenu.Components.Pages; using UkResolution.patches; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("UkResolution")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("UkResolution")] [assembly: AssemblyTitle("UkResolution")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace UkResolution { [BepInPlugin("pozdro.ultrakill.ukresolution", "Uk Resolution", "1.0.0")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; ResolutionPatch.Initialize(); Harmony.CreateAndPatchAll(typeof(Plugin).Assembly, (string)null); Log.LogInfo((object)"Plugin Uk Resolution is loaded!"); } } internal static class PluginConfigManager { private static readonly string configPath = Path.Combine(Paths.ConfigPath, "UkResolution.cfg"); private static void CheckConfigIntegrity() { if (!File.Exists(configPath)) { Plugin.Log.LogInfo((object)"UKResolutionConfig not found, creating..."); File.WriteAllText(configPath, "[Resolutions]\r\n640 x 480\r\n720 x 480\r\n800 x 480\r\n800 x 600\r\n1024 x 768\r\n1280 x 720\r\n1280 x 800\r\n1280 x 1024\r\n1366 x 768\r\n1440 x 900\r\n1600 x 900\r\n1600 x 1200\r\n1680 x 1050\r\n1920 x 1080\r\n1920 x 1200\r\n2048 x 1080\r\n2560 x 1080\r\n2560 x 1440\r\n2560 x 1600\r\n2880 x 1800\r\n3200 x 1800\r\n3440 x 1440\r\n3840 x 1600\r\n3840 x 2160\r\n4096 x 2160\r\n5120 x 1440\r\n5120 x 2160\r\n5120 x 2880\r\n6016 x 3384\r\n7680 x 4320\r\n8192 x 4320"); Plugin.Log.LogInfo((object)("Created " + configPath)); } } private static List GetConfigPart(string part) { CheckConfigIntegrity(); string[] array = File.ReadAllLines(configPath); bool flag = false; List list = new List(); string[] array2 = array; foreach (string text in array2) { string text2 = text.Trim(); if (string.IsNullOrWhiteSpace(text2) || text2.StartsWith("#")) { continue; } if (text2.StartsWith("[")) { if (flag) { break; } flag = false; if (text2.Equals(part)) { flag = true; } } else if (flag) { list.Add(text2); } } return list; } public static List LoadConfigResolutions() { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) CheckConfigIntegrity(); List list = new List(); List configPart = GetConfigPart("[Resolutions]"); foreach (string item2 in configPart) { string[] array = item2.Split('x'); if (array.Length != 2) { Plugin.Log.LogWarning((object)("Invalid resolution: " + item2)); continue; } if (!int.TryParse(array[0].Trim(), out var result)) { Plugin.Log.LogWarning((object)("Invalid width: " + item2)); continue; } if (!int.TryParse(array[1].Trim(), out var result2)) { Plugin.Log.LogWarning((object)("Invalid height: " + item2)); continue; } Resolution val = default(Resolution); ((Resolution)(ref val)).width = result; ((Resolution)(ref val)).height = result2; ((Resolution)(ref val)).refreshRateRatio = new RefreshRate { numerator = 60u, denominator = 1u }; Resolution item = val; list.Add(item); } return list; } } } namespace UkResolution.patches { [HarmonyPatch] public static class ResolutionPatch { internal static List resolutions = new List(); public static void Initialize() { resolutions = PluginConfigManager.LoadConfigResolutions(); Plugin.Log.LogInfo((object)$"Loaded {resolutions.Count} resolutions from config."); } [HarmonyPatch(typeof(GraphicsSettings), "GetAvailableResolutions")] [HarmonyPostfix] private static void GetAvailableResolutions(GraphicsSettings __instance) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) FieldInfo field = typeof(GraphicsSettings).GetField("availableResolutions", BindingFlags.Instance | BindingFlags.NonPublic); List<(Resolution, string)> list = (List<(Resolution, string)>)field.GetValue(__instance); list.Clear(); foreach (Resolution resolution in resolutions) { Resolution current = resolution; list.Add((current, $"{((Resolution)(ref current)).width} x {((Resolution)(ref current)).height}")); } } [HarmonyPatch(typeof(GraphicsSettings), "SetResolution")] [HarmonyPostfix] private static void CheckResolution() { Plugin.Log.LogInfo((object)$"Resolution set to: {Screen.width} x {Screen.height}"); } } }