Decompiled source of WhereIsThing v0.1.2

WhereIsThing.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Peak;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("WhereIsThing")]
[assembly: AssemblyDescription("Shows the live locations of selected dropped items in PEAK.")]
[assembly: AssemblyProduct("WhereIsThing")]
[assembly: ComVisible(false)]
[assembly: Guid("f9d08f85-c8c7-4b51-97f9-f3a2f32f6f8a")]
[assembly: AssemblyFileVersion("0.1.2.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.1.2.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace WhereIsThing
{
	internal static class FontHelper
	{
		private const string ChineseSample = "物品在哪简体中文急救箱绷带药用根茎灵药菇";

		private static TMP_FontAsset _cached;

		public static TMP_FontAsset GetChineseCapable()
		{
			if (IsChineseCapable(_cached))
			{
				return _cached;
			}
			try
			{
				TMP_FontAsset val = FindPreferredFont();
				if ((Object)(object)val != (Object)null)
				{
					_cached = val;
					return val;
				}
			}
			catch
			{
			}
			return null;
		}

		public static void InvalidateCache()
		{
			_cached = null;
		}

		public static bool IsChineseCapable(TMP_FontAsset font)
		{
			return IsChineseCapable(font, new HashSet<TMP_FontAsset>());
		}

		public static TMP_FontAsset GetLabelFont(ThingLabelFont choice)
		{
			string source;
			TMP_FontAsset val = GetFontForChoice(choice, out source);
			if ((Object)(object)val == (Object)null)
			{
				val = GetGameDefaultFont();
			}
			return val;
		}

		private static bool IsChineseCapable(TMP_FontAsset font, HashSet<TMP_FontAsset> visited)
		{
			if ((Object)(object)font == (Object)null || !visited.Add(font))
			{
				return false;
			}
			try
			{
				if (font.HasCharacters("物品在哪简体中文急救箱绷带药用根茎灵药菇"))
				{
					return true;
				}
			}
			catch
			{
			}
			if (font.fallbackFontAssetTable == null)
			{
				return false;
			}
			foreach (TMP_FontAsset item in font.fallbackFontAssetTable)
			{
				if ((Object)(object)item != (Object)null && item != font && IsChineseCapable(item, visited))
				{
					return true;
				}
			}
			return false;
		}

		private static TMP_FontAsset FindPreferredFont()
		{
			TMP_FontAsset[] candidateFonts = GetCandidateFonts();
			foreach (TMP_FontAsset val in candidateFonts)
			{
				if (IsChineseCapable(val))
				{
					return val;
				}
			}
			candidateFonts = GetCandidateFonts();
			foreach (TMP_FontAsset val2 in candidateFonts)
			{
				if ((Object)(object)val2 != (Object)null)
				{
					return val2;
				}
			}
			return null;
		}

		private static TMP_FontAsset GetFontForChoice(ThingLabelFont choice, out string source)
		{
			switch (choice)
			{
			case ThingLabelFont.TmpDefault:
				source = "TmpDefault";
				return TMP_Settings.defaultFontAsset;
			case ThingLabelFont.KoreanBinggrae:
				source = "KoreanBinggrae";
				return FindFontAsset("Korean Binggrae-Bold SDF");
			case ThingLabelFont.Crazk:
				source = "Crazk";
				return FindFontAsset("CRAZK___ SDF");
			case ThingLabelFont.Auto:
				source = "Auto(GameDefault)";
				return GetGameDefaultFont() ?? TMP_Settings.defaultFontAsset;
			default:
				source = "GameDefault";
				return GetGameDefaultFont();
			}
		}

		private static TMP_FontAsset GetGameDefaultFont()
		{
			if (!((Object)(object)FontFallbackSwapper.instance == (Object)null))
			{
				return FontFallbackSwapper.instance.mainBaseFont;
			}
			return null;
		}

		private static TMP_FontAsset FindFontAsset(string assetName)
		{
			IEnumerable<TMP_FontAsset> first = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
			IEnumerable<TMP_FontAsset> second;
			try
			{
				second = Resources.LoadAll<TMP_FontAsset>(string.Empty);
			}
			catch
			{
				second = Enumerable.Empty<TMP_FontAsset>();
			}
			return (from font in first.Concat(second)
				where (Object)(object)font != (Object)null
				select font).Distinct().FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset font) => string.Equals(NormalizeFontName(((Object)font).name), NormalizeFontName(assetName), StringComparison.OrdinalIgnoreCase)));
		}

		private static string NormalizeFontName(string name)
		{
			if (string.IsNullOrEmpty(name))
			{
				return string.Empty;
			}
			int num = name.IndexOf(" (Clone)", StringComparison.OrdinalIgnoreCase);
			return ((num < 0) ? name : name.Substring(0, num)).Trim();
		}

		private static TMP_FontAsset[] GetCandidateFonts()
		{
			List<TMP_FontAsset> list = new List<TMP_FontAsset>();
			TMP_FontAsset gameDefaultFont = GetGameDefaultFont();
			if ((Object)(object)gameDefaultFont != (Object)null)
			{
				list.Add(gameDefaultFont);
			}
			TextMeshProUGUI val = Object.FindAnyObjectByType<TextMeshProUGUI>();
			if ((Object)(object)val != (Object)null && (Object)(object)((TMP_Text)val).font != (Object)null)
			{
				list.Add(((TMP_Text)val).font);
			}
			if ((Object)(object)TMP_Settings.defaultFontAsset != (Object)null)
			{
				list.Add(TMP_Settings.defaultFontAsset);
			}
			TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
			foreach (TMP_FontAsset val2 in array)
			{
				if ((Object)(object)val2 != (Object)null)
				{
					list.Add(val2);
				}
			}
			return list.Distinct().ToArray();
		}
	}
	internal static class ModConfigLocalization
	{
		private const string ConfigFileName = "com.wuyachiyu.WhereIsThing.cfg";

		private static readonly FieldInfo DescriptionBackingField = typeof(ConfigDescription).GetField("<Description>k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic);

		private static bool IsChinese
		{
			get
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Invalid comparison between Unknown and I4
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Invalid comparison between Unknown and I4
				if ((int)LocalizedText.CURRENT_LANGUAGE != 9)
				{
					return (int)LocalizedText.CURRENT_LANGUAGE == 10;
				}
				return true;
			}
		}

		public static void PatchDisplayNames(Harmony harmony)
		{
			ModConfigUiAdapter.Install(harmony, "com.wuyachiyu.WhereIsThing.cfg", "WhereIsThing", (ConfigEntryBase entry) => GetLocalizedConfigText(entry.Definition.Section, entry.Definition.Key), GetLocalizedToken, delegate(string message)
			{
				Debug.LogWarning((object)("[WhereIsThing] " + message));
			});
		}

		public static void RefreshVisibleUi()
		{
			ModConfigUiAdapter.RefreshVisibleUi();
		}

		public static void Shutdown()
		{
			ModConfigUiAdapter.Shutdown();
		}

		public static void ApplyLocalizedDescriptions(IEnumerable<ConfigEntryBase> entries)
		{
			if (entries == null)
			{
				return;
			}
			foreach (ConfigEntryBase item in entries.Where((ConfigEntryBase entry) => entry != null))
			{
				if (IsKnownConfigKey(item.Definition.Section, item.Definition.Key))
				{
					SetDescription(item, GetLocalizedDescription(item.Definition.Key));
				}
			}
		}

		private static string GetLocalizedConfigText(string section, string key)
		{
			string canonicalToken = GetCanonicalToken((section == null) ? string.Empty : section.Replace(" ", string.Empty));
			string canonicalToken2 = GetCanonicalToken((key == null) ? string.Empty : key.Replace(" ", string.Empty));
			if (string.IsNullOrEmpty(canonicalToken2))
			{
				return null;
			}
			if (!IsKnownConfigKey(canonicalToken, canonicalToken2))
			{
				return null;
			}
			return GetLocalizedToken(canonicalToken2);
		}

		private static bool IsKnownConfigKey(string section, string key)
		{
			switch (section)
			{
			case "General":
				switch (key)
				{
				default:
					return key == "DisplayDurationSeconds";
				case "Enabled":
				case "ScanKey":
				case "WindowKey":
				case "ScanMode":
					return true;
				}
			case "Display":
				switch (key)
				{
				default:
					return key == "ShowOwnerNames";
				case "NameLanguage":
				case "MaxDistance":
				case "FontSize":
				case "LabelFont":
				case "ShowOffscreenDirection":
					return true;
				}
			case "Presets":
				switch (key)
				{
				default:
					return key == "ShareMode";
				case "PresetSchemaVersion":
				case "LocalPresets":
				case "ActiveLocalPresetId":
				case "SelectedSharedPresetId":
					return true;
				}
			case "Selection":
				switch (key)
				{
				default:
					return key == "LocationScopes";
				case "SelectedItemIds":
				case "SelectedLuggage":
				case "SelectedLuggageTypes":
				case "SelectedSceneTargetTypes":
					return true;
				}
			default:
				return false;
			}
		}

		private static string GetCanonicalToken(string value)
		{
			if (string.IsNullOrEmpty(value))
			{
				return null;
			}
			return value switch
			{
				"物品在哪" => "WhereIsThing", 
				"常规" => "General", 
				"显示" => "Display", 
				"选择" => "Selection", 
				"预设" => "Presets", 
				"启用MOD" => "Enabled", 
				"扫描快捷键" => "ScanKey", 
				"选择窗口快捷键" => "WindowKey", 
				"显示模式" => "ScanMode", 
				"定时显示秒数" => "DisplayDurationSeconds", 
				"名称语言" => "NameLanguage", 
				"最大距离" => "MaxDistance", 
				"标签字号" => "FontSize", 
				"标签字体" => "LabelFont", 
				"屏外方向提示" => "ShowOffscreenDirection", 
				"玩家名" => "ShowOwnerNames", 
				"已选物品ID" => "SelectedItemIds", 
				"兼容行李箱开关" => "SelectedLuggage", 
				"已选行李箱类型" => "SelectedLuggageTypes", 
				"已选场景目标" => "SelectedSceneTargetTypes", 
				"位置范围" => "LocationScopes", 
				"预设版本号" => "PresetSchemaVersion", 
				"本地预设数据" => "LocalPresets", 
				"当前本地预设" => "ActiveLocalPresetId", 
				"当前共享预设" => "SelectedSharedPresetId", 
				"房主共享模式" => "ShareMode", 
				"常驻" => "Persistent", 
				"定时" => "Timed", 
				"关闭" => "Off", 
				"仅默认预设" => "BuiltInOnly", 
				"已发布预设" => "PublishedPresets", 
				"跟随游戏" => "Game", 
				"简体中文" => "SimplifiedChinese", 
				"自动" => "Auto", 
				"游戏默认" => "GameDefault", 
				"TMP默认字体" => "TmpDefault", 
				"无" => "None", 
				"地面" => "Ground", 
				"手持" => "Held", 
				"背包" => "Backpack", 
				"行李箱" => "Luggage", 
				_ => value, 
			};
		}

		private static string GetLocalizedToken(string key)
		{
			bool isChinese = IsChinese;
			switch (key)
			{
			case "WhereIsThing":
				if (!isChinese)
				{
					return "WhereIsThing";
				}
				return "物品在哪";
			case "General":
				if (!isChinese)
				{
					return "General";
				}
				return "常规";
			case "Display":
				if (!isChinese)
				{
					return "Display";
				}
				return "显示";
			case "Selection":
				if (!isChinese)
				{
					return "Selection";
				}
				return "选择";
			case "Presets":
				if (!isChinese)
				{
					return "Presets";
				}
				return "预设";
			case "Enabled":
				if (!isChinese)
				{
					return "Enabled";
				}
				return "启用 MOD";
			case "ScanKey":
				if (!isChinese)
				{
					return "Scan Key";
				}
				return "扫描快捷键";
			case "WindowKey":
				if (!isChinese)
				{
					return "Window Key";
				}
				return "选择窗口快捷键";
			case "ScanMode":
				if (!isChinese)
				{
					return "Display Mode";
				}
				return "显示模式";
			case "DisplayDurationSeconds":
				if (!isChinese)
				{
					return "Display Duration";
				}
				return "定时显示秒数";
			case "NameLanguage":
				if (!isChinese)
				{
					return "Name Language";
				}
				return "名称语言";
			case "MaxDistance":
				if (!isChinese)
				{
					return "Max Distance";
				}
				return "最大距离";
			case "FontSize":
				if (!isChinese)
				{
					return "Label Font Size";
				}
				return "标签字号";
			case "LabelFont":
				if (!isChinese)
				{
					return "Label Font";
				}
				return "标签字体";
			case "ShowOffscreenDirection":
				if (!isChinese)
				{
					return "Off-screen Direction";
				}
				return "屏外方向提示";
			case "ShowOwnerNames":
				if (!isChinese)
				{
					return "Player Names";
				}
				return "玩家名";
			case "SelectedItemIds":
				if (!isChinese)
				{
					return "Selected Item IDs";
				}
				return "已选物品 ID";
			case "SelectedLuggage":
				if (!isChinese)
				{
					return "Legacy Luggage Toggle";
				}
				return "兼容行李箱开关";
			case "SelectedLuggageTypes":
				if (!isChinese)
				{
					return "Selected Luggage Types";
				}
				return "已选行李箱类型";
			case "SelectedSceneTargetTypes":
				if (!isChinese)
				{
					return "Selected Scene Targets";
				}
				return "已选场景目标";
			case "LocationScopes":
				if (!isChinese)
				{
					return "Location Scopes";
				}
				return "位置范围";
			case "PresetSchemaVersion":
				if (!isChinese)
				{
					return "Preset Schema Version";
				}
				return "预设版本号";
			case "LocalPresets":
				if (!isChinese)
				{
					return "Local Presets";
				}
				return "本地预设数据";
			case "ActiveLocalPresetId":
				if (!isChinese)
				{
					return "Active Local Preset";
				}
				return "当前本地预设";
			case "SelectedSharedPresetId":
				if (!isChinese)
				{
					return "Selected Shared Preset";
				}
				return "当前共享预设";
			case "ShareMode":
				if (!isChinese)
				{
					return "Share Mode";
				}
				return "房主共享模式";
			case "MushroomZombie":
				if (!isChinese)
				{
					return "Mushroom Zombie";
				}
				return "森蕈僵尸";
			case "Beetle":
				if (!isChinese)
				{
					return "Beetle";
				}
				return "甲虫";
			case "Scorpion":
				if (!isChinese)
				{
					return "Scorpion";
				}
				return "蝎子";
			case "Spider":
				if (!isChinese)
				{
					return "Spider";
				}
				return "蜘蛛";
			case "BeeSwarm":
				if (!isChinese)
				{
					return "Bee Swarm";
				}
				return "蜂群";
			case "Scoutmaster":
				if (!isChinese)
				{
					return "Scoutmaster";
				}
				return "童军领队";
			case "TumbleWeed":
				if (!isChinese)
				{
					return "Tumbleweed";
				}
				return "风滚草";
			case "GhostBall":
				if (!isChinese)
				{
					return "Ghost Ball";
				}
				return "鬼球";
			case "SpikeTrap":
				if (!isChinese)
				{
					return "Spike Trap";
				}
				return "地刺";
			case "Antlion":
				if (!isChinese)
				{
					return "Antlion";
				}
				return "蚁狮";
			case "VenusFlyTrap":
				if (!isChinese)
				{
					return "Venus Flytrap";
				}
				return "捕蝇草";
			case "Tornado":
				if (!isChinese)
				{
					return "Tornado";
				}
				return "龙卷风";
			case "NapberryHypnoOrb":
				if (!isChinese)
				{
					return "Unpicked Napberry";
				}
				return "未摘下的晚安莓";
			case "ArrowShooter":
				if (!isChinese)
				{
					return "Arrow Shooter";
				}
				return "箭矢发射器";
			case "MovingSawBlade":
				if (!isChinese)
				{
					return "Moving Sawblade";
				}
				return "移动锯刃";
			case "SpikeRoller":
				if (!isChinese)
				{
					return "Spike Roller";
				}
				return "滚刺机关";
			case "SwingingAxe":
				if (!isChinese)
				{
					return "Swinging Axe";
				}
				return "摆斧机关";
			case "GloomBellTower":
				if (!isChinese)
				{
					return "Gloom Bell Tower";
				}
				return "雾沼钟塔";
			case "Persistent":
				if (!isChinese)
				{
					return "Persistent";
				}
				return "常驻";
			case "Timed":
				if (!isChinese)
				{
					return "Timed";
				}
				return "定时";
			case "Off":
				if (!isChinese)
				{
					return "Off";
				}
				return "关闭";
			case "BuiltInOnly":
				if (!isChinese)
				{
					return "Built-in Only";
				}
				return "仅默认预设";
			case "PublishedPresets":
				if (!isChinese)
				{
					return "Published Presets";
				}
				return "已发布预设";
			case "Game":
				if (!isChinese)
				{
					return "Follow Game";
				}
				return "跟随游戏";
			case "English":
				return "English";
			case "SimplifiedChinese":
				if (!isChinese)
				{
					return "Simplified Chinese";
				}
				return "简体中文";
			case "Auto":
				if (!isChinese)
				{
					return "Auto";
				}
				return "自动";
			case "GameDefault":
				if (!isChinese)
				{
					return "Game Default";
				}
				return "游戏默认";
			case "TmpDefault":
				if (!isChinese)
				{
					return "TMP Default";
				}
				return "TMP 默认字体";
			case "KoreanBinggrae":
				return "KoreanBinggrae";
			case "Crazk":
				return "Crazk";
			case "None":
				if (!isChinese)
				{
					return "None";
				}
				return "无";
			case "Ground":
				if (!isChinese)
				{
					return "Ground";
				}
				return "地面";
			case "Held":
				if (!isChinese)
				{
					return "Held";
				}
				return "手持";
			case "Backpack":
				if (!isChinese)
				{
					return "Backpack";
				}
				return "背包";
			case "Luggage":
				if (!isChinese)
				{
					return "Luggage";
				}
				return "行李箱";
			case "Statue":
				if (!isChinese)
				{
					return "Statue";
				}
				return "雕像";
			default:
				return null;
			}
		}

		private static string GetLocalizedDescription(string key)
		{
			bool isChinese = IsChinese;
			switch (key)
			{
			case "Enabled":
				if (!isChinese)
				{
					return "Enable or disable WhereIsThing.";
				}
				return "启用或关闭 WhereIsThing。";
			case "ScanKey":
				if (!isChinese)
				{
					return "Key used to show the locations of selected targets.";
				}
				return "显示当前已选目标位置的快捷键。";
			case "WindowKey":
				if (!isChinese)
				{
					return "Hold Alt and press this key to open the target selection window.";
				}
				return "按住 Alt 后使用此键打开物品选择窗口。";
			case "ScanMode":
				if (!isChinese)
				{
					return "Keep location labels visible or hide them automatically after a few seconds.";
				}
				return "选择位置标签常驻显示,或在数秒后自动隐藏。";
			case "DisplayDurationSeconds":
				if (!isChinese)
				{
					return "Number of seconds labels remain visible in Timed mode.";
				}
				return "定时模式下标签持续显示的秒数。";
			case "NameLanguage":
				if (!isChinese)
				{
					return "Follow the game language for item names, or force English/Simplified Chinese.";
				}
				return "物品名称跟随游戏语言,或强制使用英文/简体中文。";
			case "MaxDistance":
				if (!isChinese)
				{
					return "Maximum label distance in meters. Set to 0 for unlimited.";
				}
				return "显示标签的最大距离,单位米。0 表示不限制。";
			case "FontSize":
				if (!isChinese)
				{
					return "Font size used by location and distance labels.";
				}
				return "位置与距离标签的字号。";
			case "LabelFont":
				if (!isChinese)
				{
					return "Choose a font for English location labels only. Chinese text may display as tofu boxes.";
				}
				return "选择仅用于英文位置标签的字体;中文可能显示为口口口。";
			case "ShowOffscreenDirection":
				if (!isChinese)
				{
					return "Show a direction indicator when a target is off-screen.";
				}
				return "目标在屏幕外时显示方向提示。";
			case "ShowOwnerNames":
				if (!isChinese)
				{
					return "Show the placer name after supported labels.";
				}
				return "在支持的目标后显示放置者玩家名。";
			case "SelectedItemIds":
				if (!isChinese)
				{
					return "Item IDs managed by the Alt+C selection window. Do not edit manually.";
				}
				return "由 Alt+C 选择窗口维护的物品 ID,请勿手动编辑。";
			case "SelectedLuggage":
				if (!isChinese)
				{
					return "Legacy compatibility setting. Choose luggage types in the selection window.";
				}
				return "旧版配置兼容项,请使用选择窗口设置行李箱类型。";
			case "SelectedLuggageTypes":
				if (!isChinese)
				{
					return "Luggage types managed by the Alt+C selection window. Do not edit manually.";
				}
				return "由 Alt+C 选择窗口维护的行李箱类型,请勿手动编辑。";
			case "SelectedSceneTargetTypes":
				if (!isChinese)
				{
					return "Scene target types managed by the Alt+C selection window. Do not edit manually.";
				}
				return "由 Alt+C 选择窗口维护的动态危险和钟塔类型,请勿手动编辑。";
			case "LocationScopes":
				if (!isChinese)
				{
					return "Target location scopes. Statue scope shows selected amulet fragments held by scene statues. Luggage scanning is controlled automatically by the luggage types selected in the Alt+C window.";
				}
				return "目标位置范围。雕像范围会显示已选护符在场景雕像手中的碎片;行李箱是否扫描由 Alt+C 窗口中已选的行李箱类型自动控制。";
			case "PresetSchemaVersion":
				if (!isChinese)
				{
					return "Internal preset schema version used by WhereIsThing. Do not edit manually.";
				}
				return "WhereIsThing 内部使用的预设数据版本,请勿手动编辑。";
			case "LocalPresets":
				if (!isChinese)
				{
					return "Serialized local presets managed by WhereIsThing. Do not edit manually.";
				}
				return "WhereIsThing 保存的本地预设内容,请勿手动编辑。";
			case "ActiveLocalPresetId":
				if (!isChinese)
				{
					return "Preset ID currently selected for local use. Do not edit manually.";
				}
				return "当前本地玩家使用的预设 ID,请勿手动编辑。";
			case "SelectedSharedPresetId":
				if (!isChinese)
				{
					return "Shared preset ID currently selected by this client. Do not edit manually.";
				}
				return "当前客户端选择的共享预设 ID,请勿手动编辑。";
			case "ShareMode":
				if (!isChinese)
				{
					return "Whether the host shares built-in presets or published presets with clients.";
				}
				return "房主是否向客机共享默认预设或已发布预设。";
			default:
				return string.Empty;
			}
		}

		private static void SetDescription(ConfigEntryBase entry, string text)
		{
			if (!ModConfigUiAdapter.Owns(entry, "com.wuyachiyu.WhereIsThing.cfg") || entry.Description == null || DescriptionBackingField == null || string.IsNullOrEmpty(text))
			{
				return;
			}
			try
			{
				DescriptionBackingField.SetValue(entry.Description, text);
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[WhereIsThing] Description localization skipped: " + ex.Message));
			}
		}
	}
	internal static class ModConfigUiAdapter
	{
		internal sealed class ActionFieldSubscription : IDisposable
		{
			private FieldInfo _field;

			private Action _handler;

			internal void Subscribe(FieldInfo field, Action handler)
			{
				if (!(field == null) && !(field.FieldType != typeof(Action)) && field.IsStatic && handler != null && (!(_field == field) || _handler != handler))
				{
					Dispose();
					field.SetValue(null, (Action)Delegate.Combine((Action)field.GetValue(null), handler));
					_field = field;
					_handler = handler;
				}
			}

			public void Dispose()
			{
				if (_field != null)
				{
					_field.SetValue(null, (Action)Delegate.Remove((Action)_field.GetValue(null), _handler));
				}
				_field = null;
				_handler = null;
			}
		}

		private const string Guid = "com.github.PEAKModding.PEAKLib.ModConfig";

		private const BindingFlags Members = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private static readonly HashSet<MethodBase> Patched = new HashSet<MethodBase>();

		private static readonly HashSet<string> Warnings = new HashSet<string>();

		private static readonly Dictionary<Tuple<Type, string>, MemberInfo> MemberCache = new Dictionary<Tuple<Type, string>, MemberInfo>();

		private static string _fileName;

		private static string _modName;

		private static Func<ConfigEntryBase, string> _name;

		private static Func<string, string> _token;

		private static Action<string> _warn;

		private static Type _inputCell;

		private static Type _row;

		private static Type _tab;

		private static MonoBehaviour _menu;

		private static Coroutine _refresh;

		internal static void Install(Harmony harmony, string fileName, string modName, Func<ConfigEntryBase, string> name, Func<string, string> token, Action<string> warn)
		{
			_fileName = fileName;
			_modName = modName;
			_name = name;
			_token = token;
			_warn = warn;
			if (harmony == null || !Chainloader.PluginInfos.TryGetValue("com.github.PEAKModding.PEAKLib.ModConfig", out var value) || (Object)(object)((value != null) ? value.Instance : null) == (Object)null)
			{
				return;
			}
			Assembly assembly = ((object)value.Instance).GetType().Assembly;
			foreach (Type item in from t in assembly.GetTypes()
				where t.FullName != null && t.FullName.StartsWith("PEAKLib.ModConfig.SettingOptions.BepInEx", StringComparison.Ordinal) && !t.ContainsGenericParameters && !t.IsAbstract
				select t)
			{
				Patch(harmony, DeclaredImplementation(item, "GetDisplayName", Type.EmptyTypes), "DisplayNamePostfix");
			}
			Type type = assembly.GetType("PEAKLib.ModConfig.Components.ModSettingsMenu") ?? assembly.GetType("PEAKLib.ModConfig.Components.ModdedSettingsMenu");
			if (type == null)
			{
				Warn("menu", "Unsupported ModConfig menu type.");
				return;
			}
			string[] array = new string[4] { "OnEnable", "ShowSettings", "SetSection", "UpdateSectionTabs" };
			foreach (string text in array)
			{
				Patch(harmony, DeclaredImplementation(type, text, (!(text == "SetSection") && !(text == "UpdateSectionTabs")) ? Type.EmptyTypes : new Type[1] { typeof(string) }), "MenuPostfix");
			}
			array = new string[2] { "OnDisable", "OnDestroy" };
			foreach (string name2 in array)
			{
				MethodInfo methodInfo = DeclaredImplementation(type, name2, Type.EmptyTypes);
				if (methodInfo != null)
				{
					Patch(harmony, methodInfo, "MenuClosedPostfix");
				}
			}
			_inputCell = AccessTools.TypeByName("Zorro.Settings.SettingInputUICell");
			_row = AccessTools.TypeByName("SettingsUICell");
			_tab = assembly.GetType("PEAKLib.ModConfig.Components.ModdedTABSButton");
			Type type2 = AccessTools.TypeByName("Zorro.Settings.UI.EnumSettingUI");
			Patch(harmony, DeclaredImplementation(type2, "RefreshText", Type.EmptyTypes), "ControlPostfix");
			foreach (Type item2 in from t in assembly.GetTypes()
				where _inputCell != null && _inputCell.IsAssignableFrom(t) && !t.IsAbstract
				select t)
			{
				foreach (MethodInfo item3 in from m in item2.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
					where m.Name == "Setup" && m.GetParameters().Length == 2
					select m)
				{
					Patch(harmony, item3, "ControlPostfix");
				}
			}
		}

		internal static MethodInfo DeclaredImplementation(Type type, string name, Type[] parameters)
		{
			while (type != null)
			{
				MethodInfo method = type.GetMethod(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, parameters, null);
				if (method != null)
				{
					if (!method.ContainsGenericParameters && !method.IsAbstract)
					{
						return method;
					}
					return null;
				}
				type = type.BaseType;
			}
			return null;
		}

		private static void Patch(Harmony harmony, MethodInfo method, string callback)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			if (method == null)
			{
				Warn(callback, "A ModConfig hook is unavailable: " + callback);
			}
			else if (!Patched.Contains(method))
			{
				try
				{
					harmony.Patch((MethodBase)method, (HarmonyMethod)null, new HarmonyMethod(typeof(ModConfigUiAdapter), callback, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					Patched.Add(method);
				}
				catch (Exception ex)
				{
					Warn(method.ToString(), "ModConfig hook skipped: " + method?.ToString() + ": " + ex.Message);
				}
			}
		}

		internal static bool Owns(ConfigEntryBase entry, string fileName)
		{
			if (((entry != null) ? entry.ConfigFile : null) != null && !string.IsNullOrEmpty(fileName))
			{
				return string.Equals(Path.GetFileName(entry.ConfigFile.ConfigFilePath), fileName, StringComparison.OrdinalIgnoreCase);
			}
			return false;
		}

		internal static ConfigEntryBase Entry(object setting)
		{
			if (setting == null)
			{
				return null;
			}
			Type[] interfaces = setting.GetType().GetInterfaces();
			for (int i = 0; i < interfaces.Length; i++)
			{
				PropertyInfo property = interfaces[i].GetProperty("ConfigBase", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (property != null && typeof(ConfigEntryBase).IsAssignableFrom(property.PropertyType))
				{
					object? value = property.GetValue(setting, null);
					return (ConfigEntryBase)((value is ConfigEntryBase) ? value : null);
				}
			}
			object obj = Read(setting, "ConfigBase");
			return (ConfigEntryBase)((obj is ConfigEntryBase) ? obj : null);
		}

		private static void DisplayNamePostfix(object __instance, ref string __result)
		{
			try
			{
				ConfigEntryBase val = Entry(__instance);
				if (Owns(val, _fileName))
				{
					string text = _name(val);
					if (!string.IsNullOrEmpty(text))
					{
						__result = text;
					}
				}
			}
			catch (Exception ex)
			{
				Warn("name", ex.Message);
			}
		}

		private static void MenuPostfix(MonoBehaviour __instance, MethodBase __originalMethod)
		{
			if ((Object)(object)_menu != (Object)(object)__instance || __originalMethod.Name == "OnEnable")
			{
				StopRefresh();
			}
			_menu = __instance;
			RefreshVisibleUi();
		}

		private static void MenuClosedPostfix(MonoBehaviour __instance)
		{
			if (!((Object)(object)_menu != (Object)(object)__instance))
			{
				StopRefresh();
				_menu = null;
			}
		}

		internal static void RefreshVisibleUi()
		{
			if ((Object)(object)_menu == (Object)null || !((Behaviour)_menu).isActiveAndEnabled)
			{
				StopRefresh();
				_menu = null;
			}
			else if (_refresh == null)
			{
				_refresh = _menu.StartCoroutine(DeferredRefresh(_menu));
			}
		}

		private static IEnumerator DeferredRefresh(MonoBehaviour owner)
		{
			yield return null;
			try
			{
				if (!((Object)(object)owner == (Object)null) && !((Object)(object)owner != (Object)(object)_menu) && ((Behaviour)owner).isActiveAndEnabled)
				{
					RefreshMenu(owner);
				}
			}
			finally
			{
				if ((Object)(object)owner == (Object)(object)_menu)
				{
					_refresh = null;
				}
			}
		}

		private static void RefreshMenu(MonoBehaviour owner)
		{
			try
			{
				RefreshTabs(owner, "ModTabController", sections: false);
				if (SameMod(Read(owner, "selectedMod") as string, _modName))
				{
					RefreshTabs(owner, "SectionTabController", sections: true);
				}
				object obj = Read(owner, "Content");
				Transform val = (Transform)((obj is Transform) ? obj : null);
				if (!((Object)(object)val == (Object)null) && !(_inputCell == null))
				{
					Component[] componentsInChildren = ((Component)val).GetComponentsInChildren(_inputCell, false);
					for (int i = 0; i < componentsInChildren.Length; i++)
					{
						RefreshControl(componentsInChildren[i]);
					}
				}
			}
			catch (Exception ex)
			{
				Warn("menu-refresh", ex.Message);
			}
		}

		internal static bool SameMod(string category, string modName)
		{
			if (!string.IsNullOrEmpty(category) && !string.IsNullOrEmpty(modName))
			{
				return string.Equals(category.Replace(" ", ""), modName.Replace(" ", ""), StringComparison.OrdinalIgnoreCase);
			}
			return false;
		}

		private static void RefreshTabs(MonoBehaviour menu, string controllerName, bool sections)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			try
			{
				if (_tab == null || !(Read(Read(menu, controllerName), "Tabs") is IEnumerable enumerable))
				{
					return;
				}
				foreach (GameObject item in enumerable)
				{
					GameObject val = item;
					if (!((Object)(object)val == (Object)null))
					{
						Component component = val.GetComponent(_tab);
						string text = Read(component, "category") as string;
						if (sections || SameMod(text, _modName))
						{
							SetText(Read(component, "text"), _token(sections ? text : _modName));
						}
					}
				}
			}
			catch (Exception ex)
			{
				Warn("tabs", ex.Message);
			}
		}

		private static void ControlPostfix(Component __instance)
		{
			RefreshControl(__instance);
		}

		private static void RefreshControl(Component control)
		{
			try
			{
				if ((Object)(object)control == (Object)null || !control.gameObject.activeInHierarchy)
				{
					return;
				}
				object obj = Read(control, "KeySetting") ?? Read(control, "_listeningSetting");
				ConfigEntryBase val = Entry(obj);
				if (!Owns(val, _fileName))
				{
					return;
				}
				if (_row != null)
				{
					Component componentInParent = control.GetComponentInParent(_row);
					if ((Object)(object)componentInParent != (Object)null)
					{
						string text = _name(val);
						if (!string.IsNullOrEmpty(text))
						{
							object obj2 = Read(componentInParent, "localizedText");
							if (obj2 != null)
							{
								Write(obj2, "autoSet", false);
							}
							SetText(Read(componentInParent, "m_text"), text);
						}
					}
				}
				if (!val.SettingType.IsEnum && !(val.Description.AcceptableValues is AcceptableValueList<string>))
				{
					return;
				}
				object obj3 = Read(control, "dropdown");
				if (obj3 == null || !(Read(obj3, "options") is IList list) || !(DeclaredImplementation(obj.GetType(), "GetUnlocalizedChoices", Type.EmptyTypes)?.Invoke(obj, null) is IEnumerable<string> source))
				{
					return;
				}
				string[] array = source.ToArray();
				if (array.Length != list.Count)
				{
					return;
				}
				ApplyOptionText(list, array, _token);
				DeclaredImplementation(obj3.GetType(), "RefreshShownValue", Type.EmptyTypes)?.Invoke(obj3, null);
				if (Read(obj3, "m_Items") is IList list2 && list2.Count == array.Length)
				{
					for (int i = 0; i < list2.Count; i++)
					{
						SetText(Read(list2[i], "text"), Read(list[i], "text") as string);
					}
				}
			}
			catch (Exception ex)
			{
				Warn("control", ex.Message);
			}
		}

		internal static void ApplyOptionText(IList options, string[] raw, Func<string, string> translate)
		{
			if (options != null && raw != null && options.Count == raw.Length)
			{
				for (int i = 0; i < raw.Length; i++)
				{
					SetText(options[i], translate(raw[i]) ?? raw[i]);
				}
			}
		}

		private static void SetText(object target, string text)
		{
			if (target != null && !string.IsNullOrEmpty(text) && !object.Equals(Read(target, "text"), text))
			{
				Write(target, "text", text);
			}
		}

		private static MemberInfo Member(Type type, string name)
		{
			Tuple<Type, string> key = Tuple.Create(type, name);
			if (MemberCache.TryGetValue(key, out var value))
			{
				return value;
			}
			Type type2 = type;
			while (type2 != null)
			{
				value = (MemberInfo)(((object)type2.GetProperty(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) ?? ((object)type2.GetField(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)));
				if (value != null)
				{
					break;
				}
				type2 = type2.BaseType;
			}
			MemberCache[key] = value;
			return value;
		}

		private static object Read(object target, string name)
		{
			if (target == null)
			{
				return null;
			}
			MemberInfo memberInfo = Member(target.GetType(), name);
			if (!(memberInfo is PropertyInfo propertyInfo))
			{
				return (memberInfo as FieldInfo)?.GetValue(target);
			}
			return propertyInfo.GetValue(target, null);
		}

		private static void Write(object target, string name, object value)
		{
			MemberInfo memberInfo = Member(target.GetType(), name);
			if (memberInfo is PropertyInfo propertyInfo)
			{
				propertyInfo.SetValue(target, value, null);
			}
			else if (memberInfo is FieldInfo fieldInfo)
			{
				fieldInfo.SetValue(target, value);
			}
		}

		private static void StopRefresh()
		{
			if (_refresh != null && _menu != null && (Object)(object)_menu != (Object)null)
			{
				_menu.StopCoroutine(_refresh);
			}
			_refresh = null;
		}

		internal static void Shutdown()
		{
			StopRefresh();
			_menu = null;
			Patched.Clear();
			Warnings.Clear();
			MemberCache.Clear();
			_name = null;
			_token = null;
			_warn = null;
		}

		private static void Warn(string key, string message)
		{
			if (Warnings.Add(key))
			{
				_warn?.Invoke("ModConfig localization: " + message);
			}
		}
	}
	internal static class ThingUi
	{
		public static bool IsChinese
		{
			get
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Invalid comparison between Unknown and I4
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Invalid comparison between Unknown and I4
				if ((int)LocalizedText.CURRENT_LANGUAGE != 9)
				{
					return (int)LocalizedText.CURRENT_LANGUAGE == 10;
				}
				return true;
			}
		}

		public static string Text(string english, string chinese)
		{
			if (!IsChinese)
			{
				return english;
			}
			return chinese;
		}

		public static string PresetWindowTitle(bool allowEditing)
		{
			if (!allowEditing)
			{
				return Text("Shared Presets", "共享预设");
			}
			return Text("WhereIsThing Presets", "WhereIsThing 预设");
		}

		public static string PresetWindowSubtitle(bool allowEditing, bool usingFallbackPresets)
		{
			if (allowEditing)
			{
				return Text("Manage preset contents and sharing.", "管理预设内容与共享。");
			}
			if (usingFallbackPresets)
			{
				return Text("Host is not sharing presets. Using fallback presets.", "房主未共享预设,当前使用保底预设。");
			}
			return Text("Choose one preset for your own scan settings.", "为你自己的扫描设置选择一个预设。");
		}

		public static string SelectionWindowTitle()
		{
			return Text("Preset Targets", "预设目标");
		}

		public static string SelectionWindowSubtitle()
		{
			return Text("Choose which items and targets belong to this preset.", "选择哪些物品和目标属于这个预设。");
		}

		public static string SearchPlaceholder()
		{
			return Text("Search", "搜索");
		}

		public static string SelectedOnly()
		{
			return Text("Selected only", "仅显示已选");
		}

		public static string SelectVisible()
		{
			return Text("Select visible", "全选当前");
		}

		public static string ClearVisible()
		{
			return Text("Clear visible", "清除当前");
		}

		public static string Cancel()
		{
			return Text("Cancel", "取消");
		}

		public static string Apply()
		{
			return Text("Apply", "应用");
		}

		public static string Close()
		{
			return Text("Close", "关闭");
		}

		public static string LanguageLabel(ThingNameLanguage language)
		{
			return Text("Language: ", "语言:") + GetLanguageDisplay(language);
		}

		public static string CategoryLabel(string category, ThingNameLanguage language)
		{
			return Text("Category: ", "分类:") + ThingCatalog.GetCategoryDisplay(category, language);
		}

		public static string SelectedCount(int selectedCount, int totalCount)
		{
			if (!IsChinese)
			{
				return string.Format(CultureInfo.InvariantCulture, "{0} selected / {1}", selectedCount, totalCount);
			}
			return string.Format(CultureInfo.InvariantCulture, "已选 {0} / {1}", selectedCount, totalCount);
		}

		public static string NoMatchingTargets()
		{
			return Text("No matching targets", "没有匹配目标");
		}

		public static string ShareModeLabel(ThingPresetShareMode shareMode)
		{
			return shareMode switch
			{
				ThingPresetShareMode.BuiltInOnly => Text("Share: Built-in only", "共享:仅默认预设"), 
				ThingPresetShareMode.PublishedPresets => Text("Share: Published presets", "共享:已发布预设"), 
				_ => Text("Share: Off", "共享:关闭"), 
			};
		}

		public static string NewPreset()
		{
			return Text("New preset", "新增预设");
		}

		public static string Edit()
		{
			return Text("Edit", "编辑");
		}

		public static string Rename()
		{
			return Text("Rename", "重命名");
		}

		public static string RenamePresetTitle()
		{
			return Text("Rename custom preset", "重命名自定义预设");
		}

		public static string PresetNamePlaceholder()
		{
			return Text("Preset name", "预设名称");
		}

		public static string Save()
		{
			return Text("Save", "保存");
		}

		public static string PresetNameRequired()
		{
			return Text("Enter a preset name.", "请输入预设名称。");
		}

		public static string Hide()
		{
			return Text("Hide", "隐藏");
		}

		public static string Publish()
		{
			return Text("Publish", "公开");
		}

		public static string Delete()
		{
			return Text("Delete", "删除");
		}

		public static string Use(bool active)
		{
			if (!active)
			{
				return Text("Use", "使用");
			}
			return Text("Using", "使用中");
		}

		public static string LocalScanSettings()
		{
			return Text("Your scan settings", "你的扫描设置");
		}

		public static string ScanModeLabel(ThingScanMode scanMode, float durationSeconds)
		{
			if (scanMode == ThingScanMode.Persistent)
			{
				return Text("Mode: Persistent", "模式:常驻");
			}
			if (!IsChinese)
			{
				return string.Format(CultureInfo.InvariantCulture, "Mode: Timed {0:0}s", durationSeconds);
			}
			return string.Format(CultureInfo.InvariantCulture, "模式:定时 {0:0}s", durationSeconds);
		}

		public static string ScopeTitle()
		{
			return Text("Locations", "显示范围");
		}

		public static string MaxDistanceLabel(float distance)
		{
			if (!(distance <= 0f))
			{
				return string.Format(CultureInfo.InvariantCulture, Text("Max distance: {0:0}m", "最大距离:{0:0}米"), distance);
			}
			return Text("Max distance: unlimited", "最大距离:不限");
		}

		public static string PlayerNames()
		{
			return Text("Player names", "玩家名");
		}

		public static string Ground()
		{
			return Text("Ground", "地面");
		}

		public static string Held()
		{
			return Text("Held", "手持");
		}

		public static string Backpack()
		{
			return Text("Backpack", "背包");
		}

		public static string Luggage()
		{
			return Text("Luggage", "行李箱");
		}

		public static string Statue()
		{
			return Text("Statue", "雕像");
		}

		public static string TimeMinus()
		{
			return "-";
		}

		public static string TimePlus()
		{
			return "+";
		}

		public static string EmptyPresets()
		{
			return Text("No presets", "暂无预设");
		}

		public static string NoTargets()
		{
			return Text("No targets", "暂无目标");
		}

		public static string PublishedTag()
		{
			return Text("Published", "已公开");
		}

		public static string BuiltInTag()
		{
			return Text("Built-in", "保底");
		}

		public static string CustomPresetName(int index)
		{
			if (!IsChinese)
			{
				return "Custom Preset " + index;
			}
			return "自定义预设 " + index;
		}

		public static string MigratedPresetName()
		{
			return Text("Migrated", "旧配置导入");
		}

		public static string AchievementPresetName()
		{
			return Text("Achievement", "成就探索");
		}

		public static string SurvivalPresetName()
		{
			return Text("Survival Medical", "生存急救");
		}

		public static string AscentEightPresetName()
		{
			return Text("Ascent 8", "天阶 8");
		}

		public static string PlayerPlacedPresetName()
		{
			return Text("Player Placed", "玩家放置");
		}

		public static string GetLanguageDisplay(ThingNameLanguage language)
		{
			return language switch
			{
				ThingNameLanguage.English => "English", 
				ThingNameLanguage.SimplifiedChinese => "简体中文", 
				_ => Text("Follow Game", "跟随游戏"), 
			};
		}
	}
	internal sealed class ThingLabel
	{
		private readonly string _key;

		private readonly Transform _target;

		private readonly Func<Vector3> _positionProvider;

		private readonly Func<bool> _isValid;

		private readonly Func<string> _titleProvider;

		private readonly Func<string> _ownerProvider;

		private readonly GameObject _root;

		private readonly CanvasGroup _group;

		private readonly TextMeshProUGUI _mainTitle;

		private readonly TextMeshProUGUI _mainOwner;

		private readonly TextMeshProUGUI _mainDistance;

		private readonly TextMeshProUGUI _arrow;

		private float _fontSize;

		private string _cachedTitle = string.Empty;

		private string _cachedOwner = string.Empty;

		private string _lastTitle = string.Empty;

		private string _lastOwner = string.Empty;

		private string _lastDistance = string.Empty;

		private int _lastDistanceMeters;

		private bool _contentDirty = true;

		private bool _hasTextState;

		private bool _lastPlaceAboveTarget;

		private bool _visible;

		private const float LabelWidth = 420f;

		private const float OwnerFontScale = 0.78f;

		private const float DistanceFontScale = 0.78f;

		private const float RowGap = 1f;

		public string Key => _key;

		public bool IsValid
		{
			get
			{
				if ((Object)(object)_target != (Object)null && _isValid != null)
				{
					return _isValid();
				}
				return false;
			}
		}

		public ThingLabel(string key, Transform canvas, Transform target, Func<string> titleProvider, Func<bool> isValid, TMP_FontAsset font, Material titleMaterial, Material detailMaterial, float fontSize)
			: this(key, canvas, target, titleProvider, isValid, null, null, font, titleMaterial, detailMaterial, fontSize)
		{
		}

		public ThingLabel(string key, Transform canvas, Transform target, Func<string> titleProvider, Func<bool> isValid, Func<Vector3> positionProvider, TMP_FontAsset font, Material titleMaterial, Material detailMaterial, float fontSize)
			: this(key, canvas, target, titleProvider, isValid, positionProvider, null, font, titleMaterial, detailMaterial, fontSize)
		{
		}

		public ThingLabel(string key, Transform canvas, Transform target, Func<string> titleProvider, Func<bool> isValid, Func<Vector3> positionProvider, Func<string> ownerProvider, TMP_FontAsset font, Material titleMaterial, Material detailMaterial, float fontSize)
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_0167: 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_01af: 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_01c4: Expected O, but got Unknown
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			_key = key;
			_target = target;
			_positionProvider = positionProvider;
			_titleProvider = titleProvider;
			_ownerProvider = ownerProvider;
			_isValid = isValid;
			_fontSize = Mathf.Clamp(fontSize, 10f, 64f);
			_root = new GameObject("WhereIsThingLabel");
			_root.transform.SetParent(canvas, false);
			_root.layer = 5;
			_group = _root.AddComponent<CanvasGroup>();
			_group.blocksRaycasts = false;
			_group.interactable = false;
			_group.alpha = 0f;
			_mainTitle = CreateText("MainTitle", font, titleMaterial, _fontSize);
			_mainOwner = CreateText("OwnerName", font, detailMaterial, _fontSize * 0.78f);
			_mainDistance = CreateText("Distance", font, detailMaterial, _fontSize * 0.78f);
			((Graphic)_mainTitle).color = new Color(0.875f, 0.855f, 0.761f, 1f);
			((Graphic)_mainOwner).color = new Color(0.847f, 0.788f, 0.584f, 1f);
			((Graphic)_mainDistance).color = new Color(0.784f, 0.745f, 0.6f, 1f);
			GameObject val = new GameObject("OffscreenDirection");
			val.transform.SetParent(_root.transform, false);
			val.layer = 5;
			_arrow = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)_arrow).font = font;
			((TMP_Text)_arrow).fontSharedMaterial = ((TMP_Asset)font).material;
			((TMP_Text)_arrow).UpdateMeshPadding();
			((TMP_Text)_arrow).text = "^";
			((TMP_Text)_arrow).alignment = (TextAlignmentOptions)514;
			((TMP_Text)_arrow).fontSize = 22f;
			((Graphic)_arrow).color = new Color(1f, 0.85f, 0.2f, 1f);
			((Graphic)_arrow).raycastTarget = false;
			((TMP_Text)_arrow).rectTransform.sizeDelta = new Vector2(18f, 18f);
			((TMP_Text)_arrow).rectTransform.anchoredPosition = new Vector2(0f, -28f);
			((Behaviour)_arrow).enabled = false;
		}

		public void ApplyStyle(TMP_FontAsset font, Material titleMaterial, Material detailMaterial, float fontSize)
		{
			if (!((Object)(object)font == (Object)null))
			{
				_fontSize = Mathf.Clamp(fontSize, 10f, 64f);
				_hasTextState = false;
				ApplyFont(_mainTitle, font, titleMaterial, _fontSize);
				ApplyFont(_mainOwner, font, detailMaterial, _fontSize * 0.78f);
				ApplyFont(_mainDistance, font, detailMaterial, _fontSize * 0.78f);
				((TMP_Text)_arrow).font = font;
				((TMP_Text)_arrow).fontSharedMaterial = ((TMP_Asset)font).material;
				((TMP_Text)_arrow).UpdateMeshPadding();
			}
		}

		public void RefreshContent()
		{
			_cachedTitle = ((_titleProvider == null) ? string.Empty : (_titleProvider() ?? string.Empty));
			_cachedOwner = ((_ownerProvider == null) ? string.Empty : (_ownerProvider() ?? string.Empty).Trim());
			_contentDirty = false;
		}

		public void Update(Camera camera, float maxDistance, bool showOffscreen)
		{
			//IL_002c: 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_0031: 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_0033: 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_0042: 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_0049: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_0124: 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_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: 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_01bc: 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_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)camera == (Object)null)
			{
				SetVisible(visible: false);
				return;
			}
			Vector3 val = ((_positionProvider == null) ? _target.position : _positionProvider());
			Vector3 val2 = val + Vector3.up * 0.8f;
			Vector3 val3 = camera.WorldToViewportPoint(val2);
			float num = Vector3.Distance(((Component)camera).transform.position, val);
			bool flag = maxDistance <= 0f || num <= maxDistance;
			bool flag2 = val3.z > 0f;
			if (flag2 && val3.x >= 0f && val3.x <= 1f && val3.y >= 0f && val3.y <= 1f && flag)
			{
				_root.transform.position = camera.WorldToScreenPoint(val2);
				EnsureContent();
				SetText(_cachedTitle, _cachedOwner, GetDistanceText(num), placeAboveTarget: true);
				((Behaviour)_arrow).enabled = false;
				SetVisible(visible: true);
				return;
			}
			if (!showOffscreen || !flag)
			{
				SetVisible(visible: false);
				return;
			}
			Vector2 val4 = default(Vector2);
			((Vector2)(ref val4))..ctor(val3.x - 0.5f, val3.y - 0.5f);
			if (!flag2)
			{
				val4 = -val4;
			}
			if (((Vector2)(ref val4)).sqrMagnitude < 0.001f)
			{
				val4 = Vector2.up;
			}
			((Vector2)(ref val4)).Normalize();
			Vector2 val5 = default(Vector2);
			((Vector2)(ref val5))..ctor((float)Screen.width * 0.5f, (float)Screen.height * 0.5f);
			float num2 = (float)Mathf.Min(Screen.width, Screen.height) * 0.42f;
			_root.transform.position = Vector2.op_Implicit(val5 + val4 * num2);
			SetText(string.Empty, string.Empty, GetDistanceText(num), placeAboveTarget: false);
			((Behaviour)_arrow).enabled = true;
			((Transform)((TMP_Text)_arrow).rectTransform).localRotation = Quaternion.Euler(0f, 0f, Mathf.Atan2(val4.y, val4.x) * 57.29578f - 90f);
			SetVisible(visible: true);
		}

		public void Dispose()
		{
			if ((Object)(object)_root != (Object)null)
			{
				Object.Destroy((Object)(object)_root);
			}
		}

		private TextMeshProUGUI CreateText(string name, TMP_FontAsset font, Material material, float size)
		{
			//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_001d: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(_root.transform, false);
			val.layer = 5;
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
			((Graphic)val2).raycastTarget = false;
			((TMP_Text)val2).overflowMode = (TextOverflowModes)1;
			((TMP_Text)val2).richText = false;
			((TMP_Text)val2).font = font;
			((TMP_Text)val2).fontSharedMaterial = material;
			((TMP_Text)val2).UpdateMeshPadding();
			((TMP_Text)val2).fontStyle = (FontStyles)0;
			((TMP_Text)val2).fontSize = Mathf.Clamp(size, 8f, 64f);
			((TMP_Text)val2).fontSizeMax = ((TMP_Text)val2).fontSize;
			((TMP_Text)val2).fontSizeMin = Mathf.Max(8f, ((TMP_Text)val2).fontSize * 0.65f);
			((TMP_Text)val2).enableAutoSizing = true;
			((TMP_Text)val2).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)val2).rectTransform.sizeDelta = new Vector2(420f, 24f);
			((TMP_Text)val2).rectTransform.anchoredPosition = Vector2.zero;
			return val2;
		}

		private static void ApplyFont(TextMeshProUGUI text, TMP_FontAsset font, Material material, float size)
		{
			((TMP_Text)text).font = font;
			((TMP_Text)text).fontSharedMaterial = material;
			((TMP_Text)text).UpdateMeshPadding();
			((TMP_Text)text).fontSize = Mathf.Clamp(size, 8f, 64f);
			((TMP_Text)text).fontSizeMax = ((TMP_Text)text).fontSize;
			((TMP_Text)text).fontSizeMin = Mathf.Max(8f, ((TMP_Text)text).fontSize * 0.65f);
		}

		private void SetVisible(bool visible)
		{
			if (_visible != visible)
			{
				_visible = visible;
				_group.alpha = (visible ? 1f : 0f);
			}
		}

		private void SetText(string title, string owner, string distance, bool placeAboveTarget)
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			if (!_hasTextState || !string.Equals(_lastTitle, title, StringComparison.Ordinal) || !string.Equals(_lastOwner, owner, StringComparison.Ordinal) || !string.Equals(_lastDistance, distance, StringComparison.Ordinal) || _lastPlaceAboveTarget != placeAboveTarget)
			{
				_hasTextState = true;
				_lastTitle = title;
				_lastOwner = owner;
				_lastDistance = distance;
				_lastPlaceAboveTarget = placeAboveTarget;
				if (!placeAboveTarget)
				{
					SetTextPart(_mainTitle, string.Empty, enabled: false, 0f, 24f, new Vector2(0.5f, 0.5f), Vector2.zero);
					SetTextPart(_mainOwner, string.Empty, enabled: false, 0f, 24f, new Vector2(0.5f, 0.5f), Vector2.zero);
					SetTextPart(_mainDistance, distance, enabled: true, 0f, 24f, new Vector2(0.5f, 0.5f), Vector2.zero);
					return;
				}
				int num = CountLines(title);
				float height = Mathf.Max(18f, (float)num * _fontSize * 1.15f);
				float num2 = Mathf.Max(16f, _fontSize * 0.78f * 1.15f);
				float num3 = Mathf.Max(16f, _fontSize * 0.78f * 1.15f);
				float y = 0f;
				float num4 = num3 + 1f;
				float y2 = (string.IsNullOrEmpty(owner) ? num4 : (num4 + num2 + 1f));
				SetTextPart(_mainTitle, title, enabled: true, y2, height, new Vector2(0.5f, 0f), Vector2.zero);
				SetTextPart(_mainOwner, owner, !string.IsNullOrEmpty(owner), num4, num2, new Vector2(0.5f, 0f), Vector2.zero);
				SetTextPart(_mainDistance, distance, enabled: true, y, num3, new Vector2(0.5f, 0f), Vector2.zero);
			}
		}

		private void EnsureContent()
		{
			if (_contentDirty)
			{
				RefreshContent();
			}
		}

		private string GetDistanceText(float distance)
		{
			int num = Mathf.RoundToInt(distance);
			if (num == _lastDistanceMeters && !string.IsNullOrEmpty(_lastDistance))
			{
				return _lastDistance;
			}
			_lastDistanceMeters = num;
			return num.ToString(CultureInfo.InvariantCulture) + "m";
		}

		private static void SetTextPart(TextMeshProUGUI text, string value, bool enabled, float y, float height, Vector2 pivot, Vector2 position)
		{
			//IL_001b: 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_0038: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			((TMP_Text)text).text = value;
			((Behaviour)text).enabled = enabled;
			((TMP_Text)text).rectTransform.sizeDelta = new Vector2(420f, height);
			((TMP_Text)text).rectTransform.pivot = pivot;
			((TMP_Text)text).rectTransform.anchoredPosition = position + new Vector2(0f, y);
		}

		private static int CountLines(string value)
		{
			int num = 1;
			if (!string.IsNullOrEmpty(value))
			{
				for (int i = 0; i < value.Length; i++)
				{
					if (value[i] == '\n')
					{
						num++;
					}
				}
			}
			return num;
		}
	}
	internal sealed class ThingPresetPickerWindow
	{
		private const float MaxDistanceStep = 20f;

		private const float MaxDistanceMaximum = 500f;

		private readonly Canvas _canvas;

		private readonly TMP_FontAsset _font;

		private readonly GameObject _root;

		private readonly GameObject _cursorWindowObject;

		private readonly MenuWindow _cursorWindow;

		private readonly RectTransform _panelRect;

		private readonly RectTransform _content;

		private readonly TextMeshProUGUI _titleText;

		private readonly TextMeshProUGUI _subtitleText;

		private readonly TextMeshProUGUI _shareModeText;

		private readonly Button _shareModeButton;

		private readonly Button _newButton;

		private readonly TextMeshProUGUI _settingsTitleText;

		private readonly TextMeshProUGUI _scanModeText;

		private readonly TextMeshProUGUI _durationText;

		private readonly Button _durationMinusButton;

		private readonly Button _durationPlusButton;

		private readonly Toggle _ownerNamesToggle;

		private readonly Slider _maxDistanceSlider;

		private readonly TextMeshProUGUI _maxDistanceText;

		private readonly Dictionary<ThingLocationScope, Toggle> _scopeToggles = new Dictionary<ThingLocationScope, Toggle>();

		private readonly List<ThingPresetDefinition> _presets = new List<ThingPresetDefinition>();

		private GameObject _renameOverlay;

		private TMP_InputField _renameInput;

		private TextMeshProUGUI _renameTitleText;

		private TextMeshProUGUI _renameErrorText;

		private Func<ThingPresetDefinition, string> _summaryProvider;

		private Action<string> _usePreset;

		private Action<string> _editPreset;

		private Action<string, string> _renamePreset;

		private Action<string> _togglePublished;

		private Action<string> _deletePreset;

		private Action _createPreset;

		private Action<ThingPresetShareMode> _setShareMode;

		private Action<ThingLocationScope, bool> _setScope;

		private Action _cycleScanMode;

		private Action<int> _adjustDisplayDuration;

		private Action<bool> _setShowOwnerNames;

		private Action<float> _setMaxDistance;

		private bool _usingFallbackPresets;

		private bool _allowEditing;

		private bool _isOpen;

		private bool _isRebuilding;

		private bool _previousCursorVisible;

		private CursorLockMode _previousCursorLockState;

		private ThingPresetShareMode _shareMode;

		private ThingLocationScope _scopes;

		private ThingScanMode _scanMode;

		private float _displayDuration;

		private float _maxDistance;

		private bool _showOwnerNames;

		private string _activePresetId;

		private string _renamingPresetId;

		public bool IsOpen => _isOpen;

		public ThingPresetPickerWindow(Canvas canvas, TMP_FontAsset font)
		{
			//IL_0084: 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_0118: 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_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: 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_0195: 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_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Expected O, but got Unknown
			//IL_02f9: 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_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Expected O, but got Unknown
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Expected O, but got Unknown
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: 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_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_048a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04be: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_04de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0515: Unknown result type (might be due to invalid IL or missing references)
			//IL_051f: Expected O, but got Unknown
			//IL_057d: 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_059b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0601: Unknown result type (might be due to invalid IL or missing references)
			//IL_060c: Expected O, but got Unknown
			//IL_062d: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0648: Unknown result type (might be due to invalid IL or missing references)
			//IL_0653: Expected O, but got Unknown
			//IL_067e: Unknown result type (might be due to invalid IL or missing references)
			//IL_068d: Unknown result type (might be due to invalid IL or missing references)
			//IL_069c: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0702: Unknown result type (might be due to invalid IL or missing references)
			//IL_070d: Expected O, but got Unknown
			//IL_0736: Unknown result type (might be due to invalid IL or missing references)
			//IL_074b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0760: Unknown result type (might be due to invalid IL or missing references)
			//IL_0775: Unknown result type (might be due to invalid IL or missing references)
			//IL_0789: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_080b: Unknown result type (might be due to invalid IL or missing references)
			//IL_081a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0829: Unknown result type (might be due to invalid IL or missing references)
			//IL_0838: Unknown result type (might be due to invalid IL or missing references)
			//IL_0877: Unknown result type (might be due to invalid IL or missing references)
			//IL_088c: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b5: Unknown result type (might be due to invalid IL or missing references)
			_canvas = canvas;
			_font = font;
			_root = CreateRect("WhereIsThingPresetPickerOverlay", ((Component)canvas).transform);
			Stretch(_root.GetComponent<RectTransform>(), 0f, 0f, 0f, 0f);
			Image obj = _root.AddComponent<Image>();
			((Graphic)obj).color = new Color(0f, 0f, 0f, 0.54f);
			((Graphic)obj).raycastTarget = true;
			_cursorWindowObject = CreateRect("WhereIsThingPresetMenuWindow", _root.transform);
			_cursorWindowObject.SetActive(false);
			_cursorWindow = _cursorWindowObject.AddComponent<MenuWindow>();
			GameObject val = CreateRect("PresetPickerPanel", _root.transform);
			_panelRect = val.GetComponent<RectTransform>();
			_panelRect.anchorMin = new Vector2(0.2f, 0.14f);
			_panelRect.anchorMax = new Vector2(0.8f, 0.86f);
			_panelRect.offsetMin = Vector2.zero;
			_panelRect.offsetMax = Vector2.zero;
			((Graphic)val.AddComponent<Image>()).color = new Color(0.075f, 0.08f, 0.075f, 0.98f);
			Outline obj2 = val.AddComponent<Outline>();
			((Shadow)obj2).effectColor = new Color(0.7f, 0.66f, 0.52f, 0.75f);
			((Shadow)obj2).effectDistance = new Vector2(2f, 2f);
			_titleText = CreateText(val.transform, "Title", string.Empty, 22f, (TextAlignmentOptions)513, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(22f, -42f), new Vector2(-22f, -8f), wrap: false, autoSize: true);
			_subtitleText = CreateText(val.transform, "Subtitle", string.Empty, 12f, (TextAlignmentOptions)513, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(22f, -72f), new Vector2(-22f, -40f), wrap: true, autoSize: true);
			_shareModeText = CreateButton(val.transform, "ShareMode", new Vector2(22f, -88f), new Vector2(232f, 38f), string.Empty, new UnityAction(CycleShareModeInternal));
			_shareModeButton = ((Component)_shareModeText).GetComponentInParent<Button>();
			_newButton = CreateActionButton(val.transform, "New", ThingUi.NewPreset(), new Vector2(264f, -88f), new Vector2(150f, 38f), new UnityAction(CreatePresetInternal), anchorRight: false);
			CreateActionButton(val.transform, "Close", ThingUi.Close(), new Vector2(-22f, 18f), new Vector2(140f, 38f), new UnityAction(Close), anchorRight: true);
			GameObject val2 = CreateRect("Viewport", val.transform);
			RectTransform component = val2.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 0f);
			component.anchorMax = new Vector2(1f, 1f);
			component.offsetMin = new Vector2(22f, 142f);
			component.offsetMax = new Vector2(-22f, -132f);
			((Graphic)val2.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.18f);
			val2.AddComponent<Mask>().showMaskGraphic = false;
			GameObject val3 = CreateRect("Scroll", val2.transform);
			Stretch(val3.GetComponent<RectTransform>(), 0f, 0f, 0f, 0f);
			ScrollRect obj3 = val3.AddComponent<ScrollRect>();
			obj3.horizontal = false;
			obj3.vertical = true;
			obj3.scrollSensitivity = 72f;
			obj3.movementType = (MovementType)2;
			obj3.viewport = component;
			_content = CreateRect("Content", val3.transform).GetComponent<RectTransform>();
			_content.anchorMin = new Vector2(0f, 1f);
			_content.anchorMax = new Vector2(1f, 1f);
			_content.pivot = new Vector2(0.5f, 1f);
			_content.anchoredPosition = Vector2.zero;
			_content.sizeDelta = Vector2.zero;
			obj3.content = _content;
			VerticalLayoutGroup obj4 = ((Component)_content).gameObject.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj4).spacing = 8f;
			((LayoutGroup)obj4).padding = new RectOffset(10, 10, 6, 6);
			((HorizontalOrVerticalLayoutGroup)obj4).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj4).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandHeight = false;
			ContentSizeFitter obj5 = ((Component)_content).gameObject.AddComponent<ContentSizeFitter>();
			obj5.horizontalFit = (FitMode)0;
			obj5.verticalFit = (FitMode)2;
			_settingsTitleText = CreateText(val.transform, "SettingsTitle", ThingUi.LocalScanSettings(), 13f, (TextAlignmentOptions)513, new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(22f, 98f), new Vector2(-22f, 122f), wrap: false, autoSize: true);
			_scanModeText = CreateButton(val.transform, "ScanMode", new Vector2(22f, 52f), new Vector2(196f, 36f), string.Empty, new UnityAction(CycleScanModeInternal));
			_durationMinusButton = CreateActionButton(val.transform, "DurationMinus", ThingUi.TimeMinus(), new Vector2(228f, 52f), new Vector2(36f, 36f), (UnityAction)delegate
			{
				AdjustDurationInternal(-1);
			}, anchorRight: false);
			_durationText = CreateText(val.transform, "DurationText", string.Empty, 13f, (TextAlignmentOptions)514, new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(270f, 52f), new Vector2(350f, 88f), wrap: false, autoSize: true);
			_durationPlusButton = CreateActionButton(val.transform, "DurationPlus", ThingUi.TimePlus(), new Vector2(358f, 52f), new Vector2(36f, 36f), (UnityAction)delegate
			{
				AdjustDurationInternal(1);
			}, anchorRight: false);
			GameObject val4 = CreateRect("MaxDistanceRow", val.transform);
			RectTransform component2 = val4.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(1f, 1f);
			component2.anchorMax = new Vector2(1f, 1f);
			component2.pivot = new Vector2(1f, 0.5f);
			component2.sizeDelta = new Vector2(360f, 36f);
			component2.anchoredPosition = new Vector2(-22f, 52f);
			_maxDistanceText = CreateText(val4.transform, "MaxDistanceText", string.Empty, 12f, (TextAlignmentOptions)513, new Vector2(0f, 0f), new Vector2(0f, 0.5f), new Vector2(0.3f, 1f), Vector2.zero, Vector2.zero, wrap: false, autoSize: true);
			_maxDistanceSlider = CreateSlider(val4.transform, "MaxDistanceSlider", new Vector2(0.3f, 0.5f), new Vector2(1f, 0.5f), new Vector2(0f, 0f), new Vector2(-4f, 0f), SetMaxDistanceInternal);
			GameObject val5 = CreateRect("ScopeOptions", val.transform);
			RectTransform component3 = val5.GetComponent<RectTransform>();
			component3.anchorMin = new Vector2(0f, 0f);
			component3.anchorMax = new Vector2(0.78f, 0f);
			component3.offsetMin = new Vector2(22f, 28f);
			component3.offsetMax = new Vector2(-8f, 56f);
			CreateScopeToggle(val5.transform, ThingUi.Ground(), ThingLocationScope.Ground, 0f, 0.2f);
			CreateScopeToggle(val5.transform, ThingUi.Held(), ThingLocationScope.Held, 0.2f, 0.4f);
			CreateScopeToggle(val5.transform, ThingUi.Backpack(), ThingLocationScope.Backpack, 0.4f, 0.6f);
			CreateScopeToggle(val5.transform, ThingUi.Statue(), ThingLocationScope.Statue, 0.6f, 0.8f);
			_ownerNamesToggle = CreateInlineBoolToggle(val5.transform, "OwnerNames", ThingUi.PlayerNames(), 0.8f, 1f, SetOwnerNamesInternal);
			CreateRenameDialog();
			_root.SetActive(false);
		}

		public void Open(IEnumerable<ThingPresetDefinition> presets, string activePresetId, bool allowEditing, bool usingFallbackPresets, ThingPresetShareMode shareMode, ThingLocationScope scopes, ThingScanMode scanMode, float displayDurationSeconds, float maxDistance, bool showOwnerNames, Func<ThingPresetDefinition, string> summaryProvider, Action<string> usePreset, Action<string> editPreset, Action<string, string> renamePreset, Action<string> togglePublished, Action<string> deletePreset, Action createPreset, Action<ThingPresetShareMode> setShareMode, Action<ThingLocationScope, bool> setScope, Action cycleScanMode, Action<int> adjustDisplayDuration, Action<bool> setShowOwnerNames, Action<float> setMaxDistance)
		{
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			_presets.Clear();
			_presets.AddRange((from preset in presets ?? Enumerable.Empty<ThingPresetDefinition>()
				where preset != null
				select preset.Clone()).ToList());
			_activePresetId = activePresetId ?? string.Empty;
			_allowEditing = allowEditing;
			_usingFallbackPresets = usingFallbackPresets;
			_shareMode = shareMode;
			_scopes = scopes;
			_scanMode = scanMode;
			_displayDuration = Mathf.Clamp(displayDurationSeconds, 2f, 60f);
			_maxDistance = Mathf.Round(Mathf.Clamp(maxDistance, 0f, 500f) / 20f) * 20f;
			_showOwnerNames = showOwnerNames;
			_summaryProvider = summaryProvider;
			_usePreset = usePreset;
			_editPreset = editPreset;
			_renamePreset = renamePreset;
			_togglePublished = togglePublished;
			_deletePreset = deletePreset;
			_createPreset = createPreset;
			_setShareMode = setShareMode;
			_setScope = setScope;
			_cycleScanMode = cycleScanMode;
			_adjustDisplayDuration = adjustDisplayDuration;
			_setShowOwnerNames = setShowOwnerNames;
			_setMaxDistance = setMaxDistance;
			_isOpen = true;
			_previousCursorVisible = Cursor.visible;
			_previousCursorLockState = Cursor.lockState;
			_root.SetActive(true);
			CloseRenameDialog();
			RegisterCursorWindow();
			MaintainCursor();
			RebuildRows();
			RebuildSettings();
		}

		public void Tick()
		{
			if (_isOpen)
			{
				MaintainCursor();
				if ((Object)(object)_renameOverlay != (Object)null && _renameOverlay.activeSelf && Input.GetKeyDown((KeyCode)27))
				{
					CloseRenameDialog();
				}
			}
		}

		public void MaintainCursor()
		{
			if (_isOpen)
			{
				RegisterCursorWindow();
				Cursor.visible = true;
				Cursor.lockState = (CursorLockMode)0;
			}
		}

		public void Close()
		{
			if (_isOpen)
			{
				RestoreCursor();
				_isOpen = false;
				CloseRenameDialog();
				_root.SetActive(false);
				UnregisterCursorWindow();
			}
		}

		public void Dispose()
		{
			if (_isOpen)
			{
				RestoreCursor();
			}
			_isOpen = false;
			UnregisterCursorWindow();
			if ((Object)(object)_root != (Object)null)
			{
				Object.Destroy((Object)(object)_root);
			}
		}

		private void RebuildRows()
		{
			//IL_0014: 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_0056: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: 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_019e: 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_01bc: Unknown result type (might be due to invalid IL or missing references)
			foreach (Transform item in (Transform)_content)
			{
				Object.Destroy((Object)(object)((Component)item).gameObject);
			}
			_panelRect.anchorMin = (_allowEditing ? new Vector2(0.16f, 0.12f) : new Vector2(0.23f, 0.16f));
			_panelRect.anchorMax = (_allowEditing ? new Vector2(0.84f, 0.88f) : new Vector2(0.77f, 0.84f));
			((TMP_Text)_titleText).text = ThingUi.PresetWindowTitle(_allowEditing);
			((TMP_Text)_subtitleText).text = ThingUi.PresetWindowSubtitle(_allowEditing, _usingFallbackPresets);
			((Component)_shareModeButton).gameObject.SetActive(_allowEditing);
			((Component)_newButton).gameObject.SetActive(_allowEditing);
			((TMP_Text)_shareModeText).text = ThingUi.ShareModeLabel(_shareMode);
			foreach (ThingPresetDefinition preset in _presets)
			{
				AddPresetRow(preset);
			}
			if (_presets.Count == 0)
			{
				CreateText((Transform)(object)_content, "Empty", ThingUi.EmptyPresets(), 14f, (TextAlignmentOptions)514, new Vector2(0f, 1f), new Vector2(0.5f, 1f), new Vector2(1f, 1f), new Vector2(12f, 0f), new Vector2(-12f, -36f), wrap: false, autoSize: true);
			}
		}

		private void RebuildSettings()
		{
			_isRebuilding = true;
			((TMP_Text)_settingsTitleText).text = ThingUi.LocalScanSettings();
			((TMP_Text)_scanModeText).text = ThingUi.ScanModeLabel(_scanMode, _displayDuration);
			((TMP_Text)_durationText).text = $"{_displayDuration:0}s";
			bool active = _scanMode == ThingScanMode.Timed;
			((Component)_durationText).gameObject.SetActive(active);
			((Component)_durationMinusButton).gameObject.SetActive(active);
			((Component)_durationPlusButton).gameObject.SetActive(active);
			_ownerNamesToggle.isOn = _showOwnerNames;
			_maxDistanceSlider.SetValueWithoutNotify(_maxDistance / 20f);
			((TMP_Text)_maxDistanceText).text = ThingUi.MaxDistanceLabel(_maxDistance);
			foreach (KeyValuePair<ThingLocationScope, Toggle> scopeToggle in _scopeToggles)
			{
				scopeToggle.Value.isOn = (_scopes & scopeToggle.Key) != 0;
			}
			_isRebuilding = false;
		}

		private void AddPresetRow(ThingPresetDefinition preset)
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Expected O, but got Unknown
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Expected O, but got Unknown
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Expected O, but got Unknown
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: Expected O, but got Unknown
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Expected O, but got Unknown
			GameObject val = CreateRect("Preset_" + preset.Id, (Transform)(object)_content);
			LayoutElement obj = val.AddComponent<LayoutElement>();
			bool flag = string.Equals(preset.Id, _activePresetId, StringComparison.Ordinal);
			bool flag2 = ThingPresetFactory.IsBuiltInPresetId(preset.Id);
			obj.minHeight = (_allowEditing ? 82f : 70f);
			obj.preferredHeight = obj.minHeight;
			((Graphic)val.AddComponent<Image>()).color = (flag ? new Color(0.22f, 0.22f, 0.16f, 1f) : new Color(0.12f, 0.12f, 0.1f, 1f));
			int num = 1 + (_allowEditing ? 1 : 0) + ((_allowEditing && !flag2) ? 3 : 0);
			float num2 = 80f + (_allowEditing ? 60f : 0f) + ((_allowEditing && !flag2) ? 188f : 0f) + (float)Mathf.Max(0, num - 1) * 4f;
			GameObject val2 = CreateRect("Info", val.transform);
			RectTransform component = val2.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = new Vector2(24f, 8f);
			component.offsetMax = new Vector2(0f - (num2 + 32f), -8f);
			CreateText(val2.transform, "Name", (flag ? "● " : string.Empty) + ThingPresetFactory.GetDisplayName(preset), 15f, (TextAlignmentOptions)513, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0f, -28f), Vector2.zero, wrap: false, autoSize: true);
			CreateText(val2.transform, "Summary", (_summaryProvider == null) ? string.Empty : _summaryProvider(preset), 12f, (TextAlignmentOptions)513, Vector2.zero, Vector2.zero, Vector2.one, Vector2.zero, new Vector2(0f, -30f), wrap: true, autoSize: true);
			GameObject val3 = CreateRect("Actions", val.transform);
			RectTransform component2 = val3.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(1f, 0.5f);
			component2.anchorMax = new Vector2(1f, 0.5f);
			component2.pivot = new Vector2(1f, 0.5f);
			component2.sizeDelta = new Vector2(num2, 32f);
			component2.anchoredPosition = new Vector2(-18f, 0f);
			HorizontalLayoutGroup obj2 = val3.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj2).spacing = 4f;
			((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false;
			((LayoutGroup)obj2).childAlignment = (TextAnchor)5;
			CreateLayoutButton(val3.transform, "Use", ThingUi.Use(flag), 80f, (UnityAction)delegate
			{
				if (_usePreset != null)
				{
					_usePreset(preset.Id);
				}
			});
			if (!_allowEditing)
			{
				return;
			}
			CreateLayoutButton(val3.transform, "Edit", ThingUi.Edit(), 60f, (UnityAction)delegate
			{
				if (_editPreset != null)
				{
					_editPreset(preset.Id);
				}
			});
			if (!flag2)
			{
				CreateLayoutButton(val3.transform, "Rename", ThingUi.Rename(), 68f, (UnityAction)delegate
				{
					OpenRenameDialog(preset);
				});
				CreateLayoutButton(val3.transform, "Publish", preset.Published ? ThingUi.Hide() : ThingUi.Publish(), 60f, (UnityAction)delegate
				{
					InvokeAndRefresh(_togglePublished, preset.Id);
				});
				CreateLayoutButton(val3.transform, "Delete", ThingUi.Delete(), 60f, (UnityAction)delegate
				{
					InvokeAndRefresh(_deletePreset, preset.Id);
				});
			}
		}

		private void CreateRenameDialog()
		{
			//IL_005f: 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_00ab: 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_00c0: 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_0109: 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_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: 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_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_042d: Expected O, but got Unknown
			//IL_0449: Unknown result type (might be due to invalid IL or missing references)
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: Unknown result type (might be due to invalid IL or missing references)
			//IL_046f: Expected O, but got Unknown
			_renameOverlay = CreateRect("RenameOverlay", _root.transform);
			Stretch(_renameOverlay.GetComponent<RectTransform>(), 0f, 0f, 0f, 0f);
			Image obj = _renameOverlay.AddComponent<Image>();
			((Graphic)obj).color = new Color(0f, 0f, 0f, 0.68f);
			((Graphic)obj).raycastTarget = true;
			GameObject val = CreateRect("RenamePanel", _renameOverlay.transform);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.32f, 0.34f);
			component.anchorMax = new Vector2(0.68f, 0.66f);
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			((Graphic)val.AddComponent<Image>()).color = new Color(0.075f, 0.08f, 0.075f, 1f);
			Outline obj2 = val.AddComponent<Outline>();
			((Shadow)obj2).effectColor = new Color(0.7f, 0.66f, 0.52f, 0.75f);
			((Shadow)obj2).effectDistance = new Vector2(2f, 2f);
			_renameTitleText = CreateText(val.transform, "Title", ThingUi.RenamePresetTitle(), 20f, (TextAlignmentOptions)513, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(22f, -48f), new Vector2(-22f, -10f), wrap: false, autoSize: true);
			GameObject val2 = CreateRect("NameInput", val.transform);
			RectTransform component2 = val2.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0f, 1f);
			component2.anchorMax = new Vector2(1f, 1f);
			component2.pivot = new Vector2(0.5f, 1f);
			component2.sizeDelta = new Vector2(-44f, 42f);
			component2.anchoredPosition = new Vector2(0f, -62f);
			((Graphic)val2.AddComponent<Image>()).color = new Color(0.03f, 0.035f, 0.03f, 1f);
			TextMeshProUGUI textComponent = CreateText(val2.transform, "Text", string.Empty, 16f, (TextAlignmentOptions)513, Vector2.zero, Vector2.zero, Vector2.one, new Vector2(12f, 0f), new Vector2(-12f, 0f), wrap: false, autoSize: true);
			TextMeshProUGUI val3 = CreateText(val2.transform, "Placeholder", ThingUi.PresetNamePlaceholder(), 16f, (TextAlignmentOptions)513, Vector2.zero, Vector2.zero, Vector2.one, new Vector2(12f, 0f), new Vector2(-12f, 0f), wrap: false, autoSize: true);
			((Graphic)val3).color = new Color(0.55f, 0.56f, 0.52f, 1f);
			_renameInput = val2.AddComponent<TMP_InputField>();
			_renameInput.textComponent = (TMP_Text)(object)textComponent;
			_renameInput.placeholder = (Graphic)(object)val3;
			_renameInput.lineType = (LineType)0;
			_renameInput.characterLimit = 24;
			((UnityEvent<string>)(object)_renameInput.onSubmit).AddListener((UnityAction<string>)delegate
			{
				ConfirmRename();
			});
			_renameErrorText = CreateText(val.transform, "Error", string.Empty, 12f, (TextAlignmentOptions)513, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(22f, -130f), new Vector2(-22f, -106f), wrap: false, autoSize: true);
			((Graphic)_renameErrorText).color = new Color(0.95f, 0.48f, 0.4f, 1f);
			CreateActionButton(val.transform, "Cancel", ThingUi.Cancel(), new Vector2(-152f, 18f), new Vector2(120f, 36f), new UnityAction(CloseRenameDialog), anchorRight: true);
			CreateActionButton(val.transform, "Save", ThingUi.Save(), new Vector2(-22f, 18f), new Vector2(120f, 36f), new UnityAction(ConfirmRename), anchorRight: true);
			_renameOverlay.SetActive(false);
		}

		private void OpenRenameDialog(ThingPresetDefinition preset)
		{
			if (_allowEditing && preset != null && !ThingPresetFactory.IsBuiltInPresetId(preset.Id) && _renamePreset != null)
			{
				_renamingPresetId = preset.Id;
				((TMP_Text)_renameTitleText).text = ThingUi.RenamePresetTitle();
				_renameInput.text = preset.Name ?? string.Empty;
				((TMP_Text)_renameErrorText).text = string.Empty;
				_renameOverlay.SetActive(true);
				_renameOverlay.transform.SetAsLastSibling();
				_renameInput.ActivateInputField();
				_renameInput.MoveTextEnd(false);
			}
		}

		private void ConfirmRename()
		{
			if ((Object)(object)_renameOverlay == (Object)null || !_renameOverlay.activeSelf)
			{
				return;
			}
			string text = (_renameInput.text ?? string.Empty).Trim();
			if (string.IsNullOrWhiteSpace(text))
			{
				((TMP_Text)_renameErrorText).text = ThingUi.PresetNameRequired();
				_renameInput.ActivateInputField();
				return;
			}
			string renamingPresetId = _renamingPresetId;
			CloseRenameDialog();
			if (_renamePreset != null)
			{
				_renamePreset(renamingPresetId, text);
			}
		}

		private void CloseRenameDialog()
		{
			_renamingPresetId = string.Empty;
			if ((Object)(object)_renameErrorText != (Object)null)
			{
				((TMP_Text)_renameErrorText).text = string.Empty;
			}
			if ((Object)(object)_renameOverlay != (Object)null)
			{
				_renameOverlay.SetActive(false);
			}
		}

		private void InvokeAndRefresh(Action<string> action, string presetId)
		{
			action?.Invoke(presetId);
		}

		private void CreatePresetInternal()
		{
			if (_createPreset != null)
			{
				_createPreset();
			}
		}

		private void CycleShareModeInternal()
		{
			if (_allowEditing && _setShareMode != null)
			{
				ThingPresetShareMode obj = ((_shareMode == ThingPresetShareMode.Off) ? ThingPresetShareMode.BuiltInOnly : ((_shareMode == ThingPresetShareMode.BuiltInOnly) ? ThingPresetShareMode.PublishedPresets : ThingPresetShareMode.Off));
				_setShareMode(obj);
			}
		}

		private void CycleScanModeInternal()
		{
			if (_cycleScanMode != null)
			{
				_cycleScanMode();
			}
		}

		private void AdjustDurationInternal(int delta)
		{
			if (_adjustDisplayDuration != null)
			{
				_adjustDisplayDuration(delta);
			}
		}

		private void SetScopeInternal(ThingLocationScope scope, bool value)
		{
			if (!_isRebuilding && _setScope != null)
			{
				_setScope(scope, value);
			}
		}

		private void SetOwnerNamesInternal(bool value)
		{
			if (!_isRebuilding && _setShowOwnerNames != null)
			{
				_setShowOwnerNames(value);
			}
		}

		private void SetMaxDistanceInternal(float value)
		{
			if (!_isRebuilding && _setMaxDistance != null)
			{
				float num = Mathf.Round(Mathf.Clamp(value, 0f, 25f)) * 20f;
				_maxDistanceSlider.SetValueWithoutNotify(num / 20f);
				_setMaxDistance(num);
			}
		}

		private void RegisterCursorWindow()
		{
			if (!((Object)(object)_cursorWindow == (Object)null) && !MenuWindow.AllActiveWindows.Contains(_cursorWindow))
			{
				MenuWindow.AllActiveWindows.Add(_cursorWindow);
				if ((Object)(object)GUIManager.instance != (Object)null)
				{
					GUIManager.instance.UpdateWindowStatus();
				}
			}
		}

		private void UnregisterCursorWindow()
		{
			if ((Object)(object)_cursorWindow != (Object)null && MenuWindow.AllActiveWindows.Remove(_cursorWindow) && (Object)(object)GUIManager.instance != (Object)null)
			{
				GUIManager.instance.UpdateWindowStatus();
			}
		}

		private void RestoreCursor()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			Cursor.visible = _previousCursorVisible;
			Cursor.lockState = _previousCursorLockState;
		}

		private Toggle CreateScopeToggle(Transform parent, string label, ThingLocationScope scope, float anchorMinX, float anchorMaxX)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateRect("Scope_" + scope, parent);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(anchorMinX, 0f);
			component.anchorMax = new Vector2(anchorMaxX, 1f);
			component.sizeDelta = new Vector2(-8f, 0f);
			component.anchoredPosition = Vector2.zero;
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = new Color(0.2f, 0.2f, 0.18f, 1f);
			GameObject obj = CreateRect("Checkmark", val.transform);
			RectTransform component2 = obj.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0f, 0.5f);
			component2.anchorMax = new Vector2(0f, 0.5f);
			component2.sizeDelta = new Vector2(18f, 18f);
			component2.anchoredPosition = new Vec