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 NekosVersionTitle v1.1.0
plugins/NekosVersionTitle.dll
Decompiled a day agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using On.RoR2.UI; using On.RoR2.UI.MainMenu; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2.UI; using RoR2.UI.MainMenu; using TMPro; using UnityEngine; using UnityEngine.UI; [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("NekosVersionTitle")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+2e915a8159d78ccc2174f22b11bf1710d00d78c9")] [assembly: AssemblyProduct("NekosVersionTitle")] [assembly: AssemblyTitle("NekosVersionTitle")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 NekosVersionTitle { 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); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Weby.NekosVersionTitle", "NekosVersionTitle", "1.1.0")] public class NekosVersionTitle : BaseUnityPlugin { public const string PluginGUID = "Weby.NekosVersionTitle"; public const string PluginAuthor = "Weby"; public const string PluginName = "NekosVersionTitle"; public const string PluginVersion = "1.1.0"; private const string EmbeddedLogoPath = "NekosVersionTitle.Resources.Logo.png"; internal const string EmbeddedIconPath = "NekosVersionTitle.Resources.icon.png"; internal ConfigEntry<bool> replaceLogo; internal ConfigEntry<string> customLogoPath; internal ConfigEntry<bool> showVersionText; internal ConfigEntry<string> versionText; private Image logoImage; private Sprite vanillaLogoSprite; private bool vanillaPreserveAspect; private Sprite customLogoSprite; private TMP_Text versionLabel; public void Awake() { //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown Log.Init(((BaseUnityPlugin)this).Logger); replaceLogo = ((BaseUnityPlugin)this).Config.Bind<bool>("Logo", "ReplaceLogo", true, "Replace the main menu logo."); customLogoPath = ((BaseUnityPlugin)this).Config.Bind<string>("Logo", "CustomLogoPath", "", "Path to a PNG to use instead of the built-in logo. Relative paths start from the BepInEx/config folder. Leave empty to use the built-in logo."); showVersionText = ((BaseUnityPlugin)this).Config.Bind<bool>("VersionText", "ShowVersionText", true, "Show the modpack version under the game's build number on the main menu."); versionText = ((BaseUnityPlugin)this).Config.Bind<string>("VersionText", "Text", "Neko's Version", "Text to show, e.g. \"Neko's Version v1.2\"."); replaceLogo.SettingChanged += delegate { ApplyLogo(); }; customLogoPath.SettingChanged += delegate { ApplyLogo(); }; showVersionText.SettingChanged += delegate { ApplyVersionLabel(); }; versionText.SettingChanged += delegate { ApplyVersionLabel(); }; if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions")) { RiskOfOptionsCompat.Init(this); } MainMenuController.Awake += (hook_Awake)delegate(orig_Awake orig, MainMenuController self) { orig.Invoke(self); FindLogo(self); ApplyLogo(); }; SteamBuildIdLabel.Start += (hook_Start)delegate(orig_Start orig, SteamBuildIdLabel self) { orig.Invoke(self); AddVersionLabel(self); ApplyVersionLabel(); }; } private void FindLogo(MainMenuController self) { try { Image[] componentsInChildren = ((Component)self.titleMenuScreen).GetComponentsInChildren<Image>(); foreach (Image val in componentsInChildren) { if (((Object)((Component)val).transform).name == "LogoImage") { logoImage = val; vanillaLogoSprite = val.sprite; vanillaPreserveAspect = val.preserveAspect; return; } } Log.Warning("LogoImage not found in the main menu"); } catch (Exception ex) { Log.Error("Error finding title: " + ex.Message); } } private void ApplyLogo() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)logoImage == (Object)null) { return; } try { DestroyCustomLogo(); if (!replaceLogo.Value) { logoImage.sprite = vanillaLogoSprite; logoImage.preserveAspect = vanillaPreserveAspect; return; } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val, ReadLogoBytes())) { Log.Error("Could not decode the logo image, keeping the vanilla logo"); Object.Destroy((Object)(object)val); logoImage.sprite = vanillaLogoSprite; logoImage.preserveAspect = vanillaPreserveAspect; } else { float num = (((Object)(object)vanillaLogoSprite != (Object)null) ? vanillaLogoSprite.pixelsPerUnit : 100f); customLogoSprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), num); logoImage.sprite = customLogoSprite; logoImage.preserveAspect = true; } } catch (Exception ex) { Log.Error("Error replacing title: " + ex.Message); } } private void DestroyCustomLogo() { if ((Object)(object)customLogoSprite != (Object)null) { Object.Destroy((Object)(object)customLogoSprite.texture); Object.Destroy((Object)(object)customLogoSprite); customLogoSprite = null; } } private void AddVersionLabel(SteamBuildIdLabel self) { //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) try { TMP_Text component = ((Component)self).GetComponent<TMP_Text>(); if ((Object)(object)component == (Object)null) { Log.Warning("SteamBuildIdLabel has no text component"); return; } GameObject val = Object.Instantiate<GameObject>(((Component)self).gameObject, ((Component)self).transform.parent); ((Object)val).name = "NekosVersionLabel"; Object.DestroyImmediate((Object)(object)val.GetComponent<SteamBuildIdLabel>()); LanguageTextMeshController component2 = val.GetComponent<LanguageTextMeshController>(); if ((Object)(object)component2 != (Object)null) { Object.DestroyImmediate((Object)(object)component2); } TMP_Text val2 = (versionLabel = val.GetComponent<TMP_Text>()); if ((Object)(object)((Component)((Component)self).transform.parent).GetComponent<LayoutGroup>() != (Object)null) { val.transform.SetAsLastSibling(); return; } Vector3[] array = (Vector3[])(object)new Vector3[4]; component.rectTransform.GetWorldCorners(array); float x = array[0].x; float x2 = array[2].x; float y = array[1].y; float y2 = array[0].y; float num = y - y2; TMP_Text[] componentsInChildren = ((Component)((Component)self).GetComponentInParent<Canvas>()).GetComponentsInChildren<TMP_Text>(); Vector3[] array2 = (Vector3[])(object)new Vector3[4]; bool flag; do { flag = false; TMP_Text[] array3 = componentsInChildren; foreach (TMP_Text val3 in array3) { if (!((Object)(object)val3 == (Object)(object)component) && !((Object)(object)val3 == (Object)(object)val2) && ((Behaviour)val3).isActiveAndEnabled && !string.IsNullOrWhiteSpace(val3.text)) { val3.rectTransform.GetWorldCorners(array2); bool num2 = array2[0].x < x2 && array2[2].x > x; bool flag2 = Mathf.Abs(array2[1].y - y2) <= num * 0.5f; if (num2 && flag2 && array2[0].y < y2 - 1f) { y2 = array2[0].y; flag = true; } } } } while (flag); Transform transform = val.transform; transform.position += new Vector3(0f, y2 - y, 0f); } catch (Exception ex) { Log.Error("Error adding version text: " + ex.Message); } } private void ApplyVersionLabel() { if (!((Object)(object)versionLabel == (Object)null)) { versionLabel.text = versionText.Value; ((Component)versionLabel).gameObject.SetActive(showVersionText.Value && !string.IsNullOrWhiteSpace(versionText.Value)); } } private byte[] ReadLogoBytes() { string text = customLogoPath.Value; if (!string.IsNullOrWhiteSpace(text)) { if (!Path.IsPathRooted(text)) { text = Path.Combine(Paths.ConfigPath, text); } if (File.Exists(text)) { return File.ReadAllBytes(text); } Log.Warning("Custom logo not found at " + text + ", using the built-in logo"); } return ReadEmbeddedBytes("NekosVersionTitle.Resources.Logo.png"); } internal static byte[] ReadEmbeddedBytes(string resourcePath) { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourcePath); using BinaryReader binaryReader = new BinaryReader(stream); return binaryReader.ReadBytes((int)stream.Length); } } internal static class RiskOfOptionsCompat { internal const string PluginGUID = "com.rune580.riskofoptions"; [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static void Init(NekosVersionTitle plugin) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) ModSettingsManager.SetModDescription("Neko's Version main menu logo and version text."); Texture2D val = new Texture2D(2, 2); if (ImageConversion.LoadImage(val, NekosVersionTitle.ReadEmbeddedBytes("NekosVersionTitle.Resources.icon.png"))) { ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f))); } ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(plugin.replaceLogo)); ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(plugin.customLogoPath, new InputFieldConfig { submitOn = (SubmitEnum)6, lineType = (LineType)0, richText = false })); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(plugin.showVersionText)); ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(plugin.versionText, new InputFieldConfig { submitOn = (SubmitEnum)6, lineType = (LineType)0 })); } } }