Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of KeepMyResolution v1.0.2
plugins/KeepMyResolution/KeepMyResolution.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; 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.Logging; using Microsoft.CodeAnalysis; using On.RoR2.ConVar; using RiskOfOptions; using RiskOfOptions.Options; using RoR2; using RoR2.ConVar; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("KeepMyResolution")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+7ef688d6f970caa45331636f4efd50ee330aaa92")] [assembly: AssemblyProduct("KeepMyResolution")] [assembly: AssemblyTitle("KeepMyResolution")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace KeepMyResolution { [BepInPlugin("InkyaRev.KeepMyResolution", "KeepMyResolution", "1.0.0")] public class KeepMyResolutionPlugin : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<string, string, string> <>9__7_0; public static hook_AttemptSetString <>9__7_1; internal string <Awake>b__7_0(string str, string res) { return str + "\n" + res; } internal void <Awake>b__7_1(orig_AttemptSetString orig, BaseConVar self, string value) { if (self.name == "resolution") { if (!(self.GetString() == PreferredResolution.Value) && ResolutionsList.Contains(PreferredResolution.Value)) { self.SetString(PreferredResolution.Value); } } else { orig.Invoke(self, value); } } } private const string PluginGUID = "InkyaRev.KeepMyResolution"; private const string PluginAuthor = "InkyaRev"; private const string PluginName = "KeepMyResolution"; private const string PluginVersion = "1.0.0"; public static ConfigEntry<string> PreferredResolution; private static IEnumerable<string> ResolutionsList => Screen.resolutions.Select(ResolutionToString); public void Awake() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown Log.Init(((BaseUnityPlugin)this).Logger); string text = ResolutionsList.Aggregate(string.Empty, (string str, string res) => str + "\n" + res); PreferredResolution = ((BaseUnityPlugin)this).Config.Bind<string>("Settings", "Preferred Resolution", ResolutionToString(Screen.resolutions.Last()), "Available resolutions: " + text); ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(PreferredResolution)); object obj = <>c.<>9__7_1; if (obj == null) { hook_AttemptSetString val = delegate(orig_AttemptSetString orig, BaseConVar self, string value) { if (self.name == "resolution") { if (!(self.GetString() == PreferredResolution.Value) && ResolutionsList.Contains(PreferredResolution.Value)) { self.SetString(PreferredResolution.Value); } } else { orig.Invoke(self, value); } }; <>c.<>9__7_1 = val; obj = (object)val; } BaseConVar.AttemptSetString += (hook_AttemptSetString)obj; } private static string ResolutionToString(Resolution resolution) { return $"{((Resolution)(ref resolution)).width}x{((Resolution)(ref resolution)).height}x{((Resolution)(ref resolution)).refreshRate}".Trim(); } private void FixedUpdate() { if (Console.instance != null) { BaseConVar obj = Console.instance.FindConVar("resolution"); if (obj != null) { obj.AttemptSetString(PreferredResolution.Value); } } } } internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(data); } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } }