Decompiled source of WhereIsThing v0.1.1
WhereIsThing.dll
Decompiled 2 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; 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.1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.1.1.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 ModConfigGuid = "com.github.PEAKModding.PEAKLib.ModConfig"; 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 Type _tmpTextType; private static PropertyInfo _tmpTextProperty; 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) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown if (harmony == null || !Chainloader.PluginInfos.TryGetValue("com.github.PEAKModding.PEAKLib.ModConfig", out var value) || value == null || (Object)(object)value.Instance == (Object)null) { return; } Assembly assembly = ((object)value.Instance).GetType().Assembly; HarmonyMethod val = new HarmonyMethod(typeof(ModConfigLocalization).GetMethod("ModConfigDisplayNamePostfix", BindingFlags.Static | BindingFlags.NonPublic)); Type[] types = assembly.GetTypes(); foreach (Type type in types) { if (!(type == null) && !type.IsAbstract && !type.IsInterface && type.FullName != null && type.FullName.StartsWith("PEAKLib.ModConfig.SettingOptions.BepInEx", StringComparison.Ordinal)) { MethodInfo methodInfo = AccessTools.Method(type, "GetDisplayName", Type.EmptyTypes, (Type[])null); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } Type type2 = assembly.GetType("PEAKLib.ModConfig.Components.ModdedSettingsMenu"); if (type2 == null) { return; } HarmonyMethod val2 = new HarmonyMethod(typeof(ModConfigLocalization).GetMethod("ModConfigUiChangedPostfix", BindingFlags.Static | BindingFlags.NonPublic)); string[] array = new string[4] { "OnEnable", "ShowSettings", "SetSection", "UpdateSectionTabs" }; foreach (string methodName in array) { MethodInfo methodInfo2 = type2.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((MethodInfo candidate) => candidate.Name == methodName); if (methodInfo2 != null) { harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } public static void ApplyLocalizedDescriptions(IEnumerable<ConfigEntryBase> entries) { if (entries == null) { return; } foreach (ConfigEntryBase item in entries.Where((ConfigEntryBase entry) => entry != null)) { SetDescription(item, GetLocalizedDescription(item.Definition.Key)); } } private static void ModConfigDisplayNamePostfix(object __instance, ref string __result) { ConfigEntryBase val = TryGetConfigEntry(__instance); if (IsWhereIsThingEntry(val)) { string localizedConfigText = GetLocalizedConfigText(val.Definition.Section, val.Definition.Key); if (!string.IsNullOrEmpty(localizedConfigText)) { __result = localizedConfigText; } } } private static void ModConfigUiChangedPostfix(MonoBehaviour __instance) { if ((Object)(object)__instance != (Object)null) { __instance.StartCoroutine(LocalizeModConfigUiDeferred(((Component)__instance).transform)); } } private static IEnumerator LocalizeModConfigUiDeferred(Transform root) { yield return null; LocalizeTextInHierarchy(root); } private static void LocalizeTextInHierarchy(Transform root) { if ((Object)(object)root == (Object)null) { return; } try { EnsureTmpReflection(); if (_tmpTextType == null || _tmpTextProperty == null) { return; } Component[] componentsInChildren = ((Component)root).GetComponentsInChildren(_tmpTextType, true); foreach (Component obj in componentsInChildren) { string text = _tmpTextProperty.GetValue(obj, null) as string; string localizedUiText = GetLocalizedUiText(text); if (!string.IsNullOrEmpty(localizedUiText) && localizedUiText != text) { _tmpTextProperty.SetValue(obj, localizedUiText, null); } } } catch { } } private static void EnsureTmpReflection() { if (_tmpTextType != null) { return; } Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { _tmpTextType = assemblies[i].GetType("TMPro.TextMeshProUGUI"); if (_tmpTextType != null) { _tmpTextProperty = _tmpTextType.GetProperty("text"); break; } } } private static string GetLocalizedUiText(string text) { if (string.IsNullOrWhiteSpace(text)) { return null; } string text2 = text.Replace(" ", string.Empty); string localizedToken = GetLocalizedToken(GetCanonicalToken(text2)); if (!string.IsNullOrEmpty(localizedToken)) { return localizedToken; } if (text2.IndexOf(',') >= 0) { string[] array = text2.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(GetCanonicalToken).Select(GetLocalizedToken) .ToArray(); if (array.All((string value) => !string.IsNullOrEmpty(value))) { return string.Join(IsChinese ? "、" : ", ", array); } } return null; } 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 == "ShowOffscreenDirection"; case "NameLanguage": case "MaxDistance": case "FontSize": case "LabelFont": 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", "已选物品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 "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 "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 ConfigEntryBase TryGetConfigEntry(object instance) { if (instance == null) { return null; } Type type = instance.GetType(); FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (typeof(ConfigEntryBase).IsAssignableFrom(fieldInfo.FieldType)) { object? value = fieldInfo.GetValue(instance); return (ConfigEntryBase)((value is ConfigEntryBase) ? value : null); } } PropertyInfo[] properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (PropertyInfo propertyInfo in properties) { if (typeof(ConfigEntryBase).IsAssignableFrom(propertyInfo.PropertyType) && propertyInfo.GetIndexParameters().Length == 0) { try { object? value2 = propertyInfo.GetValue(instance, null); return (ConfigEntryBase)((value2 is ConfigEntryBase) ? value2 : null); } catch { return null; } } } return null; } private static bool IsWhereIsThingEntry(ConfigEntryBase entry) { try { string text = ((entry == null || entry.ConfigFile == null) ? null : entry.ConfigFile.ConfigFilePath); return !string.IsNullOrEmpty(text) && text.EndsWith("com.wuyachiyu.WhereIsThing.cfg", StringComparison.OrdinalIgnoreCase); } catch { return false; } } private static void SetDescription(ConfigEntryBase entry, string text) { if (entry != null && entry.Description != null && !(DescriptionBackingField == null) && !string.IsNullOrEmpty(text)) { DescriptionBackingField.SetValue(entry.Description, text); } } } 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 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 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 GameObject _root; private readonly CanvasGroup _group; private readonly List<TextMeshProUGUI> _shadowTexts = new List<TextMeshProUGUI>(); private readonly TextMeshProUGUI _mainText; private readonly TextMeshProUGUI _arrow; private float _fontSize; private static readonly Vector2[] ShadowOffsets = (Vector2[])(object)new Vector2[4] { new Vector2(0f, 1f), new Vector2(0f, -1f), new Vector2(-1f, 0f), new Vector2(1f, 0f) }; 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, float fontSize) : this(key, canvas, target, titleProvider, isValid, null, font, fontSize) { } public ThingLabel(string key, Transform canvas, Transform target, Func<string> titleProvider, Func<bool> isValid, Func<Vector3> positionProvider, TMP_FontAsset font, float fontSize) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) _key = key; _target = target; _positionProvider = positionProvider; _titleProvider = titleProvider; _isValid = isValid; _fontSize = fontSize; _root = new GameObject("WhereIsThingLabel"); _root.transform.SetParent(canvas, false); _root.layer = 5; _group = _root.AddComponent<CanvasGroup>(); _group.blocksRaycasts = false; _group.interactable = false; for (int i = 0; i < ShadowOffsets.Length; i++) { TextMeshProUGUI val = CreateText("Shadow_" + i, font, fontSize); ((Graphic)val).color = new Color(0f, 0f, 0f, 0.9f); ((TMP_Text)val).rectTransform.anchoredPosition = ShadowOffsets[i]; _shadowTexts.Add(val); } _mainText = CreateText("MainText", font, fontSize); ((Graphic)_mainText).color = new Color(0.875f, 0.855f, 0.761f, 1f); GameObject val2 = new GameObject("OffscreenDirection"); val2.transform.SetParent(_root.transform, false); val2.layer = 5; _arrow = val2.AddComponent<TextMeshProUGUI>(); ((TMP_Text)_arrow).font = font; ((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, float fontSize) { if ((Object)(object)font == (Object)null) { return; } _fontSize = Mathf.Clamp(fontSize, 10f, 64f); ((TMP_Text)_mainText).font = font; ((TMP_Text)_mainText).fontSize = _fontSize; foreach (TextMeshProUGUI shadowText in _shadowTexts) { ((TMP_Text)shadowText).font = font; ((TMP_Text)shadowText).fontSize = _fontSize; } ((TMP_Text)_arrow).font = font; } 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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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_0151: 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_01b3: 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_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0221: 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) //IL_0166: 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); string arg = _titleProvider(); SetText($"{arg}\n<size=18>{num:F0}m</size>"); ((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($"{num:F0}m"); ((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, 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(_root.transform, false); val.layer = 5; TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>(); ((TMP_Text)obj).alignment = (TextAlignmentOptions)514; ((Graphic)obj).raycastTarget = false; ((TMP_Text)obj).overflowMode = (TextOverflowModes)0; ((TMP_Text)obj).richText = true; ((TMP_Text)obj).font = font; ((TMP_Text)obj).fontStyle = (FontStyles)0; ((TMP_Text)obj).fontSize = Mathf.Clamp(size, 10f, 64f); ((TMP_Text)obj).rectTransform.sizeDelta = new Vector2(320f, 96f); ((TMP_Text)obj).rectTransform.anchoredPosition = Vector2.zero; return obj; } private void SetVisible(bool visible) { _group.alpha = (visible ? 1f : 0f); } private void SetText(string value) { ((TMP_Text)_mainText).text = value; foreach (TextMeshProUGUI shadowText in _shadowTexts) { ((TMP_Text)shadowText).text = value; } } } internal sealed class ThingPresetPickerWindow { 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 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 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 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_0737: Unknown result type (might be due to invalid IL or missing references) //IL_0746: Unknown result type (might be due to invalid IL or missing references) //IL_0755: Unknown result type (might be due to invalid IL or missing references) //IL_0764: Unknown result type (might be due to invalid IL or missing references) //IL_0773: 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); CreateText(val.transform, "ScopeTitle", ThingUi.ScopeTitle(), 13f, (TextAlignmentOptions)513, new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(22f, 18f), new Vector2(128f, 44f), wrap: false, autoSize: true); CreateScopeToggle(val.transform, ThingUi.Ground(), ThingLocationScope.Ground, 110f); CreateScopeToggle(val.transform, ThingUi.Held(), ThingLocationScope.Held, 250f); CreateScopeToggle(val.transform, ThingUi.Backpack(), ThingLocationScope.Backpack, 390f); CreateScopeToggle(val.transform, ThingUi.Statue(), ThingLocationScope.Statue, 530f); CreateRenameDialog(); _root.SetActive(false); } public void Open(IEnumerable<ThingPresetDefinition> presets, string activePresetId, bool allowEditing, bool usingFallbackPresets, ThingPresetShareMode shareMode, ThingLocationScope scopes, ThingScanMode scanMode, float displayDurationSeconds, 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) { //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) _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); _summaryProvider = summaryProvider; _usePreset = usePreset; _editPreset = editPreset; _renamePreset = renamePreset; _togglePublished = togglePublished; _deletePreset = deletePreset; _createPreset = createPreset; _setShareMode = setShareMode; _setScope = setScope; _cycleScanMode = cycleScanMode; _adjustDisplayDuration = adjustDisplayDuration; _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); 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 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 left) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: 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(0f, 0f); component.anchorMax = new Vector2(0f, 0f); component.sizeDelta = new Vector2(128f, 28f); component.anchoredPosition = new Vector2(left + 64f, 18f); 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 Vector2(12f, 0f); Image val3 = obj.AddComponent<Image>(); ((Graphic)val3).color = new Color(0.85f, 0.72f, 0.28f, 1f); Toggle val4 = val.AddComponent<Toggle>(); ((Selectable)val4).targetGraphic = (Graphic)(object)val2; val4.graphic = (Graphic)(object)val3; ((UnityEvent<bool>)(object)val4.onValueChanged).AddListener((UnityAction<bool>)delegate(bool value) { SetScopeInternal(scope, value); }); CreateText(val.transform, "Label", label, 12f, (TextAlignmentOptions)513, new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(1f, 1f), new Vector2(30f, 0f), new Vector2(-4f, 0f), wrap: false, autoSize: true); _scopeToggles[scope] = val4; return val4; } private TextMeshProUGUI CreateRowButton(Transform parent, string name, string label, float right, UnityAction action, float width) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) return CreateButton(parent, name, new Vector2(right - width, -16f), new Vector2(width, 28f), label, action, anchorRight: true); } private TextMeshProUGUI CreateLayoutText(Transform parent, string name, string value, float size, float preferredHeight, bool wrap, TextAlignmentOptions alignment = (TextAlignmentOptions)513) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) GameObject obj = CreateRect(name, parent); LayoutElement obj2 = obj.AddComponent<LayoutElement>(); obj2.minHeight = preferredHeight; obj2.preferredHeight = preferredHeight; TextMeshProUGUI obj3 = obj.AddComponent<TextMeshProUGUI>(); ((TMP_Text)obj3).font = _font; ((TMP_Text)obj3).fontSize = Mathf.Clamp(size, 8f, 24f); ((TMP_Text)obj3).alignment = alignment; ((TMP_Text)obj3).text = value; ((Graphic)obj3).color = new Color(0.9f, 0.88f, 0.8f, 1f); ((Graphic)obj3).raycastTarget = false; ((TMP_Text)obj3).enableAutoSizing = true; ((TMP_Text)obj3).fontSizeMin = Mathf.Max(9f, size - 4f); ((TMP_Text)obj3).fontSizeMax = Mathf.Clamp(size, 9f, 24f); ((TMP_Text)obj3).textWrappingMode = (TextWrappingModes)(wrap ? 1 : 0); ((TMP_Text)obj3).overflowMode = (TextOverflowModes)((!wrap) ? 1 : 3); ((TMP_Text)obj3).margin = new Vector4(2f, 0f, 2f, 0f); return obj3; } private TextMeshProUGUI CreateLayoutButton(Transform parent, string name, string label, float preferredWidth, UnityAction action) { //IL_004f: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) GameObject val = CreateRect(name, parent); LayoutElement obj = val.AddComponent<LayoutElement>(); obj.minWidth = preferredWidth; obj.preferredWidth = preferredWidth; obj.minHeight = 28f; obj.preferredHeight = 28f; Image val2 = val.AddComponent<Image>(); ((Graphic)val2).color = new Color(0.2f, 0.2f, 0.18f, 1f); Button obj2 = val.AddComponent<Button>(); ((Selectable)obj2).targetGraphic = (Graphic)(object)val2; ((UnityEvent)obj2.onClick).AddListener(action); return CreateText(val.transform, "Text", label, 11f, (TextAlignmentOptions)514, Vector2.zero, new Vector2(0.5f, 0.5f), Vector2.one, Vector2.zero, Vector2.zero, wrap: false, autoSize: true); } private TextMeshProUGUI CreateButton(Transform parent, string name, Vector2 position, Vector2 size, string text, UnityAction action, bool anchorRight = false) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) GameObject val = CreateRect(name, parent); RectTransform component = val.GetComponent<RectTransform>(); if (anchorRight) { component.anchorMin = new Vector2(1f, 1f); component.anchorMax = new Vector2(1f, 1f); component.sizeDelta = size; component.anchoredPosition = new Vector2(position.x + size.x, position.y - size.y * 0.5f); } else { component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(0f, 1f); component.sizeDelta = size; component.anchoredPosition = position + new Vector2(size.x * 0.5f, (0f - size.y) * 0.5f); } Image val2 = val.AddComponent<Image>(); ((Graphic)val2).color = new Color(0.2f, 0.2f, 0.18f, 1f); Button obj = val.AddComponent<Button>(); ((Selectable)obj).targetGraphic = (Graphic)(object)val2; ((UnityEvent)obj.onClick).AddListener(action); return CreateText(val.transform, "Text", text, 12f, (TextAlignmentOptions)514, new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(1f, 1f), Vector2.zero, Vector2.zero, wrap: false, autoSize: true); } private Button CreateActionButton(Transform parent, string name, string text, Vector2 position, Vector2 size, UnityAction action, bool anchorRight) { //IL_0030: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) GameObject val = CreateRect(name, parent); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(anchorRight ? 1f : 0f, anchorRight ? 0f : 1f); component.anchorMax = new Vector2(anchorRight ? 1f : 0f, anchorRight ? 0f : 1f); component.sizeDelta = size; if (anchorRight) { component.anchoredPosition = new Vector2(position.x - size.x * 0.5f, position.y + size.y * 0.5f); } else { component.anchoredPosition = position + new Vector2(size.x * 0.5f, (0f - size.y) * 0.5f); } Image val2 = val.AddComponent<Image>(); ((Graphic)val2).color = new Color(0.2f, 0.2f, 0.18f, 1f); Button obj = val.AddComponent<Button>(); ((Selectable)obj).targetGraphic = (Graphic)(object)val2; ((UnityEvent)obj.onClick).AddListener(action); CreateText(val.transform, "Text", text, 13f, (TextAlignmentOptions)514, new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(1f, 1f), Vector2.zero, Vector2.zero, wrap: false, autoSize: true); return obj; } private TextMeshProUGUI CreateText(Transform parent, string name, string value, float size, TextAlignmentOptions alignment, Vector2 anchorMin, Vector2 pivot, Vector2 anchorMax, Vector2 offsetMin, Vector2 offsetMax, bool wrap, bool autoSize) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) GameObject obj = CreateRect(name, parent); RectTransform component = obj.GetComponent<RectTransform>(); component.anchorMin = anchorMin; component.anchorMax = anchorMax; component.pivot = pivot; component.offsetMin = offsetMin; component.offsetMax = offsetMax; TextMeshProUGUI val = obj.AddComponent<TextMeshProUGUI>(); ((TMP_Text)val).font = _font; ((TMP_Text)val).fontSize = Mathf.Clamp(size, 8f, 24f); ((TMP_Text)val).alignment = alignment; ((TMP_Text)val).text = value; ((Graphic)val).color = new Color(0.9f, 0.88f, 0.8f, 1f); ((Graphic)val).raycastTarget = false; ((TMP_Text)val).enableAutoSizing = autoSize; if (autoSize) { ((TMP_Text)val).fontSizeMin = Mathf.Max(9f, size - 4f); ((TMP_Text)val).fontSizeMax = Mathf.Clamp(size, 9f, 24f); } ((TMP_Text)val).textWrappingMode = (TextWrappingModes)(wrap ? 1 : 0); ((TMP_Text)val).overflowMode = (TextOverflowModes)((!wrap) ? 1 : 3); ((TMP_Text)val).margin = new Vector4(4f, 0f, 4f, 0f); return val; } private static GameObject CreateRect(string name, Transform parent) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); val.layer = 5; return val; } private static void Stretch(RectTransform rect, float left, float bottom, float right, float top) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) rect.anchorMin = Vector2.zero; rect.anchorMax = Vector2.one; rect.offsetMin = new Vector2(left, bottom); rect.offsetMax = new Vector2(0f - right, 0f - top); } } internal enum ThingPresetShareMode { Off, BuiltInOnly, PublishedPresets } internal sealed class ThingPresetDefinition { public string Id { get; set; } public string Name { get; set; } public bool Published { get; set; } public HashSet<ushort> SelectedItemIds { get; private set; } public HashSet<ThingLuggageType> SelectedLuggageTypes { get; private set; } public HashSet<ThingSceneTargetType> SelectedSceneTargetTypes { get; private set; } public ThingPresetDefinition(string id, string name) { Id = (string.IsNullOrWhiteSpace(id) ? Guid.NewGuid().ToString("N") : id); Name = (string.IsNullOrWhiteSpace(name) ? ThingUi.Text("Preset", "预设") : name); SelectedItemIds = new HashSet<ushort>(); SelectedLuggageTypes = new HashSet<ThingLuggageType>(); SelectedSceneTargetTypes = new HashSet<ThingSceneTargetType>(); } public ThingPresetDefinition Clone(string newId = null, string newName = null) { ThingPresetDefinition thingPresetDefinition = new ThingPresetDefinition(newId ?? Id, newName ?? Name); thingPresetDefinition.Published = Published; thingPresetDefinition.SelectedItemIds.UnionWith(SelectedItemIds); thingPresetDefinition.SelectedLuggageTypes.UnionWith(SelectedLuggageTypes); thingPresetDefinition.SelectedSceneTargetTypes.UnionWith(SelectedSceneTargetTypes); return thingPresetDefinition; } public void Normalize() { } } internal static class ThingPresetCodec { private const char RecordSeparator = '\n'; private const char FieldSeparator = '|'; public static string SerializePresets(IEnumerable<ThingPresetDefinition> presets) { if (presets == null) { return string.Empty; } StringBuilder stringBuilder = new StringBuilder(); foreach (ThingPresetDefinition preset in presets) { if (preset != null) { preset.Normalize(); if (stringBuilder.Length > 0) { stringBuilder.Append('\n'); } stringBuilder.Append(preset.Id ?? string.Empty); stringBuilder.Append('|'); stringBuilder.Append(EncodeText(preset.Name ?? string.Empty)); stringBuilder.Append('|'); stringBuilder.Append(preset.Published ? "1" : "0"); stringBuilder.Append('|'); stringBuilder.Append(string.Join(",", (from value in preset.SelectedItemIds orderby value select value.ToString()).ToArray())); stringBuilder.Append('|'); stringBuilder.Append(string.Join(",", (from value in preset.SelectedLuggageTypes orderby (int)value select value.ToString()).ToArray())); stringBuilder.Append('|'); stringBuilder.Append(string.Join(",", (from value in preset.SelectedSceneTargetTypes orderby (int)value select value.ToString()).ToArray())); } } return stringBuilder.ToString(); } public static List<ThingPresetDefinition> DeserializePresets(string payload) { List<ThingPresetDefinition> list = new List<ThingPresetDefinition>(); if (string.IsNullOrWhiteSpace(payload)) { return list; } string[] array = payload.Split(new char[1] { '\n' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { '|' }); if (array2.Length < 6) { continue; } ThingPresetDefinition thingPresetDefinition = new ThingPresetDefinition(array2[0], DecodeText(array2[1])) { Published = (array2[2] == "1") }; string[] array3 = array2[3].Split(new char[3] { ',', ';', ' ' }, StringSplitOptions.RemoveEmptyEntries); for (int j = 0; j < array3.Length; j++) { if (ushort.TryParse(array3[j], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { thingPresetDefinition.SelectedItemIds.Add(result); } } array3 = array2[4].Split(new char[3] { ',', ';', ' ' }, StringSplitOptions.RemoveEmptyEntries); for (int j = 0; j < array3.Length; j++) { if (Enum.TryParse<ThingLuggageType>(array3[j], ignoreCase: true, out var result2) && Enum.IsDefined(typeof(ThingLuggageType), result2)) { thingPresetDefinition.SelectedLuggageTypes.Add(result2); } } array3 = array2[5].Split(new char[3] { ',', ';', ' ' }, StringSplitOptions.RemoveEmptyEntries); for (int j = 0; j < array3.Length; j++) { if (Enum.TryParse<ThingSceneTargetType>(array3[j], ignoreCase: true, out var result3) && Enum.IsDefined(typeof(ThingSceneTargetType), result3)) { thingPresetDefinition.SelectedSceneTargetTypes.Add(result3); } } thingPresetDefinition.Normalize(); list.Add(thingPresetDefinition); } return list; } private static string EncodeText(string value) { return Convert.ToBase64String(Encoding.UTF8.GetBytes(value ?? string.Empty)); } private static string DecodeText(string value) { try { return Encoding.UTF8.GetString(Convert.FromBase64String(value ?? string.Empty)); } catch { return value ?? string.Empty; } } } internal static class ThingPresetFactory { public const string AchievementPresetId = "preset-achievement"; public const string SurvivalPresetId = "preset-survival"; public const string AscentEightPresetId = "preset-ascent-8"; public static ThingPresetDefinition CreateAchievementPreset() { ThingPresetDefinition thingPresetDefinition = new ThingPresetDefinition("preset-achievement", ThingUi.AchievementPresetName()); thingPresetDefinition.Published = true; thingPresetDefinition.SelectedLuggageTypes.Add(ThingLuggageType.Clown); thingPresetDefinition.SelectedSceneTargetTypes.Add(ThingSceneTargetType.GloomBellTower); thingPresetDefinition.Normalize(); return thingPresetDefinition; } public static ThingPresetDefinition CreateSurvivalPreset() { ThingPresetDefinition thingPresetDefinition = new ThingPresetDefinition("preset-survival", ThingUi.SurvivalPresetName()); thingPresetDefinition.Published = true; thingPresetDefinition.Normalize(); return thingPresetDefinition; } public static ThingPresetDefinition CreateAscentEightPreset() { ThingPresetDefinition thingPresetDefinition = new ThingPresetDefinition("preset-ascent-8", ThingUi.AscentEightPresetName()); thingPresetDefinition.Published = true; thingPresetDefinition.Normalize(); return thingPresetDefinition; } public static ThingPresetDefinition CreateCustomPreset(int index) { return new ThingPresetDefinition(Guid.NewGuid().ToString("N"), ThingUi.CustomPresetName(index)) { Published = false }; } public static bool IsBuiltInPresetId(string presetId) { if (!string.Equals(presetId, "preset-achievement", StringComparison.Ordina