Decompiled source of QuestTrackerMod v1.0.3

QuestTrackerMod.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
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 UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("QuestTrackerMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+161a9c0b6bca194599e2e871872eff202a56cc0d")]
[assembly: AssemblyProduct("QuestTrackerMod")]
[assembly: AssemblyTitle("QuestTrackerMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace QuestTrackerMod
{
	[BepInPlugin("com.github.antigravity.questtrackermod", "Quest Tracker Mod", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static ManualLogSource? Log;

		private Harmony? _harmony;

		public static ConfigEntry<KeyCode>? CfgToggleKey;

		public static ConfigEntry<float>? CfgPositionX;

		public static ConfigEntry<float>? CfgPositionY;

		public static ConfigEntry<float>? CfgWindowWidth;

		public static ConfigEntry<float>? CfgWindowHeight;

		public static ConfigEntry<float>? CfgAlmostDoneThreshold;

		public static ConfigEntry<string>? CfgPinnedQuestIds;

		public static ConfigEntry<float>? CfgHUDPositionX;

		public static ConfigEntry<float>? CfgHUDPositionY;

		public static ConfigEntry<float>? CfgHUDWidth;

		public static ConfigEntry<float>? CfgHUDHeight;

		public static ConfigEntry<int>? CfgCompactHUDMaxItems;

		public static ConfigEntry<bool>? CfgHideCompletedInAlmostDone;

		private void Awake()
		{
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Expected O, but got Unknown
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"Quest Tracker Mod initializing...");
			CfgToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ToggleKey", (KeyCode)113, "Key to cycle quest tracker views (Small Window -> Big Window -> Hidden).");
			CfgPinnedQuestIds = ((BaseUnityPlugin)this).Config.Bind<string>("General", "PinnedQuestIds", "", "Comma-separated list of pinned quest IDs.");
			CfgPositionX = ((BaseUnityPlugin)this).Config.Bind<float>("Window", "PositionX", 120f, "X position of the main quest window.");
			CfgPositionY = ((BaseUnityPlugin)this).Config.Bind<float>("Window", "PositionY", 90f, "Y position of the main quest window.");
			CfgWindowWidth = ((BaseUnityPlugin)this).Config.Bind<float>("Window", "Width", 620f, "Width of the main quest window.");
			CfgWindowHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Window", "Height", 580f, "Height of the main quest window.");
			CfgHUDPositionX = ((BaseUnityPlugin)this).Config.Bind<float>("CompactHUD", "PositionX", 1200f, "X position of the draggable small HUD window.");
			CfgHUDPositionY = ((BaseUnityPlugin)this).Config.Bind<float>("CompactHUD", "PositionY", 50f, "Y position of the draggable small HUD window.");
			CfgHUDWidth = ((BaseUnityPlugin)this).Config.Bind<float>("CompactHUD", "Width", 330f, "Width of the draggable small HUD window.");
			CfgHUDHeight = ((BaseUnityPlugin)this).Config.Bind<float>("CompactHUD", "Height", 280f, "Height of the draggable small HUD window.");
			CfgCompactHUDMaxItems = ((BaseUnityPlugin)this).Config.Bind<int>("CompactHUD", "MaxItems", 5, "Maximum number of quests to show in the small HUD.");
			CfgAlmostDoneThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("Filtering", "AlmostDoneThreshold", 0.5f, "Threshold percentage (0.0 to 1.0) to consider a quest 'Almost Done'.");
			CfgHideCompletedInAlmostDone = ((BaseUnityPlugin)this).Config.Bind<bool>("Filtering", "HideCompletedInAlmostDone", true, "Hide 100% completed quests in the 'Almost Done' tab.");
			try
			{
				GameObject val = new GameObject("QuestTrackerController");
				Object.DontDestroyOnLoad((Object)val);
				val.AddComponent<QuestTrackerUI>();
				_harmony = new Harmony("com.github.antigravity.questtrackermod");
				_harmony.PatchAll();
				Log.LogInfo((object)"Quest Tracker Mod loaded successfully!");
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Failed to initialize Quest Tracker Mod: " + ex));
			}
		}

		private void OnDestroy()
		{
			Harmony? harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	public enum QuestTrackerDisplayMode
	{
		SmallWindow,
		BigWindow,
		Hidden
	}
	public enum QuestTab
	{
		AlmostDone,
		All,
		InProgress,
		Completed
	}
	public class QuestDataModel
	{
		public QuestDefinition Definition;

		public string QuestId = "";

		public string Title = "";

		public string DescPattern = "";

		public string CachedDescription = "";

		public QuestCategory Category;

		public int CurrentProgress = -1;

		public int RequiredProgress = 1;

		public float Percent;

		public bool IsCompleted;

		public bool IsRewarded;

		public int Remaining;

		public bool IsPinned;

		public bool IsSessionQuest;

		public bool IsAlmostDone(float threshold)
		{
			if (!IsCompleted && !IsRewarded)
			{
				return Percent >= threshold;
			}
			return false;
		}

		public bool UpdateProgress(HashSet<string> pinnedIds)
		{
			if ((Object)(object)Definition == (Object)null)
			{
				return false;
			}
			int num = 0;
			bool flag = false;
			bool flag2 = false;
			try
			{
				num = QuestProgressRepository.GetProgress(Definition);
				flag = QuestProgressRepository.IsCompleted(Definition);
				flag2 = QuestProgressRepository.IsRewarded(Definition);
			}
			catch
			{
			}
			if (num >= RequiredProgress)
			{
				flag = true;
			}
			bool flag3 = pinnedIds?.Contains(QuestId) ?? false;
			if (num == CurrentProgress && flag == IsCompleted && flag2 == IsRewarded && flag3 == IsPinned)
			{
				return false;
			}
			CurrentProgress = num;
			IsCompleted = flag;
			IsRewarded = flag2;
			IsPinned = flag3;
			Percent = Mathf.Clamp01((float)num / (float)RequiredProgress);
			Remaining = Mathf.Max(0, RequiredProgress - num);
			FormatDescriptionFast();
			return true;
		}

		private void FormatDescriptionFast()
		{
			if (string.IsNullOrEmpty(DescPattern))
			{
				CachedDescription = $"Progress: {CurrentProgress} / {RequiredProgress}";
			}
			else
			{
				CachedDescription = $"{DescPattern} ({CurrentProgress} / {RequiredProgress})";
			}
		}

		public static QuestDataModel CreateStaticModel(QuestDefinition q, HashSet<string> pinnedIds)
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			string questId = q.questId ?? ((Object)q).name ?? "Quest";
			int num = 1;
			if ((Object)(object)q.condition != (Object)null && q.condition.RequiredProgress > 0)
			{
				num = q.condition.RequiredProgress;
			}
			string title = FormatTitleStatic(q);
			string descPattern = BuildDescPatternStatic(q, num);
			QuestDataModel questDataModel = new QuestDataModel();
			questDataModel.Definition = q;
			questDataModel.QuestId = questId;
			questDataModel.Title = title;
			questDataModel.DescPattern = descPattern;
			questDataModel.Category = q.category;
			questDataModel.RequiredProgress = num;
			questDataModel.IsSessionQuest = !q.persistProgress;
			questDataModel.UpdateProgress(pinnedIds);
			return questDataModel;
		}

		private static string FormatTitleStatic(QuestDefinition q)
		{
			if ((Object)(object)q == (Object)null)
			{
				return "Unknown Quest";
			}
			string text = "Objective";
			if ((Object)(object)q.condition != (Object)null)
			{
				string name = ((object)q.condition).GetType().Name;
				string text2 = ExtractTargetNameFromConditionStatic(q.condition);
				switch (name)
				{
				case "HeroLevelQuestCondition":
					text = ((!string.IsNullOrEmpty(text2)) ? ("Hero Mastery: " + text2) : "Hero Mastery");
					break;
				case "KillWithHeroTotalQuestCondition":
					text = ((!string.IsNullOrEmpty(text2)) ? ("Hero Slayer: " + text2) : "Hero Slayer");
					break;
				case "KillWithWeaponQuestCondition":
				case "WeaponLevelQuestCondition":
					text = ((!string.IsNullOrEmpty(text2)) ? ("Weapon Master: " + text2) : "Weapon Master");
					break;
				case "KillBossTotalQuestCondition":
				case "BossKillTimedQuestCondition":
					text = ((!string.IsNullOrEmpty(text2)) ? FormatBossTitleStatic(text2) : "Boss Hunter");
					break;
				case "KillMobsTotalQuestCondition":
					text = "Monster Slayer";
					break;
				case "KillSpecificMobsTotalQuestCondition":
					text = ((!string.IsNullOrEmpty(text2)) ? ("Huntsman: " + text2) : "Targeted Hunt");
					break;
				case "OpenChestsTotalQuestCondition":
					text = "Treasure Hunter";
					break;
				case "ClearLairsTotalQuestCondition":
					text = "Lair Purger";
					break;
				case "ShrineActivateQuestCondition":
					text = "Beacon Pilgrim";
					break;
				case "SurviveTimeQuestCondition":
					text = "Survivalist";
					break;
				case "UseBellsTotalQuestCondition":
					text = "Bells";
					break;
				case "UseFoxesTotalQuestCondition":
					text = "Fox Shrines";
					break;
				case "ArtifactCollectQuestCondition":
					text = ((!string.IsNullOrEmpty(text2)) ? ("Relic Collector: " + text2) : "Relic Collector");
					break;
				case "BoostLevelQuestCondition":
					text = ((!string.IsNullOrEmpty(text2)) ? ("Scroll: " + text2) : "Scroll Stacks");
					break;
				case "BagCollectQuestCondition":
					text = "Loot Bags";
					break;
				case "MapClearQuestCondition":
					text = "Stage Conqueror";
					break;
				case "CompleteQuestsTotalQuestCondition":
					text = "Master Adventurer";
					break;
				default:
				{
					string text3 = ((Object)q).name;
					if (string.IsNullOrEmpty(text3))
					{
						text3 = q.questId;
					}
					text = CleanTextStatic(text3);
					break;
				}
				}
			}
			else
			{
				string text4 = ((Object)q).name;
				if (string.IsNullOrEmpty(text4))
				{
					text4 = q.questId;
				}
				text = CleanTextStatic(text4);
			}
			return ApplySpecificRenamesStatic(text);
		}

		private static string FormatBossTitleStatic(string targetName)
		{
			if (string.IsNullOrEmpty(targetName))
			{
				return "Boss Hunter";
			}
			targetName = ApplySpecificRenamesStatic(targetName);
			if (targetName.StartsWith("Boss", StringComparison.OrdinalIgnoreCase))
			{
				return "Defeat " + targetName;
			}
			return "Boss Hunter: " + targetName;
		}

		private static string BuildDescPatternStatic(QuestDefinition q, int req)
		{
			if ((Object)(object)q == (Object)null)
			{
				return "Progress:";
			}
			string text = "Progress:";
			if ((Object)(object)q.condition != (Object)null)
			{
				string name = ((object)q.condition).GetType().Name;
				string text2 = ExtractTargetNameFromConditionStatic(q.condition);
				switch (name)
				{
				case "KillMobsTotalQuestCondition":
					text = "Slay monsters";
					break;
				case "KillSpecificMobsTotalQuestCondition":
					text = ((!string.IsNullOrEmpty(text2)) ? ("Slay " + text2) : "Slay target monsters");
					break;
				case "KillBossTotalQuestCondition":
					if (!string.IsNullOrEmpty(text2))
					{
						string text3 = (text2.StartsWith("Boss", StringComparison.OrdinalIgnoreCase) ? text2 : ("Boss " + text2));
						text = "Defeat " + text3;
					}
					else
					{
						text = "Defeat Boss";
					}
					break;
				case "BossKillTimedQuestCondition":
				{
					float singleFieldStatic = GetSingleFieldStatic(q.condition, "timeLimitSeconds", 180f);
					if (!string.IsNullOrEmpty(text2))
					{
						string arg = (text2.StartsWith("Boss", StringComparison.OrdinalIgnoreCase) ? text2 : ("Boss " + text2));
						text = $"Defeat {arg} under {singleFieldStatic:F0}s";
					}
					else
					{
						text = $"Defeat Boss under {singleFieldStatic:F0}s";
					}
					break;
				}
				case "HeroLevelQuestCondition":
				{
					int intFieldStatic2 = GetIntFieldStatic(q.condition, "requiredLevel", req);
					text = ((!string.IsNullOrEmpty(text2)) ? $"Reach Level {intFieldStatic2} with {text2}" : $"Reach Hero Level {intFieldStatic2}");
					break;
				}
				case "KillWithHeroTotalQuestCondition":
					text = ((!string.IsNullOrEmpty(text2)) ? ("Slay monsters with " + text2) : "Slay monsters with hero");
					break;
				case "KillWithWeaponQuestCondition":
					text = ((!string.IsNullOrEmpty(text2)) ? ("Slay monsters with " + text2) : "Slay monsters with weapon");
					break;
				case "WeaponLevelQuestCondition":
				{
					int intFieldStatic3 = GetIntFieldStatic(q.condition, "requiredLevel", req);
					text = ((!string.IsNullOrEmpty(text2)) ? $"Upgrade {text2} to Level {intFieldStatic3}" : $"Upgrade weapon to Level {intFieldStatic3}");
					break;
				}
				case "OpenChestsTotalQuestCondition":
					text = "Open treasure chests";
					break;
				case "ClearLairsTotalQuestCondition":
					text = "Clear lairs";
					break;
				case "ShrineActivateQuestCondition":
					text = "Activate beacon shrines";
					break;
				case "SurviveTimeQuestCondition":
				{
					float singleFieldStatic2 = GetSingleFieldStatic(q.condition, "survivalSeconds", req);
					int num = (int)(singleFieldStatic2 / 60f);
					int num2 = (int)(singleFieldStatic2 % 60f);
					text = $"Survive for {num}m {num2:D2}s";
					break;
				}
				case "UseBellsTotalQuestCondition":
					text = "Ring Bells";
					break;
				case "UseFoxesTotalQuestCondition":
					text = "Use Fox Shrines";
					break;
				case "ArtifactCollectQuestCondition":
					text = ((!string.IsNullOrEmpty(text2)) ? ("Collect artifact: " + text2) : "Collect artifacts");
					break;
				case "BoostLevelQuestCondition":
				{
					int intFieldStatic = GetIntFieldStatic(q.condition, "requiredLevel", req);
					text = ((!string.IsNullOrEmpty(text2)) ? $"Reach {intFieldStatic} stacks of {text2}" : $"Reach {intFieldStatic} stacks");
					break;
				}
				case "BagCollectQuestCondition":
					text = "Collect Bags";
					break;
				case "MapClearQuestCondition":
					text = "Clear stages";
					break;
				case "CompleteQuestsTotalQuestCondition":
					text = "Complete quests";
					break;
				}
			}
			return ApplySpecificRenamesStatic(text);
		}

		private static bool ContainsCyrillicStatic(string text)
		{
			if (string.IsNullOrEmpty(text))
			{
				return false;
			}
			foreach (char c in text)
			{
				if (c >= 'Ѐ' && c <= 'ӿ')
				{
					return true;
				}
			}
			return false;
		}

		private static string ExtractTargetNameFromConditionStatic(object condition)
		{
			if (condition == null)
			{
				return "";
			}
			try
			{
				Type type = condition.GetType();
				FieldInfo field = type.GetField("heroDefinition", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null)
				{
					object value = field.GetValue(condition);
					if (value != null)
					{
						string cleanNameFromObjectStatic = GetCleanNameFromObjectStatic(value);
						if (!string.IsNullOrEmpty(cleanNameFromObjectStatic))
						{
							return ApplySpecificRenamesStatic(cleanNameFromObjectStatic);
						}
					}
				}
				FieldInfo field2 = type.GetField("artifactPreset", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field2 != null)
				{
					object value2 = field2.GetValue(condition);
					if (value2 != null)
					{
						string cleanNameFromObjectStatic2 = GetCleanNameFromObjectStatic(value2);
						if (!string.IsNullOrEmpty(cleanNameFromObjectStatic2))
						{
							return ApplySpecificRenamesStatic(cleanNameFromObjectStatic2);
						}
					}
				}
				FieldInfo field3 = type.GetField("boostPreset", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field3 != null)
				{
					object value3 = field3.GetValue(condition);
					if (value3 != null)
					{
						string cleanNameFromObjectStatic3 = GetCleanNameFromObjectStatic(value3);
						if (!string.IsNullOrEmpty(cleanNameFromObjectStatic3))
						{
							return ApplySpecificRenamesStatic(cleanNameFromObjectStatic3);
						}
					}
				}
				FieldInfo field4 = type.GetField("bossName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field4 != null)
				{
					string text = (field4.GetValue(condition) as string) ?? "";
					if (!string.IsNullOrEmpty(text))
					{
						return ApplySpecificRenamesStatic(CleanTextStatic(text));
					}
				}
				FieldInfo field5 = type.GetField("mobNames", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field5 != null && field5.GetValue(condition) is string[] array && array.Length != 0 && !string.IsNullOrEmpty(array[0]))
				{
					return ApplySpecificRenamesStatic(CleanTextStatic(array[0]));
				}
				FieldInfo field6 = type.GetField("weaponType", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field6 != null)
				{
					object value4 = field6.GetValue(condition);
					if (value4 != null)
					{
						string text2 = value4.ToString() ?? "";
						if (!string.IsNullOrEmpty(text2))
						{
							return ApplySpecificRenamesStatic(CleanTextStatic(text2));
						}
					}
				}
			}
			catch
			{
			}
			return "";
		}

		private static string GetCleanNameFromObjectStatic(object obj)
		{
			if (obj == null)
			{
				return "";
			}
			try
			{
				Type type = obj.GetType();
				PropertyInfo property = type.GetProperty("HeroName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (property != null)
				{
					string text = (property.GetValue(obj) as string) ?? "";
					if (!string.IsNullOrEmpty(text))
					{
						return CleanTextStatic(text);
					}
				}
				FieldInfo field = type.GetField("displayName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null)
				{
					string text2 = (field.GetValue(obj) as string) ?? "";
					if (!string.IsNullOrEmpty(text2))
					{
						return CleanTextStatic(text2);
					}
				}
				PropertyInfo property2 = type.GetProperty("name", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (property2 != null)
				{
					string text3 = (property2.GetValue(obj) as string) ?? "";
					if (!string.IsNullOrEmpty(text3))
					{
						return CleanTextStatic(text3);
					}
				}
				FieldInfo field2 = type.GetField("name", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field2 != null)
				{
					string text4 = (field2.GetValue(obj) as string) ?? "";
					if (!string.IsNullOrEmpty(text4))
					{
						return CleanTextStatic(text4);
					}
				}
			}
			catch
			{
			}
			return CleanTextStatic(obj.ToString() ?? "");
		}

		private static string CleanTextStatic(string text)
		{
			if (string.IsNullOrEmpty(text))
			{
				return "";
			}
			if (ContainsCyrillicStatic(text))
			{
				text = TranslateRussianTermStatic(text);
			}
			text = text.Replace("Quest_", "").Replace("quest_", "").Replace("Achievement_", "")
				.Replace("ach_", "")
				.Replace("QUEST_", "")
				.Replace("LOC_", "")
				.Replace("(Clone)", "")
				.Trim();
			text = CleanBoostOrStatNameStatic(text);
			text = ApplySpecificRenamesStatic(text);
			if (text.Length > 0 && !ContainsCyrillicStatic(text))
			{
				return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(text);
			}
			return "Objective";
		}

		private static string CleanBoostOrStatNameStatic(string text)
		{
			if (string.IsNullOrEmpty(text))
			{
				return "";
			}
			string input = text;
			input = Regex.Replace(input, "\\b(common|uncommon|rare|epic|legendary|preset|buff|boost|stat|hero|unit|team|player)\\b", "", RegexOptions.IgnoreCase);
			input = Regex.Replace(input, "([a-z])([A-Z])", "$1 $2");
			input = input.Replace("_", " ").Trim();
			input = Regex.Replace(input, "herolifesteal|lifesteal", "Lifesteal", RegexOptions.IgnoreCase);
			input = Regex.Replace(input, "movementspeed|movespeed", "Movement Speed", RegexOptions.IgnoreCase);
			input = Regex.Replace(input, "attackspeed", "Attack Speed", RegexOptions.IgnoreCase);
			input = Regex.Replace(input, "critchance", "Critical Chance", RegexOptions.IgnoreCase);
			input = Regex.Replace(input, "critdamage", "Critical Damage", RegexOptions.IgnoreCase);
			input = Regex.Replace(input, "healthregen", "Health Regen", RegexOptions.IgnoreCase);
			input = Regex.Replace(input, "maxhp", "Max HP", RegexOptions.IgnoreCase);
			input = Regex.Replace(input, "pickuprange", "Pickup Range", RegexOptions.IgnoreCase);
			input = Regex.Replace(input, "cooldown", "Cooldown Reduction", RegexOptions.IgnoreCase);
			input = Regex.Replace(input, "\\bhero\\b", "", RegexOptions.IgnoreCase);
			input = Regex.Replace(input, "\\s+", " ").Trim();
			if (string.IsNullOrWhiteSpace(input))
			{
				return "Scroll";
			}
			return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(input);
		}

		private static string ApplySpecificRenamesStatic(string text)
		{
			if (string.IsNullOrEmpty(text))
			{
				return text;
			}
			text = Regex.Replace(text, "\\b(Storm\\s*Anchor)\\b", "Cursed Anchor", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, "\\b(Black\\s*Hole)\\b", "Ancient Cube", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, "\\b(Soup)\\b", "Ogre's Stew", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, "\\b(Hammer\\s*Chaos)\\b", "Hammer of Chaos", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, "\\b(Ice\\s*Zone)\\b", "Ice Walk", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, "\\b(Ritual\\s*Niddle|Ritual\\s*Needle|Niddle)\\b", "Needle", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, "\\b(Staff)\\b", "Follower of the Will", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, "\\b(Toxic\\s*Bomb)\\b", "Acid Bomb", RegexOptions.IgnoreCase);
			return text;
		}

		private static string TranslateRussianTermStatic(string text)
		{
			if (string.IsNullOrEmpty(text))
			{
				return "";
			}
			if (text.Contains("Светоч") || text.Contains("светоч"))
			{
				return "Beacon Shrine";
			}
			if (text.Contains("Логово") || text.Contains("логово"))
			{
				return "Lairs";
			}
			if (text.Contains("Босс") || text.Contains("босс"))
			{
				return "Boss";
			}
			if (text.Contains("Убить") || text.Contains("убить"))
			{
				return "Slay Monsters";
			}
			if (text.Contains("Сундук") || text.Contains("сундук"))
			{
				return "Chests";
			}
			if (text.Contains("Выжить") || text.Contains("выжить"))
			{
				return "Survive";
			}
			if (text.Contains("Герой") || text.Contains("герой"))
			{
				return "Hero";
			}
			if (text.Contains("Оружие") || text.Contains("оружие"))
			{
				return "Weapon";
			}
			return "";
		}

		private static int GetIntFieldStatic(object obj, string fieldName, int fallback)
		{
			try
			{
				FieldInfo field = obj.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null)
				{
					return (int)field.GetValue(obj);
				}
			}
			catch
			{
			}
			return fallback;
		}

		private static float GetSingleFieldStatic(object obj, string fieldName, float fallback)
		{
			try
			{
				FieldInfo field = obj.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null)
				{
					return (float)field.GetValue(obj);
				}
			}
			catch
			{
			}
			return fallback;
		}
	}
	public class QuestTrackerUI : MonoBehaviour
	{
		private const int MAIN_WINDOW_ID = 94821;

		private const int HUD_WINDOW_ID = 94822;

		private QuestTrackerDisplayMode _displayMode;

		private HashSet<string> _pinnedQuestIds = new HashSet<string>();

		private List<QuestDataModel> _models = new List<QuestDataModel>();

		private List<QuestDataModel> _sortedModels = new List<QuestDataModel>();

		private Rect _windowRect = new Rect(120f, 90f, 620f, 580f);

		private Vector2 _scrollPos = Vector2.zero;

		private string _searchQuery = "";

		private QuestTab _currentTab;

		private int _selectedCategoryIndex;

		private Rect _hudWindowRect = new Rect(1200f, 50f, 330f, 280f);

		private Vector2 _hudScrollPos = Vector2.zero;

		private bool _isResizingMain;

		private bool _isResizingHUD;

		private Vector2 _dragStartPos;

		private Vector2 _windowStartSize;

		private float _lastFetchTime = -10f;

		private const float REFRESH_INTERVAL = 0.5f;

		private bool _stylesInitialized;

		private GUIStyle? _windowStyle;

		private GUIStyle? _headerTitleStyle;

		private GUIStyle? _headerSubStyle;

		private GUIStyle? _tabStyle;

		private GUIStyle? _tabActiveStyle;

		private GUIStyle? _pillStyle;

		private GUIStyle? _pillActiveStyle;

		private GUIStyle? _cardBoxStyle;

		private GUIStyle? _questTitleStyle;

		private GUIStyle? _questDescStyle;

		private GUIStyle? _questRatioStyle;

		private GUIStyle? _badgeAlmostDoneStyle;

		private GUIStyle? _badgeActiveStyle;

		private GUIStyle? _badgeCompletedStyle;

		private GUIStyle? _badgePinnedStyle;

		private GUIStyle? _pinButtonStyle;

		private GUIStyle? _pinButtonActiveStyle;

		private GUIStyle? _searchStyle;

		private GUIStyle? _footerStyle;

		private GUIStyle? _hudWindowStyle;

		private GUIStyle? _hudTitleStyle;

		private GUIStyle? _hudItemStyle;

		private GUIStyle? _hudItemTitleStyle;

		private GUIStyle? _resizeGripStyle;

		private Texture2D? _bgTexture;

		private Texture2D? _hudBgTexture;

		private Texture2D? _cardBgTexture;

		private Texture2D? _barBgTexture;

		private Texture2D? _barFillAlmostDoneTexture;

		private Texture2D? _barFillActiveTexture;

		private Texture2D? _barFillCompletedTexture;

		private Texture2D? _tabActiveTex;

		private Texture2D? _tabInactiveTex;

		private Texture2D? _tabHoverTex;

		private Texture2D? _pillActiveTex;

		private Texture2D? _pillInactiveTex;

		private Texture2D? _pillHoverTex;

		private Texture2D? _pinActiveTex;

		private Texture2D? _pinInactiveTex;

		private Texture2D? _pinHoverTex;

		private void Start()
		{
			//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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			LoadPinnedQuestIds();
			float num = Plugin.CfgPositionX?.Value ?? 120f;
			float num2 = Plugin.CfgPositionY?.Value ?? 90f;
			float num3 = Plugin.CfgWindowWidth?.Value ?? 620f;
			float num4 = Plugin.CfgWindowHeight?.Value ?? 580f;
			_windowRect = new Rect(num, num2, num3, num4);
			float num5 = Plugin.CfgHUDPositionX?.Value ?? ((float)Screen.width - 340f);
			float num6 = Plugin.CfgHUDPositionY?.Value ?? 50f;
			float num7 = Plugin.CfgHUDWidth?.Value ?? 330f;
			float num8 = Plugin.CfgHUDHeight?.Value ?? 280f;
			_hudWindowRect = new Rect(num5, num6, num7, num8);
			try
			{
				if ((Object)(object)QuestService.I != (Object)null)
				{
					QuestService.I.OnProgressChanged += OnQuestProgressUpdated;
					QuestService.I.OnQuestCompleted += OnQuestProgressUpdated;
				}
			}
			catch
			{
			}
			InitializeModelsOnce();
		}

		private void LoadPinnedQuestIds()
		{
			_pinnedQuestIds.Clear();
			string text = Plugin.CfgPinnedQuestIds?.Value ?? "";
			if (string.IsNullOrEmpty(text))
			{
				return;
			}
			string[] array = text.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
			for (int i = 0; i < array.Length; i++)
			{
				string text2 = array[i].Trim();
				if (!string.IsNullOrEmpty(text2))
				{
					_pinnedQuestIds.Add(text2);
				}
			}
		}

		private void SavePinnedQuestIds()
		{
			string value = string.Join(",", _pinnedQuestIds);
			if (Plugin.CfgPinnedQuestIds != null)
			{
				Plugin.CfgPinnedQuestIds.Value = value;
			}
		}

		private void TogglePinQuest(string questId)
		{
			if (!string.IsNullOrEmpty(questId))
			{
				if (_pinnedQuestIds.Contains(questId))
				{
					_pinnedQuestIds.Remove(questId);
				}
				else
				{
					_pinnedQuestIds.Add(questId);
				}
				SavePinnedQuestIds();
				UpdateAllProgress(forceSort: true);
			}
		}

		private void OnQuestProgressUpdated(QuestDefinition quest)
		{
			_lastFetchTime = -10f;
		}

		private void Update()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			ConfigEntry<KeyCode>? cfgToggleKey = Plugin.CfgToggleKey;
			if (Input.GetKeyDown((KeyCode)((cfgToggleKey == null) ? 113 : ((int)cfgToggleKey.Value))))
			{
				_displayMode = (QuestTrackerDisplayMode)((int)(_displayMode + 1) % 3);
				if (_displayMode == QuestTrackerDisplayMode.BigWindow || _displayMode == QuestTrackerDisplayMode.SmallWindow)
				{
					UpdateAllProgress(forceSort: true);
				}
			}
			if (Time.time - _lastFetchTime >= 0.5f)
			{
				UpdateAllProgress(forceSort: false);
			}
		}

		private void InitializeModelsOnce()
		{
			if (_models.Count > 0)
			{
				return;
			}
			List<QuestDefinition> list = FetchAllQuestDefinitions();
			List<QuestDataModel> list2 = new List<QuestDataModel>();
			foreach (QuestDefinition item in list)
			{
				if ((Object)(object)item != (Object)null)
				{
					list2.Add(QuestDataModel.CreateStaticModel(item, _pinnedQuestIds));
				}
			}
			_models = list2;
			SortModels();
		}

		private void UpdateAllProgress(bool forceSort)
		{
			_lastFetchTime = Time.time;
			if (_models.Count == 0)
			{
				InitializeModelsOnce();
				return;
			}
			bool flag = false;
			foreach (QuestDataModel model in _models)
			{
				if (model.UpdateProgress(_pinnedQuestIds))
				{
					flag = true;
				}
			}
			if (flag || forceSort || _sortedModels.Count != _models.Count)
			{
				SortModels();
			}
		}

		private void SortModels()
		{
			_sortedModels = (from q in _models
				orderby q.IsPinned descending, (q.IsCompleted || q.IsRewarded) ? 1 : 0, q.Percent descending, q.Remaining, q.Title
				select q).ToList();
		}

		private List<QuestDefinition> FetchAllQuestDefinitions()
		{
			List<QuestDefinition> list = new List<QuestDefinition>();
			try
			{
				if ((Object)(object)QuestService.I != (Object)null)
				{
					QuestDatabase databaseFromObject = GetDatabaseFromObject(QuestService.I);
					if ((Object)(object)databaseFromObject != (Object)null && databaseFromObject.Quests != null)
					{
						foreach (QuestDefinition quest in databaseFromObject.Quests)
						{
							if ((Object)(object)quest != (Object)null && !list.Contains(quest))
							{
								list.Add(quest);
							}
						}
					}
				}
			}
			catch
			{
			}
			if (list.Count == 0)
			{
				try
				{
					if ((Object)(object)AchievementService.I != (Object)null)
					{
						QuestDatabase databaseFromObject2 = GetDatabaseFromObject(AchievementService.I);
						if ((Object)(object)databaseFromObject2 != (Object)null && databaseFromObject2.Quests != null)
						{
							foreach (QuestDefinition quest2 in databaseFromObject2.Quests)
							{
								if ((Object)(object)quest2 != (Object)null && !list.Contains(quest2))
								{
									list.Add(quest2);
								}
							}
						}
					}
				}
				catch
				{
				}
			}
			if (list.Count == 0)
			{
				try
				{
					QuestDatabase[] array = Resources.FindObjectsOfTypeAll<QuestDatabase>();
					if (array != null)
					{
						QuestDatabase[] array2 = array;
						foreach (QuestDatabase val in array2)
						{
							if (!((Object)(object)val != (Object)null) || val.Quests == null)
							{
								continue;
							}
							foreach (QuestDefinition quest3 in val.Quests)
							{
								if ((Object)(object)quest3 != (Object)null && !list.Contains(quest3))
								{
									list.Add(quest3);
								}
							}
						}
					}
				}
				catch
				{
				}
			}
			return list;
		}

		private static QuestDatabase? GetDatabaseFromObject(object obj)
		{
			if (obj == null)
			{
				return null;
			}
			try
			{
				Type type = obj.GetType();
				FieldInfo fieldInfo = type.GetField("_database", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? type.GetField("database", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (fieldInfo != null)
				{
					object? value = fieldInfo.GetValue(obj);
					return (QuestDatabase?)((value is QuestDatabase) ? value : null);
				}
				PropertyInfo propertyInfo = type.GetProperty("_database", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? type.GetProperty("database", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (propertyInfo != null)
				{
					object? value2 = propertyInfo.GetValue(obj);
					return (QuestDatabase?)((value2 is QuestDatabase) ? value2 : null);
				}
			}
			catch
			{
			}
			return null;
		}

		private void OnGUI()
		{
			InitStylesIfNeeded();
			HandleGlobalResizeDrag();
			switch (_displayMode)
			{
			case QuestTrackerDisplayMode.SmallWindow:
				DrawDraggableSmallWindow();
				break;
			case QuestTrackerDisplayMode.BigWindow:
				DrawFullMainWindow();
				break;
			case QuestTrackerDisplayMode.Hidden:
				break;
			}
		}

		private void HandleGlobalResizeDrag()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Invalid comparison between Unknown and I4
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Invalid comparison between Unknown and I4
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Invalid comparison between Unknown and I4
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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: Invalid comparison between Unknown and I4
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			Event current = Event.current;
			if (current == null)
			{
				return;
			}
			if (_isResizingMain)
			{
				if ((int)current.type == 3)
				{
					Vector2 val = GUIUtility.GUIToScreenPoint(current.mousePosition) - _dragStartPos;
					((Rect)(ref _windowRect)).width = Mathf.Max(420f, _windowStartSize.x + val.x);
					((Rect)(ref _windowRect)).height = Mathf.Max(320f, _windowStartSize.y + val.y);
					current.Use();
				}
				else if ((int)current.type == 1)
				{
					_isResizingMain = false;
					if (Plugin.CfgWindowWidth != null)
					{
						Plugin.CfgWindowWidth.Value = ((Rect)(ref _windowRect)).width;
					}
					if (Plugin.CfgWindowHeight != null)
					{
						Plugin.CfgWindowHeight.Value = ((Rect)(ref _windowRect)).height;
					}
					current.Use();
				}
			}
			else
			{
				if (!_isResizingHUD)
				{
					return;
				}
				if ((int)current.type == 3)
				{
					Vector2 val2 = GUIUtility.GUIToScreenPoint(current.mousePosition) - _dragStartPos;
					((Rect)(ref _hudWindowRect)).width = Mathf.Max(260f, _windowStartSize.x + val2.x);
					((Rect)(ref _hudWindowRect)).height = Mathf.Max(150f, _windowStartSize.y + val2.y);
					current.Use();
				}
				else if ((int)current.type == 1)
				{
					_isResizingHUD = false;
					if (Plugin.CfgHUDWidth != null)
					{
						Plugin.CfgHUDWidth.Value = ((Rect)(ref _hudWindowRect)).width;
					}
					if (Plugin.CfgHUDHeight != null)
					{
						Plugin.CfgHUDHeight.Value = ((Rect)(ref _hudWindowRect)).height;
					}
					current.Use();
				}
			}
		}

		private void DrawDraggableSmallWindow()
		{
			//IL_0007: 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_0028: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Invalid comparison between Unknown and I4
			_hudWindowRect = GUI.Window(94822, _hudWindowRect, new WindowFunction(DrawCompactHUDContent), "", _hudWindowStyle);
			((Rect)(ref _hudWindowRect)).x = Mathf.Clamp(((Rect)(ref _hudWindowRect)).x, 0f, (float)Screen.width - ((Rect)(ref _hudWindowRect)).width);
			((Rect)(ref _hudWindowRect)).y = Mathf.Clamp(((Rect)(ref _hudWindowRect)).y, 0f, (float)Screen.height - ((Rect)(ref _hudWindowRect)).height);
			if ((int)Event.current.type == 1)
			{
				if (Plugin.CfgHUDPositionX != null)
				{
					Plugin.CfgHUDPositionX.Value = ((Rect)(ref _hudWindowRect)).x;
				}
				if (Plugin.CfgHUDPositionY != null)
				{
					Plugin.CfgHUDPositionY.Value = ((Rect)(ref _hudWindowRect)).y;
				}
			}
		}

		private void DrawCompactHUDContent(int windowID)
		{
			//IL_00e8: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Invalid comparison between Unknown and I4
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			float threshold = Plugin.CfgAlmostDoneThreshold?.Value ?? 0.5f;
			int count = Plugin.CfgCompactHUDMaxItems?.Value ?? 5;
			List<QuestDataModel> first = _sortedModels.Where((QuestDataModel q) => q.IsPinned && !q.IsCompleted && !q.IsRewarded).ToList();
			List<QuestDataModel> second = _sortedModels.Where((QuestDataModel q) => !q.IsPinned && !q.IsCompleted && !q.IsRewarded && q.Percent >= threshold).ToList();
			List<QuestDataModel> list = first.Concat(second).Take(count).ToList();
			float width = ((Rect)(ref _hudWindowRect)).width;
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("PINNED & ALMOST DONE", _hudTitleStyle, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUILayout.Label("[Q] Cycle", _footerStyle, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.Space(6f);
			_hudScrollPos = GUILayout.BeginScrollView(_hudScrollPos, false, true, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
			if (list.Count == 0)
			{
				GUILayout.Label("No pinned or almost done quests!", _hudItemStyle, Array.Empty<GUILayoutOption>());
			}
			else
			{
				foreach (QuestDataModel item in list)
				{
					GUILayout.BeginVertical(_cardBoxStyle, Array.Empty<GUILayoutOption>());
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					if (item.IsPinned)
					{
						GUILayout.Label("PINNED", _badgePinnedStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
						{
							GUILayout.ExpandWidth(false),
							GUILayout.Height(16f)
						});
						GUILayout.Space(4f);
					}
					GUILayout.Label(item.Title, _hudItemTitleStyle, Array.Empty<GUILayoutOption>());
					GUILayout.FlexibleSpace();
					GUILayout.Label($"{item.Percent * 100f:F0}%", _hudItemTitleStyle, Array.Empty<GUILayoutOption>());
					GUILayout.EndHorizontal();
					GUILayout.Label(item.CachedDescription, _hudItemStyle, Array.Empty<GUILayoutOption>());
					GUILayout.Space(2f);
					Rect rect = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.Height(6f),
						GUILayout.ExpandWidth(true)
					});
					if ((int)Event.current.type == 7)
					{
						GUI.DrawTexture(rect, (Texture)(object)_barBgTexture);
						GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width * item.Percent, ((Rect)(ref rect)).height), (Texture)(object)_barFillAlmostDoneTexture);
					}
					GUILayout.EndVertical();
					GUILayout.Space(3f);
				}
			}
			GUILayout.EndScrollView();
			GUI.DragWindow(new Rect(0f, 0f, width - 20f, 30f));
			DrawWindowResizeGrip(ref _hudWindowRect, ref _isResizingHUD);
		}

		private void DrawFullMainWindow()
		{
			//IL_0007: 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_0028: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Invalid comparison between Unknown and I4
			_windowRect = GUI.Window(94821, _windowRect, new WindowFunction(DrawMainWindowContent), "", _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 ((int)Event.current.type == 1)
			{
				if (Plugin.CfgPositionX != null)
				{
					Plugin.CfgPositionX.Value = ((Rect)(ref _windowRect)).x;
				}
				if (Plugin.CfgPositionY != null)
				{
					Plugin.CfgPositionY.Value = ((Rect)(ref _windowRect)).y;
				}
			}
		}

		private void DrawMainWindowContent(int windowID)
		{
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			float width = ((Rect)(ref _windowRect)).width;
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			GUILayout.Label("QUEST TRACKER", _headerTitleStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Label("Real-time In-Game Quest Progress • Press [Q] to Cycle Views", _headerSubStyle, Array.Empty<GUILayoutOption>());
			GUILayout.EndVertical();
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
			GUILayout.Space(8f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Search:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
			_searchQuery = GUILayout.TextField(_searchQuery, _searchStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(24f) });
			if (!string.IsNullOrEmpty(_searchQuery) && GUILayout.Button("Clear", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(50f),
				GUILayout.Height(24f)
			}))
			{
				_searchQuery = "";
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(8f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (DrawTabButton("ALMOST DONE", QuestTab.AlmostDone))
			{
				_currentTab = QuestTab.AlmostDone;
			}
			if (DrawTabButton("ALL QUESTS", QuestTab.All))
			{
				_currentTab = QuestTab.All;
			}
			if (DrawTabButton("IN PROGRESS", QuestTab.InProgress))
			{
				_currentTab = QuestTab.InProgress;
			}
			if (DrawTabButton("COMPLETED", QuestTab.Completed))
			{
				_currentTab = QuestTab.Completed;
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(6f);
			string[] array = new string[7] { "All", "Heroes", "Weapons", "Scrolls", "Artifacts", "Map", "General" };
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			for (int i = 0; i < array.Length; i++)
			{
				GUIStyle val = ((_selectedCategoryIndex == i) ? _pillActiveStyle : _pillStyle);
				if (GUILayout.Button(array[i], val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(22f) }))
				{
					_selectedCategoryIndex = i;
				}
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(8f);
			float threshold = Plugin.CfgAlmostDoneThreshold?.Value ?? 0.5f;
			bool hideCompletedInAlmostDone = Plugin.CfgHideCompletedInAlmostDone?.Value ?? true;
			List<QuestDataModel> list = _sortedModels.Where(delegate(QuestDataModel q)
			{
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: Unknown result type (might be due to invalid IL or missing references)
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				switch (_currentTab)
				{
				case QuestTab.AlmostDone:
					if (hideCompletedInAlmostDone && (q.IsCompleted || q.IsRewarded))
					{
						return false;
					}
					if (!q.IsPinned && q.Percent < threshold)
					{
						return false;
					}
					break;
				case QuestTab.InProgress:
					if (q.IsCompleted || q.IsRewarded)
					{
						return false;
					}
					break;
				case QuestTab.Completed:
					if (!q.IsCompleted && !q.IsRewarded)
					{
						return false;
					}
					break;
				}
				if (_selectedCategoryIndex > 0)
				{
					QuestCategory val2 = (QuestCategory)(_selectedCategoryIndex - 1);
					if (q.Category != val2)
					{
						return false;
					}
				}
				if (!string.IsNullOrEmpty(_searchQuery))
				{
					string value = _searchQuery.ToLowerInvariant();
					bool num2 = q.Title.ToLowerInvariant().Contains(value);
					bool flag = q.CachedDescription.ToLowerInvariant().Contains(value);
					bool flag2 = q.QuestId.ToLowerInvariant().Contains(value);
					if (!num2 && !flag && !flag2)
					{
						return false;
					}
				}
				return true;
			}).ToList();
			int count = list.Count;
			int num = _sortedModels.Count((QuestDataModel q) => q.IsAlmostDone(threshold));
			int count2 = _pinnedQuestIds.Count;
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label($"Displaying {count} Quests  •  Pinned: {count2}  •  Almost Done: {num}", _footerStyle, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUILayout.Label("Press [Q] to cycle  •  Drag ◢ corner to resize", _footerStyle, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.Space(6f);
			_scrollPos = GUILayout.BeginScrollView(_scrollPos, false, true, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
			if (list.Count == 0)
			{
				GUILayout.Space(40f);
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				GUILayout.FlexibleSpace();
				GUILayout.Label("No quests match your current filter.", _questTitleStyle, Array.Empty<GUILayoutOption>());
				GUILayout.FlexibleSpace();
				GUILayout.EndHorizontal();
			}
			else
			{
				foreach (QuestDataModel item in list)
				{
					DrawPrettyQuestCard(item, threshold);
					GUILayout.Space(6f);
				}
			}
			GUILayout.EndScrollView();
			GUI.DragWindow(new Rect(0f, 0f, width - 20f, 40f));
			DrawWindowResizeGrip(ref _windowRect, ref _isResizingMain);
		}

		private void DrawWindowResizeGrip(ref Rect windowRect, ref bool isResizing)
		{
			//IL_002b: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			float num = 22f;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref windowRect)).width - num - 2f, ((Rect)(ref windowRect)).height - num - 2f, num, num);
			GUI.Label(val, "◢", _resizeGripStyle);
			Event current = Event.current;
			if ((int)current.type == 0 && ((Rect)(ref val)).Contains(current.mousePosition))
			{
				isResizing = true;
				_dragStartPos = GUIUtility.GUIToScreenPoint(current.mousePosition);
				_windowStartSize = new Vector2(((Rect)(ref windowRect)).width, ((Rect)(ref windowRect)).height);
				current.Use();
			}
		}

		private bool DrawTabButton(string text, QuestTab tab)
		{
			GUIStyle val = ((_currentTab == tab) ? _tabActiveStyle : _tabStyle);
			return GUILayout.Button(text, val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) });
		}

		private void DrawPrettyQuestCard(QuestDataModel quest, float threshold)
		{
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Invalid comparison between Unknown and I4
			//IL_025b: 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)
			GUILayout.BeginVertical(_cardBoxStyle, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (quest.IsPinned)
			{
				GUILayout.Label("PINNED", _badgePinnedStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.ExpandWidth(false),
					GUILayout.Height(20f)
				});
				GUILayout.Space(4f);
			}
			if (quest.IsCompleted || quest.IsRewarded)
			{
				GUILayout.Label("COMPLETED", _badgeCompletedStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.ExpandWidth(false),
					GUILayout.Height(20f)
				});
			}
			else if (quest.Percent >= threshold)
			{
				GUILayout.Label($"ALMOST DONE ({quest.Percent * 100f:F0}%)", _badgeAlmostDoneStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.ExpandWidth(false),
					GUILayout.Height(20f)
				});
			}
			else
			{
				GUILayout.Label($"ACTIVE ({quest.Percent * 100f:F0}%)", _badgeActiveStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.ExpandWidth(false),
					GUILayout.Height(20f)
				});
			}
			GUILayout.Space(6f);
			GUILayout.Label(quest.Title, _questTitleStyle, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUIStyle val = (quest.IsPinned ? _pinButtonActiveStyle : _pinButtonStyle);
			if (GUILayout.Button(quest.IsPinned ? "[PINNED]" : "[PIN]", val, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(65f),
				GUILayout.Height(20f)
			}))
			{
				TogglePinQuest(quest.QuestId);
			}
			GUILayout.Space(8f);
			GUILayout.Label($"{quest.CurrentProgress} / {quest.RequiredProgress}", _questRatioStyle, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.Space(3f);
			if (!string.IsNullOrEmpty(quest.CachedDescription))
			{
				GUILayout.Label(quest.CachedDescription, _questDescStyle, Array.Empty<GUILayoutOption>());
				GUILayout.Space(4f);
			}
			Rect rect = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Height(8f),
				GUILayout.ExpandWidth(true)
			});
			if ((int)Event.current.type == 7)
			{
				GUI.DrawTexture(rect, (Texture)(object)_barBgTexture);
				float num = ((Rect)(ref rect)).width * quest.Percent;
				if (num > 0f)
				{
					Rect val2 = new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, num, ((Rect)(ref rect)).height);
					Texture2D val3 = ((quest.IsCompleted || quest.IsRewarded) ? _barFillCompletedTexture : ((quest.Percent >= threshold) ? _barFillAlmostDoneTexture : _barFillActiveTexture));
					GUI.DrawTexture(val2, (Texture)(object)val3);
				}
			}
			GUILayout.EndVertical();
		}

		private void InitStylesIfNeeded()
		{
			//IL_00e1: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: 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_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Expected O, but got Unknown
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Expected O, but got Unknown
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_0468: Unknown result type (might be due to invalid IL or missing references)
			//IL_048f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: 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_051e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0528: Expected O, but got Unknown
			//IL_0562: Unknown result type (might be due to invalid IL or missing references)
			//IL_056c: Expected O, but got Unknown
			//IL_0577: Unknown result type (might be due to invalid IL or missing references)
			//IL_0581: Expected O, but got Unknown
			//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c3: Expected O, but got Unknown
			//IL_05ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d8: Expected O, but got Unknown
			//IL_0610: Unknown result type (might be due to invalid IL or missing references)
			//IL_0625: Unknown result type (might be due to invalid IL or missing references)
			//IL_062f: Expected O, but got Unknown
			//IL_065b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0670: Unknown result type (might be due to invalid IL or missing references)
			//IL_067a: Expected O, but got Unknown
			//IL_0692: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b0: Expected O, but got Unknown
			//IL_06d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0703: Unknown result type (might be due to invalid IL or missing references)
			//IL_0708: Unknown result type (might be due to invalid IL or missing references)
			//IL_0742: Unknown result type (might be due to invalid IL or missing references)
			//IL_0747: Unknown result type (might be due to invalid IL or missing references)
			//IL_076d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0772: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_07dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0803: Expected O, but got Unknown
			//IL_0825: Unknown result type (might be due to invalid IL or missing references)
			//IL_082f: Expected O, but got Unknown
			//IL_083a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0844: Expected O, but got Unknown
			//IL_0868: Unknown result type (might be due to invalid IL or missing references)
			//IL_087d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0887: Expected O, but got Unknown
			//IL_08bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08de: Expected O, but got Unknown
			//IL_090a: Unknown result type (might be due to invalid IL or missing references)
			//IL_091f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0929: Expected O, but got Unknown
			//IL_0955: Unknown result type (might be due to invalid IL or missing references)
			//IL_0975: Unknown result type (might be due to invalid IL or missing references)
			//IL_097a: Unknown result type (might be due to invalid IL or missing references)
			//IL_099f: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a12: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1c: Expected O, but got Unknown
			//IL_0a54: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a69: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a73: Expected O, but got Unknown
			//IL_0a97: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab6: Expected O, but got Unknown
			//IL_0ae2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b01: Expected O, but got Unknown
			//IL_0b39: Unknown result type (might be due to invalid IL or missing references)
			if (!_stylesInitialized || !((Object)(object)_bgTexture != (Object)null) || !((Object)(object)_barFillAlmostDoneTexture != (Object)null) || !((Object)(object)_cardBgTexture != (Object)null) || !((Object)(object)_tabActiveTex != (Object)null) || !((Object)(object)_pinActiveTex != (Object)null))
			{
				_stylesInitialized = true;
				Color col = default(Color);
				((Color)(ref col))..ctor(0.06f, 0.08f, 0.12f, 0.95f);
				Color col2 = default(Color);
				((Color)(ref col2))..ctor(0.05f, 0.07f, 0.1f, 0.92f);
				Color bg = default(Color);
				((Color)(ref bg))..ctor(0.09f, 0.11f, 0.16f, 0.92f);
				Color border = default(Color);
				((Color)(ref border))..ctor(0.18f, 0.22f, 0.3f, 0.8f);
				Color col3 = default(Color);
				((Color)(ref col3))..ctor(0.14f, 0.17f, 0.23f, 1f);
				_bgTexture = MakeTex(2, 2, col);
				_hudBgTexture = MakeTex(2, 2, col2);
				_cardBgTexture = MakeBorderTex(4, 4, bg, border, 1);
				_barBgTexture = MakeTex(2, 2, col3);
				_barFillAlmostDoneTexture = MakeGradientTex(2, 16, new Color(1f, 0.75f, 0.15f, 1f), new Color(0.95f, 0.5f, 0.05f, 1f));
				_barFillActiveTexture = MakeGradientTex(2, 16, new Color(0.1f, 0.7f, 1f, 1f), new Color(0.05f, 0.45f, 0.85f, 1f));
				_barFillCompletedTexture = MakeGradientTex(2, 16, new Color(0.15f, 0.85f, 0.4f, 1f), new Color(0.05f, 0.6f, 0.25f, 1f));
				Color col4 = default(Color);
				((Color)(ref col4))..ctor(0.08f, 0.1f, 0.16f, 0.85f);
				Color col5 = default(Color);
				((Color)(ref col5))..ctor(0.24f, 0.35f, 0.52f, 0.9f);
				Color col6 = default(Color);
				((Color)(ref col6))..ctor(0.95f, 0.72f, 0.15f, 1f);
				Texture2D background = MakeTex(2, 2, col4);
				Texture2D background2 = MakeTex(2, 2, col5);
				Texture2D background3 = MakeTex(2, 2, col6);
				GUI.skin.verticalScrollbar.normal.background = background;
				GUI.skin.verticalScrollbar.hover.background = background;
				GUI.skin.verticalScrollbar.active.background = background;
				GUI.skin.verticalScrollbar.fixedWidth = 14f;
				GUI.skin.verticalScrollbar.margin = new RectOffset(0, 0, 0, 0);
				GUI.skin.verticalScrollbar.padding = new RectOffset(1, 1, 1, 1);
				GUI.skin.verticalScrollbarThumb.normal.background = background2;
				GUI.skin.verticalScrollbarThumb.hover.background = background3;
				GUI.skin.verticalScrollbarThumb.active.background = background3;
				GUI.skin.verticalScrollbarThumb.fixedWidth = 12f;
				GUI.skin.verticalScrollbarUpButton.fixedWidth = 0f;
				GUI.skin.verticalScrollbarUpButton.fixedHeight = 0f;
				GUI.skin.verticalScrollbarDownButton.fixedWidth = 0f;
				GUI.skin.verticalScrollbarDownButton.fixedHeight = 0f;
				_tabInactiveTex = MakeTex(2, 2, new Color(0.11f, 0.13f, 0.19f, 0.9f));
				_tabHoverTex = MakeGradientTex(2, 16, new Color(0.18f, 0.24f, 0.36f, 1f), new Color(0.14f, 0.18f, 0.28f, 1f));
				_tabActiveTex = MakeGradientTex(2, 16, new Color(0.2f, 0.45f, 0.85f, 1f), new Color(0.12f, 0.3f, 0.65f, 1f));
				_pillInactiveTex = MakeTex(2, 2, new Color(0.11f, 0.13f, 0.18f, 0.7f));
				_pillHoverTex = MakeTex(2, 2, new Color(0.2f, 0.26f, 0.38f, 0.9f));
				_pillActiveTex = MakeTex(2, 2, new Color(0.95f, 0.72f, 0.15f, 0.95f));
				_pinInactiveTex = MakeTex(2, 2, new Color(0.14f, 0.18f, 0.26f, 0.8f));
				_pinHoverTex = MakeTex(2, 2, new Color(0.3f, 0.4f, 0.6f, 0.95f));
				_pinActiveTex = MakeTex(2, 2, new Color(0.95f, 0.65f, 0.1f, 0.95f));
				_windowStyle = new GUIStyle(GUI.skin.window);
				_windowStyle.normal.background = _bgTexture;
				_windowStyle.onNormal.background = _bgTexture;
				_windowStyle.padding = new RectOffset(14, 14, 12, 14);
				_hudWindowStyle = new GUIStyle(GUI.skin.window);
				_hudWindowStyle.normal.background = _hudBgTexture;
				_hudWindowStyle.onNormal.background = _hudBgTexture;
				_hudWindowStyle.padding = new RectOffset(10, 10, 8, 8);
				_headerTitleStyle = new GUIStyle(GUI.skin.label);
				_headerTitleStyle.fontSize = 17;
				_headerTitleStyle.fontStyle = (FontStyle)1;
				_headerTitleStyle.normal.textColor = new Color(1f, 0.82f, 0.25f, 1f);
				_headerSubStyle = new GUIStyle(GUI.skin.label);
				_headerSubStyle.fontSize = 11;
				_headerSubStyle.normal.textColor = new Color(0.68f, 0.74f, 0.82f, 1f);
				_searchStyle = new GUIStyle(GUI.skin.textField);
				_searchStyle.fontSize = 12;
				_searchStyle.normal.textColor = Color.white;
				_searchStyle.padding = new RectOffset(6, 6, 2, 2);
				_tabStyle = CreateCustomStyle(_tabInactiveTex, _tabHoverTex, _tabActiveTex, new Color(0.72f, 0.76f, 0.84f, 1f), Color.white, 12, isBold: false);
				_tabActiveStyle = CreateCustomStyle(_tabActiveTex, _tabActiveTex, _tabActiveTex, Color.white, Color.white, 12, isBold: true);
				_pillStyle = CreateCustomStyle(_pillInactiveTex, _pillHoverTex, _pillActiveTex, new Color(0.72f, 0.76f, 0.84f, 1f), Color.white, 11, isBold: false);
				_pillActiveStyle = CreateCustomStyle(_pillActiveTex, _pillActiveTex, _pillActiveTex, Color.black, Color.black, 11, isBold: true);
				_pinButtonStyle = CreateCustomStyle(_pinInactiveTex, _pinHoverTex, _pinActiveTex, new Color(0.75f, 0.8f, 0.9f, 1f), Color.white, 10, isBold: false);
				_pinButtonActiveStyle = CreateCustomStyle(_pinActiveTex, _pinActiveTex, _pinActiveTex, Color.black, Color.black, 10, isBold: true);
				_cardBoxStyle = new GUIStyle(GUI.skin.box);
				_cardBoxStyle.normal.background = _cardBgTexture;
				_cardBoxStyle.padding = new RectOffset(10, 10, 8, 8);
				_questTitleStyle = new GUIStyle(GUI.skin.label);
				_questTitleStyle.fontSize = 13;
				_questTitleStyle.fontStyle = (FontStyle)1;
				_questTitleStyle.normal.textColor = Color.white;
				_questRatioStyle = new GUIStyle(GUI.skin.label);
				_questRatioStyle.fontSize = 12;
				_questRatioStyle.fontStyle = (FontStyle)1;
				_questRatioStyle.normal.textColor = new Color(1f, 0.82f, 0.25f, 1f);
				_questDescStyle = new GUIStyle(GUI.skin.label);
				_questDescStyle.fontSize = 11;
				_questDescStyle.normal.textColor = new Color(0.78f, 0.82f, 0.88f, 1f);
				_footerStyle = new GUIStyle(GUI.skin.label);
				_footerStyle.fontSize = 10;
				_footerStyle.normal.textColor = new Color(0.65f, 0.7f, 0.78f, 1f);
				_badgeAlmostDoneStyle = MakeBadgeStyle(new Color(1f, 0.65f, 0.1f, 1f), Color.black);
				_badgeActiveStyle = MakeBadgeStyle(new Color(0.12f, 0.5f, 0.9f, 1f), Color.white);
				_badgeCompletedStyle = MakeBadgeStyle(new Color(0.15f, 0.75f, 0.35f, 1f), Color.black);
				_badgePinnedStyle = MakeBadgeStyle(new Color(0.95f, 0.65f, 0.1f, 1f), Color.black);
				_hudTitleStyle = new GUIStyle(GUI.skin.label);
				_hudTitleStyle.fontSize = 11;
				_hudTitleStyle.fontStyle = (FontStyle)1;
				_hudTitleStyle.normal.textColor = new Color(1f, 0.82f, 0.25f, 1f);
				_hudItemTitleStyle = new GUIStyle(GUI.skin.label);
				_hudItemTitleStyle.fontSize = 11;
				_hudItemTitleStyle.fontStyle = (FontStyle)1;
				_hudItemTitleStyle.normal.textColor = Color.white;
				_hudItemStyle = new GUIStyle(GUI.skin.label);
				_hudItemStyle.fontSize = 10;
				_hudItemStyle.normal.textColor = new Color(0.85f, 0.88f, 0.92f, 1f);
				_resizeGripStyle = new GUIStyle(GUI.skin.label);
				_resizeGripStyle.fontSize = 14;
				_resizeGripStyle.alignment = (TextAnchor)8;
				_resizeGripStyle.normal.textColor = new Color(0.65f, 0.72f, 0.85f, 0.8f);
			}
		}

		private GUIStyle CreateCustomStyle(Texture2D normalTex, Texture2D hoverTex, Texture2D activeTex, Color normalTextCol, Color hoverTextCol, int fontSize, bool isBold)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_005e: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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)
			GUIStyle val = new GUIStyle(GUI.skin.button);
			val.normal.background = normalTex;
			val.hover.background = hoverTex;
			val.active.background = activeTex;
			val.onNormal.background = normalTex;
			val.onHover.background = hoverTex;
			val.onActive.background = activeTex;
			val.normal.textColor = normalTextCol;
			val.hover.textColor = hoverTextCol;
			val.active.textColor = hoverTextCol;
			val.onNormal.textColor = normalTextCol;
			val.onHover.textColor = hoverTextCol;
			val.onActive.textColor = hoverTextCol;
			val.fontSize = fontSize;
			if (isBold)
			{
				val.fontStyle = (FontStyle)1;
			}
			val.alignment = (TextAnchor)4;
			val.wordWrap = false;
			return val;
		}

		private GUIStyle MakeBadgeStyle(Color bg, Color text)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			GUIStyle val = new GUIStyle(GUI.skin.label);
			val.normal.background = MakeTex(2, 2, bg);
			val.normal.textColor = text;
			val.fontSize = 10;
			val.fontStyle = (FontStyle)1;
			val.alignment = (TextAnchor)4;
			val.padding = new RectOffset(6, 6, 2, 2);
			val.wordWrap = false;
			val.clipping = (TextClipping)1;
			return val;
		}

		private Texture2D MakeTex(int width, int height, Color col)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(width, height);
			((Object)val).hideFlags = (HideFlags)32;
			Color[] array = (Color[])(object)new Color[width * height];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = col;
			}
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		private Texture2D MakeGradientTex(int width, int height, Color top, Color bottom)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0025: 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)
			//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)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(width, height);
			((Object)val).hideFlags = (HideFlags)32;
			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(bottom, top, num);
				for (int j = 0; j < width; j++)
				{
					array[i * width + j] = val2;
				}
			}
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		private Texture2D MakeBorderTex(int width, int height, Color bg, Color border, int borderWidth)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(width, height);
			((Object)val).hideFlags = (HideFlags)32;
			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 ? border : bg);
				}
			}
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		private void OnDestroy()
		{
			try
			{
				if ((Object)(object)QuestService.I != (Object)null)
				{
					QuestService.I.OnProgressChanged -= OnQuestProgressUpdated;
					QuestService.I.OnQuestCompleted -= OnQuestProgressUpdated;
				}
			}
			catch
			{
			}
		}
	}
}