Decompiled source of SMUT v2.2.2
SunHavenMuseumUtilityTracker.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using SunHavenMuseumUtilityTracker.Data; using SunHavenMuseumUtilityTracker.Patches; using SunHavenMuseumUtilityTracker.UI; using SunhavenMods.Shared; using UnityEngine; using UnityEngine.Networking; using UnityEngine.SceneManagement; using Wish; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("SunHavenMuseumUtilityTracker")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+54235fa387ce65f1ea7f743eb7e9b44371b337da")] [assembly: AssemblyProduct("SunHavenMuseumUtilityTracker")] [assembly: AssemblyTitle("SunHavenMuseumUtilityTracker")] [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 SunhavenMods.Shared { public static class VersionChecker { public class VersionCheckResult { public bool Success { get; set; } public bool UpdateAvailable { get; set; } public string CurrentVersion { get; set; } public string LatestVersion { get; set; } public string ModName { get; set; } public string NexusUrl { get; set; } public string Changelog { get; set; } public string ErrorMessage { get; set; } } private class VersionCheckRunner : MonoBehaviour { public void StartCheck(string pluginGuid, string currentVersion, Action<VersionCheckResult> onComplete) { ((MonoBehaviour)this).StartCoroutine(CheckVersionCoroutine(pluginGuid, currentVersion, onComplete)); } private IEnumerator CheckVersionCoroutine(string pluginGuid, string currentVersion, Action<VersionCheckResult> onComplete) { VersionCheckResult result = new VersionCheckResult { CurrentVersion = currentVersion }; UnityWebRequest www = UnityWebRequest.Get("https://azraelgodking.github.io/SunhavenMod/versions.json"); try { www.timeout = 10; yield return www.SendWebRequest(); if ((int)www.result == 2 || (int)www.result == 3) { result.Success = false; result.ErrorMessage = "Network error: " + www.error; LogWarning(result.ErrorMessage); onComplete?.Invoke(result); Object.Destroy((Object)(object)((Component)this).gameObject); yield break; } try { string json = www.downloadHandler.text; string modPattern = "\"" + Regex.Escape(pluginGuid) + "\"\\s*:\\s*\\{([^}]+)\\}"; Match modMatch = Regex.Match(json, modPattern, RegexOptions.Singleline); if (!modMatch.Success) { result.Success = false; result.ErrorMessage = "Mod '" + pluginGuid + "' not found in versions.json"; LogWarning(result.ErrorMessage); onComplete?.Invoke(result); Object.Destroy((Object)(object)((Component)this).gameObject); yield break; } string modJson = modMatch.Groups[1].Value; result.LatestVersion = ExtractJsonString(modJson, "version"); result.ModName = ExtractJsonString(modJson, "name"); result.NexusUrl = ExtractJsonString(modJson, "nexus"); result.Changelog = ExtractJsonString(modJson, "changelog"); if (string.IsNullOrEmpty(result.LatestVersion)) { result.Success = false; result.ErrorMessage = "Could not parse version from response"; LogWarning(result.ErrorMessage); onComplete?.Invoke(result); Object.Destroy((Object)(object)((Component)this).gameObject); yield break; } result.Success = true; result.UpdateAvailable = CompareVersions(currentVersion, result.LatestVersion) < 0; if (result.UpdateAvailable) { Log("Update available for " + result.ModName + ": " + currentVersion + " -> " + result.LatestVersion); } else { Log(result.ModName + " is up to date (v" + currentVersion + ")"); } } catch (Exception ex) { result.Success = false; result.ErrorMessage = "Parse error: " + ex.Message; LogError(result.ErrorMessage); } } finally { ((IDisposable)www)?.Dispose(); } onComplete?.Invoke(result); Object.Destroy((Object)(object)((Component)this).gameObject); } private string ExtractJsonString(string json, string key) { string pattern = "\"" + key + "\"\\s*:\\s*(?:\"([^\"]*)\"|null)"; Match match = Regex.Match(json, pattern); return match.Success ? match.Groups[1].Value : null; } } private const string VersionsUrl = "https://azraelgodking.github.io/SunhavenMod/versions.json"; private static ManualLogSource _logger; public static void CheckForUpdate(string pluginGuid, string currentVersion, ManualLogSource logger = null, Action<VersionCheckResult> onComplete = null) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) _logger = logger; VersionCheckRunner versionCheckRunner = new GameObject("VersionChecker").AddComponent<VersionCheckRunner>(); Object.DontDestroyOnLoad((Object)(object)((Component)versionCheckRunner).gameObject); versionCheckRunner.StartCheck(pluginGuid, currentVersion, onComplete); } public static int CompareVersions(string v1, string v2) { if (string.IsNullOrEmpty(v1) || string.IsNullOrEmpty(v2)) { return 0; } v1 = v1.TrimStart('v', 'V'); v2 = v2.TrimStart('v', 'V'); string[] array = v1.Split(new char[1] { '.' }); string[] array2 = v2.Split(new char[1] { '.' }); int num = Math.Max(array.Length, array2.Length); for (int i = 0; i < num; i++) { int result; int num2 = ((i < array.Length && int.TryParse(array[i], out result)) ? result : 0); int result2; int num3 = ((i < array2.Length && int.TryParse(array2[i], out result2)) ? result2 : 0); if (num2 < num3) { return -1; } if (num2 > num3) { return 1; } } return 0; } internal static void Log(string message) { ManualLogSource logger = _logger; if (logger != null) { logger.LogInfo((object)("[VersionChecker] " + message)); } } internal static void LogWarning(string message) { ManualLogSource logger = _logger; if (logger != null) { logger.LogWarning((object)("[VersionChecker] " + message)); } } internal static void LogError(string message) { ManualLogSource logger = _logger; if (logger != null) { logger.LogError((object)("[VersionChecker] " + message)); } } } public static class VersionCheckerExtensions { public static void NotifyUpdateAvailable(this VersionChecker.VersionCheckResult result, ManualLogSource logger = null) { if (!result.UpdateAvailable) { return; } string text = result.ModName + " update available: v" + result.LatestVersion; try { Type type = ReflectionHelper.FindWishType("NotificationStack"); if (type != null) { Type type2 = ReflectionHelper.FindType("SingletonBehaviour`1", "Wish"); if (type2 != null) { Type type3 = type2.MakeGenericType(type); object obj = type3.GetProperty("Instance")?.GetValue(null); if (obj != null) { MethodInfo method = type.GetMethod("SendNotification", new Type[5] { typeof(string), typeof(int), typeof(int), typeof(bool), typeof(bool) }); if (method != null) { method.Invoke(obj, new object[5] { text, 0, 1, false, true }); return; } } } } } catch (Exception ex) { if (logger != null) { logger.LogWarning((object)("Failed to send native notification: " + ex.Message)); } } if (logger != null) { logger.LogWarning((object)("[UPDATE AVAILABLE] " + text)); } if (!string.IsNullOrEmpty(result.NexusUrl) && logger != null) { logger.LogWarning((object)("Download at: " + result.NexusUrl)); } } } public static class ReflectionHelper { public static readonly BindingFlags AllBindingFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy; public static Type FindType(string typeName, params string[] namespaces) { Type type = AccessTools.TypeByName(typeName); if (type != null) { return type; } foreach (string text in namespaces) { type = AccessTools.TypeByName(text + "." + typeName); if (type != null) { return type; } } Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { try { type = assembly.GetTypes().FirstOrDefault((Type t) => t.Name == typeName || t.FullName == typeName); if (type != null) { return type; } } catch (ReflectionTypeLoadException) { } } return null; } public static Type FindWishType(string typeName) { return FindType(typeName, "Wish"); } public static object GetStaticValue(Type type, string memberName) { if (type == null) { return null; } PropertyInfo property = type.GetProperty(memberName, AllBindingFlags); if (property != null && property.GetMethod != null) { return property.GetValue(null); } FieldInfo field = type.GetField(memberName, AllBindingFlags); if (field != null) { return field.GetValue(null); } return null; } public static object GetSingletonInstance(Type type) { if (type == null) { return null; } string[] array = new string[5] { "Instance", "instance", "_instance", "Singleton", "singleton" }; string[] array2 = array; foreach (string memberName in array2) { object staticValue = GetStaticValue(type, memberName); if (staticValue != null) { return staticValue; } } return null; } public static object GetInstanceValue(object instance, string memberName) { if (instance == null) { return null; } Type type = instance.GetType(); while (type != null) { PropertyInfo property = type.GetProperty(memberName, AllBindingFlags); if (property != null && property.GetMethod != null) { return property.GetValue(instance); } FieldInfo field = type.GetField(memberName, AllBindingFlags); if (field != null) { return field.GetValue(instance); } type = type.BaseType; } return null; } public static bool SetInstanceValue(object instance, string memberName, object value) { if (instance == null) { return false; } Type type = instance.GetType(); while (type != null) { PropertyInfo property = type.GetProperty(memberName, AllBindingFlags); if (property != null && property.SetMethod != null) { property.SetValue(instance, value); return true; } FieldInfo field = type.GetField(memberName, AllBindingFlags); if (field != null) { field.SetValue(instance, value); return true; } type = type.BaseType; } return false; } public static object InvokeMethod(object instance, string methodName, params object[] args) { if (instance == null) { return null; } Type type = instance.GetType(); Type[] array = args?.Select((object a) => a?.GetType() ?? typeof(object)).ToArray() ?? Type.EmptyTypes; MethodInfo methodInfo = AccessTools.Method(type, methodName, array, (Type[])null); if (methodInfo == null) { methodInfo = type.GetMethod(methodName, AllBindingFlags); } if (methodInfo == null) { return null; } return methodInfo.Invoke(instance, args); } public static object InvokeStaticMethod(Type type, string methodName, params object[] args) { if (type == null) { return null; } Type[] array = args?.Select((object a) => a?.GetType() ?? typeof(object)).ToArray() ?? Type.EmptyTypes; MethodInfo methodInfo = AccessTools.Method(type, methodName, array, (Type[])null); if (methodInfo == null) { methodInfo = type.GetMethod(methodName, AllBindingFlags); } if (methodInfo == null) { return null; } return methodInfo.Invoke(null, args); } public static FieldInfo[] GetAllFields(Type type) { if (type == null) { return Array.Empty<FieldInfo>(); } FieldInfo[] fields = type.GetFields(AllBindingFlags); IEnumerable<FieldInfo> second; if (!(type.BaseType != null) || !(type.BaseType != typeof(object))) { second = Enumerable.Empty<FieldInfo>(); } else { IEnumerable<FieldInfo> allFields = GetAllFields(type.BaseType); second = allFields; } return fields.Concat(second).Distinct().ToArray(); } public static PropertyInfo[] GetAllProperties(Type type) { if (type == null) { return Array.Empty<PropertyInfo>(); } PropertyInfo[] properties = type.GetProperties(AllBindingFlags); IEnumerable<PropertyInfo> second; if (!(type.BaseType != null) || !(type.BaseType != typeof(object))) { second = Enumerable.Empty<PropertyInfo>(); } else { IEnumerable<PropertyInfo> allProperties = GetAllProperties(type.BaseType); second = allProperties; } return (from p in properties.Concat(second) group p by p.Name into g select g.First()).ToArray(); } public static T TryGetValue<T>(object instance, string memberName, T defaultValue = default(T)) { try { object instanceValue = GetInstanceValue(instance, memberName); if (instanceValue is T result) { return result; } if (instanceValue != null && typeof(T).IsAssignableFrom(instanceValue.GetType())) { return (T)instanceValue; } return defaultValue; } catch { return defaultValue; } } } public static class IconCache { private static readonly Dictionary<int, Texture2D> _iconCache = new Dictionary<int, Texture2D>(); private static readonly HashSet<int> _loadingItems = new HashSet<int>(); private static readonly HashSet<int> _failedItems = new HashSet<int>(); private static readonly Dictionary<string, int> _currencyToItemId = new Dictionary<string, int>(); private static Texture2D _fallbackTexture; private static ManualLogSource _log; private static Type _databaseType; private static Type _itemDataType; private static MethodInfo _getDataMethod; private static bool _reflectionInitialized; private static bool _initialized; private static bool _iconsLoaded; public static void Initialize(ManualLogSource log, int[] preloadItemIds = null) { _log = log; if (_initialized) { ManualLogSource log2 = _log; if (log2 != null) { log2.LogDebug((object)"[IconCache] Already initialized"); } return; } _initialized = true; ManualLogSource log3 = _log; if (log3 != null) { log3.LogInfo((object)"[IconCache] Initializing icon cache..."); } _fallbackTexture = CreateFallbackTexture(); ManualLogSource log4 = _log; if (log4 != null) { log4.LogInfo((object)"[IconCache] Created fallback texture"); } if (preloadItemIds != null && preloadItemIds.Length != 0) { ManualLogSource log5 = _log; if (log5 != null) { log5.LogInfo((object)"[IconCache] Preload item IDs registered (loading deferred until LoadAllIcons)"); } } } public static void RegisterCurrency(string currencyId, int itemId) { _currencyToItemId[currencyId] = itemId; } public static void LoadAllIcons() { if (_iconsLoaded) { ManualLogSource log = _log; if (log != null) { log.LogDebug((object)"[IconCache] Icons already loaded, skipping"); } return; } if (!InitializeReflection()) { ManualLogSource log2 = _log; if (log2 != null) { log2.LogError((object)"[IconCache] Failed to initialize reflection, cannot load icons"); } _iconsLoaded = true; return; } foreach (KeyValuePair<string, int> item in _currencyToItemId) { ManualLogSource log3 = _log; if (log3 != null) { log3.LogDebug((object)$"[IconCache] Queuing load for: {item.Key} (ItemID: {item.Value})"); } LoadIcon(item.Value); } _iconsLoaded = true; ManualLogSource log4 = _log; if (log4 != null) { log4.LogInfo((object)$"[IconCache] Queued {_currencyToItemId.Count} icons for loading"); } } public static Texture2D GetIconForCurrency(string currencyId) { if (_currencyToItemId.TryGetValue(currencyId, out var value)) { return GetIcon(value); } return GetFallbackTexture(); } public static Texture2D GetIcon(int itemId) { if (_iconCache.TryGetValue(itemId, out var value)) { return value; } if (!_loadingItems.Contains(itemId) && !_failedItems.Contains(itemId)) { LoadIcon(itemId); } return GetFallbackTexture(); } private static Texture2D GetFallbackTexture() { if ((Object)(object)_fallbackTexture == (Object)null) { _fallbackTexture = CreateFallbackTexture(); } return _fallbackTexture; } public static bool IsIconLoaded(int itemId) { return _iconCache.ContainsKey(itemId); } public static bool IsIconLoaded(string currencyId) { int value; return _currencyToItemId.TryGetValue(currencyId, out value) && IsIconLoaded(value); } public static int GetItemIdForCurrency(string currencyId) { int value; return _currencyToItemId.TryGetValue(currencyId, out value) ? value : (-1); } private static bool InitializeReflection() { if (_reflectionInitialized) { return _databaseType != null && _itemDataType != null && _getDataMethod != null; } _reflectionInitialized = true; try { string[] array = new string[4] { "Database", "Wish.Database", "PSS.Database", "SunHaven.Database" }; string[] array2 = array; foreach (string text in array2) { _databaseType = AccessTools.TypeByName(text); if (_databaseType != null) { ManualLogSource log = _log; if (log != null) { log.LogInfo((object)("[IconCache] Found Database type: " + _databaseType.FullName)); } break; } } if (_databaseType == null) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { try { Type[] types = assembly.GetTypes(); foreach (Type type in types) { if (!(type.Name == "Database") || type.IsNested) { continue; } MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name == "GetData" && methodInfo.IsGenericMethod) { _databaseType = type; ManualLogSource log2 = _log; if (log2 != null) { log2.LogInfo((object)("[IconCache] Found Database type: " + type.FullName)); } break; } } if (_databaseType != null) { break; } } if (_databaseType != null) { break; } } catch (Exception ex) { ManualLogSource log3 = _log; if (log3 != null) { log3.LogDebug((object)("[IconCache] Skipping assembly " + assembly.GetName().Name + ": " + ex.Message)); } } } } if (_databaseType == null) { ManualLogSource log4 = _log; if (log4 != null) { log4.LogError((object)"[IconCache] Could not find Database type"); } return false; } _itemDataType = AccessTools.TypeByName("Wish.ItemData"); if (_itemDataType == null) { ManualLogSource log5 = _log; if (log5 != null) { log5.LogError((object)"[IconCache] Could not find Wish.ItemData type"); } return false; } MethodInfo[] methods2 = _databaseType.GetMethods(BindingFlags.Static | BindingFlags.Public); MethodInfo[] array3 = methods2; foreach (MethodInfo methodInfo2 in array3) { if (!(methodInfo2.Name == "GetData") || !methodInfo2.IsGenericMethod) { continue; } ParameterInfo[] parameters = methodInfo2.GetParameters(); if (methodInfo2.GetGenericArguments().Length == 1 && parameters.Length == 3 && parameters[0].ParameterType == typeof(int)) { _getDataMethod = methodInfo2.MakeGenericMethod(_itemDataType); ManualLogSource log6 = _log; if (log6 != null) { log6.LogInfo((object)"[IconCache] Found Database.GetData method"); } break; } } if (_getDataMethod == null) { ManualLogSource log7 = _log; if (log7 != null) { log7.LogError((object)"[IconCache] Could not find Database.GetData method"); } return false; } return true; } catch (Exception ex2) { ManualLogSource log8 = _log; if (log8 != null) { log8.LogError((object)("[IconCache] Error initializing reflection: " + ex2.Message)); } return false; } } private static void LoadIcon(int itemId) { if (_loadingItems.Contains(itemId) || _iconCache.ContainsKey(itemId)) { return; } _loadingItems.Add(itemId); try { if (!InitializeReflection() || _getDataMethod == null) { _failedItems.Add(itemId); _loadingItems.Remove(itemId); return; } Type delegateType = typeof(Action<>).MakeGenericType(_itemDataType); ParameterExpression parameterExpression = Expression.Parameter(_itemDataType, "itemData"); ConstantExpression arg = Expression.Constant(itemId); MethodInfo method = typeof(IconCache).GetMethod("OnIconLoadedInternal", BindingFlags.Static | BindingFlags.NonPublic); MethodCallExpression body = Expression.Call(method, arg, Expression.Convert(parameterExpression, typeof(object))); Delegate @delegate = Expression.Lambda(delegateType, body, parameterExpression).Compile(); MethodInfo method2 = typeof(IconCache).GetMethod("OnIconLoadFailed", BindingFlags.Static | BindingFlags.NonPublic); Action action = Expression.Lambda<Action>(Expression.Call(method2, arg), Array.Empty<ParameterExpression>()).Compile(); _getDataMethod.Invoke(null, new object[3] { itemId, @delegate, action }); } catch (Exception ex) { ManualLogSource log = _log; if (log != null) { log.LogDebug((object)$"[IconCache] Error loading icon {itemId}: {ex.Message}"); } _failedItems.Add(itemId); _loadingItems.Remove(itemId); } } private static void OnIconLoadedInternal(int itemId, object itemData) { _loadingItems.Remove(itemId); if (itemData == null) { _failedItems.Add(itemId); return; } try { Type type = itemData.GetType(); object obj = null; BindingFlags[] array = new BindingFlags[4] { BindingFlags.Instance | BindingFlags.Public, BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy, BindingFlags.Instance | BindingFlags.NonPublic, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy }; BindingFlags[] array2 = array; foreach (BindingFlags bindingAttr in array2) { PropertyInfo property = type.GetProperty("icon", bindingAttr); if (property != null) { obj = property.GetValue(itemData); break; } } if (obj == null) { BindingFlags[] array3 = array; foreach (BindingFlags bindingAttr2 in array3) { FieldInfo field = type.GetField("icon", bindingAttr2); if (field != null) { obj = field.GetValue(itemData); break; } } } if (obj == null) { Type type2 = type; while (type2 != null && obj == null) { PropertyInfo[] properties = type2.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); PropertyInfo[] array4 = properties; foreach (PropertyInfo propertyInfo in array4) { if (propertyInfo.Name.Equals("icon", StringComparison.OrdinalIgnoreCase)) { obj = propertyInfo.GetValue(itemData); break; } } if (obj == null) { FieldInfo[] fields = type2.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo[] array5 = fields; foreach (FieldInfo fieldInfo in array5) { if (fieldInfo.Name.Equals("icon", StringComparison.OrdinalIgnoreCase)) { obj = fieldInfo.GetValue(itemData); break; } } } type2 = type2.BaseType; } } Sprite val = (Sprite)((obj is Sprite) ? obj : null); if (val != null) { CacheSprite(itemId, val); } else { _failedItems.Add(itemId); } } catch (Exception ex) { ManualLogSource log = _log; if (log != null) { log.LogDebug((object)$"[IconCache] Error processing icon {itemId}: {ex.Message}"); } _failedItems.Add(itemId); } } private static void OnIconLoadFailed(int itemId) { _loadingItems.Remove(itemId); _failedItems.Add(itemId); } private static void CacheSprite(int itemId, Sprite sprite) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //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) if ((Object)(object)sprite == (Object)null || (Object)(object)sprite.texture == (Object)null) { _failedItems.Add(itemId); return; } try { Rect rect = sprite.rect; Texture2D val; if (((Rect)(ref rect)).width == (float)((Texture)sprite.texture).width) { rect = sprite.rect; if (((Rect)(ref rect)).height == (float)((Texture)sprite.texture).height) { val = sprite.texture; goto IL_0084; } } val = ExtractSpriteTexture(sprite); goto IL_0084; IL_0084: if ((Object)(object)val != (Object)null) { _iconCache[itemId] = val; } else { _failedItems.Add(itemId); } } catch (Exception ex) { ManualLogSource log = _log; if (log != null) { log.LogDebug((object)$"[IconCache] Error caching sprite {itemId}: {ex.Message}"); } _failedItems.Add(itemId); } } private static Texture2D ExtractSpriteTexture(Sprite sprite) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown try { Rect rect = sprite.rect; int num = (int)((Rect)(ref rect)).width; int num2 = (int)((Rect)(ref rect)).height; if (!((Texture)sprite.texture).isReadable) { return CopyTextureViaRenderTexture(sprite); } Texture2D val = new Texture2D(num, num2, (TextureFormat)4, false); Color[] pixels = sprite.texture.GetPixels((int)((Rect)(ref rect)).x, (int)((Rect)(ref rect)).y, num, num2); val.SetPixels(pixels); val.Apply(); return val; } catch (Exception ex) { ManualLogSource log = _log; if (log != null) { log.LogDebug((object)("[IconCache] Error extracting sprite texture: " + ex.Message)); } return null; } } private static Texture2D CopyTextureViaRenderTexture(Sprite sprite) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) try { Rect rect = sprite.rect; int num = (int)((Rect)(ref rect)).width; int num2 = (int)((Rect)(ref rect)).height; RenderTexture temporary = RenderTexture.GetTemporary(((Texture)sprite.texture).width, ((Texture)sprite.texture).height, 0, (RenderTextureFormat)0); Graphics.Blit((Texture)(object)sprite.texture, temporary); RenderTexture active = RenderTexture.active; RenderTexture.active = temporary; Texture2D val = new Texture2D(num, num2, (TextureFormat)4, false); val.ReadPixels(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, (float)num, (float)num2), 0, 0); val.Apply(); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); return val; } catch (Exception ex) { ManualLogSource log = _log; if (log != null) { log.LogDebug((object)("[IconCache] Error copying texture via RenderTexture: " + ex.Message)); } return null; } } private static Texture2D CreateFallbackTexture() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) int num = 32; Texture2D val = new Texture2D(num, num); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.3f, 0.3f, 0.4f, 0.8f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.5f, 0.5f, 0.6f, 1f); for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { if (j == 0 || j == num - 1 || i == 0 || i == num - 1) { val.SetPixel(j, i, val3); } else { val.SetPixel(j, i, val2); } } } val.Apply(); return val; } public static void Clear() { _iconCache.Clear(); _loadingItems.Clear(); _failedItems.Clear(); _initialized = false; _iconsLoaded = false; } public static (int loaded, int loading, int failed) GetStats() { return (_iconCache.Count, _loadingItems.Count, _failedItems.Count); } public static void LogStatus() { (int, int, int) stats = GetStats(); ManualLogSource log = _log; if (log != null) { log.LogInfo((object)$"[IconCache] Loaded: {stats.Item1}, Loading: {stats.Item2}, Failed: {stats.Item3}"); } } } } namespace SunHavenMuseumUtilityTracker { [BepInPlugin("com.azraelgodking.sunhavenmuseumutilitytracker", "Sun Haven Museum Utility Tracker", "2.2.2")] public class Plugin : BaseUnityPlugin { private static DonationManager _staticDonationManager; private static DonationSaveSystem _staticSaveSystem; private static MuseumTrackerUI _staticTrackerUI; private static GameObject _persistentRunner; private static PersistentRunner _persistentRunnerComponent; private DonationManager _donationManager; private DonationSaveSystem _saveSystem; private MuseumTrackerUI _trackerUI; private Harmony _harmony; private ConfigEntry<KeyCode> _toggleKey; private ConfigEntry<bool> _requireCtrl; private ConfigEntry<KeyCode> _altToggleKey; private ConfigEntry<bool> _checkForUpdates; private ConfigEntry<float> _uiScale; private string _lastScene = ""; public static Plugin Instance { get; private set; } public static ManualLogSource Log { get; private set; } public static KeyCode StaticToggleKey { get; private set; } public static bool StaticRequireCtrl { get; private set; } public static KeyCode StaticAltToggleKey { get; private set; } public static float StaticUIScale { get; private set; } = 1f; public DonationManager DonationManager => _donationManager; private void Awake() { //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Sun Haven Museum Utility Tracker v2.2.2 loading..."); BindConfiguration(); CreatePersistentRunner(); _donationManager = new DonationManager(); _staticDonationManager = _donationManager; _saveSystem = new DonationSaveSystem(_donationManager); _staticSaveSystem = _saveSystem; CreateUIComponents(); ApplyPatches(); SceneManager.sceneLoaded += OnSceneLoaded; if (_checkForUpdates.Value) { VersionChecker.CheckForUpdate("com.azraelgodking.sunhavenmuseumutilitytracker", "2.2.2", Log, delegate(VersionChecker.VersionCheckResult result) { result.NotifyUpdateAvailable(Log); }); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Sun Haven Museum Utility Tracker loaded successfully!"); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("Press {0}{1} or {2} to open the tracker", _requireCtrl.Value ? "Ctrl+" : "", _toggleKey.Value, _altToggleKey.Value)); } private void BindConfiguration() { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) _toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Hotkeys", "ToggleKey", (KeyCode)99, "Key to toggle the Museum Tracker window"); _requireCtrl = ((BaseUnityPlugin)this).Config.Bind<bool>("Hotkeys", "RequireCtrl", true, "Require Ctrl to be held when pressing the toggle key"); _altToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Hotkeys", "AltToggleKey", (KeyCode)288, "Alternative key to toggle the Museum Tracker (no modifier required). Useful for Steam Deck."); _checkForUpdates = ((BaseUnityPlugin)this).Config.Bind<bool>("Updates", "CheckForUpdates", true, "Check for mod updates on startup"); _uiScale = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "UIScale", 1f, new ConfigDescription("Scale factor for the tracker window (1.0 = default, 1.5 = 50% larger)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2.5f), Array.Empty<object>())); StaticToggleKey = _toggleKey.Value; StaticRequireCtrl = _requireCtrl.Value; StaticAltToggleKey = _altToggleKey.Value; StaticUIScale = Mathf.Clamp(_uiScale.Value, 0.5f, 2.5f); _toggleKey.SettingChanged += delegate { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) StaticToggleKey = _toggleKey.Value; _trackerUI?.SetToggleKey(_toggleKey.Value, _requireCtrl.Value); }; _requireCtrl.SettingChanged += delegate { //IL_0024: Unknown result type (might be due to invalid IL or missing references) StaticRequireCtrl = _requireCtrl.Value; _trackerUI?.SetToggleKey(_toggleKey.Value, _requireCtrl.Value); }; _altToggleKey.SettingChanged += delegate { //IL_0007: Unknown result type (might be due to invalid IL or missing references) StaticAltToggleKey = _altToggleKey.Value; }; _uiScale.SettingChanged += delegate { StaticUIScale = Mathf.Clamp(_uiScale.Value, 0.5f, 2.5f); _trackerUI?.SetScale(StaticUIScale); }; } private void CreatePersistentRunner() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown if (!((Object)(object)_persistentRunner != (Object)null) || !((Object)(object)_persistentRunnerComponent != (Object)null)) { _persistentRunner = new GameObject("MuseumTracker_PersistentRunner"); Object.DontDestroyOnLoad((Object)(object)_persistentRunner); ((Object)_persistentRunner).hideFlags = (HideFlags)61; _persistentRunnerComponent = _persistentRunner.AddComponent<PersistentRunner>(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[PersistentRunner] Created"); } } private void CreateUIComponents() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("MuseumTracker_UI"); Object.DontDestroyOnLoad((Object)(object)val); _trackerUI = val.AddComponent<MuseumTrackerUI>(); _trackerUI.Initialize(_donationManager); _trackerUI.SetScale(StaticUIScale); _trackerUI.SetToggleKey(_toggleKey.Value, _requireCtrl.Value); _staticTrackerUI = _trackerUI; val.AddComponent<DebugMode>(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"UI components created"); } public static void EnsureUIComponentsExist() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)_persistentRunner == (Object)null || (Object)(object)_persistentRunnerComponent == (Object)null) { ManualLogSource log = Log; if (log != null) { log.LogInfo((object)"[EnsureUI] Recreating PersistentRunner..."); } _persistentRunner = new GameObject("MuseumTracker_PersistentRunner"); Object.DontDestroyOnLoad((Object)(object)_persistentRunner); ((Object)_persistentRunner).hideFlags = (HideFlags)61; _persistentRunnerComponent = _persistentRunner.AddComponent<PersistentRunner>(); ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)"[EnsureUI] PersistentRunner recreated"); } } if ((Object)(object)_staticTrackerUI == (Object)null) { ManualLogSource log3 = Log; if (log3 != null) { log3.LogInfo((object)"[EnsureUI] Recreating TrackerUI..."); } GameObject val = new GameObject("MuseumTracker_UI"); Object.DontDestroyOnLoad((Object)(object)val); _staticTrackerUI = val.AddComponent<MuseumTrackerUI>(); _staticTrackerUI.Initialize(_staticDonationManager); _staticTrackerUI.SetScale(StaticUIScale); _staticTrackerUI.SetToggleKey(StaticToggleKey, StaticRequireCtrl); ManualLogSource log4 = Log; if (log4 != null) { log4.LogInfo((object)"[EnsureUI] TrackerUI recreated"); } } } catch (Exception ex) { ManualLogSource log5 = Log; if (log5 != null) { log5.LogError((object)("[EnsureUI] Error recreating UI: " + ex.Message)); } } } private void ApplyPatches() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown try { _harmony = new Harmony("com.azraelgodking.sunhavenmuseumutilitytracker"); Type typeFromHandle = typeof(Player); MethodInfo methodInfo = AccessTools.Method(typeFromHandle, "InitializeAsOwner", (Type[])null, (Type[])null); if (methodInfo != null) { MethodInfo methodInfo2 = AccessTools.Method(typeof(PlayerPatches), "OnPlayerInitialized", (Type[])null, (Type[])null); _harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Patched Player.InitializeAsOwner"); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find Player.InitializeAsOwner"); } Type typeFromHandle2 = typeof(GameSave); MethodInfo methodInfo3 = AccessTools.Method(typeFromHandle2, "LoadCharacter", new Type[1] { typeof(int) }, (Type[])null); if (methodInfo3 != null) { MethodInfo methodInfo4 = AccessTools.Method(typeof(GameSavePatches), "OnLoadCharacter", (Type[])null, (Type[])null); _harmony.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(methodInfo4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Patched GameSave.LoadCharacter"); } HungryMonsterPatches.ApplyPatches(_harmony); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Harmony patches applied"); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Error applying patches: " + ex.Message)); } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[SceneChange] Scene loaded: '" + ((Scene)(ref scene)).name + "'")); string text = ((Scene)(ref scene)).name.ToLowerInvariant(); if (text.Contains("menu") || text.Contains("title") || text.Contains("mainmenu")) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Menu scene detected: " + ((Scene)(ref scene)).name)); PlayerPatches.SaveAndReset(); } } private void Update() { //IL_001e: 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 (PlayerPatches.IsDataLoaded) { _saveSystem?.CheckAutoSave(); } Scene activeScene = SceneManager.GetActiveScene(); string name = ((Scene)(ref activeScene)).name; if (name != _lastScene) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[ScenePoll] Scene changed: '" + _lastScene + "' -> '" + name + "'")); _lastScene = name; string text = name.ToLowerInvariant(); if (text.Contains("menu") || text.Contains("title")) { PlayerPatches.SaveAndReset(); } } } private void OnApplicationQuit() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Application quitting, saving data..."); _saveSystem?.ForceSave(); } private void OnDestroy() { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[CRITICAL] Plugin OnDestroy called!"); _saveSystem?.ForceSave(); } public static DonationManager GetDonationManager() { return _staticDonationManager; } public static MuseumTrackerUI GetTrackerUI() { return _staticTrackerUI; } public static void SaveData() { _staticSaveSystem?.ForceSave(); } public static void LoadDataForPlayer(string playerName) { DonationData data = _staticSaveSystem?.Load(playerName); _staticDonationManager?.LoadForCharacter(playerName, data); } public static void ToggleUI() { _staticTrackerUI?.Toggle(); } } public class PersistentRunner : MonoBehaviour { private string _lastScene = ""; private void Update() { CheckHotkeys(); CheckSceneChange(); } private void CheckHotkeys() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) bool flag = Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305); bool keyDown = Input.GetKeyDown(Plugin.StaticToggleKey); bool keyDown2 = Input.GetKeyDown(Plugin.StaticAltToggleKey); if (keyDown && flag == Plugin.StaticRequireCtrl) { Plugin.ToggleUI(); } else if (keyDown2) { Plugin.ToggleUI(); } } private void CheckSceneChange() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); string name = ((Scene)(ref activeScene)).name; if (!(name != _lastScene)) { return; } ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("[PersistentRunner] Scene changed: '" + _lastScene + "' -> '" + name + "'")); } _lastScene = name; string text = name.ToLowerInvariant(); if (text.Contains("menu") || text.Contains("title")) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)"[PersistentRunner] Menu scene detected"); } PlayerPatches.SaveAndReset(); } } private void OnDestroy() { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[PersistentRunner] OnDestroy called - this should NOT happen!"); } } } public static class PluginInfo { public const string PLUGIN_GUID = "com.azraelgodking.sunhavenmuseumutilitytracker"; public const string PLUGIN_NAME = "Sun Haven Museum Utility Tracker"; public const string PLUGIN_VERSION = "2.2.2"; } } namespace SunHavenMuseumUtilityTracker.UI { public class DebugMode : MonoBehaviour { private bool _debugEnabled = false; private void Update() { if (Input.GetKeyDown((KeyCode)291)) { _debugEnabled = !_debugEnabled; ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("[DebugMode] Debug mode: " + (_debugEnabled ? "ENABLED" : "DISABLED"))); } if (_debugEnabled) { MuseumPatches.DiscoverProgressKeyPatterns(); MuseumPatches.LogAllMappings(); } } if (_debugEnabled && Input.GetKeyDown((KeyCode)292)) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)"[DebugMode] Force syncing with game progress..."); } MuseumPatches.SyncWithGameProgress(); } } } public class MuseumTrackerUI : MonoBehaviour { private const float BASE_WINDOW_WIDTH = 640f; private const float BASE_WINDOW_HEIGHT = 700f; private const float BASE_ICON_SIZE = 34f; private const float BASE_HEADER_HEIGHT = 80f; private float _scale = 1f; private DonationManager _donationManager; private bool _isVisible; private Rect _windowRect; private Vector2 _scrollPosition; private int _windowId; private KeyCode _toggleKey = (KeyCode)109; private bool _requireCtrl = true; private int _selectedSectionIndex = 0; private HashSet<string> _expandedBundles = new HashSet<string>(); private bool _showOnlyNeeded = false; private string _searchQuery = ""; private float _openAnimation = 0f; private string _syncStatusMessage = ""; private float _syncStatusTimer = 0f; private Dictionary<string, int> _cachedGameDonationCounts = new Dictionary<string, int>(); private Dictionary<string, bool> _cachedGameCompleteStatus = new Dictionary<string, bool>(); private Coroutine _cacheRefreshCoroutine; private bool _isCacheRefreshing = false; private bool _stylesInitialized; private GUIStyle _windowStyle; private GUIStyle _titleStyle; private GUIStyle _subtitleStyle; private GUIStyle _sectionTabStyle; private GUIStyle _sectionTabActiveStyle; private GUIStyle _bundleHeaderStyle; private GUIStyle _bundleHeaderCompleteStyle; private GUIStyle _itemRowStyle; private GUIStyle _itemNameStyle; private GUIStyle _buttonStyle; private GUIStyle _closeButtonStyle; private GUIStyle _labelStyle; private GUIStyle _checkmarkStyle; private GUIStyle _toggleStyle; private GUIStyle _searchStyle; private GUIStyle _statsStyle; private GUIStyle _footerStyle; private GUIStyle _syncButtonStyle; private GUIStyle _syncStatusStyle; private GUIStyle _headerBoxStyle; private GUIStyle _headerCountStyle; private GUIStyle _searchLabelStyle; private GUIStyle _scrollStyle; private GUIStyle _emptyStyle; private GUIStyle _progressLabelStyle; private GUIStyle _itemNameDonatedStyle; private GUIStyle _rarityLabelStyleCached; private GUIStyle _checkStyleCached; private GUIStyle _neededStyleCached; private Texture2D _windowBackground; private Texture2D _headerBackground; private Texture2D _tabNormal; private Texture2D _tabHover; private Texture2D _tabActive; private Texture2D _bundleNormal; private Texture2D _bundleHover; private Texture2D _bundleComplete; private Texture2D _itemEven; private Texture2D _itemOdd; private Texture2D _itemDonated; private Texture2D _buttonNormal; private Texture2D _buttonHover; private Texture2D _progressBg; private Texture2D _searchBg; private Texture2D _dividerTex; private readonly Color _parchmentLight = new Color(0.96f, 0.93f, 0.86f, 0.98f); private readonly Color _parchment = new Color(0.92f, 0.87f, 0.78f, 0.97f); private readonly Color _parchmentDark = new Color(0.85f, 0.78f, 0.65f, 0.95f); private readonly Color _parchmentDarker = new Color(0.75f, 0.67f, 0.52f, 0.92f); private readonly Color _woodDark = new Color(0.35f, 0.25f, 0.15f); private readonly Color _woodMedium = new Color(0.5f, 0.38f, 0.25f); private readonly Color _woodLight = new Color(0.65f, 0.52f, 0.38f); private readonly Color _leather = new Color(0.55f, 0.4f, 0.28f); private readonly Color _goldRich = new Color(0.85f, 0.68f, 0.2f); private readonly Color _goldBright = new Color(0.95f, 0.8f, 0.3f); private readonly Color _goldPale = new Color(1f, 0.92f, 0.7f); private readonly Color _forestGreen = new Color(0.3f, 0.55f, 0.3f); private readonly Color _skyBlue = new Color(0.45f, 0.65f, 0.85f); private readonly Color _coralWarm = new Color(0.85f, 0.5f, 0.4f); private readonly Color _textDark = new Color(0.18f, 0.14f, 0.1f); private readonly Color _textMedium = new Color(0.32f, 0.28f, 0.22f); private readonly Color _textLight = new Color(0.48f, 0.42f, 0.34f); private readonly Color _textMuted = new Color(0.58f, 0.52f, 0.44f); private readonly Color _successGreen = new Color(0.35f, 0.65f, 0.35f); private readonly Color _successGreenLight = new Color(0.5f, 0.75f, 0.45f); private readonly Color _neededOrange = new Color(0.85f, 0.55f, 0.25f); private readonly Color _borderDark = new Color(0.45f, 0.35f, 0.22f, 0.8f); private readonly Color _borderGold = new Color(0.75f, 0.6f, 0.25f, 0.7f); private readonly Dictionary<ItemRarity, Color> _rarityColors = new Dictionary<ItemRarity, Color> { { ItemRarity.Common, new Color(0.5f, 0.45f, 0.38f) }, { ItemRarity.Uncommon, new Color(0.35f, 0.6f, 0.35f) }, { ItemRarity.Rare, new Color(0.35f, 0.55f, 0.8f) }, { ItemRarity.Epic, new Color(0.65f, 0.4f, 0.75f) }, { ItemRarity.Legendary, new Color(0.9f, 0.7f, 0.2f) } }; private readonly Dictionary<string, (Color primary, Color accent)> _sectionThemes = new Dictionary<string, (Color, Color)> { { "hall_of_gems", (new Color(0.6f, 0.5f, 0.75f), new Color(0.75f, 0.65f, 0.9f)) }, { "hall_of_culture", (new Color(0.7f, 0.55f, 0.35f), new Color(0.85f, 0.7f, 0.45f)) }, { "aquarium", (new Color(0.4f, 0.6f, 0.75f), new Color(0.55f, 0.75f, 0.9f)) } }; public bool IsVisible => _isVisible; private float WindowWidth => 640f * _scale; private float WindowHeight => 700f * _scale; private float HeaderHeight => 80f * _scale; private float IconSize => 34f * _scale; private int ScaledFont(int baseSize) { return Mathf.Max(8, Mathf.RoundToInt((float)baseSize * _scale)); } private float Scaled(float value) { return value * _scale; } private int ScaledInt(float value) { return Mathf.RoundToInt(value * _scale); } public void SetScale(float scale) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) _scale = Mathf.Clamp(scale, 0.5f, 2.5f); _stylesInitialized = false; float windowWidth = WindowWidth; float windowHeight = WindowHeight; _windowRect = new Rect(((float)Screen.width - windowWidth) / 2f, ((float)Screen.height - windowHeight) / 2f, windowWidth, windowHeight); } public void Initialize(DonationManager donationManager) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) _donationManager = donationManager; _isVisible = false; _windowId = ((object)this).GetHashCode(); float windowWidth = WindowWidth; float windowHeight = WindowHeight; float num = ((float)Screen.width - windowWidth) / 2f; float num2 = ((float)Screen.height - windowHeight) / 2f; _windowRect = new Rect(num, num2, windowWidth, windowHeight); IconCache.Initialize(Plugin.Log); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)"MuseumTrackerUI initialized"); } } public void SetToggleKey(KeyCode key, bool requireCtrl) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) _toggleKey = key; _requireCtrl = requireCtrl; } public void Toggle() { if (!PlayerPatches.IsDataLoaded) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"Cannot toggle UI: data not loaded"); } } else if (_isVisible) { Hide(); } else { Show(); } } public void Show() { _isVisible = true; _openAnimation = 0f; StartCacheRefresh(); if ((Object)(object)Player.Instance != (Object)null) { Player.Instance.AddPauseObject("MuseumTracker_UI"); } ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)"Museum Tracker UI opened"); } } private void StartCacheRefresh() { if (_cacheRefreshCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_cacheRefreshCoroutine); } _cacheRefreshCoroutine = ((MonoBehaviour)this).StartCoroutine(RefreshGameProgressCacheCoroutine()); } private IEnumerator RefreshGameProgressCacheCoroutine() { _isCacheRefreshing = true; _cachedGameDonationCounts.Clear(); _cachedGameCompleteStatus.Clear(); List<string> bundleIds = MuseumContent.GetAllBundleIds(); int processedCount = 0; foreach (string bundleId in bundleIds) { string progressKey = MuseumContent.GetProgressKeyForBundle(bundleId); if (!string.IsNullOrEmpty(progressKey)) { _cachedGameDonationCounts[bundleId] = MuseumPatches.GetBundleDonationCount(progressKey); _cachedGameCompleteStatus[bundleId] = MuseumPatches.IsBundleCompleteInGame(progressKey); } processedCount++; if (processedCount % 3 == 0) { yield return null; } } _isCacheRefreshing = false; _cacheRefreshCoroutine = null; } private void RefreshGameProgressCacheImmediate() { if (_cacheRefreshCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_cacheRefreshCoroutine); _cacheRefreshCoroutine = null; } _isCacheRefreshing = false; _cachedGameDonationCounts.Clear(); _cachedGameCompleteStatus.Clear(); List<string> allBundleIds = MuseumContent.GetAllBundleIds(); foreach (string item in allBundleIds) { string progressKeyForBundle = MuseumContent.GetProgressKeyForBundle(item); if (!string.IsNullOrEmpty(progressKeyForBundle)) { _cachedGameDonationCounts[item] = MuseumPatches.GetBundleDonationCount(progressKeyForBundle); _cachedGameCompleteStatus[item] = MuseumPatches.IsBundleCompleteInGame(progressKeyForBundle); } } } public void Hide() { _isVisible = false; if ((Object)(object)Player.Instance != (Object)null) { Player.Instance.RemovePauseObject("MuseumTracker_UI"); } ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)"Museum Tracker UI closed"); } } private void Update() { if (_isVisible && Input.GetKeyDown((KeyCode)27)) { Hide(); } if (!_isVisible) { return; } _openAnimation = Mathf.MoveTowards(_openAnimation, 1f, Time.unscaledDeltaTime * 6f); if (_syncStatusTimer > 0f) { _syncStatusTimer -= Time.unscaledDeltaTime; if (_syncStatusTimer <= 0f) { _syncStatusMessage = ""; } } } private void OnGUI() { //IL_0040: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) if (_isVisible && _donationManager != null && PlayerPatches.IsDataLoaded) { InitializeStyles(); float openAnimation = _openAnimation; GUI.color = new Color(1f, 1f, 1f, openAnimation); _windowRect = GUI.Window(_windowId, _windowRect, new WindowFunction(DrawWindow), "", _windowStyle); GUI.color = Color.white; } } private void InitializeStyles() { if (!_stylesInitialized) { CreateTextures(); CreateStyles(); _stylesInitialized = true; } } private void CreateTextures() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00b3: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_0214: 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_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) _windowBackground = MakeParchmentTexture(32, 128, _parchment, _parchmentLight, _borderDark, 4); _headerBackground = MakeGradientTex(8, 64, _parchmentDark, _parchment); _tabNormal = MakeRoundedRect(8, 8, _parchmentDark, _borderDark, 2); _tabHover = MakeRoundedRect(8, 8, _parchmentDarker, _woodMedium, 2); _tabActive = MakeRoundedRect(8, 8, _goldPale, _goldRich, 3); _bundleNormal = MakeRoundedRect(6, 6, _parchmentDark, _borderDark, 2); _bundleHover = MakeRoundedRect(6, 6, _parchmentDarker, _woodMedium, 2); _bundleComplete = MakeRoundedRect(6, 6, new Color(_successGreenLight.r, _successGreenLight.g, _successGreenLight.b, 0.3f), _successGreen, 2); _itemEven = MakeTex(1, 1, new Color(_parchmentLight.r, _parchmentLight.g, _parchmentLight.b, 0.72f)); _itemOdd = MakeTex(1, 1, new Color(_parchment.r, _parchment.g, _parchment.b, 0.68f)); _itemDonated = MakeTex(1, 1, new Color(_successGreenLight.r, _successGreenLight.g, _successGreenLight.b, 0.35f)); _buttonNormal = MakeRoundedRect(6, 6, _woodMedium, _woodDark, 2); _buttonHover = MakeRoundedRect(6, 6, _woodLight, _woodMedium, 2); _progressBg = MakeTex(1, 1, new Color(_woodDark.r, _woodDark.g, _woodDark.b, 0.4f)); _searchBg = MakeRoundedRect(6, 6, _parchmentLight, _borderDark, 1); _dividerTex = MakeTex(1, 1, _borderDark); } private void CreateStyles() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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) //IL_0036: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0051: 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_0066: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00a7: 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_00b6: Expected O, but got Unknown //IL_00bc: Expected O, but got Unknown //IL_00c7: 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_00db: 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) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Expected O, but got Unknown //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Expected O, but got Unknown //IL_01fe: Expected O, but got Unknown //IL_0205: 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_021c: 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_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Expected O, but got Unknown //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Expected O, but got Unknown //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Expected O, but got Unknown //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Expected O, but got Unknown //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Expected O, but got Unknown //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Expected O, but got Unknown //IL_03e3: Expected O, but got Unknown //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Expected O, but got Unknown //IL_042c: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_04df: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Expected O, but got Unknown //IL_04ef: Expected O, but got Unknown //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_050a: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Unknown result type (might be due to invalid IL or missing references) //IL_0547: Unknown result type (might be due to invalid IL or missing references) //IL_0552: Unknown result type (might be due to invalid IL or missing references) //IL_056a: Unknown result type (might be due to invalid IL or missing references) //IL_0570: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Expected O, but got Unknown //IL_05a2: Unknown result type (might be due to invalid IL or missing references) //IL_05a7: Unknown result type (might be due to invalid IL or missing references) //IL_05b6: Unknown result type (might be due to invalid IL or missing references) //IL_05bd: Unknown result type (might be due to invalid IL or missing references) //IL_05cd: Expected O, but got Unknown //IL_05d8: Unknown result type (might be due to invalid IL or missing references) //IL_05dd: Unknown result type (might be due to invalid IL or missing references) //IL_05ec: Unknown result type (might be due to invalid IL or missing references) //IL_05f4: Unknown result type (might be due to invalid IL or missing references) //IL_05fb: Unknown result type (might be due to invalid IL or missing references) //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_0613: Expected O, but got Unknown //IL_061e: Unknown result type (might be due to invalid IL or missing references) //IL_0623: Unknown result type (might be due to invalid IL or missing references) //IL_0632: Unknown result type (might be due to invalid IL or missing references) //IL_0639: Unknown result type (might be due to invalid IL or missing references) //IL_0644: Unknown result type (might be due to invalid IL or missing references) //IL_064b: Unknown result type (might be due to invalid IL or missing references) //IL_065b: Expected O, but got Unknown //IL_0666: Unknown result type (might be due to invalid IL or missing references) //IL_066b: Unknown result type (might be due to invalid IL or missing references) //IL_067a: Unknown result type (might be due to invalid IL or missing references) //IL_068c: Unknown result type (might be due to invalid IL or missing references) //IL_0693: Unknown result type (might be due to invalid IL or missing references) //IL_069e: Unknown result type (might be due to invalid IL or missing references) //IL_06b0: Unknown result type (might be due to invalid IL or missing references) //IL_06b7: Unknown result type (might be due to invalid IL or missing references) //IL_06c2: Unknown result type (might be due to invalid IL or missing references) //IL_06ef: Unknown result type (might be due to invalid IL or missing references) //IL_06f9: Expected O, but got Unknown //IL_06ff: Expected O, but got Unknown //IL_070a: Unknown result type (might be due to invalid IL or missing references) //IL_070f: Unknown result type (might be due to invalid IL or missing references) //IL_071e: Unknown result type (might be due to invalid IL or missing references) //IL_0726: Unknown result type (might be due to invalid IL or missing references) //IL_072e: Unknown result type (might be due to invalid IL or missing references) //IL_0735: Unknown result type (might be due to invalid IL or missing references) //IL_0745: Expected O, but got Unknown //IL_0750: Unknown result type (might be due to invalid IL or missing references) //IL_0755: Unknown result type (might be due to invalid IL or missing references) //IL_0764: Unknown result type (might be due to invalid IL or missing references) //IL_076c: Unknown result type (might be due to invalid IL or missing references) //IL_0774: Unknown result type (might be due to invalid IL or missing references) //IL_077b: Unknown result type (might be due to invalid IL or missing references) //IL_078b: Expected O, but got Unknown //IL_0796: Unknown result type (might be due to invalid IL or missing references) //IL_079b: Unknown result type (might be due to invalid IL or missing references) //IL_07b3: Unknown result type (might be due to invalid IL or missing references) //IL_07c7: Unknown result type (might be due to invalid IL or missing references) //IL_07d8: Unknown result type (might be due to invalid IL or missing references) //IL_07df: Unknown result type (might be due to invalid IL or missing references) //IL_07ea: Unknown result type (might be due to invalid IL or missing references) //IL_0802: Unknown result type (might be due to invalid IL or missing references) //IL_0816: Unknown result type (might be due to invalid IL or missing references) //IL_0827: Unknown result type (might be due to invalid IL or missing references) //IL_082d: Unknown result type (might be due to invalid IL or missing references) //IL_0838: Unknown result type (might be due to invalid IL or missing references) //IL_0850: Unknown result type (might be due to invalid IL or missing references) //IL_0864: Unknown result type (might be due to invalid IL or missing references) //IL_0875: Unknown result type (might be due to invalid IL or missing references) //IL_087b: Unknown result type (might be due to invalid IL or missing references) //IL_0886: Unknown result type (might be due to invalid IL or missing references) //IL_0895: Unknown result type (might be due to invalid IL or missing references) //IL_089d: Unknown result type (might be due to invalid IL or missing references) //IL_08ca: Unknown result type (might be due to invalid IL or missing references) //IL_08d4: Expected O, but got Unknown //IL_08da: Expected O, but got Unknown //IL_08e5: Unknown result type (might be due to invalid IL or missing references) //IL_08ea: Unknown result type (might be due to invalid IL or missing references) //IL_08f9: Unknown result type (might be due to invalid IL or missing references) //IL_0901: Unknown result type (might be due to invalid IL or missing references) //IL_0909: Unknown result type (might be due to invalid IL or missing references) //IL_0910: Unknown result type (might be due to invalid IL or missing references) //IL_0920: Expected O, but got Unknown //IL_092b: Unknown result type (might be due to invalid IL or missing references) //IL_0930: Unknown result type (might be due to invalid IL or missing references) //IL_095f: Unknown result type (might be due to invalid IL or missing references) //IL_0965: Unknown result type (might be due to invalid IL or missing references) //IL_0976: Unknown result type (might be due to invalid IL or missing references) //IL_09a3: Unknown result type (might be due to invalid IL or missing references) //IL_09ad: Expected O, but got Unknown //IL_09b3: Expected O, but got Unknown //IL_09ba: Unknown result type (might be due to invalid IL or missing references) //IL_09bf: Unknown result type (might be due to invalid IL or missing references) //IL_09c7: Unknown result type (might be due to invalid IL or missing references) //IL_09d6: Unknown result type (might be due to invalid IL or missing references) //IL_09de: Unknown result type (might be due to invalid IL or missing references) //IL_09e5: Unknown result type (might be due to invalid IL or missing references) //IL_09f5: Expected O, but got Unknown //IL_09fc: Unknown result type (might be due to invalid IL or missing references) //IL_0a01: Unknown result type (might be due to invalid IL or missing references) //IL_0a0e: Expected O, but got Unknown //IL_0a19: Unknown result type (might be due to invalid IL or missing references) //IL_0a23: Expected O, but got Unknown //IL_0a2a: Unknown result type (might be due to invalid IL or missing references) //IL_0a2f: Unknown result type (might be due to invalid IL or missing references) //IL_0a37: Unknown result type (might be due to invalid IL or missing references) //IL_0a46: Unknown result type (might be due to invalid IL or missing references) //IL_0a4e: Unknown result type (might be due to invalid IL or missing references) //IL_0a55: Unknown result type (might be due to invalid IL or missing references) //IL_0a65: Expected O, but got Unknown //IL_0a6c: Unknown result type (might be due to invalid IL or missing references) //IL_0a71: Unknown result type (might be due to invalid IL or missing references) //IL_0a79: Unknown result type (might be due to invalid IL or missing references) //IL_0a88: Unknown result type (might be due to invalid IL or missing references) //IL_0a95: Expected O, but got Unknown //IL_0a9c: Unknown result type (might be due to invalid IL or missing references) //IL_0aa1: Unknown result type (might be due to invalid IL or missing references) //IL_0ab0: Unknown result type (might be due to invalid IL or missing references) //IL_0ab8: Unknown result type (might be due to invalid IL or missing references) //IL_0acd: Unknown result type (might be due to invalid IL or missing references) //IL_0add: Expected O, but got Unknown //IL_0ae4: Unknown result type (might be due to invalid IL or missing references) //IL_0ae9: Unknown result type (might be due to invalid IL or missing references) //IL_0af8: Unknown result type (might be due to invalid IL or missing references) //IL_0b00: Unknown result type (might be due to invalid IL or missing references) //IL_0b0d: Expected O, but got Unknown //IL_0b14: Unknown result type (might be due to invalid IL or missing references) //IL_0b19: Unknown result type (might be due to invalid IL or missing references) //IL_0b2d: Expected O, but got Unknown //IL_0b34: Unknown result type (might be due to invalid IL or missing references) //IL_0b39: Unknown result type (might be due to invalid IL or missing references) //IL_0b40: Unknown result type (might be due to invalid IL or missing references) //IL_0b4b: Unknown result type (might be due to invalid IL or missing references) //IL_0b5f: Expected O, but got Unknown int num = ScaledInt(16f); GUIStyle val = new GUIStyle(GUI.skin.window); val.normal.background = _windowBackground; val.normal.textColor = _textDark; val.padding = new RectOffset(0, 0, 0, 0); val.border = new RectOffset(num, num, num, num); _windowStyle = val; GUIStyle val2 = new GUIStyle(GUI.skin.label) { fontSize = ScaledFont(26), fontStyle = (FontStyle)1, alignment = (TextAnchor)3 }; val2.normal.textColor = _woodDark; val2.padding = new RectOffset(0, 0, 0, 0); _titleStyle = val2; GUIStyle val3 = new GUIStyle(GUI.skin.label) { fontSize = ScaledFont(13), fontStyle = (FontStyle)0, alignment = (TextAnchor)3 }; val3.normal.textColor = _textMedium; _subtitleStyle = val3; GUIStyle val4 = new GUIStyle(GUI.skin.button); val4.normal.background = _tabNormal; val4.normal.textColor = _textDark; val4.hover.background = _tabHover; val4.hover.textColor = _woodDark; val4.active.background = _tabHover; val4.active.textColor = _woodDark; val4.fontSize = ScaledFont(13); val4.fontStyle = (FontStyle)1; val4.alignment = (TextAnchor)4; val4.padding = new RectOffset(ScaledInt(14f), ScaledInt(10f), ScaledInt(12f), ScaledInt(10f)); val4.margin = new RectOffset(ScaledInt(4f), ScaledInt(4f), 0, 0); _sectionTabStyle = val4; GUIStyle val5 = new GUIStyle(_sectionTabStyle); val5.normal.background = _tabActive; val5.normal.textColor = _woodDark; val5.hover.background = _tabActive; val5.hover.textColor = _woodDark; _sectionTabActiveStyle = val5; GUIStyle val6 = new GUIStyle(GUI.skin.button); val6.normal.background = _bundleNormal; val6.normal.textColor = _textDark; val6.hover.background = _bundleHover; val6.hover.textColor = _woodDark; val6.active.background = _bundleHover; val6.active.textColor = _woodDark; val6.fontSize = ScaledFont(14); val6.fontStyle = (FontStyle)1; val6.alignment = (TextAnchor)3; val6.padding = new RectOffset(ScaledInt(18f), ScaledInt(14f), ScaledInt(14f), ScaledInt(14f)); val6.wordWrap = true; _bundleHeaderStyle = val6; GUIStyle val7 = new GUIStyle(_bundleHeaderStyle); val7.normal.background = _bundleComplete; val7.normal.textColor = _successGreen; val7.hover.background = _bundleComplete; val7.hover.textColor = _forestGreen; _bundleHeaderCompleteStyle = val7; _itemRowStyle = new GUIStyle { padding = new RectOffset(ScaledInt(16f), ScaledInt(10f), ScaledInt(8f), ScaledInt(8f)), margin = new RectOffset(0, 0, 2, 1) }; GUIStyle val8 = new GUIStyle(GUI.skin.label) { fontSize = ScaledFont(14) }; val8.normal.textColor = _textDark; val8.wordWrap = true; _itemNameStyle = val8; GUIStyle val9 = new GUIStyle(GUI.skin.button); val9.normal.background = _buttonNormal; val9.normal.textColor = _parchmentLight; val9.hover.background = _buttonHover; val9.hover.textColor = Color.white; val9.active.background = _buttonHover; val9.active.textColor = Color.white; val9.fontSize = ScaledFont(12); val9.fontStyle = (FontStyle)1; val9.padding = new RectOffset(ScaledInt(14f), ScaledInt(14f), ScaledInt(8f), ScaledInt(8f)); _buttonStyle = val9; GUIStyle val10 = new GUIStyle(_buttonStyle) { fontSize = ScaledFont(18), fontStyle = (FontStyle)1 }; val10.normal.background = MakeRoundedRect(6, 6, _coralWarm, new Color(0.7f, 0.35f, 0.25f), 2); val10.normal.textColor = Color.white; val10.hover.background = MakeRoundedRect(6, 6, new Color(0.95f, 0.55f, 0.45f), _coralWarm, 2); val10.hover.textColor = Color.white; _closeButtonStyle = val10; GUIStyle val11 = new GUIStyle(GUI.skin.label) { fontSize = ScaledFont(12) }; val11.normal.textColor = _textDark; _labelStyle = val11; GUIStyle val12 = new GUIStyle(GUI.skin.label) { fontSize = ScaledFont(16), fontStyle = (FontStyle)1 }; val12.normal.textColor = _successGreen; val12.alignment = (TextAnchor)4; _checkmarkStyle = val12; GUIStyle val13 = new GUIStyle(GUI.skin.toggle) { fontSize = ScaledFont(12) }; val13.normal.textColor = _textMedium; val13.hover.textColor = _textDark; _toggleStyle = val13; GUIStyle val14 = new GUIStyle(GUI.skin.textField) { fontSize = ScaledFont(14) }; val14.normal.background = _searchBg; val14.normal.textColor = _textDark; val14.focused.background = _searchBg; val14.focused.textColor = _textDark; val14.padding = new RectOffset(ScaledInt(14f), ScaledInt(10f), ScaledInt(10f), ScaledInt(10f)); _searchStyle = val14; GUIStyle val15 = new GUIStyle(GUI.skin.label) { fontSize = ScaledFont(22), fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; val15.normal.textColor = _woodDark; _statsStyle = val15; GUIStyle val16 = new GUIStyle(GUI.skin.label) { fontSize = ScaledFont(12), fontStyle = (FontStyle)0, alignment = (TextAnchor)4 }; val16.normal.textColor = _textLight; _footerStyle = val16; GUIStyle val17 = new GUIStyle(GUI.skin.button); val17.normal.background = MakeRoundedRect(6, 6, new Color(0.3f, 0.55f, 0.5f), new Color(0.2f, 0.4f, 0.35f), 2); val17.normal.textColor = _parchmentLight; val17.hover.background = MakeRoundedRect(6, 6, new Color(0.4f, 0.65f, 0.6f), new Color(0.3f, 0.5f, 0.45f), 2); val17.hover.textColor = Color.white; val17.active.background = MakeRoundedRect(6, 6, new Color(0.35f, 0.6f, 0.55f), new Color(0.25f, 0.45f, 0.4f), 2); val17.active.textColor = Color.white; val17.fontSize = ScaledFont(11); val17.fontStyle = (FontStyle)1; val17.padding = new RectOffset(ScaledInt(10f), ScaledInt(10f), ScaledInt(6f), ScaledInt(6f)); _syncButtonStyle = val17; GUIStyle val18 = new GUIStyle(GUI.skin.label) { fontSize = ScaledFont(11), fontStyle = (FontStyle)2, alignment = (TextAnchor)5 }; val18.normal.textColor = _successGreen; _syncStatusStyle = val18; GUIStyle val19 = new GUIStyle(GUI.skin.box); val19.normal.background = MakeRoundedRect(6, 6, new Color(_goldPale.r, _goldPale.g, _goldPale.b, 0.65f), _goldRich, 2); val19.padding = new RectOffset(ScaledInt(18f), ScaledInt(12f), ScaledInt(10f), ScaledInt(10f)); _headerBoxStyle = val19; GUIStyle val20 = new GUIStyle(_labelStyle) { alignment = (TextAnchor)4, fontSize = ScaledFont(12), fontStyle = (FontStyle)1 }; val20.normal.textColor = _textDark; _headerCountStyle = val20; _searchLabelStyle = new GUIStyle(_labelStyle) { fontStyle = (FontStyle)1 }; _scrollStyle = new GUIStyle(GUI.skin.scrollView); GUIStyle val21 = new GUIStyle(_labelStyle) { alignment = (TextAnchor)4, fontSize = ScaledFont(15), fontStyle = (FontStyle)0 }; val21.normal.textColor = _textMedium; _emptyStyle = val21; _progressLabelStyle = new GUIStyle(_labelStyle) { alignment = (TextAnchor)4, fontSize = ScaledFont(13), fontStyle = (FontStyle)1 }; GUIStyle val22 = new GUIStyle(_itemNameStyle) { fontSize = ScaledFont(14), fontStyle = (FontStyle)0 }; val22.normal.textColor = new Color(0.22f, 0.52f, 0.28f); _itemNameDonatedStyle = val22; _rarityLabelStyleCached = new GUIStyle(_labelStyle) { fontSize = ScaledFont(12), fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; _checkStyleCached = new GUIStyle(_checkmarkStyle) { fontSize = ScaledFont(14) }; GUIStyle val23 = new GUIStyle(_checkmarkStyle); val23.normal.textColor = _neededOrange; val23.fontSize = ScaledFont(12); _neededStyleCached = val23; } private Texture2D MakeTex(int width, int height, Color color) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown Color[] array = (Color[])(object)new Color[width * height]; for (int i = 0; i < array.Length; i++) { array[i] = color; } Texture2D val = new Texture2D(width, height); val.SetPixels(array); val.Apply(); return val; } private Texture2D MakeGradientTex(int width, int height, Color topColor, Color bottomColor) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_001f: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(width, height); Color[] array = (Color[])(object)new Color[width * height]; for (int i = 0; i < height; i++) { float num = (float)i / (float)(height - 1); Color val2 = Color.Lerp(topColor, bottomColor, num); for (int j = 0; j < width; j++) { array[i * width + j] = val2; } } val.SetPixels(array); val.Apply(); return val; } private Texture2D MakeRoundedRect(int width, int height, Color fillColor, Color borderColor, int borderWidth) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(width, height); Color[] array = (Color[])(object)new Color[width * height]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { bool flag = j < borderWidth || j >= width - borderWidth || i < borderWidth || i >= height - borderWidth; array[i * width + j] = (flag ? borderColor : fillColor); } } val.SetPixels(array); val.Apply(); return val; } private Texture2D MakeParchmentTexture(int width, int height, Color baseColor, Color lightColor, Color borderColor, int borderWidth) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(width, height); Color[] array = (Color[])(object)new Color[width * height]; for (int i = 0; i < height; i++) { float num = (float)i / (float)(height - 1); Color val2 = Color.Lerp(lightColor, baseColor, num * 0.3f); for (int j = 0; j < width; j++) { if (j < borderWidth || j >= width - borderWidth || i < borderWidth || i >= height - borderWidth) { array[i * width + j] = borderColor; continue; } float num2 = (float)((j + i) % 3) * 0.01f; array[i * width + j] = new Color(val2.r + num2, val2.g + num2 * 0.8f, val2.b + num2 * 0.5f, val2.a); } } val.SetPixels(array); val.Apply(); return val; } private void DrawWindow(int windowId) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); DrawHeader(); DrawGoldDivider(); GUILayout.Space(Scaled(14f)); DrawSearchBar(); GUILayout.Space(Scaled(14f)); DrawSectionTabs(); GUILayout.Space(Scaled(16f)); DrawContent(); GUILayout.Space(Scaled(10f)); DrawFooter(); GUILayout.EndVertical(); GUI.DragWindow(new Rect(0f, 0f, WindowWidth, HeaderHeight)); } private void DrawHeader() { //IL_001b: 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_0021: 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) Rect rect = GUILayoutUtility.GetRect(0f, HeaderHeight, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUI.DrawTexture(rect, (Texture)(object)_headerBackground, (ScaleMode)0); float num = Scaled(25f); GUILayout.BeginArea(new Rect(((Rect)(ref rect)).x + num, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width - num * 2f, ((Rect)(ref rect)).height)); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.Space(Scaled(12f)); GUILayout.Label("S.M.U.T.", _titleStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label("Sun Haven Museum Utility Tracker", _subtitleStyle, Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.Space(12f); (int donated, int total) overallStats = _donationManager.GetOverallStats(); int item = overallStats.donated; int item2 = overallStats.total; float overallCompletionPercent = _donationManager.GetOverallCompletionPercent(); GUILayout.BeginVertical(_headerBoxStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(Scaled(100f)) }); GUILayout.Label($"{overallCompletionPercent:F0}%", _statsStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label($"{item}/{item2}", _headerCountStyle, Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); GUILayout.EndVertical(); GUILayout.Space(Scaled(10f)); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.Space(Scaled(20f)); if (GUILayout.Button("X", _closeButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(Scaled(38f)), GUILayout.Height(Scaled(38f)) })) { Hide(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.EndArea(); } private void DrawGoldDivider() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_0106: Unknown result type (might be due to invalid IL or missing references) Rect rect = GUILayoutUtility.GetRect(0f, Scaled(5f), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); float num = Scaled(24f); ((Rect)(ref rect)).x = ((Rect)(ref rect)).x + num; ((Rect)(ref rect)).width = ((Rect)(ref rect)).width - num * 2f; GUI.color = _borderDark; GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 1f), (Texture)(object)Texture2D.whiteTexture); GUI.color = _goldRich; GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + 1f, ((Rect)(ref rect)).width, 2f), (Texture)(object)Texture2D.whiteTexture); GUI.color = _goldPale; GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + 3f, ((Rect)(ref rect)).width, 1f), (Texture)(object)Texture2D.whiteTexture); GUI.color = Color.white; } private void DrawSearchBar() { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Space(Scaled(20f)); GUILayout.Label("Search", _searchLabelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(Scaled(52f)) }); _searchQuery = GUILayout.TextField(_searchQuery, _searchStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(Scaled(180f)), GUILayout.Height(Scaled(28f)) }); GUILayout.Space(Scaled(15f)); _showOnlyNeeded = GUILayout.Toggle(_showOnlyNeeded, " Needed only", _toggleStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(Scaled(115f)) }); GUILayout.FlexibleSpace(); if (!string.IsNullOrEmpty(_syncStatusMessage)) { GUILayout.Label(_syncStatusMessage, _syncStatusStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(Scaled(150f)) }); GUILayout.Space(Scaled(8f)); } if (!string.IsNullOrEmpty(_searchQuery)) { if (GUILayout.Button("Clear", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(Scaled(55f)), GUILayout.Height(Scaled(28f)) })) { _searchQuery = ""; } GUILayout.Space(Scaled(8f)); } if (GUILayout.Button("Sync with Game", _syncButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(Scaled(105f)), GUILayout.Height(Scaled(28f)) })) { PerformGameSync(); } GUILayout.Space(Scaled(20f)); GUILayout.EndHorizontal(); } private void PerformGameSync() { try { int item = _donationManager.GetOverallStats().donated; MuseumPatches.SyncWithGameProgress(); RefreshGameProgressCacheImmediate(); (int donated, int total) overallStats = _donationManager.GetOverallStats(); int item2 = overallStats.donated; int item3 = overallStats.total; int num = item2 - item; if (num > 0) { _syncStatusMessage = $"Synced {num} items!"; ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[UI] Synced {num} items from game progress"); } } else { _syncStatusMessage = "Already in sync!"; } _syncStatusTimer = 4f; } catch (Exception ex) { _syncStatusMessage = "Sync failed"; _syncStatusTimer = 4f; ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogError((object)("[UI] Sync failed: " + ex.Message)); } } } private void DrawSectionTabs() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) List<MuseumSection> allSections = MuseumContent.GetAllSections(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Space(Scaled(20f)); for (int i = 0; i < allSections.Count; i++) { MuseumSection museumSection = allSections[i]; (int, int) sectionStats = _donationManager.GetSectionStats(museumSection); bool flag = _donationManager.IsSectionComplete(museumSection); bool flag2 = i == _selectedSectionIndex; (Color, Color) value; (Color, Color) tuple = (_sectionThemes.TryGetValue(museumSection.Id, out value) ? value : (_woodMedium, _woodLight)); GUIStyle val = (flag2 ? _sectionTabActiveStyle : _sectionTabStyle); string text = (flag ? " *" : ""); string text2 = $"{museumSection.Name}{text}\n{sectionStats.Item1}/{sectionStats.Item2}"; if (GUILayout.Button(text2, val, (GUILayoutOption[])(object)new GUILayoutOption[2]