Decompiled source of SunHavenTodo v1.0.0
SunhavenTodo.dll
Decompiled 2 days 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.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 SunhavenMods.Shared; using SunhavenTodo.Data; using SunhavenTodo.UI; using UnityEngine; using UnityEngine.Networking; using UnityEngine.SceneManagement; using Wish; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("SunhavenTodo")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+c7976283ee1309608b00428a169c130e784344a0")] [assembly: AssemblyProduct("SunhavenTodo")] [assembly: AssemblyTitle("SunhavenTodo")] [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 text = www.downloadHandler.text; string pattern = "\"" + Regex.Escape(pluginGuid) + "\"\\s*:\\s*\\{([^}]+)\\}"; Match match = Regex.Match(text, pattern, RegexOptions.Singleline); if (!match.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 value = match.Groups[1].Value; result.LatestVersion = ExtractJsonString(value, "version"); result.ModName = ExtractJsonString(value, "name"); result.NexusUrl = ExtractJsonString(value, "nexus"); result.Changelog = ExtractJsonString(value, "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); if (!match.Success) { return null; } return match.Groups[1].Value; } } 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_000b: 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) { object obj = type2.MakeGenericType(type).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; } for (int i = 0; i < namespaces.Length; i++) { type = AccessTools.TypeByName(namespaces[i] + "." + 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" }; foreach (string memberName in array) { 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; } } } } namespace SunhavenTodo { [BepInPlugin("com.azraelgodking.sunhaventodo", "Sunhaven Todo", "1.0.0")] public class Plugin : BaseUnityPlugin { private static TodoManager _staticTodoManager; private static TodoSaveSystem _staticSaveSystem; private static TodoUI _staticTodoUI; private static TodoHUD _staticTodoHUD; private static GameObject _persistentRunner; private static PersistentRunner _persistentRunnerComponent; private static KeyCode _staticToggleKey = (KeyCode)116; private static bool _staticRequireCtrl = true; private static bool _staticAutoSave = true; private static float _staticAutoSaveInterval = 60f; private static bool _staticHUDEnabled = true; private static float _staticHUDPositionX = -1f; private static float _staticHUDPositionY = -1f; private static KeyCode _staticHUDToggleKey = (KeyCode)104; private ConfigEntry<KeyCode> _toggleKey; private ConfigEntry<bool> _requireCtrl; private ConfigEntry<bool> _autoSave; private ConfigEntry<float> _autoSaveInterval; private ConfigEntry<bool> _hudEnabled; private ConfigEntry<float> _hudPositionX; private ConfigEntry<float> _hudPositionY; private ConfigEntry<KeyCode> _hudToggleKey; private ConfigEntry<bool> _checkForUpdates; private TodoManager _todoManager; private TodoSaveSystem _saveSystem; private TodoUI _todoUI; private TodoHUD _todoHUD; private Harmony _harmony; private float _lastAutoSaveTime; private bool _isDataLoaded; private string _loadedCharacterName; public static Plugin Instance { get; private set; } public static ManualLogSource Log { get; private set; } public static KeyCode StaticToggleKey => _staticToggleKey; public static bool StaticRequireCtrl => _staticRequireCtrl; public static KeyCode StaticHUDToggleKey => _staticHUDToggleKey; public static bool StaticHUDEnabled => _staticHUDEnabled; private void Awake() { Instance = this; Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"Loading Sunhaven Todo v1.0.0"); BindConfiguration(); CreatePersistentRunner(); InitializeManagers(); ApplyPatches(); SceneManager.sceneLoaded += OnSceneLoaded; if (_checkForUpdates.Value) { VersionChecker.CheckForUpdate("com.azraelgodking.sunhaventodo", "1.0.0", Log, delegate(VersionChecker.VersionCheckResult result) { result.NotifyUpdateAvailable(Log); }); } Log.LogInfo((object)"Sunhaven Todo loaded successfully!"); } private void BindConfiguration() { //IL_0028: 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_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) _toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Hotkeys", "ToggleKey", (KeyCode)116, "Key to toggle the Todo List window"); _staticToggleKey = _toggleKey.Value; _toggleKey.SettingChanged += delegate { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) _staticToggleKey = _toggleKey.Value; }; _requireCtrl = ((BaseUnityPlugin)this).Config.Bind<bool>("Hotkeys", "RequireCtrl", true, "Require Ctrl to be held when pressing the toggle key"); _staticRequireCtrl = _requireCtrl.Value; _requireCtrl.SettingChanged += delegate { _staticRequireCtrl = _requireCtrl.Value; }; _autoSave = ((BaseUnityPlugin)this).Config.Bind<bool>("Saving", "AutoSave", true, "Automatically save the todo list periodically"); _staticAutoSave = _autoSave.Value; _autoSave.SettingChanged += delegate { _staticAutoSave = _autoSave.Value; }; _autoSaveInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Saving", "AutoSaveInterval", 60f, "Auto-save interval in seconds"); _staticAutoSaveInterval = _autoSaveInterval.Value; _autoSaveInterval.SettingChanged += delegate { _staticAutoSaveInterval = _autoSaveInterval.Value; }; _hudEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "Enabled", true, "Show the movable HUD panel with top 5 urgent tasks"); _staticHUDEnabled = _hudEnabled.Value; _hudEnabled.SettingChanged += delegate { _staticHUDEnabled = _hudEnabled.Value; _staticTodoHUD?.SetEnabled(_staticHUDEnabled); }; _hudPositionX = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "PositionX", -1f, "HUD X position (-1 for default)"); _staticHUDPositionX = _hudPositionX.Value; _hudPositionY = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "PositionY", -1f, "HUD Y position (-1 for default)"); _staticHUDPositionY = _hudPositionY.Value; _hudToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Hotkeys", "HUDToggleKey", (KeyCode)104, "Key to toggle the HUD panel (with Ctrl if RequireCtrl is enabled)"); _staticHUDToggleKey = _hudToggleKey.Value; _hudToggleKey.SettingChanged += delegate { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) _staticHUDToggleKey = _hudToggleKey.Value; }; _checkForUpdates = ((BaseUnityPlugin)this).Config.Bind<bool>("Updates", "CheckForUpdates", true, "Check for mod updates on startup"); } private void CreatePersistentRunner() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown if (!((Object)(object)_persistentRunner != (Object)null) || !((Object)(object)_persistentRunnerComponent != (Object)null)) { _persistentRunner = new GameObject("SunhavenTodo_PersistentRunner"); Object.DontDestroyOnLoad((Object)(object)_persistentRunner); ((Object)_persistentRunner).hideFlags = (HideFlags)61; _persistentRunnerComponent = _persistentRunner.AddComponent<PersistentRunner>(); Log.LogInfo((object)"[PersistentRunner] Created"); } } private void InitializeManagers() { _todoManager = new TodoManager(); _staticTodoManager = _todoManager; _saveSystem = new TodoSaveSystem(_todoManager); _staticSaveSystem = _saveSystem; _todoManager.OnTodosChanged += OnTodosChanged; } private void ApplyPatches() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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 _harmony = new Harmony("com.azraelgodking.sunhaventodo"); try { Type type = AccessTools.TypeByName("Wish.Player"); if (type != null) { MethodInfo methodInfo = AccessTools.Method(type, "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); Log.LogInfo((object)"Applied player initialization patch"); } } } catch (Exception ex) { Log.LogWarning((object)("Failed to apply patches: " + ex.Message)); } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { EnsureUIComponentsExist(); } public static void EnsureUIComponentsExist() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown 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("SunhavenTodo_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)_staticTodoUI == (Object)null) { ManualLogSource log3 = Log; if (log3 != null) { log3.LogInfo((object)"[EnsureUI] Recreating TodoUI..."); } GameObject val = new GameObject("SunhavenTodo_UI"); Object.DontDestroyOnLoad((Object)val); _staticTodoUI = val.AddComponent<TodoUI>(); _staticTodoUI.Initialize(_staticTodoManager); ManualLogSource log4 = Log; if (log4 != null) { log4.LogInfo((object)"[EnsureUI] TodoUI recreated"); } } if ((Object)(object)_staticTodoHUD == (Object)null) { ManualLogSource log5 = Log; if (log5 != null) { log5.LogInfo((object)"[EnsureUI] Recreating TodoHUD..."); } GameObject val2 = new GameObject("SunhavenTodo_HUD"); Object.DontDestroyOnLoad((Object)val2); _staticTodoHUD = val2.AddComponent<TodoHUD>(); _staticTodoHUD.Initialize(_staticTodoManager); _staticTodoHUD.SetEnabled(_staticHUDEnabled); if (_staticHUDPositionX >= 0f && _staticHUDPositionY >= 0f) { _staticTodoHUD.SetPosition(_staticHUDPositionX, _staticHUDPositionY); } _staticTodoHUD.OnPositionChanged = delegate(float x, float y) { _staticHUDPositionX = x; _staticHUDPositionY = y; Plugin instance = Instance; if (instance != null) { ConfigEntry<float> hudPositionX = instance._hudPositionX; if (hudPositionX != null) { ((ConfigEntryBase)hudPositionX).SetSerializedValue(x.ToString()); } } Plugin instance2 = Instance; if (instance2 != null) { ConfigEntry<float> hudPositionY = instance2._hudPositionY; if (hudPositionY != null) { ((ConfigEntryBase)hudPositionY).SetSerializedValue(y.ToString()); } } }; ManualLogSource log6 = Log; if (log6 != null) { log6.LogInfo((object)"[EnsureUI] TodoHUD recreated"); } } if ((Object)(object)Instance != (Object)null) { Instance._todoUI = _staticTodoUI; Instance._todoHUD = _staticTodoHUD; } } catch (Exception ex) { ManualLogSource log7 = Log; if (log7 != null) { log7.LogError((object)("[EnsureUI] Error: " + ex.Message)); } } } private void Update() { if (_staticAutoSave && _staticTodoManager != null && _staticTodoManager.IsDirty && Time.unscaledTime - _lastAutoSaveTime >= _staticAutoSaveInterval) { SaveData(); _lastAutoSaveTime = Time.unscaledTime; } } private void OnTodosChanged() { _lastAutoSaveTime = Time.unscaledTime - _staticAutoSaveInterval + 5f; } public void LoadDataForCharacter(string characterName) { if (string.IsNullOrEmpty(characterName)) { Log.LogWarning((object)"Cannot load data: No character name"); return; } if (_isDataLoaded && _loadedCharacterName != characterName) { SaveData(); } TodoListData data = _staticSaveSystem.Load(characterName); _staticTodoManager.LoadForCharacter(characterName, data); _isDataLoaded = true; _loadedCharacterName = characterName; Log.LogInfo((object)("Loaded todo list for character: " + characterName)); } public static void SaveData() { _staticSaveSystem?.Save(); } public static void ToggleUI() { EnsureUIComponentsExist(); _staticTodoUI?.Toggle(); } public static void ShowUI() { EnsureUIComponentsExist(); _staticTodoUI?.Show(); } public static void HideUI() { _staticTodoUI?.Hide(); } public static TodoManager GetTodoManager() { return _staticTodoManager; } public static TodoUI GetTodoUI() { return _staticTodoUI; } public static TodoHUD GetTodoHUD() { return _staticTodoHUD; } public static void ToggleHUD() { EnsureUIComponentsExist(); _staticTodoHUD?.Toggle(); } private void OnDestroy() { Log.LogWarning((object)"[CRITICAL] Plugin OnDestroy called!"); SaveData(); } private void OnApplicationQuit() { SaveData(); } } public class PersistentRunner : MonoBehaviour { private void Update() { CheckHotkeys(); } private void CheckHotkeys() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) TodoUI todoUI = Plugin.GetTodoUI(); if (!((Object)(object)todoUI != (Object)null) || !todoUI.IsVisible) { bool flag = Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305); bool keyDown = Input.GetKeyDown(Plugin.StaticToggleKey); bool keyDown2 = Input.GetKeyDown(Plugin.StaticHUDToggleKey); if (keyDown && flag == Plugin.StaticRequireCtrl) { Plugin.ToggleUI(); } if (keyDown2 && flag == Plugin.StaticRequireCtrl) { Plugin.ToggleHUD(); } } } private void OnDestroy() { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[PersistentRunner] OnDestroy called - this should NOT happen!"); } } } public static class PlayerPatches { private static bool _isDataLoaded; private static string _loadedCharacterName; public static void OnPlayerInitialized(object __instance) { try { Plugin.EnsureUIComponentsExist(); string currentCharacterName = GetCurrentCharacterName(__instance); if (_isDataLoaded && _loadedCharacterName != currentCharacterName) { Plugin.SaveData(); ResetState(); } if (!string.IsNullOrEmpty(currentCharacterName)) { Plugin.Instance?.LoadDataForCharacter(currentCharacterName); _isDataLoaded = true; _loadedCharacterName = currentCharacterName; } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("Error in OnPlayerInitialized: " + ex.Message)); } } } private static string GetCurrentCharacterName(object player) { try { Type type = AccessTools.TypeByName("Wish.GameSave"); if (type != null) { PropertyInfo propertyInfo = AccessTools.Property(type, "Current"); if (propertyInfo != null) { object value = propertyInfo.GetValue(null); if (value != null) { PropertyInfo propertyInfo2 = AccessTools.Property(value.GetType(), "characterName"); if (propertyInfo2 != null) { string text = propertyInfo2.GetValue(value) as string; if (!string.IsNullOrEmpty(text)) { return text; } } } } } if (player != null) { PropertyInfo propertyInfo3 = AccessTools.Property(player.GetType(), "playerName"); if (propertyInfo3 != null) { string text2 = propertyInfo3.GetValue(player) as string; if (!string.IsNullOrEmpty(text2)) { return text2; } } } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("Failed to get character name: " + ex.Message)); } } return "DefaultCharacter"; } private static void ResetState() { _isDataLoaded = false; _loadedCharacterName = null; } } public static class PluginInfo { public const string PLUGIN_GUID = "com.azraelgodking.sunhaventodo"; public const string PLUGIN_NAME = "Sunhaven Todo"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace SunhavenTodo.UI { public class TodoHUD : MonoBehaviour { private const int WINDOW_ID = 98766; private const float WINDOW_WIDTH = 280f; private const float MIN_HEIGHT = 100f; private const float MAX_HEIGHT = 300f; private const float HEADER_HEIGHT = 28f; private const float ITEM_HEIGHT = 24f; private const int MAX_ITEMS = 5; private TodoManager _manager; private bool _isEnabled = true; private Rect _windowRect; public Action<float, float> OnPositionChanged; private List<TodoItem> _cachedItems = new List<TodoItem>(); private float _lastUpdateTime; private const float UPDATE_INTERVAL = 1f; private readonly Color _parchmentLight = new Color(0.96f, 0.93f, 0.86f, 0.95f); private readonly Color _parchment = new Color(0.92f, 0.87f, 0.78f, 0.95f); private readonly Color _parchmentDark = new Color(0.85f, 0.78f, 0.65f, 0.95f); 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 _goldRich = new Color(0.85f, 0.68f, 0.2f); private readonly Color _goldBright = new Color(0.95f, 0.8f, 0.3f); private readonly Color _textDark = new Color(0.25f, 0.2f, 0.15f); private readonly Color _borderDark = new Color(0.4f, 0.3f, 0.2f, 0.8f); private readonly Dictionary<TodoPriority, Color> _priorityColors = new Dictionary<TodoPriority, Color> { { TodoPriority.Low, new Color(0.5f, 0.6f, 0.7f) }, { TodoPriority.Normal, new Color(0.45f, 0.55f, 0.45f) }, { TodoPriority.High, new Color(0.85f, 0.65f, 0.25f) }, { TodoPriority.Urgent, new Color(0.8f, 0.3f, 0.25f) } }; private readonly Dictionary<TodoCategory, Color> _categoryColors = new Dictionary<TodoCategory, Color> { { TodoCategory.General, new Color(0.55f, 0.5f, 0.45f) }, { TodoCategory.Farming, new Color(0.45f, 0.65f, 0.35f) }, { TodoCategory.Mining, new Color(0.5f, 0.45f, 0.55f) }, { TodoCategory.Fishing, new Color(0.4f, 0.6f, 0.75f) }, { TodoCategory.Combat, new Color(0.75f, 0.35f, 0.35f) }, { TodoCategory.Crafting, new Color(0.65f, 0.55f, 0.4f) }, { TodoCategory.Social, new Color(0.7f, 0.5f, 0.6f) }, { TodoCategory.Quests, new Color(0.8f, 0.7f, 0.3f) }, { TodoCategory.Collection, new Color(0.55f, 0.7f, 0.65f) } }; private bool _stylesInitialized; private GUIStyle _windowStyle; private GUIStyle _headerStyle; private GUIStyle _itemStyle; private GUIStyle _priorityStyle; private GUIStyle _categoryStyle; private GUIStyle _titleStyle; private GUIStyle _emptyStyle; private Texture2D _windowBackground; private Texture2D _headerBackground; private Texture2D _itemEven; private Texture2D _itemOdd; public bool IsEnabled => _isEnabled; public void Initialize(TodoManager manager) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) _manager = manager; _windowRect = new Rect((float)Screen.width - 280f - 20f, 100f, 280f, 100f); if (_manager != null) { _manager.OnTodosChanged += RefreshCache; _manager.OnDataLoaded += RefreshCache; } } public void SetPosition(float x, float y) { ((Rect)(ref _windowRect)).x = Mathf.Clamp(x, 0f, (float)Screen.width - ((Rect)(ref _windowRect)).width); ((Rect)(ref _windowRect)).y = Mathf.Clamp(y, 0f, (float)Screen.height - ((Rect)(ref _windowRect)).height); } public (float x, float y) GetPosition() { return (((Rect)(ref _windowRect)).x, ((Rect)(ref _windowRect)).y); } public void SetEnabled(bool enabled) { _isEnabled = enabled; } public void Toggle() { _isEnabled = !_isEnabled; ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("TodoHUD toggled: " + (_isEnabled ? "ON" : "OFF"))); } } private void Update() { if (_isEnabled && _manager != null && Time.unscaledTime - _lastUpdateTime > 1f) { RefreshCache(); _lastUpdateTime = Time.unscaledTime; } } private void RefreshCache() { if (_manager != null) { _cachedItems = (from t in _manager.GetActiveTodos() orderby (int)t.Priority descending, t.CreatedAt descending select t).Take(5).ToList(); } } private void OnGUI() { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00ce: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) if (!_isEnabled || _manager == null) { return; } TodoUI todoUI = Plugin.GetTodoUI(); if ((!((Object)(object)todoUI != (Object)null) || !todoUI.IsVisible) && !string.IsNullOrEmpty(_manager.CurrentCharacter)) { InitializeStyles(); float num = 36f; num = ((_cachedItems.Count != 0) ? (num + ((float)_cachedItems.Count * 24f + 4f)) : (num + 40f)); ((Rect)(ref _windowRect)).height = Mathf.Clamp(num, 100f, 300f); Rect windowRect = _windowRect; GUI.depth = -500; _windowRect = GUI.Window(98766, _windowRect, new WindowFunction(DrawWindow), "", _windowStyle); ((Rect)(ref _windowRect)).x = Mathf.Clamp(((Rect)(ref _windowRect)).x, 0f, (float)Screen.width - ((Rect)(ref _windowRect)).width); ((Rect)(ref _windowRect)).y = Mathf.Clamp(((Rect)(ref _windowRect)).y, 0f, (float)Screen.height - ((Rect)(ref _windowRect)).height); if (Math.Abs(((Rect)(ref _windowRect)).x - ((Rect)(ref windowRect)).x) > 0.1f || Math.Abs(((Rect)(ref _windowRect)).y - ((Rect)(ref windowRect)).y) > 0.1f) { OnPositionChanged?.Invoke(((Rect)(ref _windowRect)).x, ((Rect)(ref _windowRect)).y); } } } private void DrawWindow(int windowId) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); DrawHeader(); DrawItems(); GUILayout.EndVertical(); GUI.DragWindow(new Rect(0f, 0f, 280f, 28f)); } private void DrawHeader() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown Rect val = default(Rect); ((Rect)(ref val))..ctor(0f, 0f, 280f, 28f); if ((Object)(object)_headerBackground != (Object)null) { GUI.DrawTexture(val, (Texture)(object)_headerBackground); } GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Space(8f); int num = _manager?.GetActiveTodos().Count() ?? 0; GUILayout.Label($"Todo ({num})", _headerStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) }); GUILayout.FlexibleSpace(); GUIStyle val2 = new GUIStyle(_headerStyle) { fontSize = 9, fontStyle = (FontStyle)2 }; val2.normal.textColor = new Color(_textDark.r, _textDark.g, _textDark.b, 0.5f); GUIStyle val3 = val2; GUILayout.Label("drag to move", val3, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) }); GUILayout.Space(8f); GUILayout.EndHorizontal(); } private void DrawItems() { GUILayout.Space(4f); if (_cachedItems.Count == 0) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); GUILayout.Label("No active tasks", _emptyStyle, Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } else { for (int i = 0; i < _cachedItems.Count; i++) { DrawItem(_cachedItems[i], i); } } GUILayout.Space(4f); } private void DrawItem(TodoItem item, int index) { //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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_007c: 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_004e: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_0097: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown Texture2D val = ((index % 2 == 0) ? _itemEven : _itemOdd); GUILayout.BeginHorizontal(_itemStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(24f) }); Rect lastRect = GUILayoutUtility.GetLastRect(); if ((int)Event.current.type == 7 && (Object)(object)val != (Object)null) { GUI.DrawTexture(lastRect, (Texture)(object)val); } GUILayout.Space(6f); Color value; Color textColor = (_priorityColors.TryGetValue(item.Priority, out value) ? value : _textDark); GUIStyle val2 = new GUIStyle(_priorityStyle); val2.normal.textColor = textColor; GUIStyle val3 = val2; GUILayout.Label(GetPriorityIcon(item.Priority), val3, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(16f) }); Color value2; Color textColor2 = (_categoryColors.TryGetValue(item.Category, out value2) ? value2 : _textDark); GUIStyle val4 = new GUIStyle(_categoryStyle); val4.normal.textColor = textColor2; GUIStyle val5 = val4; GUILayout.Label("[" + GetCategoryShort(item.Category) + "]", val5, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(36f) }); GUILayout.Space(4f); GUILayout.Label((item.Title.Length > 25) ? (item.Title.Substring(0, 22) + "...") : item.Title, _titleStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.Space(6f); GUILayout.EndHorizontal(); } private string GetPriorityIcon(TodoPriority priority) { return priority switch { TodoPriority.Low => "-", TodoPriority.Normal => "o", TodoPriority.High => "!", TodoPriority.Urgent => "!!", _ => "o", }; } private string GetCategoryShort(TodoCategory category) { return category switch { TodoCategory.General => "GEN", TodoCategory.Farming => "FRM", TodoCategory.Mining => "MIN", TodoCategory.Fishing => "FSH", TodoCategory.Combat => "CMB", TodoCategory.Crafting => "CRF", TodoCategory.Social => "SOC", TodoCategory.Quests => "QST", TodoCategory.Collection => "COL", _ => "GEN", }; } private void InitializeStyles() { if (!_stylesInitialized) { CreateTextures(); CreateStyles(); _stylesInitialized = true; } } private void CreateTextures() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) _windowBackground = MakeParchmentTexture(16, 64, _parchment, _parchmentLight, _borderDark, 2); _headerBackground = MakeGradientTex(8, 28, _parchmentDark, _parchment); _itemEven = MakeTex(1, 1, new Color(_parchmentLight.r, _parchmentLight.g, _parchmentLight.b, 0.3f)); _itemOdd = MakeTex(1, 1, new Color(_parchment.r, _parchment.g, _parchment.b, 0.3f)); } private void CreateStyles() { //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) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_004b: Expected O, but got Unknown //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) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_008c: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00bf: Expected O, but got Unknown //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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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_0154: Expected O, but got Unknown //IL_0155: 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_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0169: 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_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Expected O, but got Unknown //IL_01be: Expected O, but got Unknown GUIStyle val = new GUIStyle(); val.normal.background = _windowBackground; val.normal.textColor = _textDark; val.padding = new RectOffset(4, 4, 4, 4); val.border = new RectOffset(4, 4, 4, 4); _windowStyle = val; GUIStyle val2 = new GUIStyle { fontSize = 13, fontStyle = (FontStyle)1 }; val2.normal.textColor = _woodDark; val2.alignment = (TextAnchor)3; val2.padding = new RectOffset(2, 2, 2, 2); _headerStyle = val2; GUIStyle val3 = new GUIStyle { fontSize = 11 }; val3.normal.textColor = _textDark; val3.padding = new RectOffset(2, 2, 2, 2); _itemStyle = val3; GUIStyle val4 = new GUIStyle { fontSize = 11, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; val4.normal.textColor = _textDark; _priorityStyle = val4; GUIStyle val5 = new GUIStyle { fontSize = 8, fontStyle = (FontStyle)1, alignment = (TextAnchor)3 }; val5.normal.textColor = _textDark; _categoryStyle = val5; GUIStyle val6 = new GUIStyle { fontSize = 11 }; val6.normal.textColor = _textDark; val6.alignment = (TextAnchor)3; val6.clipping = (TextClipping)1; _titleStyle = val6; GUIStyle val7 = new GUIStyle { fontSize = 11, fontStyle = (FontStyle)2 }; val7.normal.textColor = new Color(_textDark.r, _textDark.g, _textDark.b, 0.6f); val7.alignment = (TextAnchor)4; val7.padding = new RectOffset(10, 10, 10, 10); _emptyStyle = val7; } private Texture2D MakeTex(int width, int height, Color color) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0026: 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_0034: 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_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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) 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 MakeParchmentTexture(int width, int height, Color baseColor, Color lightColor, Color borderColor, int borderWidth) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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) Texture2D val = new Texture2D(width, height); Color[] array = (Color[])(object)new Color[width * height]; Random random = new Random(42); 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)random.NextDouble() * 0.02f - 0.01f; array[i * width + j] = new Color(Mathf.Clamp01(val2.r + num2), Mathf.Clamp01(val2.g + num2), Mathf.Clamp01(val2.b + num2), val2.a); } } val.SetPixels(array); val.Apply(); return val; } private void OnDestroy() { if (_manager != null) { _manager.OnTodosChanged -= RefreshCache; _manager.OnDataLoaded -= RefreshCache; } } } public class TodoUI : MonoBehaviour { private const int WINDOW_ID = 98765; private const float WINDOW_WIDTH = 520f; private const float WINDOW_HEIGHT = 600f; private const float HEADER_HEIGHT = 50f; private const float ITEM_HEIGHT = 36f; private const string PAUSE_ID = "SunhavenTodo_UI"; private bool _isVisible; private Rect _windowRect; private Vector2 _scrollPosition; private float _openAnimation; private string _newTodoTitle = ""; private string _newTodoDescription = ""; private int _selectedPriority = 1; private int _selectedCategory; private bool _showAddForm; private string _editingItemId; private int _selectedCategoryFilter = -1; private bool _showCompletedItems = true; private string _searchQuery = ""; private TodoManager _manager; 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 _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 _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(0.98f, 0.95f, 0.85f); private readonly Color _forestGreen = new Color(0.3f, 0.55f, 0.3f); private readonly Color _successGreen = new Color(0.35f, 0.65f, 0.35f); private readonly Color _skyBlue = new Color(0.45f, 0.65f, 0.85f); private readonly Color _urgentRed = new Color(0.8f, 0.3f, 0.25f); private readonly Color _textDark = new Color(0.25f, 0.2f, 0.15f); private readonly Color _textLight = new Color(0.95f, 0.92f, 0.88f); private readonly Color _borderDark = new Color(0.4f, 0.3f, 0.2f, 0.8f); private readonly Dictionary<TodoPriority, Color> _priorityColors = new Dictionary<TodoPriority, Color> { { TodoPriority.Low, new Color(0.5f, 0.6f, 0.7f) }, { TodoPriority.Normal, new Color(0.45f, 0.55f, 0.45f) }, { TodoPriority.High, new Color(0.85f, 0.65f, 0.25f) }, { TodoPriority.Urgent, new Color(0.8f, 0.3f, 0.25f) } }; private readonly Dictionary<TodoCategory, Color> _categoryColors = new Dictionary<TodoCategory, Color> { { TodoCategory.General, new Color(0.55f, 0.5f, 0.45f) }, { TodoCategory.Farming, new Color(0.45f, 0.65f, 0.35f) }, { TodoCategory.Mining, new Color(0.5f, 0.45f, 0.55f) }, { TodoCategory.Fishing, new Color(0.4f, 0.6f, 0.75f) }, { TodoCategory.Combat, new Color(0.75f, 0.35f, 0.35f) }, { TodoCategory.Crafting, new Color(0.65f, 0.55f, 0.4f) }, { TodoCategory.Social, new Color(0.7f, 0.5f, 0.6f) }, { TodoCategory.Quests, new Color(0.8f, 0.7f, 0.3f) }, { TodoCategory.Collection, new Color(0.55f, 0.7f, 0.65f) } }; private bool _stylesInitialized; private GUIStyle _windowStyle; private GUIStyle _titleStyle; private GUIStyle _headerStyle; private GUIStyle _labelStyle; private GUIStyle _labelBoldStyle; private GUIStyle _buttonStyle; private GUIStyle _textFieldStyle; private GUIStyle _textAreaStyle; private GUIStyle _itemStyle; private GUIStyle _itemCompletedStyle; private GUIStyle _tabStyle; private GUIStyle _tabActiveStyle; private GUIStyle _statsStyle; private GUIStyle _categoryLabelStyle; private GUIStyle _priorityLabelStyle; private GUIStyle _footerStyle; private GUIStyle _completedTitleStyle; private Dictionary<TodoPriority, GUIStyle> _priorityStyleCache; private Dictionary<TodoCategory, GUIStyle> _categoryStyleCache; private Texture2D _windowBackground; private Texture2D _headerBackground; private Texture2D _buttonNormal; private Texture2D _buttonHover; private Texture2D _buttonActive; private Texture2D _itemEven; private Texture2D _itemOdd; private Texture2D _itemCompleted; private Texture2D _tabNormal; private Texture2D _tabActive; private Texture2D _textFieldBg; private Texture2D _goldLine; private Texture2D _progressBg; private Texture2D _progressFill; public bool IsVisible => _isVisible; public void Initialize(TodoManager manager) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) _manager = manager; _windowRect = new Rect(((float)Screen.width - 520f) / 2f, ((float)Screen.height - 600f) / 2f, 520f, 600f); } public void Show() { _isVisible = true; _openAnimation = 0f; PauseGame(pause: true); } public void Hide() { _isVisible = false; _showAddForm = false; _editingItemId = null; PauseGame(pause: false); } private void PauseGame(bool pause) { try { if ((Object)(object)Player.Instance != (Object)null) { if (pause) { Player.Instance.AddPauseObject("SunhavenTodo_UI"); } else { Player.Instance.RemovePauseObject("SunhavenTodo_UI"); } } Type type = Type.GetType("PlayerInput, Assembly-CSharp"); if (type != null) { type.GetMethod(pause ? "DisableInput" : "EnableInput", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(string) }, null)?.Invoke(null, new object[1] { "SunhavenTodo_UI" }); } } catch (Exception ex) { Debug.LogWarning((object)("[SunhavenTodo] Input blocking failed: " + ex.Message)); } } public void Toggle() { if (_isVisible) { Hide(); } else { Show(); } } private void Update() { if (_isVisible && Input.GetKeyDown((KeyCode)27)) { if (_showAddForm) { _showAddForm = false; _editingItemId = null; } else { Hide(); } } if (_isVisible) { _openAnimation = Mathf.MoveTowards(_openAnimation, 1f, Time.unscaledDeltaTime * 8f); } } private void OnGUI() { //IL_002c: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0063: 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_00d1: Unknown result type (might be due to invalid IL or missing references) if (_isVisible && _manager != null) { InitializeStyles(); GUI.color = new Color(1f, 1f, 1f, _openAnimation); GUI.depth = -1000; _windowRect = GUI.Window(98765, _windowRect, new WindowFunction(DrawWindow), "", _windowStyle); ((Rect)(ref _windowRect)).x = Mathf.Clamp(((Rect)(ref _windowRect)).x, 0f, (float)Screen.width - ((Rect)(ref _windowRect)).width); ((Rect)(ref _windowRect)).y = Mathf.Clamp(((Rect)(ref _windowRect)).y, 0f, (float)Screen.height - ((Rect)(ref _windowRect)).height); GUI.color = Color.white; } } private void DrawWindow(int windowId) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); DrawHeader(); DrawGoldDivider(); DrawStats(); DrawFilterBar(); if (_showAddForm) { DrawAddForm(); } else { DrawCategoryTabs(); DrawTodoList(); } DrawFooter(); GUILayout.EndVertical(); GUI.DragWindow(new Rect(0f, 0f, 520f, 50f)); } private void DrawHeader() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Todo List", _titleStyle, Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent(_showAddForm ? "Cancel" : "+ Add"), _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(70f), GUILayout.Height(28f) })) { _showAddForm = !_showAddForm; if (!_showAddForm) { ResetAddForm(); } } GUILayout.Space(8f); if (GUILayout.Button("X", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(28f), GUILayout.Height(28f) })) { Hide(); } GUILayout.EndHorizontal(); } private void DrawGoldDivider() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 //IL_0035: Unknown result type (might be due to invalid IL or missing references) GUILayout.Space(4f); Rect rect = GUILayoutUtility.GetRect(480f, 3f); if ((int)Event.current.type == 7 && (Object)(object)_goldLine != (Object)null) { GUI.DrawTexture(rect, (Texture)(object)_goldLine); } GUILayout.Space(4f); } private void DrawStats() { //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Invalid comparison between Unknown and I4 //IL_0114: 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) (int total, int completed, int active) stats = _manager.GetStats(); int item = stats.total; int item2 = stats.completed; int item3 = stats.active; float completionPercent = _manager.GetCompletionPercent(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); GUILayout.Label($"Active: {item3}", _statsStyle, Array.Empty<GUILayoutOption>()); GUILayout.Space(20f); GUILayout.Label($"Completed: {item2}", _statsStyle, Array.Empty<GUILayoutOption>()); GUILayout.Space(20f); GUILayout.Label($"Total: {item}", _statsStyle, Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(4f); Rect rect = GUILayoutUtility.GetRect(460f, 12f); ((Rect)(ref rect)).x = ((Rect)(ref rect)).x + 10f; ((Rect)(ref rect)).width = ((Rect)(ref rect)).width - 20f; if ((int)Event.current.type == 7) { if ((Object)(object)_progressBg != (Object)null) { GUI.DrawTexture(rect, (Texture)(object)_progressBg); } if ((Object)(object)_progressFill != (Object)null && completionPercent > 0f) { GUI.DrawTexture(new Rect(((Rect)(ref rect)).x + 2f, ((Rect)(ref rect)).y + 2f, (((Rect)(ref rect)).width - 4f) * (completionPercent / 100f), ((Rect)(ref rect)).height - 4f), (Texture)(object)_progressFill); } } GUILayout.Space(8f); } private void DrawFilterBar() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Search:", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); _searchQuery = GUILayout.TextField(_searchQuery, _textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(150f), GUILayout.Height(24f) }); GUILayout.Space(10f); if (GUILayout.Button(new GUIContent(_showCompletedItems ? "[v] Show Done" : "[ ] Show Done"), _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(100f), GUILayout.Height(24f) })) { _showCompletedItems = !_showCompletedItems; } GUILayout.FlexibleSpace(); if (_manager.GetCompletedTodos().Any() && GUILayout.Button("Clear Done", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(80f), GUILayout.Height(24f) })) { _manager.ClearCompleted(); } GUILayout.EndHorizontal(); GUILayout.Space(8f); } private void DrawCategoryTabs() { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUIStyle val = ((_selectedCategoryFilter == -1) ? _tabActiveStyle : _tabStyle); if (GUILayout.Button("All", val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) })) { _selectedCategoryFilter = -1; } Dictionary<TodoCategory, int> countsByCategory = _manager.GetCountsByCategory(); foreach (TodoCategory value2 in Enum.GetValues(typeof(TodoCategory))) { int value; int num = (countsByCategory.TryGetValue(value2, out value) ? value : 0); GUIStyle val2 = ((value2 == (TodoCategory)_selectedCategoryFilter) ? _tabActiveStyle : _tabStyle); if (GUILayout.Button((num > 0) ? $"{value2} ({num})" : value2.ToString(), val2, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) })) { _selectedCategoryFilter = (int)value2; } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(8f); } private void DrawTodoList() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) List<TodoItem> list = GetFilteredTodos().ToList(); _scrollPosition = GUILayout.BeginScrollView(_scrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) }); if (list.Count == 0) { GUILayout.Space(20f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); GUILayout.Label("No tasks to show", _labelStyle, Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(20f); } else { List<TodoItem> list2 = (from t in list orderby t.IsCompleted, (int)t.Priority descending, t.CreatedAt descending select t).ToList(); for (int i = 0; i < list2.Count; i++) { DrawTodoItem(list2[i], i); } } GUILayout.EndScrollView(); } private void DrawTodoItem(TodoItem item, int index) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 //IL_006e: Unknown result type (might be due to invalid IL or missing references) Texture2D val = (item.IsCompleted ? _itemCompleted : ((index % 2 == 0) ? _itemEven : _itemOdd)); GUILayout.BeginHorizontal(item.IsCompleted ? _itemCompletedStyle : _itemStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) }); Rect lastRect = GUILayoutUtility.GetLastRect(); if ((int)Event.current.type == 7 && (Object)(object)val != (Object)null) { GUI.DrawTexture(lastRect, (Texture)(object)val); } if (GUILayout.Toggle(item.IsCompleted, "", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(20f) }) != item.IsCompleted) { _manager.ToggleComplete(item.Id); } GUILayout.Space(4f); GUIStyle value; GUIStyle val2 = (_priorityStyleCache.TryGetValue(item.Priority, out value) ? value : _priorityLabelStyle); GUILayout.Label(GetPriorityIcon(item.Priority), val2, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(20f) }); GUIStyle value2; GUIStyle val3 = (_categoryStyleCache.TryGetValue(item.Category, out value2) ? value2 : _categoryLabelStyle); GUILayout.Label("[" + GetCategoryShort(item.Category) + "]", val3, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(45f) }); GUILayout.Space(4f); GUIStyle val4 = (item.IsCompleted ? _completedTitleStyle : _labelBoldStyle); GUILayout.Label(item.Title, val4, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (GUILayout.Button("x", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(22f), GUILayout.Height(22f) })) { _manager.RemoveTodo(item.Id); } GUILayout.EndHorizontal(); } private void DrawAddForm() { GUILayout.Space(10f); GUILayout.BeginVertical(_windowStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label((_editingItemId != null) ? "Edit Task" : "Add New Task", _headerStyle, Array.Empty<GUILayoutOption>()); GUILayout.Space(8f); GUILayout.Label("Title:", _labelStyle, Array.Empty<GUILayoutOption>()); _newTodoTitle = GUILayout.TextField(_newTodoTitle, _textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) }); GUILayout.Space(6f); GUILayout.Label("Description (optional):", _labelStyle, Array.Empty<GUILayoutOption>()); _newTodoDescription = GUILayout.TextArea(_newTodoDescription, _textAreaStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(50f) }); GUILayout.Space(6f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Priority:", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }); string[] names = Enum.GetNames(typeof(TodoPriority)); for (int i = 0; i < names.Length; i++) { GUIStyle val = ((i == _selectedPriority) ? _tabActiveStyle : _tabStyle); if (GUILayout.Button(names[i], val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(24f) })) { _selectedPriority = i; } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(6f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Category:", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }); string[] names2 = Enum.GetNames(typeof(TodoCategory)); _selectedCategory = GUILayout.SelectionGrid(_selectedCategory, names2, 5, _tabStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(50f) }); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(10f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); if (GUILayout.Button("Cancel", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(80f), GUILayout.Height(28f) })) { _showAddForm = false; ResetAddForm(); } GUILayout.Space(10f); GUI.enabled = !string.IsNullOrWhiteSpace(_newTodoTitle); if (GUILayout.Button((_editingItemId != null) ? "Update" : "Add Task", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(100f), GUILayout.Height(28f) })) { SaveNewTodo(); } GUI.enabled = true; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } private void DrawFooter() { GUILayout.Space(4f); DrawGoldDivider(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); GUILayout.Label("Press ESC to close | Drag header to move", _footerStyle, Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } private IEnumerable<TodoItem> GetFilteredTodos() { IEnumerable<TodoItem> enumerable = _manager.GetAllTodos(); if (!_showCompletedItems) { enumerable = enumerable.Where((TodoItem t) => !t.IsCompleted); } if (_selectedCategoryFilter >= 0) { TodoCategory category2 = (TodoCategory)_selectedCategoryFilter; enumerable = enumerable.Where((TodoItem t) => t.Category == category2); } if (!string.IsNullOrWhiteSpace(_searchQuery)) { enumerable = _manager.SearchTodos(_searchQuery); if (!_showCompletedItems) { enumerable = enumerable.Where((TodoItem t) => !t.IsCompleted); } if (_selectedCategoryFilter >= 0) { TodoCategory category = (TodoCategory)_selectedCategoryFilter; enumerable = enumerable.Where((TodoItem t) => t.Category == category); } } return enumerable; } private void SaveNewTodo() { if (!string.IsNullOrWhiteSpace(_newTodoTitle)) { TodoItem todoItem = new TodoItem(_newTodoTitle.Trim(), _newTodoDescription?.Trim() ?? "", (TodoPriority)_selectedPriority, (TodoCategory)_selectedCategory); if (_editingItemId != null) { todoItem.Id = _editingItemId; _manager.UpdateTodo(todoItem); } else { _manager.AddTodo(todoItem); } _showAddForm = false; ResetAddForm(); } } private void ResetAddForm() { _newTodoTitle = ""; _newTodoDescription = ""; _selectedPriority = 1; _selectedCategory = 0; _editingItemId = null; } private string GetPriorityIcon(TodoPriority priority) { return priority switch { TodoPriority.Low => "-", TodoPriority.Normal => "o", TodoPriority.High => "!", TodoPriority.Urgent => "!!", _ => "o", }; } private string GetCategoryShort(TodoCategory category) { return category switch { TodoCategory.General => "GEN", TodoCategory.Farming => "FRM", TodoCategory.Mining => "MIN", TodoCategory.Fishing => "FSH", TodoCategory.Combat => "CMB", TodoCategory.Crafting => "CRF", TodoCategory.Social => "SOC", TodoCategory.Quests => "QST", TodoCategory.Collection => "COL", _ => "GEN", }; } private void InitializeStyles() { if (!_stylesInitialized) { CreateTextures(); CreateStyles(); _stylesInitialized = true; } } private void CreateTextures() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0032: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) _windowBackground = MakeParchmentTexture(32, 128, _parchment, _parchmentLight, _borderDark, 4); _headerBackground = MakeGradientTex(8, 32, _parchmentDark, _parchment); _buttonNormal = MakeRoundedRect(8, 8, _parchmentDark, _borderDark, 2); _buttonHover = MakeRoundedRect(8, 8, _woodLight, _borderDark, 2); _buttonActive = MakeRoundedRect(8, 8, _goldPale, _goldRich, 2); _itemEven = MakeTex(1, 1, new Color(_parchmentLight.r, _parchmentLight.g, _parchmentLight.b, 0.4f)); _itemOdd = MakeTex(1, 1, new Color(_parchment.r, _parchment.g, _parchment.b, 0.4f)); _itemCompleted = MakeTex(1, 1, new Color(_successGreen.r, _successGreen.g, _successGreen.b, 0.15f)); _tabNormal = MakeRoundedRect(8, 8, _parchmentDark, _borderDark, 1); _tabActive = MakeRoundedRect(8, 8, _goldPale, _goldRich, 2); _textFieldBg = MakeTex(1, 1, new Color(1f, 1f, 1f, 0.9f)); _goldLine = MakeGradientTex(64, 3, _goldBright, _goldRich); _progressBg = MakeTex(1, 1, new Color(_woodDark.r, _woodDark.g, _woodDark.b, 0.4f)); _progressFill = MakeGradientTex(8, 8, _goldBright, _goldRich); } private void CreateStyles() { //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) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_004f: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_0090: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00d1: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_010b: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown //IL_0155: 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_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Expected O, but got Unknown //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Expected O, but got Unknown //IL_01f9: Expected O, but got Unknown //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Expected O, but got Unknown //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Expected O, but got Unknown //IL_026e: Expected O, but got Unknown //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Expected O, but got Unknown //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Expected O, but got Unknown //IL_02b9: Expected O, but got Unknown //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Expected O, but got Unknown //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Expected O, but got Unknown //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Expected O, but got Unknown //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Expected O, but got Unknown //IL_0396: Expected O, but got Unknown //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Expected O, but got Unknown //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Expected O, but got Unknown //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Expected O, but got Unknown //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Expected O, but got Unknown //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Expected O, but got Unknown //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Expected O, but got Unknown //IL_0575: Unknown result type (might be due to invalid IL or missing references) //IL_056e: Unknown result type (might be due to invalid IL or missing references) //IL_0577: 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_058c: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_059e: Expected O, but got Unknown GUIStyle val = new GUIStyle(); val.normal.background = _windowBackground; val.normal.textColor = _textDark; val.padding = new RectOffset(15, 15, 15, 15); val.border = new RectOffset(8, 8, 8, 8); _windowStyle = val; GUIStyle val2 = new GUIStyle { fontSize = 22, fontStyle = (FontStyle)1 }; val2.normal.textColor = _woodDark; val2.alignment = (TextAnchor)3; val2.padding = new RectOffset(5, 5, 5, 5); _titleStyle = val2; GUIStyle val3 = new GUIStyle { fontSize = 16, fontStyle = (FontStyle)1 }; val3.normal.textColor = _woodDark; val3.alignment = (TextAnchor)4; val3.padding = new RectOffset(5, 5, 5, 5); _headerStyle = val3; GUIStyle val4 = new GUIStyle { fontSize = 12 }; val4.normal.textColor = _textDark; val4.alignment = (TextAnchor)3; val4.padding = new RectOffset(2, 2, 2, 2); _labelStyle = val4; _labelBoldStyle = new GUIStyle(_labelStyle) { fontStyle = (FontStyle)1 }; GUIStyle val5 = new GUIStyle(_labelStyle) { fontSize = 11, alignment = (TextAnchor)4 }; val5.normal.textColor = _woodMedium; _statsStyle = val5; GUIStyle val6 = new GUIStyle { fontSize = 11, fontStyle = (FontStyle)1 }; val6.normal.background = _buttonNormal; val6.normal.textColor = _textDark; val6.hover.background = _buttonHover; val6.hover.textColor = _textDark; val6.active.background = _buttonActive; val6.active.textColor = _woodDark; val6.alignment = (TextAnchor)4; val6.padding = new RectOffset(8, 8, 4, 4); val6.border = new RectOffset(4, 4, 4, 4); _buttonStyle = val6; GUIStyle val7 = new GUIStyle { fontSize = 12 }; val7.normal.background = _textFieldBg; val7.normal.textColor = _textDark; val7.focused.background = _textFieldBg; val7.focused.textColor = _textDark; val7.padding = new RectOffset(6, 6, 4, 4); val7.border = new RectOffset(2, 2, 2, 2); _textFieldStyle = val7; _textAreaStyle = new GUIStyle(_textFieldStyle) { wordWrap = true }; GUIStyle val8 = new GUIStyle { fontSize = 12 }; val8.normal.textColor = _textDark; val8.padding = new RectOffset(8, 8, 4, 4); _itemStyle = val8; GUIStyle val9 = new GUIStyle(_itemStyle); val9.normal.textColor = new Color(0.5f, 0.5f, 0.5f); _itemCompletedStyle = val9; GUIStyle val10 = new GUIStyle { fontSize = 10 }; val10.normal.background = _tabNormal; val10.normal.textColor = _textDark; val10.hover.background = _buttonHover; val10.hover.textColor = _textDark; val10.active.background = _tabActive; val10.active.textColor = _woodDark; val10.alignment = (TextAnchor)4; val10.padding = new RectOffset(6, 6, 3, 3); val10.margin = new RectOffset(2, 2, 0, 0); val10.border = new RectOffset(4, 4, 4, 4); _tabStyle = val10; GUIStyle val11 = new GUIStyle(_tabStyle); val11.normal.background = _tabActive; val11.normal.textColor = _woodDark; val11.fontStyle = (FontStyle)1; _tabActiveStyle = val11; _categoryLabelStyle = new GUIStyle(_labelStyle) { fontSize = 9, fontStyle = (FontStyle)1 }; _priorityLabelStyle = new GUIStyle(_labelStyle) { fontSize = 12, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; GUIStyle val12 = new GUIStyle(_labelStyle) { fontSize = 10, fontStyle = (FontStyle)2 }; val12.normal.textColor = new Color(_textDark.r, _textDark.g, _textDark.b, 0.6f); _footerStyle = val12; GUIStyle val13 = new GUIStyle(_labelBoldStyle); val13.normal.textColor = new Color(0.5f, 0.5f, 0.5f); val13.fontStyle = (FontStyle)2; _completedTitleStyle = val13; _priorityStyleCache = new Dictionary<TodoPriority, GUIStyle>(); foreach (TodoPriority value3 in Enum.GetValues(typeof(TodoPriority))) { Color value; Color textColor = (_priorityColors.TryGetValue(value3, out value) ? value : _textDark); Dictionary<TodoPriority, GUIStyle> priorityStyleCache = _priorityStyleCache; GUIStyle val14 = new GUIStyle(_priorityLabelStyle); val14.normal.textColor = textColor; priorityStyleCache[value3] = val14; } _categoryStyleCache = new Dictionary<TodoCategory, GUIStyle>(); foreach (TodoCategory value4 in Enum.GetValues(typeof(TodoCategory))) { Color value2; Color textColor2 = (_categoryColors.TryGetValue(value4, out value2) ? value2 : _textDark); Dictionary<TodoCategory, GUIStyle> categoryStyleCache = _categoryStyleCache; GUIStyle val15 = new GUIStyle(_categoryLabelStyle); val15.normal.textColor = textColor2; categoryStyleCache[value4] = val15; } } private Texture2D MakeTex(int width, int height, Color color) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0026: 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_0034: 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_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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) 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_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) 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_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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) Texture2D val = new Texture2D(width, height); Color[] array = (Color[])(object)new Color[width * height]; Random random = new Random(42); 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)random.NextDouble() * 0.03f - 0.015f; array[i * width + j] = new Color(Mathf.Clamp01(val2.r + num2), Mathf.Clamp01(val2.g + num2), Mathf.Clamp01(val2.b + num2), val2.a); } } val.SetPixels(array); val.Apply(); return val; } } } namespace SunhavenTodo.Data { public enum TodoPriority { Low, Normal, High, Urgent } public enum TodoCategory { General, Farming, Mining, Fishing, Combat, Crafting, Social, Quests, Collection } [Serializable] public class TodoItem { public string Id { get; set; } public string Title { get; set; } public string Description { get; set; } public TodoPriority Priority { get; set; } public TodoCategory Category { get; set; } public bool IsCompleted { get; set; } public DateTime CreatedAt { get; set; } public DateTime? CompletedAt { get; set; } public TodoItem() { Id = Guid.NewGuid().ToString(); Priority = TodoPriority.Normal; Category = TodoCategory.General; CreatedAt = DateTime.Now; IsCompleted = false; } public TodoItem(string title, string description = "", To