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 SwapLogo v1.1.0
plugins/SwapLogo.dll
Decompiled 2 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; using UnityEngine.Networking; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("SwapLogo")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("SwapLogo")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("d787473a-309b-47e6-97e0-e342266ce9fa")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace SwapLogo; [BepInPlugin("h4nz0.valheim.swaplogo", "Swap Logo", "1.1.0")] public class SwapLogoPlugin : BaseUnityPlugin { [CompilerGenerated] private sealed class <>c__DisplayClass33_0 { public bool attemptSuccess; internal void <ReplaceLogoDelayed>b__0(bool result) { attemptSuccess = result; } } [CompilerGenerated] private sealed class <>c__DisplayClass34_0 { public Sprite customSprite; internal void <TryReplaceLogoCoroutine>b__0(Sprite sprite) { customSprite = sprite; } } [CompilerGenerated] private sealed class <FadeInLogoCoroutine>d__40 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Image targetImage; private float <duration>5__1; private Color <color>5__2; private float <elapsed>5__3; private float <t>5__4; private float <smooth>5__5; private Color <newColor>5__6; private Color <finalColor>5__7; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <FadeInLogoCoroutine>d__40(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; if ((Object)(object)targetImage == (Object)null || (Object)(object)((Component)targetImage).gameObject == (Object)null) { return false; } <duration>5__1 = ((FadeDuration != null) ? Mathf.Max(0.01f, FadeDuration.Value) : 0.8f); <color>5__2 = ((Graphic)targetImage).color; <color>5__2.a = 0f; ((Graphic)targetImage).color = <color>5__2; <elapsed>5__3 = 0f; break; case 1: <>1__state = -1; break; } if (<elapsed>5__3 < <duration>5__1) { if ((Object)(object)targetImage == (Object)null || (Object)(object)((Component)targetImage).gameObject == (Object)null) { return false; } <elapsed>5__3 += Time.unscaledDeltaTime; <t>5__4 = Mathf.Clamp01(<elapsed>5__3 / <duration>5__1); <smooth>5__5 = Mathf.SmoothStep(0f, 1f, <t>5__4); <newColor>5__6 = ((Graphic)targetImage).color; <newColor>5__6.a = <smooth>5__5; ((Graphic)targetImage).color = <newColor>5__6; <>2__current = null; <>1__state = 1; return true; } if ((Object)(object)targetImage != (Object)null) { <finalColor>5__7 = ((Graphic)targetImage).color; <finalColor>5__7.a = 1f; ((Graphic)targetImage).color = <finalColor>5__7; } LogVerbose("[Swap Logo] Áttűnés (fade) animáció kész."); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <LoadSpriteFromFileCoroutine>d__32 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public string filePath; public Action<Sprite> onLoaded; private string <url>5__1; private UnityWebRequest <request>5__2; private bool <hasError>5__3; private Texture2D <texture>5__4; private Rect <rect>5__5; private Vector2 <pivot>5__6; private Sprite <sprite>5__7; private Exception <ex>5__8; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadSpriteFromFileCoroutine>d__32(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <url>5__1 = null; <request>5__2 = null; <texture>5__4 = null; <sprite>5__7 = null; <ex>5__8 = null; <>1__state = -2; } private bool MoveNext() { //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Invalid comparison between Unknown and I4 //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) bool result; try { switch (<>1__state) { default: result = false; break; case 0: <>1__state = -1; if (string.IsNullOrWhiteSpace(filePath)) { LogWarning("[Swap Logo] A logófájl útvonala üres."); onLoaded?.Invoke(null); result = false; break; } if (!File.Exists(filePath)) { LogWarning("[Swap Logo] A logófájl nem található: " + filePath); onLoaded?.Invoke(null); result = false; break; } <url>5__1 = "file:///" + filePath.Replace("\\", "/"); LogVerbose("[Swap Logo] Logó betöltése innen: " + <url>5__1); <request>5__2 = UnityWebRequestTexture.GetTexture(<url>5__1); <>1__state = -3; <>2__current = <request>5__2.SendWebRequest(); <>1__state = 1; result = true; break; case 1: { <>1__state = -3; <hasError>5__3 = (int)<request>5__2.result != 1; if (<hasError>5__3) { LogError(string.Format("[{0}] Hiba a logó betöltése közben: {1} | {2}", "Swap Logo", <request>5__2.result, <request>5__2.error)); onLoaded?.Invoke(null); result = false; } else { try { <texture>5__4 = DownloadHandlerTexture.GetContent(<request>5__2); if (!((Object)(object)<texture>5__4 == (Object)null)) { ((Object)<texture>5__4).name = "SwapLogoTexture"; ((Texture)<texture>5__4).wrapMode = (TextureWrapMode)1; ((Texture)<texture>5__4).filterMode = (FilterMode)1; <rect>5__5 = new Rect(0f, 0f, (float)((Texture)<texture>5__4).width, (float)((Texture)<texture>5__4).height); <pivot>5__6 = new Vector2(0.5f, 0.5f); <sprite>5__7 = Sprite.Create(<texture>5__4, <rect>5__5, <pivot>5__6, 100f); ((Object)<sprite>5__7).name = "SwapLogoSprite"; LogVerbose(string.Format("[{0}] Logó betöltve: {1}x{2}", "Swap Logo", ((Texture)<texture>5__4).width, ((Texture)<texture>5__4).height)); onLoaded?.Invoke(<sprite>5__7); <texture>5__4 = null; <sprite>5__7 = null; goto IL_030f; } LogError("[Swap Logo] A textúra betöltése sikertelen, a kapott Texture2D null."); onLoaded?.Invoke(null); result = false; } catch (Exception ex) { <ex>5__8 = ex; LogError(string.Format("[{0}] Kivétel a textúra vagy sprite létrehozásakor: {1}", "Swap Logo", <ex>5__8)); onLoaded?.Invoke(null); goto IL_030f; } } <>m__Finally1(); break; } IL_030f: <>m__Finally1(); <request>5__2 = null; result = false; break; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<request>5__2 != null) { ((IDisposable)<request>5__2).Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <ReplaceLogoDelayed>d__33 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private float <initialDelay>5__1; private int <attempts>5__2; private float <interval>5__3; private int <minScore>5__4; private bool <success>5__5; private int <i>5__6; private <>c__DisplayClass33_0 <>8__7; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ReplaceLogoDelayed>d__33(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__7 = null; <>1__state = -2; } private bool MoveNext() { //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if ((Object)(object)Instance == (Object)null) { return false; } if (_replaceRoutineStarted) { LogVerbose("[Swap Logo] A logócsere rutin már elindult, új példány nem indul."); return false; } _replaceRoutineStarted = true; <initialDelay>5__1 = ((ReplaceDelaySeconds != null) ? Mathf.Max(0f, ReplaceDelaySeconds.Value) : 0f); if (<initialDelay>5__1 > 0f) { LogVerbose(string.Format("[{0}] Várakozás {1:0.00} mp-ig az első logócsere előtt.", "Swap Logo", <initialDelay>5__1)); <>2__current = (object)new WaitForSeconds(<initialDelay>5__1); <>1__state = 1; return true; } goto IL_00e5; case 1: <>1__state = -1; goto IL_00e5; case 2: <>1__state = -1; if (<>8__7.attemptSuccess) { <success>5__5 = true; LogInfo(string.Format("[{0}] A logócsere sikeres volt a(z) {1}. próbálkozásra.", "Swap Logo", <i>5__6)); break; } if (<i>5__6 < <attempts>5__2) { <>2__current = (object)new WaitForSeconds(<interval>5__3); <>1__state = 3; return true; } goto IL_0252; case 3: { <>1__state = -1; goto IL_0252; } IL_00e5: <attempts>5__2 = GetRetryAttemptsByMode(); <interval>5__3 = GetRetryIntervalByMode(); <minScore>5__4 = GetMinimumScoreByMode(); LogInfo(string.Format("[{0}] Logócsere indul. Próbálkozások száma: {1}, intervallum: {2:0.00} mp, minimum pontszám: {3}", "Swap Logo", <attempts>5__2, <interval>5__3, <minScore>5__4)); <success>5__5 = false; <i>5__6 = 1; goto IL_026c; IL_026c: if (<i>5__6 <= <attempts>5__2) { <>8__7 = new <>c__DisplayClass33_0(); LogVerbose(string.Format("[{0}] Logócsere próbálkozás: {1}/{2}", "Swap Logo", <i>5__6, <attempts>5__2)); <>8__7.attemptSuccess = false; <>2__current = ((MonoBehaviour)Instance).StartCoroutine(TryReplaceLogoCoroutine(delegate(bool result) { <>8__7.attemptSuccess = result; }, <minScore>5__4)); <>1__state = 2; return true; } break; IL_0252: <>8__7 = null; <i>5__6++; goto IL_026c; } if (!<success>5__5) { LogWarning("[Swap Logo] A logócsere egyik próbálkozás során sem sikerült."); } _replaceRoutineStarted = false; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <TryReplaceLogoCoroutine>d__34 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Action<bool> onFinished; public int minimumScore; private <>c__DisplayClass34_0 <>8__1; private string <logoPath>5__2; private Image[] <images>5__3; private Image <bestMatch>5__4; private int <bestScore>5__5; private bool <shouldAnimate>5__6; private Image[] <>s__7; private int <>s__8; private Image <img>5__9; private int <score>5__10; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <TryReplaceLogoCoroutine>d__34(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <logoPath>5__2 = null; <images>5__3 = null; <bestMatch>5__4 = null; <>s__7 = null; <img>5__9 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass34_0(); if ((Object)(object)Instance == (Object)null) { LogWarning("[Swap Logo] A plugin példány nem elérhető."); onFinished?.Invoke(obj: false); return false; } <logoPath>5__2 = GetLogoPath(); <>8__1.customSprite = null; <>2__current = ((MonoBehaviour)Instance).StartCoroutine(LoadSpriteFromFileCoroutine(<logoPath>5__2, delegate(Sprite sprite) { <>8__1.customSprite = sprite; })); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)<>8__1.customSprite == (Object)null) { LogWarning("[Swap Logo] A saját logó betöltése sikertelen."); onFinished?.Invoke(obj: false); return false; } <images>5__3 = Resources.FindObjectsOfTypeAll<Image>(); if (<images>5__3 == null || <images>5__3.Length == 0) { LogWarning("[Swap Logo] Nem találtam UI Image objektumokat."); onFinished?.Invoke(obj: false); return false; } LogVerbose(string.Format("[{0}] Talált Image objektumok száma: {1}", "Swap Logo", <images>5__3.Length)); if (DumpAllImages != null && DumpAllImages.Value) { DumpImageCandidates(<images>5__3); } <bestMatch>5__4 = null; <bestScore>5__5 = int.MinValue; <>s__7 = <images>5__3; for (<>s__8 = 0; <>s__8 < <>s__7.Length; <>s__8++) { <img>5__9 = <>s__7[<>s__8]; if (!((Object)(object)<img>5__9 == (Object)null) && !((Object)(object)((Component)<img>5__9).gameObject == (Object)null)) { <score>5__10 = CalculateImageScore(<img>5__9); if (<score>5__10 > <bestScore>5__5) { <bestScore>5__5 = <score>5__10; <bestMatch>5__4 = <img>5__9; } <img>5__9 = null; } } <>s__7 = null; if ((Object)(object)<bestMatch>5__4 == (Object)null) { LogWarning("[Swap Logo] Nem találtam megfelelő logó objektumot a cseréhez."); onFinished?.Invoke(obj: false); return false; } if (<bestScore>5__5 < minimumScore) { LogWarning(string.Format("[{0}] A legjobb találat pontszáma túl alacsony: {1}. Minimum szükséges: {2}. Objektum: {3}", "Swap Logo", <bestScore>5__5, minimumScore, ((Object)((Component)<bestMatch>5__4).gameObject).name)); onFinished?.Invoke(obj: false); return false; } ApplyLogo(<bestMatch>5__4, <>8__1.customSprite); <shouldAnimate>5__6 = EnableFade != null && EnableFade.Value && !_fadeAlreadyPlayed; if (<shouldAnimate>5__6) { _fadeAlreadyPlayed = true; <>2__current = ((MonoBehaviour)Instance).StartCoroutine(FadeInLogoCoroutine(<bestMatch>5__4)); <>1__state = 2; return true; } break; case 2: <>1__state = -1; break; } _lastAppliedObjectName = ((Object)((Component)<bestMatch>5__4).gameObject).name; LogInfo(string.Format("[{0}] A logó sikeresen lecserélve erre az objektumra: {1} | Pontszám: {2}", "Swap Logo", ((Object)((Component)<bestMatch>5__4).gameObject).name, <bestScore>5__5)); onFinished?.Invoke(obj: true); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public const string ModGuid = "h4nz0.valheim.swaplogo"; public const string ModName = "Swap Logo"; public const string ModVersion = "1.1.0"; internal static SwapLogoPlugin Instance; internal static ManualLogSource Log; private Harmony _harmony; internal static ConfigEntry<bool> ModEnabled; internal static ConfigEntry<bool> VerboseLogging; internal static ConfigEntry<string> LogoFileName; internal static ConfigEntry<float> ReplaceDelaySeconds; internal static ConfigEntry<bool> UseFixedSize; internal static ConfigEntry<float> FixedWidth; internal static ConfigEntry<float> FixedHeight; internal static ConfigEntry<float> LogoScale; internal static ConfigEntry<bool> EnableFade; internal static ConfigEntry<float> FadeDuration; internal static ConfigEntry<string> CompatibilityMode; internal static ConfigEntry<int> RetryCount; internal static ConfigEntry<float> RetryIntervalSeconds; internal static ConfigEntry<int> MinimumScoreThreshold; internal static ConfigEntry<bool> DumpAllImages; private static bool _replaceRoutineStarted; private static bool _fadeAlreadyPlayed; private static string _lastAppliedObjectName = string.Empty; private void Awake() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; InitConfig(); if (!ModEnabled.Value) { Log.LogInfo((object)"[Swap Logo] A mod ki van kapcsolva a configban."); return; } _harmony = new Harmony("h4nz0.valheim.swaplogo"); _harmony.PatchAll(); Log.LogInfo((object)"[Swap Logo] Betöltve."); Log.LogInfo((object)("[Swap Logo] Logó elérési út: " + GetLogoPath())); Log.LogInfo((object)("[Swap Logo] Kompatibilitási mód: " + CompatibilityMode.Value)); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void InitConfig() { ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "A mod be- vagy kikapcsolása."); VerboseLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "VerboseLogging", true, "Részletes naplózás be- vagy kikapcsolása."); LogoFileName = ((BaseUnityPlugin)this).Config.Bind<string>("General", "LogoFileName", "logo.png", "A betöltendő logófájl neve a plugin saját mappájából."); ReplaceDelaySeconds = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ReplaceDelaySeconds", 0.75f, "Ennyi másodpercet vár a főmenü indulása után, mielőtt megpróbálja lecserélni a logót."); UseFixedSize = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "UseFixedSize", true, "Fix UI méretet használjon a logóhoz."); FixedWidth = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "FixedWidth", 900f, "A logó fix szélessége UI egységben."); FixedHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "FixedHeight", 260f, "A logó fix magassága UI egységben."); LogoScale = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "LogoScale", 1f, "A logó méretezése a fix méret után. 1.0 = alap, 0.8 = kisebb, 1.2 = nagyobb."); EnableFade = ((BaseUnityPlugin)this).Config.Bind<bool>("Animation", "EnableFade", true, "Áttűnéses animáció használata a logócsere után."); FadeDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Animation", "FadeDuration", 0.8f, "Az áttűnés animáció hossza másodpercben."); CompatibilityMode = ((BaseUnityPlugin)this).Config.Bind<string>("Compatibility", "CompatibilityMode", "Auto", "Kompatibilitási mód. Lehetséges értékek: Strict, Auto, Aggressive"); RetryCount = ((BaseUnityPlugin)this).Config.Bind<int>("Compatibility", "RetryCount", 4, "Hányszor próbálja meg újra a logócserét, ha elsőre nem sikerül."); RetryIntervalSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Compatibility", "RetryIntervalSeconds", 0.75f, "Ennyi időt vár két újrapróbálkozás között."); MinimumScoreThreshold = ((BaseUnityPlugin)this).Config.Bind<int>("Compatibility", "MinimumScoreThreshold", 50, "A minimális pontszám, ami felett egy UI elem megfelelő jelöltnek számít."); DumpAllImages = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "DumpAllImages", false, "Ha engedélyezve van, kilogolja az összes talált UI Image objektumot és pontszámukat."); ((BaseUnityPlugin)this).Config.Save(); } internal static string GetLogoPath() { try { if ((Object)(object)Instance == (Object)null || ((BaseUnityPlugin)Instance).Info == null) { return Path.Combine(Paths.PluginPath, "SwapLogo", LogoFileName.Value); } string location = ((BaseUnityPlugin)Instance).Info.Location; if (string.IsNullOrWhiteSpace(location)) { return Path.Combine(Paths.PluginPath, "SwapLogo", LogoFileName.Value); } string directoryName = Path.GetDirectoryName(location); if (string.IsNullOrWhiteSpace(directoryName)) { return Path.Combine(Paths.PluginPath, "SwapLogo", LogoFileName.Value); } string text = Path.Combine(directoryName, "SwapLogo"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); LogInfo("[Swap Logo] SwapLogo mappa létrehozva: " + text); } string text2 = Path.Combine(text, LogoFileName.Value); LogVerbose("[Swap Logo] Keresett logó útvonal: " + text2); return text2; } catch (Exception arg) { LogError(string.Format("[{0}] Hiba a logó elérési út meghatározásakor: {1}", "Swap Logo", arg)); return Path.Combine(Paths.PluginPath, "SwapLogo", LogoFileName.Value); } } internal static void LogInfo(string message) { ManualLogSource log = Log; if (log != null) { log.LogInfo((object)message); } } internal static void LogWarning(string message) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)message); } } internal static void LogError(string message) { ManualLogSource log = Log; if (log != null) { log.LogError((object)message); } } internal static void LogVerbose(string message) { if (VerboseLogging != null && VerboseLogging.Value) { ManualLogSource log = Log; if (log != null) { log.LogInfo((object)message); } } } [IteratorStateMachine(typeof(<LoadSpriteFromFileCoroutine>d__32))] internal static IEnumerator LoadSpriteFromFileCoroutine(string filePath, Action<Sprite> onLoaded) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadSpriteFromFileCoroutine>d__32(0) { filePath = filePath, onLoaded = onLoaded }; } [IteratorStateMachine(typeof(<ReplaceLogoDelayed>d__33))] internal static IEnumerator ReplaceLogoDelayed() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ReplaceLogoDelayed>d__33(0); } [IteratorStateMachine(typeof(<TryReplaceLogoCoroutine>d__34))] internal static IEnumerator TryReplaceLogoCoroutine(Action<bool> onFinished, int minimumScore) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <TryReplaceLogoCoroutine>d__34(0) { onFinished = onFinished, minimumScore = minimumScore }; } internal static int CalculateImageScore(Image img) { //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: 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_020e: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)img == (Object)null || (Object)(object)((Component)img).gameObject == (Object)null) { return int.MinValue; } GameObject gameObject = ((Component)img).gameObject; RectTransform rectTransform = ((Graphic)img).rectTransform; string text = ((Object)gameObject).name ?? string.Empty; string text2 = text.ToLowerInvariant(); string text3 = (((Object)(object)img.sprite != (Object)null && !string.IsNullOrWhiteSpace(((Object)img.sprite).name)) ? ((Object)img.sprite).name.ToLowerInvariant() : string.Empty); int num = 0; if (text2.Contains("logo")) { num += 100; } if (text2.Contains("valheim")) { num += 80; } if (text2.Contains("title")) { num += 40; } if (text2.Contains("menu")) { num += 10; } if (text3.Contains("logo")) { num += 50; } if (text3.Contains("valheim")) { num += 40; } if (gameObject.activeInHierarchy) { num += 15; } if (((Behaviour)img).enabled) { num += 10; } if ((Object)(object)((Graphic)img).canvasRenderer != (Object)null && ((Graphic)img).canvasRenderer.GetAlpha() > 0.01f) { num += 10; } Rect rect; if ((Object)(object)rectTransform != (Object)null) { rect = rectTransform.rect; float width = ((Rect)(ref rect)).width; rect = rectTransform.rect; float num2 = Mathf.Abs(width * ((Rect)(ref rect)).height); if (num2 > 10000f) { num += 10; } if (num2 > 50000f) { num += 10; } if (num2 > 150000f) { num += 10; } Vector3 position = ((Transform)rectTransform).position; if (position.y > (float)Screen.height * 0.45f) { num += 10; } } string text4 = NormalizeMode((CompatibilityMode != null) ? CompatibilityMode.Value : "Auto"); string text5 = text4; string text6 = text5; if (!(text6 == "STRICT")) { if (text6 == "AGGRESSIVE") { if ((Object)(object)rectTransform != (Object)null) { rect = rectTransform.rect; float width2 = ((Rect)(ref rect)).width; rect = rectTransform.rect; float num3 = Mathf.Abs(width2 * ((Rect)(ref rect)).height); if (num3 > 30000f) { num += 15; } } if (gameObject.activeInHierarchy) { num += 10; } } } else { if (!text2.Contains("logo") && !text3.Contains("logo")) { num -= 40; } if (!text2.Contains("valheim") && !text3.Contains("valheim")) { num -= 20; } } LogVerbose(string.Format("[{0}] Vizsgált objektum: {1} | Sprite: {2} | Pontszám: {3}", "Swap Logo", text, text3, num)); return num; } internal static void DumpImageCandidates(Image[] images) { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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 (images == null || images.Length == 0) { return; } LogInfo("[Swap Logo] --- UI Image dump indul ---"); foreach (Image val in images) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null)) { string text = ((Object)((Component)val).gameObject).name ?? "<névtelen>"; string text2 = (((Object)(object)val.sprite != (Object)null) ? ((Object)val.sprite).name : "<nincs sprite>"); string hierarchyPath = GetHierarchyPath(((Component)val).transform); RectTransform rectTransform = ((Graphic)val).rectTransform; object obj; if (!((Object)(object)rectTransform != (Object)null)) { obj = "nincs RectTransform"; } else { Rect rect = rectTransform.rect; object arg = ((Rect)(ref rect)).width; rect = rectTransform.rect; obj = $"size=({arg:0.##}x{((Rect)(ref rect)).height:0.##}), pos={rectTransform.anchoredPosition}"; } string text3 = (string)obj; int num = CalculateImageScore(val); LogInfo(string.Format("[{0}] Image: {1} | Sprite: {2} | Active: {3} | {4} | Score: {5} | Path: {6}", "Swap Logo", text, text2, ((Component)val).gameObject.activeInHierarchy, text3, num, hierarchyPath)); } } LogInfo("[Swap Logo] --- UI Image dump vége ---"); } internal static string GetHierarchyPath(Transform transform) { if ((Object)(object)transform == (Object)null) { return "<null>"; } List<string> list = new List<string>(); Transform val = transform; while ((Object)(object)val != (Object)null) { list.Insert(0, ((Object)val).name); val = val.parent; } return string.Join("/", list); } internal static void ApplyLogo(Image targetImage, Sprite newSprite) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)targetImage == (Object)null || (Object)(object)newSprite == (Object)null) { return; } targetImage.sprite = newSprite; targetImage.overrideSprite = newSprite; ((Behaviour)targetImage).enabled = true; targetImage.preserveAspect = true; targetImage.type = (Type)0; ((Graphic)targetImage).material = null; Color white = Color.white; white.a = 1f; ((Graphic)targetImage).color = white; RectTransform rectTransform = ((Graphic)targetImage).rectTransform; if ((Object)(object)rectTransform != (Object)null) { if (UseFixedSize != null && UseFixedSize.Value) { rectTransform.sizeDelta = new Vector2(Mathf.Max(1f, FixedWidth.Value), Mathf.Max(1f, FixedHeight.Value)); } else { Rect rect = newSprite.rect; float num = Mathf.Max(1f, ((Rect)(ref rect)).width); rect = newSprite.rect; rectTransform.sizeDelta = new Vector2(num, Mathf.Max(1f, ((Rect)(ref rect)).height)); } ((Transform)rectTransform).localScale = Vector3.one * Mathf.Max(0.01f, LogoScale.Value); } DebugLogoState(targetImage, newSprite); } internal static void DebugLogoState(Image targetImage, Sprite sprite) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)targetImage == (Object)null) && !((Object)(object)sprite == (Object)null)) { RectTransform rectTransform = ((Graphic)targetImage).rectTransform; Rect rect = sprite.rect; object arg = ((Rect)(ref rect)).width; rect = sprite.rect; LogInfo(string.Format("[{0}] Sprite méret: {1} x {2}", "Swap Logo", arg, ((Rect)(ref rect)).height)); LogInfo(string.Format("[{0}] Image color: {1}", "Swap Logo", ((Graphic)targetImage).color)); LogInfo("[Swap Logo] Utoljára alkalmazott objektum: " + _lastAppliedObjectName); if ((Object)(object)rectTransform != (Object)null) { LogInfo(string.Format("[{0}] Rect sizeDelta: {1}", "Swap Logo", rectTransform.sizeDelta)); LogInfo(string.Format("[{0}] Rect localScale: {1}", "Swap Logo", ((Transform)rectTransform).localScale)); LogInfo(string.Format("[{0}] Rect anchoredPosition: {1}", "Swap Logo", rectTransform.anchoredPosition)); } } } [IteratorStateMachine(typeof(<FadeInLogoCoroutine>d__40))] internal static IEnumerator FadeInLogoCoroutine(Image targetImage) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <FadeInLogoCoroutine>d__40(0) { targetImage = targetImage }; } internal static string NormalizeMode(string mode) { if (string.IsNullOrWhiteSpace(mode)) { return "AUTO"; } return mode.Trim().ToUpperInvariant(); } internal static int GetRetryAttemptsByMode() { string text = NormalizeMode((CompatibilityMode != null) ? CompatibilityMode.Value : "Auto"); int num = ((RetryCount != null) ? Mathf.Max(1, RetryCount.Value) : 4); string text2 = text; string text3 = text2; if (!(text3 == "STRICT")) { if (text3 == "AGGRESSIVE") { return Mathf.Max(num, 6); } return Mathf.Max(num, 4); } return Mathf.Max(1, num); } internal static float GetRetryIntervalByMode() { string text = NormalizeMode((CompatibilityMode != null) ? CompatibilityMode.Value : "Auto"); float num = ((RetryIntervalSeconds != null) ? Mathf.Max(0.1f, RetryIntervalSeconds.Value) : 0.75f); string text2 = text; string text3 = text2; if (!(text3 == "STRICT")) { if (text3 == "AGGRESSIVE") { return Mathf.Max(0.25f, num); } return num; } return num; } internal static int GetMinimumScoreByMode() { string text = NormalizeMode((CompatibilityMode != null) ? CompatibilityMode.Value : "Auto"); int num = ((MinimumScoreThreshold != null) ? Mathf.Max(0, MinimumScoreThreshold.Value) : 50); string text2 = text; string text3 = text2; if (!(text3 == "STRICT")) { if (text3 == "AGGRESSIVE") { return Mathf.Min(num, 35); } return num; } return Mathf.Max(num, 80); } } [HarmonyPatch(typeof(FejdStartup), "Start")] public static class FejdStartup_Start_Patch { private static void Postfix(FejdStartup __instance) { if (SwapLogoPlugin.ModEnabled != null && SwapLogoPlugin.ModEnabled.Value) { if ((Object)(object)__instance == (Object)null) { SwapLogoPlugin.LogWarning("[Swap Logo] A FejdStartup példány null."); return; } SwapLogoPlugin.LogVerbose("[Swap Logo] FejdStartup.Start postfix lefutott."); ((MonoBehaviour)__instance).StartCoroutine(SwapLogoPlugin.ReplaceLogoDelayed()); } } }