Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of DrakesRenameit v1.0.0
DrakesRenameit.dll
Decompiled 2 weeks 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.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using DrakeRenameit.API; using DrakeRenameit.Ext.UI; using DrakeRenameit.ModText; using DrakeRenameit.Patches; using DrakeRenameit.Permissions; using DrakeRenameit.UI; using HarmonyLib; using JetBrains.Annotations; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("DrakeRenameit")] [assembly: AssemblyDescription("Manage your doors and chests better")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("DrakeMods")] [assembly: AssemblyProduct("DrakeRenameit")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("5DF97E86-BF46-46C5-894F-6B2D80EA6645")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace DrakeRenameit { public static class MenuKeyBinding { public static bool IsHeld(string? binding) { if (string.IsNullOrWhiteSpace(binding)) { return false; } string text = binding.Trim(); if (string.Equals(text, "None", StringComparison.OrdinalIgnoreCase)) { return true; } foreach (string item in SplitTokens(text)) { if (!IsTokenHeld(item)) { return false; } } return true; } public static string FormatForDisplay(string? binding) { if (string.IsNullOrWhiteSpace(binding)) { return RenameItLocalization.T("menu_key_fallback"); } string text = binding.Trim(); if (string.Equals(text, "None", StringComparison.OrdinalIgnoreCase)) { return ""; } List<string> list = SplitTokens(text).ToList(); if (list.Count == 0) { return text; } return string.Join(" + ", list.Select(FormatToken)); } private static IEnumerable<string> SplitTokens(string binding) { return from t in binding.Split(new char[4] { '+', ',', '&', ';' }, StringSplitOptions.RemoveEmptyEntries) select t.Trim() into t where t.Length > 0 select t; } private static bool IsTokenHeld(string token) { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) switch (token.ToLowerInvariant()) { case "shift": return Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303); case "ctrl": case "control": return Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305); case "alt": return Input.GetKey((KeyCode)308) || Input.GetKey((KeyCode)307); default: { if (Enum.TryParse<KeyCode>(token, ignoreCase: true, out KeyCode result)) { return Input.GetKey(result); } return false; } } } private static string FormatToken(string token) { switch (token.ToLowerInvariant()) { case "shift": return "Shift"; case "ctrl": case "control": return "Ctrl"; case "alt": return "Alt"; default: { if (Enum.TryParse<KeyCode>(token, ignoreCase: true, out KeyCode result)) { return ((object)(KeyCode)(ref result)).ToString(); } return token; } } } } public static class RenameitConfig { private const int ExpectedSyncedEntryCount = 31; private const string SectionAdmin = "01 Admin"; private const string SectionFeatures = "02 Features"; private const string SectionExclusions = "03 Exclusions"; private const string SectionCraftedBy = "04 CraftedBy"; private const string SectionGeneral = "05 General"; private const string SectionStacks = "06 Stacks"; private const string SectionUnlockCost = "07 UnlockCost"; private const string SectionLimits = "08 Limits"; private const string SectionModifiers = "09 Modifiers"; private const string SectionUI = "10 UI-NotSynced"; private const string DisplayAdmin = "Admin"; private const string DisplayFeatures = "Features"; private const string DisplayExclusions = "Exclusions"; private const string DisplayCraftedBy = "Crafted by"; private const string DisplayGeneral = "General"; private const string DisplayStacks = "Stacks"; private const string DisplayUnlockCost = "Unlock cost"; private const string DisplayLimits = "Limits"; private const string DisplayModifiers = "Modifiers"; private const string DisplayUI = "UI-NotSynced"; private static ConfigSync configSync = new ConfigSync("DrakesRenameit") { DisplayName = "DrakesRenameit", CurrentVersion = "1.0.0", MinimumRequiredVersion = "1.0.0" }; private static ConfigEntry<bool> _lockToOwner = null; private static ConfigEntry<bool> _rewriteDescriptionsEnable = null; private static ConfigEntry<bool> _RenameEnable = null; private static ConfigEntry<bool> _nameClaimsOwner = null; private static ConfigEntry<bool> _allowAdminOverride = null; private static ConfigEntry<bool> _allowRenameUnownedItems = null; private static ConfigEntry<int> _nameCharLimit = null; private static ConfigEntry<int> _descCharLimit = null; private static ConfigEntry<int> _craftedByCharLimit = null; private static ConfigEntry<string> _vipList = null; private static ConfigEntry<bool> _configLock = null; private static ConfigEntry<string> _menuHintColor = null; private static ConfigEntry<string> _excludedNames = null; private static ConfigEntry<string> _excludedCategory = null; private static ConfigEntry<string> _renameAllowlist = null; private static ConfigEntry<bool> _excludeStacks = null; private static ConfigEntry<bool> _vipOnlyOverride = null; private static ConfigEntry<bool> _showDenialUi = null; private static ConfigEntry<bool> _showReason = null; private static ConfigEntry<bool> _separateStacks = null; private static ConfigEntry<bool> _separateStacksHardLock = null; private static ConfigEntry<bool> _craftedByLabelEnabled = null; private static ConfigEntry<bool> _craftedByLabelCustomizable = null; private static ConfigEntry<string> _craftedByAllowedLabels = null; private static ConfigEntry<string> _menuOpenModifier = null; private static ConfigEntry<string> _serverDefaultMenuOpenModifier = null; private static ConfigEntry<bool> _unlockCostEnabled = null; private static ConfigEntry<string> _unlockCost = null; private static ConfigEntry<bool> _showItemStandItemNameWhenNoAccess = null; private static ConfigEntry<bool> _durabilityModifierEnabled = null; private static ConfigEntry<string> _durabilityUnbrokenLabel = null; private static ConfigEntry<string> _durabilityBrokenLabel = null; private static ConfigEntry<string> _durabilityTierModifiers = null; private static int _syncedEntryCount; private static bool _lockingConfigRegistered; internal static ManualLogSource? Log { get; set; } public static bool LockToOwner => _lockToOwner.Value; public static int DescCharLimit => _descCharLimit.Value; public static bool NameClaimsOwner => _nameClaimsOwner.Value; public static bool RewriteDescriptionsEnabled => _rewriteDescriptionsEnable.Value; public static bool RenameEnabled => _RenameEnable.Value; public static bool CraftedByLabelEnabled => _craftedByLabelEnabled.Value; public static bool CraftedByLabelCustomizable => _craftedByLabelCustomizable.Value; public static string CraftedByAllowedLabels => _craftedByAllowedLabels.Value; public static bool AllowRenameUnownedItems => _allowRenameUnownedItems.Value; public static bool AllowAdminOverride => _allowAdminOverride.Value; public static int NameCharLimit => _nameCharLimit.Value; public static int CraftedByCharLimit => _craftedByCharLimit.Value; public static string VipList => _vipList.Value; public static bool LockSyncedConfig => _configLock.Value; public static string MenuHintColor => _menuHintColor.Value; public static string ExcludedNames => _excludedNames.Value; public static string ExcludedCategory => _excludedCategory.Value; public static string RenameAllowlist => _renameAllowlist.Value; public static bool ExcludeStacks => _excludeStacks.Value; public static bool VipOnlyOverride => _vipOnlyOverride.Value; public static bool ShowDenialUi => _showDenialUi.Value; public static bool ShowReason => _showReason.Value; public static bool SeparateStacks => _separateStacks.Value; public static bool SeparateStacksHardLock => _separateStacksHardLock.Value; public static string ServerDefaultMenuOpenModifier => _serverDefaultMenuOpenModifier.Value; public static string MenuOpenModifier => string.IsNullOrWhiteSpace(_menuOpenModifier.Value) ? _serverDefaultMenuOpenModifier.Value : _menuOpenModifier.Value; public static bool UnlockCostEnabled => _unlockCostEnabled.Value; public static string UnlockCost => _unlockCost.Value; public static bool ShowItemStandItemNameWhenNoAccess => _showItemStandItemNameWhenNoAccess.Value; public static bool DurabilityModifierEnabled => _durabilityModifierEnabled.Value; public static string DurabilityUnbrokenLabel => _durabilityUnbrokenLabel.Value; public static string DurabilityBrokenLabel => _durabilityBrokenLabel.Value; public static string DurabilityTierModifiers => _durabilityTierModifiers.Value; public static List<string> GetCraftedByAllowedLabelsList() { string value = _craftedByAllowedLabels.Value; if (string.IsNullOrWhiteSpace(value)) { return new List<string> { "Crafted By", "Belongs To", "Return to" }; } List<string> list = (from s in value.Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries) select s.Trim() into s where s.Length > 0 select s).ToList(); if (list.Count == 0) { return new List<string> { "Crafted By", "Belongs To", "Return to" }; } List<string> list2 = new List<string>(); foreach (string p in list) { if (!list2.Exists((string x) => string.Equals(x, p, StringComparison.Ordinal))) { list2.Add(p); } } return list2; } public static void Bind(ConfigFile config) { _allowAdminOverride = config.BindSynced("01 Admin", "Admin", "AllowAdminOverride", defaultValue: true, "If enabled, Valheim server admins and VIP list / API users may bypass ownership, exclusions, and most per-item blocks (still respects Features toggles unless elevated logic applies). Does NOT grant Valheim admin commands."); _configLock = config.BindSynced("01 Admin", "Admin", "LockSyncedConfig", defaultValue: true, "When true, only Valheim server admins can change synced gameplay settings (sections 01–09: Admin through Modifiers). Clients cannot push config edits to the server. UI section (10) stays per-client. Strongly recommended for public servers."); configSync.AddLockingConfigEntry<bool>(_configLock); _lockingConfigRegistered = true; _vipList = config.BindSynced("01 Admin", "Admin", "VipList", "", "Comma- or semicolon-separated character names and/or platform user IDs (Steam ID / GetPlayerID — same as adminlist.txt IDs). Server-synced; edit on the server only when LockSyncedConfig is on. Grants mod bypass only, not Valheim admin."); _vipOnlyOverride = config.BindSynced("01 Admin", "Admin", "VipOnlyOverride", defaultValue: false, "If true (and AdminOverride is on), only VIP list / AddVIP API users are treated as elevated for bypassing rules—Valheim server admin is NOT. Useful for testing VIP behavior locally. If false, Valheim admin OR VIP is elevated."); _RenameEnable = config.BindSynced("02 Features", "Features", "RenameEnabled", defaultValue: true, "If enabled, players may edit item display names (subject to all other rules). Turn off to freeze names on new edits while leaving descriptions/crafted-by alone."); _rewriteDescriptionsEnable = config.BindSynced("02 Features", "Features", "RewriteDescriptionsEnabled", defaultValue: true, "If enabled, players may edit item descriptions. Turn off to pre-place lore text and block further description changes."); _craftedByLabelEnabled = config.BindSynced("02 Features", "Features", "CraftedByLabelEnabled", defaultValue: true, "If true, players may set a display-only override for the crafted-by line (real crafter id/name unchanged)."); _excludedNames = config.BindSynced("03 Exclusions", "Exclusions", "ExcludedNames", "", "Comma-separated entries: Jotunn Token ($item_...) OR Item spawn name (AxeStone) OR English display name. Admins/VIP ignore when AdminOverride is on. See ExcludedCategory and RenameAllowlist."); _excludedCategory = config.BindSynced("03 Exclusions", "Exclusions", "ExcludedCategory", "", "Comma-separated category tokens (non-elevated players). Examples: Swords,Armor,Material,Bows. Reference file: BepInEx/config/<mod GUID>/ExcludedCategoryReference.txt on first run or version change."); _renameAllowlist = config.BindSynced("03 Exclusions", "Exclusions", "RenameAllowlist", "", "Comma-separated entries (same format as ExcludedNames). When RenameEnabled / RewriteDescriptionsEnabled are ON, these items bypass ExcludedNames, ExcludedCategory, ExcludeStacks, and the unowned (AllowRenameUnownedItems) rule. Does NOT bypass global Features toggles when those are off. Does not bypass LockToOwner."); _craftedByLabelCustomizable = config.BindSynced("04 CraftedBy", "Crafted by", "LabelCustomizable", defaultValue: true, "If true, players who can edit crafted-by may choose a tooltip line label from AllowedLabels. If false, the label picker is greyed out for normal players (default line only) while admins/VIPs can still change it."); _craftedByAllowedLabels = config.BindSynced("04 CraftedBy", "Crafted by", "AllowedLabels", "Crafted By, Belongs To, Return to", "Comma- or semicolon-separated labels shown before the crafter name (e.g. “Belongs To: Name”). The first entry is the default (vanilla localized crafted-by line when that option is selected)."); _lockToOwner = config.BindSynced("05 General", "General", "LockToOwner", defaultValue: true, "If true, only the crafter/owner can rename the item, edit its description, or crafted-by display. Items with no crafter (unowned stacks) are not locked until someone claims them (NameClaimsOwner) or the item is crafted."); _nameClaimsOwner = config.BindSynced("05 General", "General", "NameClaimsOwner", defaultValue: true, "If true, renaming an unowned item assigns ownership to the renamer. Used with LockToOwner: the first successful rename on an unclaimed stack makes you the owner."); _allowRenameUnownedItems = config.BindSynced("05 General", "General", "AllowRenameUnownedItems", defaultValue: true, "If true, unowned items may be renamed or given a description/crafted-by display. Unowned means no crafter id and no crafter name — e.g. picked up from the world, spawned (console/admin), loot drops, and uncrafted resource stacks. When false, those stacks are blocked unless on RenameAllowlist. Not the same as ExcludedCategory Material (that blocks by item type even when crafted). When false, NameClaimsOwner cannot claim those stacks."); _showDenialUi = config.BindSynced("05 General", "General", "ShowDenialUi", defaultValue: true, "If true, access denials (not your item, excluded, rename disabled, etc.) show a red strikethrough menu hint, denial lines in tooltips, and a center message when modifier+right-click cannot open the menu. If false, those access cues are hidden. Unlock-cost, not-in-inventory, and empty-field errors are unchanged. Server-synced."); _showReason = config.BindSynced("05 General", "General", "ShowReason", defaultValue: false, "If true, denial text (when ShowDenialUi is on) uses specific reasons (ownership, exclusion, unowned, etc.). If false, generic messages only. Has no effect when ShowDenialUi is off. Server-synced."); _showItemStandItemNameWhenNoAccess = config.BindSynced("05 General", "General", "ShowItemStandItemNameWhenNoAccess", defaultValue: true, "If true, item stands inside warded/private areas still show 'no access' but also append the stand's current item name to the hover label (display only; permissions unchanged)."); _serverDefaultMenuOpenModifier = config.BindSynced("05 General", "General", "ServerDefaultMenuOpenModifier", "Shift", "Default keys for opening the Renameit menu when a player's local MenuOpenModifier (section 10) is empty. Set on the server/modpack for compatibility (e.g. None if another mod uses Shift). Non-empty local MenuOpenModifier always overrides on that client."); _separateStacks = config.BindSynced("06 Stacks", "Stacks", "SeparateStacks", defaultValue: true, "If true, stacks only combine when Drake custom name, description, and crafted-by display match (same identity). Renamed or customized stacks no longer absorb mismatched pickups automatically."); _separateStacksHardLock = config.BindSynced("06 Stacks", "Stacks", "SeparateStacksHardLock", defaultValue: false, "Only applies when SeparateStacks is on. If true, mismatched stacks never merge — including manual drags. If false, auto pickup still will not combine mismatched stacks, but you can drag one stack onto another to merge immediately (target stack keeps its custom data)."); _excludeStacks = config.BindSynced("06 Stacks", "Stacks", "ExcludeStacks", defaultValue: false, "When true, non-elevated players cannot rename, change descriptions, or edit crafted-by on stackable vanilla items (m_maxStackSize > 1). Admins/VIPs override when AllowAdminOverride is on. Items on RenameAllowlist bypass this. Does not change SeparateStacks merge behavior."); _unlockCostEnabled = config.BindSynced("07 UnlockCost", "Unlock cost", "UnlockCostEnabled", defaultValue: false, "If true, each item stack must be unlocked once (pay UnlockCost from your inventory) before rename, description, or crafted-by edits apply. Invalid/empty UnlockCost is ignored. Elevated players skip the cost when AdminOverride applies."); _unlockCost = config.BindSynced("07 UnlockCost", "Unlock cost", "UnlockCost", "Coins:5", "Comma or semicolon separated: PrefabName:amount (e.g. Coins:4, Coal:10) or $item_token:amount. Uses player inventory. Paid once per stack via the Unlock button in the action menu."); _nameCharLimit = config.BindSynced("08 Limits", "Limits", "NameCharacterLimit", 50, "Max characters for rename text (count <color=> tag codes toward the limit)."); _craftedByCharLimit = config.BindSynced("08 Limits", "Limits", "CraftedByCharLimit", 50, "Max characters for crafted-by display name (count rich-text tags toward the limit)."); _descCharLimit = config.BindSynced("08 Limits", "Limits", "DescriptionCharacterLimit", 1000, "Max characters for item description (count rich-text tags toward the limit)."); _durabilityModifierEnabled = config.BindSynced("09 Modifiers", "Modifiers", "DurabilityModifierEnabled", defaultValue: false, "If true, prepends a durability wear label (Pristine / tiers / Broken) in front of the item name everywhere Drake builds display names — only for forge-repair gear and tools (m_useDurability), not spoilage timers. Does not change stored rename text."); _durabilityUnbrokenLabel = config.BindSynced("09 Modifiers", "Modifiers", "DurabilityUnbrokenLabel", "Pristine", "Prepended at full durability (100%). Empty = no label when pristine. Rich-text color tags allowed."); _durabilityBrokenLabel = config.BindSynced("09 Modifiers", "Modifiers", "DurabilityBrokenLabel", "<#f00>Broken</color>", "Prepended only when durability is 0 (item is broken in-game and must be repaired). Not used for worn but usable gear. Empty = no label when broken."); _durabilityTierModifiers = config.BindSynced("09 Modifiers", "Modifiers", "DurabilityTierModifiers", "{<#c50>Rusty</color>,0.4},{<#888>Worn</color>,0.6},{<#aaa>Tarnished</color>,0.8}", "Wear bands between broken and pristine: {Name,fraction} or {Name,percent}. Each applies when current/max is at or below that value; lowest matching band wins. Supports <color> tags; terminate with </color> unless you add a high threshold near 1."); _menuHintColor = config.BindClientOnly("10 UI-NotSynced", "UI-NotSynced", "MenuHintColor", "yellow", "Color for the inventory tooltip hint (Modifier + Right Click). Unity color names or hex (#fff / #ffffff). Per-client only."); _menuOpenModifier = config.BindClientOnly("10 UI-NotSynced", "UI-NotSynced", "MenuOpenModifier", "", "Optional per-client override for menu keys. Leave empty to use ServerDefaultMenuOpenModifier from the server. When set, always wins on this machine. Examples: Shift, Ctrl, Alt, Shift+Alt, F1, None. Combine with + , or &."); MigrateLegacyConfigSections(config); RenameitPermission.WireVipListSync(_vipList, configSync); FinalizeServerSync(); } private static ConfigEntry<T> BindSynced<T>(this ConfigFile config, string section, string displayCategory, string key, T defaultValue, string description) { //IL_0011: 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: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown ConfigEntry<T> val = config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Category = displayCategory } })); SyncedConfigEntry<T> syncedConfigEntry = configSync.AddConfigEntry<T>(val); syncedConfigEntry.SynchronizedConfig = true; _syncedEntryCount++; return val; } private static ConfigEntry<T> BindClientOnly<T>(this ConfigFile config, string section, string displayCategory, string key, T defaultValue, string description) { //IL_0011: 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: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Category = displayCategory } })); } private static void FinalizeServerSync() { if (!_lockingConfigRegistered) { ManualLogSource? log = Log; if (log != null) { log.LogError((object)"[ServerSync] LockSyncedConfig was not registered via AddLockingConfigEntry — synced settings are not admin-locked."); } } if (_syncedEntryCount != 31) { ManualLogSource? log2 = Log; if (log2 != null) { log2.LogError((object)$"[ServerSync] Expected {31} synced entries, registered {_syncedEntryCount}."); } } configSync.SourceOfTruthChanged += OnConfigAuthorityChanged; OnConfigAuthorityChanged(configSync.IsSourceOfTruth); } private static void OnConfigAuthorityChanged(bool localIsAuthoritative) { if (localIsAuthoritative) { if (!LockSyncedConfig) { ManualLogSource? log = Log; if (log != null) { log.LogWarning((object)"[ServerSync] LockSyncedConfig is false on the host. Non-admin clients can change and broadcast gameplay settings (sections 01–09). Set LockSyncedConfig = true on the server."); } } } else if (!LockSyncedConfig) { ManualLogSource? log2 = Log; if (log2 != null) { log2.LogInfo((object)"[ServerSync] Connected to a host with config lock disabled; server values still apply until changed."); } } } private static void MigrateLegacyConfigSections(ConfigFile config) { MigrateSectionKeys(config, "Admin", "01 Admin", "AllowAdminOverride", "LockSyncedConfig", "VipList", "VipOnlyOverride"); MigrateSectionKeys(config, "Features", "02 Features", "RenameEnabled", "RewriteDescriptionsEnabled", "CraftedByLabelEnabled"); MigrateSectionKeys(config, "Exclusions", "03 Exclusions", "ExcludedNames", "ExcludedCategory", "RenameAllowlist"); MigrateSectionKeys(config, "CraftedBy", "04 CraftedBy", "LabelCustomizable", "AllowedLabels"); MigrateSectionKeys(config, "General", "05 General", "LockToOwner", "NameClaimsOwner", "AllowRenameUnownedItems", "ShowDenialUi", "ShowReason", "ShowItemStandItemNameWhenNoAccess", "ServerDefaultMenuOpenModifier"); MigrateHideDisabledDenialUiToShowDenialUi(config); MigrateSectionKeys(config, "Stacks", "06 Stacks", "SeparateStacks", "SeparateStacksHardLock", "ExcludeStacks"); MigrateSectionKeys(config, "UnlockCost", "07 UnlockCost", "UnlockCostEnabled", "UnlockCost"); MigrateSectionKeys(config, "Limits", "08 Limits", "NameCharacterLimit", "CraftedByCharLimit", "DescriptionCharacterLimit"); MigrateSectionKeys(config, "Modifiers", "09 Modifiers", "DurabilityModifierEnabled", "DurabilityUnbrokenLabel", "DurabilityBrokenLabel", "DurabilityTierModifiers"); MigrateSectionKeys(config, "UI-NotSynced", "10 UI-NotSynced", "MenuHintColor", "MenuOpenModifier"); MigrateSectionKeys(config, "Stacks", "07 UnlockCost", "UnlockCostEnabled", "UnlockCost"); } private static void MigrateSectionKeys(ConfigFile config, string legacySection, string newSection, params string[] keys) { foreach (string key in keys) { if (!TryMigrate<bool>(config, legacySection, key, newSection) && !TryMigrate<int>(config, legacySection, key, newSection)) { TryMigrate<string>(config, legacySection, key, newSection); } } } private static bool TryMigrate<T>(ConfigFile config, string legacySection, string key, string newSection) { ConfigEntry<T> val = default(ConfigEntry<T>); if (!config.TryGetEntry<T>(legacySection, key, ref val)) { return false; } ConfigEntry<T> val2 = default(ConfigEntry<T>); if (!config.TryGetEntry<T>(newSection, key, ref val2)) { return false; } val2.Value = val.Value; return true; } private static void MigrateHideDisabledDenialUiToShowDenialUi(ConfigFile config) { string[] array = new string[2] { "05 General", "General" }; ConfigEntry<bool> val = default(ConfigEntry<bool>); ConfigEntry<bool> val2 = default(ConfigEntry<bool>); foreach (string text in array) { if (config.TryGetEntry<bool>(text, "HideDisabledDenialUi", ref val)) { if (config.TryGetEntry<bool>("05 General", "ShowDenialUi", ref val2)) { val2.Value = !val.Value; } break; } } } } internal static class RenameUnlockCost { private static ManualLogSource? _log; internal static void Init(ManualLogSource log) { _log = log; } internal static bool HasValidCostConfigured() { List<(string, int, string)> lines; string error; return TryBuildResolvedCost(out lines, out error); } internal static bool UnlockCostApplies() { return RenameitConfig.UnlockCostEnabled && HasValidCostConfigured(); } internal static bool CanPlayerAfford(Player? player) { if ((Object)(object)player == (Object)null) { return false; } if (!TryBuildResolvedCost(out List<(string, int, string)> lines, out string _)) { return true; } Inventory inventory = ((Humanoid)player).GetInventory(); if (inventory == null) { return false; } foreach (var (text, num, _) in lines) { if (inventory.CountItems(text, -1, true) < num) { return false; } } return true; } internal static bool TryConsumeUnlockCost(Player? player, out string errorMessage) { errorMessage = ""; if ((Object)(object)player == (Object)null) { errorMessage = RenameItLocalization.T("unlock_err_no_player"); return false; } if (!TryBuildResolvedCost(out List<(string, int, string)> lines, out string error)) { errorMessage = error ?? RenameItLocalization.T("unlock_err_not_configured"); return false; } if (lines.Count == 0) { errorMessage = RenameItLocalization.T("unlock_err_empty"); return false; } Inventory inventory = ((Humanoid)player).GetInventory(); if (inventory == null) { errorMessage = RenameItLocalization.T("unlock_err_no_inventory"); return false; } foreach (var (text, num, _) in lines) { if (inventory.CountItems(text, -1, true) < num) { errorMessage = RenameItLocalization.T("unlock_err_not_enough"); return false; } } foreach (var (text2, num2, _) in lines) { inventory.RemoveItem(text2, num2, -1, true); } return true; } internal static string GetCostDisplayShort() { if (!TryBuildResolvedCost(out List<(string, int, string)> lines, out string _) || lines.Count == 0) { return ""; } List<string> list = new List<string>(); foreach (var item3 in lines) { string item = item3.Item1; int item2 = item3.Item2; string arg = item; if (Localization.instance != null) { arg = Localization.instance.Localize(item); } list.Add($"{item2}x {arg}"); } return string.Join(", ", list); } internal static List<(string LocalizedName, int Amount, string PrefabName)> GetCostDisplayEntries() { List<(string, int, string)> list = new List<(string, int, string)>(); if (!TryBuildResolvedCost(out List<(string, int, string)> lines, out string _) || lines.Count == 0) { return list; } foreach (var item5 in lines) { string item = item5.Item1; int item2 = item5.Item2; string item3 = item5.Item3; string item4 = item; if (Localization.instance != null) { item4 = Localization.instance.Localize(item); } list.Add((item4, item2, item3)); } return list; } internal static string GetItemTokenPublic(string prefabName) { return ResolveItemSharedName(prefabName); } internal static Sprite? GetItemIconSprite(string configPrefabName) { if (string.IsNullOrWhiteSpace(configPrefabName) || (Object)(object)ObjectDB.instance == (Object)null) { return null; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(configPrefabName); if ((Object)(object)itemPrefab == (Object)null) { return null; } ItemDrop component = itemPrefab.GetComponent<ItemDrop>(); object result; if (component == null) { result = null; } else { ItemData itemData = component.m_itemData; result = ((itemData != null) ? itemData.GetIcon() : null); } return (Sprite?)result; } private static bool TryBuildResolvedCost(out List<(string SharedName, int Amount, string ConfigKey)> lines, out string? error) { lines = new List<(string, int, string)>(); error = null; string text = RenameitConfig.UnlockCost?.Trim() ?? ""; if (string.IsNullOrEmpty(text)) { error = "UnlockCost is empty."; return false; } string[] array = text.Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); string[] array2 = array; foreach (string text2 in array2) { string text3 = text2.Trim(); if (string.IsNullOrEmpty(text3)) { continue; } int num = text3.LastIndexOf(':'); if (num <= 0 || num >= text3.Length - 1) { ManualLogSource? log = _log; if (log != null) { log.LogWarning((object)("[UnlockCost] Ignoring invalid segment (need Name:Amount): \"" + text3 + "\"")); } continue; } string text4 = text3.Substring(0, num).Trim(); string s = text3.Substring(num + 1).Trim(); if (!int.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) || result <= 0) { ManualLogSource? log2 = _log; if (log2 != null) { log2.LogWarning((object)("[UnlockCost] Ignoring invalid amount in: \"" + text3 + "\"")); } continue; } string text5 = ResolveItemSharedName(text4); if (string.IsNullOrEmpty(text5)) { ManualLogSource? log3 = _log; if (log3 != null) { log3.LogWarning((object)("[UnlockCost] Unknown item or token: \"" + text4 + "\"")); } } else { lines.Add((text5, result, text4)); } } if (lines.Count == 0) { error = "No valid UnlockCost entries (use Item prefab name or $item_ token, e.g. Coins:4)."; return false; } return true; } private static string ResolveItemSharedName(string tokenOrPrefab) { if (string.IsNullOrWhiteSpace(tokenOrPrefab)) { return ""; } if ((Object)(object)ObjectDB.instance == (Object)null) { return tokenOrPrefab.StartsWith("$", StringComparison.Ordinal) ? tokenOrPrefab : ""; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(tokenOrPrefab); if ((Object)(object)itemPrefab != (Object)null) { string text = itemPrefab.GetComponent<ItemDrop>()?.m_itemData?.m_shared?.m_name ?? ""; if (!string.IsNullOrEmpty(text)) { return text; } } if (tokenOrPrefab.StartsWith("$", StringComparison.Ordinal)) { return tokenOrPrefab; } return ""; } } internal static class DurabilityNameModifier { private readonly struct DurabilityModifierRules { internal string UnbrokenLabel { get; } internal string BrokenLabel { get; } internal List<DurabilityTier> Tiers { get; } internal DurabilityModifierRules(string unbrokenLabel, string brokenLabel, List<DurabilityTier> tiers) { UnbrokenLabel = unbrokenLabel; BrokenLabel = brokenLabel; Tiers = tiers; } } private readonly struct DurabilityTier { internal string Label { get; } internal float Threshold { get; } internal DurabilityTier(string label, float threshold) { Label = label.Trim(); Threshold = threshold; } } private const float FullEpsilon = 0.0001f; private static readonly Regex TierRegex = new Regex("\\{([^}]*)\\}", RegexOptions.Compiled); internal static bool AffectsDisplay(ItemData? item) { return !string.IsNullOrEmpty(GetPrefixRaw(item)); } internal static string GetPrefixRaw(ItemData? item) { if (!RenameitConfig.DurabilityModifierEnabled || item?.m_shared == null) { return ""; } if (!TryGetDurabilityRatio(item, out var ratio)) { return ""; } DurabilityModifierRules rules = BuildRules(); string text = ResolveLabel(rules, item, ratio); return string.IsNullOrEmpty(text) ? "" : text.Trim(); } private static string ResolveLabel(DurabilityModifierRules rules, ItemData item, float ratio) { if (item.m_durability <= 0f) { return rules.BrokenLabel; } if (ratio >= 0.9999f) { return rules.UnbrokenLabel; } foreach (DurabilityTier tier in rules.Tiers) { if (ratio <= tier.Threshold + 0.0001f) { return tier.Label; } } return ""; } private static DurabilityModifierRules BuildRules() { string unbrokenLabel = (RenameitConfig.DurabilityUnbrokenLabel ?? "").Trim(); string brokenLabel = (RenameitConfig.DurabilityBrokenLabel ?? "").Trim(); List<DurabilityTier> tiers = ParseTiers(RenameitConfig.DurabilityTierModifiers ?? ""); return new DurabilityModifierRules(unbrokenLabel, brokenLabel, tiers); } private static List<DurabilityTier> ParseTiers(string raw) { List<DurabilityTier> list = new List<DurabilityTier>(); if (string.IsNullOrWhiteSpace(raw)) { return list; } foreach (Match item in TierRegex.Matches(raw)) { if (TryParseTierInner(item.Groups[1].Value, out var tier)) { list.Add(tier); } } list.Sort((DurabilityTier a, DurabilityTier b) => a.Threshold.CompareTo(b.Threshold)); return list; } private static bool UsesWearTierDurabilityItem(ItemData item) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Invalid comparison between Unknown and I4 //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected I4, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Invalid comparison between Unknown and I4 //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected I4, but got Unknown SharedData shared = item.m_shared; if (!shared.m_useDurability || shared.m_maxDurability <= 0f) { return false; } ItemType itemType = shared.m_itemType; if (1 == 0) { } bool result; if ((int)itemType <= 13) { switch ((int)itemType) { case 0: goto IL_0085; case 1: goto IL_0089; case 2: goto IL_008d; } switch (itemType - 9) { case 0: break; case 1: goto IL_009d; case 4: goto IL_00a1; default: goto IL_00a5; } result = false; } else if ((int)itemType != 16) { if ((int)itemType != 21) { goto IL_00a5; } result = false; } else { result = false; } goto IL_00a9; IL_00a1: result = false; goto IL_00a9; IL_009d: result = false; goto IL_00a9; IL_00a5: result = true; goto IL_00a9; IL_00a9: if (1 == 0) { } return result; IL_008d: result = false; goto IL_00a9; IL_0089: result = false; goto IL_00a9; IL_0085: result = false; goto IL_00a9; } private static bool TryGetDurabilityRatio(ItemData item, out float ratio) { ratio = 1f; if (!UsesWearTierDurabilityItem(item)) { return false; } float maxDurability; try { maxDurability = item.GetMaxDurability(); } catch { return false; } if (maxDurability <= 0f) { return false; } ratio = item.m_durability / maxDurability; if (ratio < 0f) { ratio = 0f; } if (ratio > 1f) { ratio = 1f; } return true; } private static bool TryParseTierInner(string inner, out DurabilityTier tier) { tier = default(DurabilityTier); inner = inner.Trim(); if (inner.Length == 0) { return false; } int num = inner.LastIndexOf(','); if (num <= 0 || num >= inner.Length - 1) { return false; } string text = inner.Substring(0, num).Trim(); string text2 = inner.Substring(num + 1).Trim(); if (text.Length == 0 || text2.Length == 0) { return false; } if (!float.TryParse(text2, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return false; } if (result > 1.0001f) { result /= 100f; } if (result < 0f) { result = 0f; } if (result > 1f) { result = 1f; } tier = new DurabilityTier(text, result); return true; } } [BepInPlugin("com.DrakeMods.DrakesRenameit", "DrakesRenameit", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class DrakeRenameit : BaseUnityPlugin { public const string CompanyName = "DrakeMods"; public const string ModName = "DrakesRenameit"; public const string Version = "1.0.0"; public const string GUID = "com.DrakeMods.DrakesRenameit"; public const string DrakeNewName = "Drake_Rename"; public const string DrakeNewDesc = "Drake_Rename_Desc"; public const string DrakeCraftedByDisplay = "Drake_CraftedByDisplay"; public const string DrakeCraftedByLineLabel = "Drake_CraftedByLineLabel"; public const string DrakeRenameUnlocked = "Drake_RenameUnlocked"; public const string TooltipUnlockCostLockedEmoji = "\ud83d\udd12"; public const string TooltipDrakeEditableEmoji = "\ud83d\udd8a\ufe0f"; private readonly Harmony harmony = new Harmony("drakesmod.DrakeRenameit"); public static ItemData? CurrentItem { get; set; } public static bool IsItemInLocalPlayerInventory(ItemData? item) { if (item == null || (Object)(object)Player.m_localPlayer == (Object)null) { return false; } Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory(); return inventory != null && inventory.ContainsItem(item); } private void Awake() { RenameItLocalization.Init((BaseUnityPlugin)(object)this, ((BaseUnityPlugin)this).Logger); RenameitConfig.Log = ((BaseUnityPlugin)this).Logger; RenameitConfig.Bind(((BaseUnityPlugin)this).Config); ExcludedCategoryReferenceWriter.EnsureGenerated(); RenamePermissionManager.Init(((BaseUnityPlugin)this).Logger); RenameUnlockCost.Init(((BaseUnityPlugin)this).Logger); InventoryStackPatches.Apply(harmony, ((BaseUnityPlugin)this).Logger); ItemTooltipPatches.Apply(harmony, ((BaseUnityPlugin)this).Logger); DropHudMessagePatches.ApplyDropItemPendingCapture(harmony, ((BaseUnityPlugin)this).Logger); harmony.PatchAll(); DropHudMessagePatches.ApplyMessageHudShowMessage(harmony, ((BaseUnityPlugin)this).Logger); } public static string GetPropperName(ItemData? item) { if (item?.m_shared == null) { return ""; } return getPropperName(item, item.m_shared.m_name); } public static string GetDisplayNameForUi(ItemData? item, bool localize) { if (item?.m_shared == null) { return ""; } string text = GetPropperName(item) ?? item.m_shared.m_name; string prefixRaw = DurabilityNameModifier.GetPrefixRaw(item); string text2 = (string.IsNullOrEmpty(prefixRaw) ? text : (prefixRaw + " " + text)); string text3 = TooltipRichText.EnsureRichTextTagsClosedForTooltip(text2); if (!localize || Localization.instance == null) { return text3; } return Localization.instance.Localize(text3); } public static bool hasNewDesc(ItemData? item) { if (item?.m_customData == null) { return false; } string value; return item.m_customData.TryGetValue("Drake_Rename_Desc", out value); } public static bool hasNewName(ItemData? item) { if (item == null || item.m_customData == null) { return false; } string value; return item.m_customData.TryGetValue("Drake_Rename", out value); } public static bool HasAnyDrakeRenameCustomization(ItemData? item) { if (item?.m_customData == null) { return false; } if (hasNewName(item)) { return true; } if (hasNewDesc(item)) { return true; } if (HasCraftedByDisplayOverride(item)) { return true; } return HasCraftedByLineLabelOverride(item); } private static bool ReadRenameUnlockedFlag(ItemData item) { if (!item.m_customData.TryGetValue("Drake_RenameUnlocked", out var value)) { return false; } return value == "1" || string.Equals(value, "true", StringComparison.OrdinalIgnoreCase); } public static bool IsRenameUnlocked(ItemData? item) { if (item?.m_customData == null) { return false; } bool flag = ReadRenameUnlockedFlag(item); if (RenameUnlockCost.UnlockCostApplies()) { if (!flag && HasAnyDrakeRenameCustomization(item)) { SetRenameUnlocked(item); return true; } return flag; } return flag; } internal static void SetRenameUnlocked(ItemData item) { if (item.m_customData == null) { item.m_customData = new Dictionary<string, string>(); } item.m_customData["Drake_RenameUnlocked"] = "1"; } public static bool WouldHaveAnyDrakeEditIfUnlockIgnored(ItemData? item) { if (item == null || (Object)(object)Player.m_localPlayer == (Object)null) { return false; } RenamePermissionManager.BeginIgnoreUnlockRequirement(); try { return CanChangeName(item) || CanChangeDesc(item) || CanChangeCraftedByLabel(item); } finally { RenamePermissionManager.EndIgnoreUnlockRequirement(); } } public static bool ShowUnlockButton(ItemData? item) { if (item == null || (Object)(object)Player.m_localPlayer == (Object)null) { return false; } if (!RenameUnlockCost.UnlockCostApplies()) { return false; } if (IsRenameUnlocked(item)) { return false; } if (RenameitPermission.IsElevatedForOverrides(Player.m_localPlayer)) { return false; } return WouldHaveAnyDrakeEditIfUnlockIgnored(item); } public static bool TryPayRenameUnlock(ItemData? item) { if (item == null || (Object)(object)Player.m_localPlayer == (Object)null) { return false; } if (!IsItemInLocalPlayerInventory(item)) { ((Character)Player.m_localPlayer).Message((MessageType)2, RenameItLocalization.T("msg_item_not_in_inventory_unlock"), 0, (Sprite)null); return false; } if (!RenameUnlockCost.UnlockCostApplies() || IsRenameUnlocked(item)) { return false; } if (!WouldHaveAnyDrakeEditIfUnlockIgnored(item)) { if (RenameitConfig.ShowDenialUi) { string menuBlockedReason = GetMenuBlockedReason(item); if (!string.IsNullOrEmpty(menuBlockedReason)) { ((Character)Player.m_localPlayer).Message((MessageType)2, menuBlockedReason, 0, (Sprite)null); } } return false; } if (!RenameUnlockCost.TryConsumeUnlockCost(Player.m_localPlayer, out string errorMessage)) { ((Character)Player.m_localPlayer).Message((MessageType)2, errorMessage, 0, (Sprite)null); return false; } SetRenameUnlocked(item); ((Character)Player.m_localPlayer).Message((MessageType)2, RenameItLocalization.T("msg_item_unlocked"), 0, (Sprite)null); return true; } public static bool HasCraftedByDisplayOverride(ItemData? item) { if (item?.m_customData == null) { return false; } string value; return item.m_customData.TryGetValue("Drake_CraftedByDisplay", out value) && !string.IsNullOrEmpty(value); } public static bool HasCraftedByLineLabelOverride(ItemData? item) { if (item?.m_customData == null) { return false; } string value; return item.m_customData.TryGetValue("Drake_CraftedByLineLabel", out value) && !string.IsNullOrEmpty(value); } public static bool CanResetAnyCustomization(ItemData? item) { if (item == null) { return false; } if (CanChangeName(item) && hasNewName(item)) { return true; } if (CanChangeDesc(item) && hasNewDesc(item)) { return true; } if (CanChangeCraftedByLabel(item) && (HasCraftedByDisplayOverride(item) || HasCraftedByLineLabelOverride(item))) { return true; } return false; } public static void ResetAllCustomizations(ItemData? item) { if (item == null) { return; } if (!IsItemInLocalPlayerInventory(item)) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, RenameItLocalization.T("msg_item_not_in_inventory"), 0, (Sprite)null); } return; } if (CanChangeName(item) && hasNewName(item)) { resetName(item); } if (CanChangeDesc(item) && hasNewDesc(item)) { resetDesc(item); } if (CanChangeCraftedByLabel(item) && (HasCraftedByDisplayOverride(item) || HasCraftedByLineLabelOverride(item)) && item.m_customData != null) { string craftedByDisplay = getCraftedByDisplay(item); item.m_customData.Remove("Drake_CraftedByDisplay"); item.m_customData.Remove("Drake_CraftedByLineLabel"); string newDisplay = item.m_crafterName ?? ""; RenameEvents.RaiseCraftedByDisplayChanged(Player.m_localPlayer, item, item.m_shared.m_name, craftedByDisplay, newDisplay); } } public static string resetName(ItemData? item) { if (item == null) { return ""; } item.m_customData.Remove("Drake_Rename"); return item.m_shared.m_name; } public static string resetDesc(ItemData? item) { if (item == null) { return ""; } item.m_customData.Remove("Drake_Rename_Desc"); return item.m_shared.m_name; } public static string getPropperName(ItemData? item) { if (item?.m_shared == null) { return ""; } return getPropperName(item, item.m_shared.m_name); } public static string getPropperName(ItemData? item, string defaultName) { if (item == null) { return defaultName; } if (item.m_customData == null) { item.m_customData = new Dictionary<string, string>(); } string value; return item.m_customData.TryGetValue("Drake_Rename", out value) ? value : defaultName; } public static string getPropperDesc(ItemData? item) { if (item?.m_shared == null) { return ""; } return getPropperDesc(item, item.m_shared.m_description); } public static string getPropperDesc(ItemData? item, string defaultDesc) { if (item == null) { return defaultDesc; } if (item.m_customData == null) { item.m_customData = new Dictionary<string, string>(); } string value; return item.m_customData.TryGetValue("Drake_Rename_Desc", out value) ? value : defaultDesc; } public static void OpenRename(ItemData? item) { if (!((Object)(object)InventoryGui.instance == (Object)null) && item != null) { CurrentItem = item; if ((Object)(object)UIPanels.InputNamePanel == (Object)null) { UIPanels.CreateRenameInput(); } string propperName = GetPropperName(item); UIPanels.RenameNameInput.text = propperName; UIPanels.InputNamePanel.SetActive(true); UIPanels.EnsureInputBlocked(); } } public static void OpenRewriteDesc(ItemData? item) { if (!((Object)(object)InventoryGui.instance == (Object)null) && item != null) { CurrentItem = item; if ((Object)(object)UIPanels.InputDescPanel == (Object)null) { UIPanels.CreateRenameDescInput(); } string propperDesc = getPropperDesc(item); UIPanels.RenameDescInput.text = propperDesc; UIPanels.InputDescPanel.SetActive(true); UIPanels.EnsureInputBlocked(); } } public static void RenameItem(string name) { if (CurrentItem == null) { return; } if (CurrentItem.m_customData == null) { CurrentItem.m_customData = new Dictionary<string, string>(); } if (string.IsNullOrEmpty(name)) { CurrentItem.m_customData.Remove("Drake_Rename"); } else { CurrentItem.m_customData["Drake_Rename"] = name; RenameEvents.RaiseNameChanged(Player.m_localPlayer, CurrentItem, CurrentItem.m_shared.m_name, name); } if (RenameitConfig.NameClaimsOwner && (RenameitConfig.AllowRenameUnownedItems || RenameExclusionRules.MatchesRenameAllowlist(CurrentItem)) && string.IsNullOrEmpty(CurrentItem.m_crafterName)) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { CurrentItem.m_crafterID = localPlayer.GetPlayerID(); CurrentItem.m_crafterName = localPlayer.GetPlayerName(); } } } public static void RewriteItemDesc(string name) { if (CurrentItem == null) { return; } if (CurrentItem.m_customData == null) { CurrentItem.m_customData = new Dictionary<string, string>(); } if (string.IsNullOrEmpty(name)) { CurrentItem.m_customData.Remove("Drake_Rename_Desc"); } else { CurrentItem.m_customData["Drake_Rename_Desc"] = name; RenameEvents.RaiseDescriptionChanged(Player.m_localPlayer, CurrentItem, CurrentItem.m_shared.m_name, name); } if (RenameitConfig.NameClaimsOwner && (RenameitConfig.AllowRenameUnownedItems || RenameExclusionRules.MatchesRenameAllowlist(CurrentItem)) && string.IsNullOrEmpty(CurrentItem.m_crafterName)) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { CurrentItem.m_crafterID = localPlayer.GetPlayerID(); CurrentItem.m_crafterName = localPlayer.GetPlayerName(); } } } public static void ApplyRewriteDesc(string newDesc) { if (CurrentItem == null) { return; } if (!IsItemInLocalPlayerInventory(CurrentItem)) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, RenameItLocalization.T("msg_item_not_in_inventory_apply"), 0, (Sprite)null); } UIPanels.CloseAllRenameEditingUi(); } else { RewriteItemDesc(newDesc); ItemData currentItem = CurrentItem; UIPanels.InputDescPanel.SetActive(false); UIPanels.OpenActionMenu(currentItem); } } public static void ApplyRename(string newName) { if (CurrentItem == null) { return; } if (!IsItemInLocalPlayerInventory(CurrentItem)) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, RenameItLocalization.T("msg_item_not_in_inventory_apply"), 0, (Sprite)null); } UIPanels.CloseAllRenameEditingUi(); } else { RenameItem(newName); ItemData currentItem = CurrentItem; UIPanels.InputNamePanel.SetActive(false); UIPanels.OpenActionMenu(currentItem); } } public static bool CanChangeName(ItemData? item, bool showError = false) { return RenamePermissionManager.Evaluate(RenamePermissionOperation.RenameItemName, item, Player.m_localPlayer, showError).Allowed; } public static bool CanChangeDesc(ItemData item, bool showError = false) { return RenamePermissionManager.Evaluate(RenamePermissionOperation.RewriteDescription, item, Player.m_localPlayer, showError).Allowed; } public static bool CanChangeCraftedByLabel(ItemData? item, bool showError = false) { if (item == null) { return false; } return RenamePermissionManager.Evaluate(RenamePermissionOperation.EditCraftedByLabel, item, Player.m_localPlayer, showError).Allowed; } public static bool AnyInventoryActionAvailable(ItemData? item) { if (item == null || (Object)(object)Player.m_localPlayer == (Object)null) { return false; } if (!RenameUnlockCost.UnlockCostApplies() || IsRenameUnlocked(item)) { return CanChangeName(item) || CanChangeDesc(item) || CanChangeCraftedByLabel(item); } if (RenameitPermission.IsElevatedForOverrides(Player.m_localPlayer)) { return CanChangeName(item) || CanChangeDesc(item) || CanChangeCraftedByLabel(item); } return WouldHaveAnyDrakeEditIfUnlockIgnored(item); } public static bool IsMenuOpenModifierHeld() { return MenuKeyBinding.IsHeld(RenameitConfig.MenuOpenModifier); } public static string GetMenuTooltipLockSuffix(ItemData? item) { if (item == null || (Object)(object)Player.m_localPlayer == (Object)null) { return ""; } if (!RenameUnlockCost.UnlockCostApplies()) { return ""; } if (RenameitPermission.IsElevatedForOverrides(Player.m_localPlayer)) { return " \ud83d\udd8a\ufe0f"; } return IsRenameUnlocked(item) ? " \ud83d\udd8a\ufe0f" : " \ud83d\udd12"; } public static string GetMenuBlockedReason(ItemData? item) { if (!RenameitConfig.ShowDenialUi) { return ""; } if (item == null || (Object)(object)Player.m_localPlayer == (Object)null) { return ""; } List<string> list = new List<string>(); RenamePermissionResult renamePermissionResult = RenamePermissionManager.TryGetDenial(RenamePermissionOperation.RenameItemName, item, Player.m_localPlayer); if (!renamePermissionResult.Allowed && RenamePermissionManager.HasAccessDenial(renamePermissionResult.Reasons)) { list.Add(RenamePermissionManager.FormatDenialForPlayer(RenamePermissionOperation.RenameItemName, renamePermissionResult.Reasons)); } RenamePermissionResult renamePermissionResult2 = RenamePermissionManager.TryGetDenial(RenamePermissionOperation.RewriteDescription, item, Player.m_localPlayer); if (!renamePermissionResult2.Allowed && RenamePermissionManager.HasAccessDenial(renamePermissionResult2.Reasons) && (list.Count == 0 || renamePermissionResult2.Reasons != renamePermissionResult.Reasons)) { list.Add(RenamePermissionManager.FormatDenialForPlayer(RenamePermissionOperation.RewriteDescription, renamePermissionResult2.Reasons)); } RenamePermissionResult renamePermissionResult3 = RenamePermissionManager.TryGetDenial(RenamePermissionOperation.EditCraftedByLabel, item, Player.m_localPlayer); if (!renamePermissionResult3.Allowed && RenamePermissionManager.HasAccessDenial(renamePermissionResult3.Reasons) && (list.Count == 0 || (renamePermissionResult3.Reasons != renamePermissionResult.Reasons && renamePermissionResult3.Reasons != renamePermissionResult2.Reasons))) { list.Add(RenamePermissionManager.FormatDenialForPlayer(RenamePermissionOperation.EditCraftedByLabel, renamePermissionResult3.Reasons)); } if (list.Count == 0) { return RenameItLocalization.T("msg_cannot_edit_item"); } HashSet<string> hashSet = new HashSet<string>(); List<string> list2 = new List<string>(); foreach (string item2 in list) { if (hashSet.Add(item2)) { list2.Add(item2); } } return string.Join(" | ", list2); } public static string getCraftedByDisplay(ItemData? item) { if (item?.m_customData == null) { return item?.m_crafterName ?? ""; } if (item.m_customData.TryGetValue("Drake_CraftedByDisplay", out var value) && !string.IsNullOrEmpty(value)) { return value; } return item.m_crafterName ?? ""; } private static void EnsureLocalPlayerCrafterIfAbsent(ItemData item) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && item.m_crafterID == 0L && string.IsNullOrEmpty(item.m_crafterName)) { item.m_crafterID = localPlayer.GetPlayerID(); item.m_crafterName = localPlayer.GetPlayerName(); } } public static void OpenCraftedByEditor(ItemData? item) { if (!((Object)(object)InventoryGui.instance == (Object)null) && item != null) { CurrentItem = item; EnsureLocalPlayerCrafterIfAbsent(item); if ((Object)(object)UIPanels.InputCraftedByPanel == (Object)null) { UIPanels.CreateCraftedByInput(); } UIPanels.RenameCraftedByInput.text = getCraftedByDisplay(item); UIPanels.RefreshCraftedByLineLabelPicker(item); UIPanels.InputCraftedByPanel.SetActive(true); UIPanels.EnsureInputBlocked(); } } public static void ApplyCraftedByLabel(string display) { if (CurrentItem == null) { return; } if (!IsItemInLocalPlayerInventory(CurrentItem)) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, RenameItLocalization.T("msg_item_not_in_inventory_apply"), 0, (Sprite)null); } UIPanels.CloseAllRenameEditingUi(); return; } EnsureLocalPlayerCrafterIfAbsent(CurrentItem); if (CurrentItem.m_customData == null) { CurrentItem.m_customData = new Dictionary<string, string>(); } string craftedByDisplay = getCraftedByDisplay(CurrentItem); if (string.IsNullOrEmpty(display)) { CurrentItem.m_customData.Remove("Drake_CraftedByDisplay"); } else { CurrentItem.m_customData["Drake_CraftedByDisplay"] = display; } if (RenameitConfig.CraftedByLabelCustomizable || RenameitPermission.IsElevatedForOverrides(Player.m_localPlayer)) { string craftedByLineLabelPendingToken = UIPanels.CraftedByLineLabelPendingToken; if (string.IsNullOrEmpty(craftedByLineLabelPendingToken)) { CurrentItem.m_customData.Remove("Drake_CraftedByLineLabel"); } else if (IsAllowedCustomCraftedByLineLabel(craftedByLineLabelPendingToken)) { CurrentItem.m_customData["Drake_CraftedByLineLabel"] = craftedByLineLabelPendingToken; } } string newDisplay = (string.IsNullOrEmpty(display) ? (CurrentItem.m_crafterName ?? "") : display); RenameEvents.RaiseCraftedByDisplayChanged(Player.m_localPlayer, CurrentItem, CurrentItem.m_shared.m_name, craftedByDisplay, newDisplay); ItemData currentItem = CurrentItem; UIPanels.InputCraftedByPanel.SetActive(false); UIPanels.OpenActionMenu(currentItem); } public static bool IsExcluded(ItemData? item) { return RenameExclusionRules.IsExcludedFromConfig(item); } public static bool IsRenameAllowlisted(ItemData? item) { return RenameExclusionRules.MatchesRenameAllowlist(item); } private static bool IsAllowedCustomCraftedByLineLabel(string value) { List<string> craftedByAllowedLabelsList = RenameitConfig.GetCraftedByAllowedLabelsList(); for (int i = 1; i < craftedByAllowedLabelsList.Count; i++) { if (string.Equals(craftedByAllowedLabelsList[i], value, StringComparison.Ordinal)) { return true; } } return false; } } internal static class StackIdentity { internal static string GetFingerprint(ItemData? item) { if (item?.m_customData == null) { return ""; } StringBuilder stringBuilder = new StringBuilder(); Append(stringBuilder, item, "Drake_Rename"); Append(stringBuilder, item, "Drake_Rename_Desc"); Append(stringBuilder, item, "Drake_CraftedByDisplay"); Append(stringBuilder, item, "Drake_CraftedByLineLabel"); return stringBuilder.ToString(); } private static void Append(StringBuilder sb, ItemData item, string key) { if (item.m_customData.TryGetValue(key, out var value) && !string.IsNullOrEmpty(value)) { sb.Append('|').Append(value); } else { sb.Append('|'); } } internal static bool SameDrakeStackIdentity(ItemData? a, ItemData? b) { if (a == null || b == null) { return false; } return string.Equals(GetFingerprint(a), GetFingerprint(b), StringComparison.Ordinal); } } } namespace DrakeRenameit.UI { internal static class TooltipRichText { private enum RtKind { Color, Size } private static readonly Regex HexColorRegex = new Regex("^[0-9a-fA-F]{3,8}$", RegexOptions.Compiled); internal static string EnsureRichTextTagsClosedForTooltip(string? text) { if (text == null || text.Length == 0) { return ""; } Stack<RtKind> stack = new Stack<RtKind>(); int num = 0; while (num < text.Length) { if (text[num] != '<') { num++; continue; } int num2 = text.IndexOf('>', num); if (num2 < 0) { break; } string text2 = text.Substring(num, num2 - num + 1); if (text2.Length >= 2 && text2[1] == '/') { if (text2.StartsWith("</color", StringComparison.OrdinalIgnoreCase)) { if (stack.Count > 0 && stack.Peek() == RtKind.Color) { stack.Pop(); } } else if (text2.StartsWith("</size", StringComparison.OrdinalIgnoreCase) && stack.Count > 0 && stack.Peek() == RtKind.Size) { stack.Pop(); } } else if (text2.StartsWith("<color", StringComparison.OrdinalIgnoreCase)) { stack.Push(RtKind.Color); } else if (IsHashColorOpenTag(text2)) { stack.Push(RtKind.Color); } else if (text2.StartsWith("<size", StringComparison.OrdinalIgnoreCase)) { stack.Push(RtKind.Size); } num = num2 + 1; } if (stack.Count == 0) { return text; } StringBuilder stringBuilder = new StringBuilder(text, text.Length + stack.Count * 10); while (stack.Count > 0) { RtKind rtKind = stack.Pop(); stringBuilder.Append((rtKind == RtKind.Color) ? "</color>" : "</size>"); } return stringBuilder.ToString(); } internal static string WrapCraftedByDisplayWithDefaultStatColorIfNeeded(string text) { if (string.IsNullOrEmpty(text)) { return text; } if (HasExplicitColorMarkup(text)) { return text; } return GetValheimTooltipStatColorOpenTag() + text + "</color>"; } internal static bool HasExplicitColorMarkup(string text) { if (string.IsNullOrEmpty(text)) { return false; } if (text.IndexOf("<color", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } for (int i = 0; i < text.Length - 3; i++) { if (text[i] == '<' && text[i + 1] == '#') { int j; for (j = i + 2; j < text.Length && IsHex(text[j]); j++) { } if (j != i + 2 && j - (i + 2) >= 3 && j - (i + 2) <= 8 && j < text.Length && text[j] == '>') { return true; } } } return false; } private static bool IsHex(char c) { switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': return true; default: return false; } } private static string GetValheimTooltipStatColorOpenTag() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) try { GUIManager instance = GUIManager.Instance; if (instance != null) { Color valheimOrange = instance.ValheimOrange; return "<color=#" + ColorUtility.ToHtmlStringRGB(valheimOrange) + ">"; } } catch { } return "<color=#ff8800>"; } private static bool IsHashColorOpenTag(string tag) { if (tag.Length < 5 || tag[0] != '<' || tag[1] != '#' || tag[tag.Length - 1] != '>') { return false; } string input = tag.Substring(2, tag.Length - 3); return HexColorRegex.IsMatch(input); } } public static class UIPanels { [CompilerGenerated] private static class <>O { public static UnityAction <0>__CloseActionMenuOnly; public static UnityAction <1>__CancelCraftedByEditor; public static UnityAction <2>__CancelNameEditor; public static UnityAction <3>__CancelDescEditor; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Action <>9__82_0; public static Action <>9__82_1; public static Action <>9__83_0; public static Action <>9__83_1; public static Action <>9__84_0; public static Action <>9__84_1; public static UnityAction <>9__87_0; public static UnityAction <>9__87_1; public static UnityAction <>9__87_2; public static UnityAction <>9__87_3; public static UnityAction <>9__87_4; public static UnityAction <>9__95_0; public static UnityAction <>9__95_1; public static UnityAction <>9__103_0; public static UnityAction <>9__103_1; public static UnityAction <>9__105_0; public static UnityAction <>9__105_1; public static UnityAction <>9__108_0; public static UnityAction <>9__115_0; public static UnityAction <>9__115_1; public static UnityAction <>9__116_0; public static UnityAction <>9__116_1; internal void <CancelNameEditor>b__82_0() { if (DrakeRenameit.CurrentItem != null && (Object)(object)RenameNameInput != (Object)null) { RenameNameInput.text = DrakeRenameit.GetPropperName(DrakeRenameit.CurrentItem); } } internal void <CancelNameEditor>b__82_1() { GameObject? inputNamePanel = InputNamePanel; if (inputNamePanel != null) { inputNamePanel.SetActive(false); } } internal void <CancelDescEditor>b__83_0() { if (DrakeRenameit.CurrentItem != null && (Object)(object)RenameDescInput != (Object)null) { RenameDescInput.text = DrakeRenameit.getPropperDesc(DrakeRenameit.CurrentItem); } } internal void <CancelDescEditor>b__83_1() { GameObject? inputDescPanel = InputDescPanel; if (inputDescPanel != null) { inputDescPanel.SetActive(false); } } internal void <CancelCraftedByEditor>b__84_0() { if (DrakeRenameit.CurrentItem != null) { if ((Object)(object)RenameCraftedByInput != (Object)null) { RenameCraftedByInput.text = DrakeRenameit.getCraftedByDisplay(DrakeRenameit.CurrentItem); } RefreshCraftedByLineLabelPicker(DrakeRenameit.CurrentItem); CloseCraftedByLineLabelPopover(); } } internal void <CancelCraftedByEditor>b__84_1() { GameObject? inputCraftedByPanel = InputCraftedByPanel; if (inputCraftedByPanel != null) { inputCraftedByPanel.SetActive(false); } } internal void <EnsureActionMenu>b__87_0() { ItemData currentItem = DrakeRenameit.CurrentItem; if (currentItem != null) { ActionMenuPanel.SetActive(false); OpenUnlockConfirmPanel(currentItem); } } internal void <EnsureActionMenu>b__87_1() { ItemData currentItem = DrakeRenameit.CurrentItem; CloseActionMenuOnly(); if (currentItem != null) { DrakeRenameit.OpenRename(currentItem); } } internal void <EnsureActionMenu>b__87_2() { ItemData currentItem = DrakeRenameit.CurrentItem; CloseActionMenuOnly(); if (currentItem != null) { DrakeRenameit.OpenRewriteDesc(currentItem); } } internal void <EnsureActionMenu>b__87_3() { ItemData currentItem = DrakeRenameit.CurrentItem; CloseActionMenuOnly(); if (currentItem != null) { DrakeRenameit.OpenCraftedByEditor(currentItem); } } internal void <EnsureActionMenu>b__87_4() { ItemData currentItem = DrakeRenameit.CurrentItem; if (currentItem != null) { OpenResetAllConfirmPanel(currentItem); } } internal void <EnsureResetAllConfirmPanel>b__95_0() { ItemData currentItem = DrakeRenameit.CurrentItem; if (currentItem != null) { DrakeRenameit.ResetAllCustomizations(currentItem); } CloseResetAllConfirmPanel(reopenActionMenu: false); } internal void <EnsureResetAllConfirmPanel>b__95_1() { CloseResetAllConfirmPanel(reopenActionMenu: true); } internal void <EnsureUnlockConfirmPanel>b__103_0() { ItemData currentItem = DrakeRenameit.CurrentItem; if (currentItem == null) { CloseUnlockConfirmPanel(reopenActionMenu: false); } else if (!DrakeRenameit.TryPayRenameUnlock(currentItem)) { if (DrakeRenameit.CurrentItem == null || !DrakeRenameit.IsItemInLocalPlayerInventory(DrakeRenameit.CurrentItem)) { CloseAllRenameEditingUi(); return; } RefreshUnlockConfirmBody(); ((Selectable)_buttonConfirmUnlock).interactable = RenameUnlockCost.CanPlayerAfford(Player.m_localPlayer); } else { CloseUnlockConfirmPanel(reopenActionMenu: true); } } internal void <EnsureUnlockConfirmPanel>b__103_1() { CloseUnlockConfirmPanel(reopenActionMenu: false); } internal void <CreateCraftedByInput>b__105_0() { DrakeRenameit.ApplyCraftedByLabel(RenameCraftedByInput.text.Trim()); } internal void <CreateCraftedByInput>b__105_1() { if (DrakeRenameit.CurrentItem != null) { RenameCraftedByInput.text = DrakeRenameit.CurrentItem.m_crafterName ?? ""; } List<string> craftedByAllowedLabelsList = RenameitConfig.GetCraftedByAllowedLabelsList(); _craftedByLineLabelPendingToken = null; SetCraftedByLineLabelPickButtonText(craftedByAllowedLabelsList, 0); CloseCraftedByLineLabelPopover(); } internal void <EnsureCraftedByLineLabelControls>b__108_0() { if (!((Object)(object)_buttonCraftedByLineLabelPick == (Object)null) && ((Selectable)_buttonCraftedByLineLabelPick).interactable) { ToggleCraftedByLineLabelPopover(); } } internal void <CreateRenameInput>b__115_0() { DrakeRenameit.ApplyRename(RenameNameInput.text.Trim()); } internal void <CreateRenameInput>b__115_1() { if (DrakeRenameit.CurrentItem != null) { RenameNameInput.text = DrakeRenameit.resetName(DrakeRenameit.CurrentItem); } } internal void <CreateRenameDescInput>b__116_0() { if (string.IsNullOrEmpty(RenameDescInput.text)) { <CreateRenameDescInput>g__GetPlayerAndSendError|116_2(RenameItLocalization.T("msg_desc_empty")); } else { DrakeRenameit.ApplyRewriteDesc(RenameDescInput.text.Trim()); } } internal void <CreateRenameDescInput>b__116_1() { RenameDescInput.text = DrakeRenameit.resetDesc(DrakeRenameit.CurrentItem); } } private static Button _buttonOkName; private static Button _buttonOkDesc; private static Button _buttonCancelName; private static Button _buttonCancelDesc; private static Button _buttonResetName; private static Button _buttonResetDesc; private static Button? _buttonMenuRename; private static Button? _buttonMenuDesc; private static Button? _buttonMenuCraftedBy; private static Button? _buttonMenuResetAll; private static Button? _buttonMenuUnlock; private static Button? _buttonMenuCancel; private static Text? _actionMenuTitleText; private static Text? _craftedByPanelTitleText; private static Text? _craftedByTooltipLineLabelText; private static Button? _buttonOkCraftedBy; private static Button? _buttonCancelCraftedBy; private static Button? _buttonResetCraftedBy; private static Button? _buttonCraftedByLineLabelPick; private static GameObject? _craftedByLineLabelPopover; private static string? _craftedByLineLabelPendingToken; private const float ActionMenuButtonWidth = 200f; private const float ActionMenuOkButtonWidth = 64f; private const float ActionMenuBottomButtonGap = 8f; private const float ActionMenuResetButtonWidth = 128f; private const float CraftedByPanelWidth = 400f; private const float CraftedByPanelHeight = 258f; private const float CraftedByContentWidth = 340f; private const float CraftedByDropdownWidth = 280f; private const float CraftedByDropdownHeight = 32f; private const float CraftedByPopoverWidth = 290f; private const float CraftedByPopoverRowHeight = 32f; private const float CraftedByFooterButtonWidth = 72f; private const float CraftedByInputAnchorY = -56f; private const float CraftedByFooterButtonY = 32f; private static GameObject? _unlockConfirmPanel; private static RectTransform? _unlockCostListRoot; private static Text? _unlockAffordWarning; private static Button? _buttonConfirmUnlock; private static Button? _buttonConfirmCancel; private static Text? _unlockPanelTitleText; private static Text? _unlockCostLabelText; private static GameObject? _resetAllConfirmPanel; private static Button? _buttonResetAllConfirmYes; private static Button? _buttonResetAllConfirmNo; private static bool _inputBlocked; private const float ResetAllConfirmPanelWidth = 300f; private const float ResetAllConfirmPanelHeight = 178f; private const float ResetAllConfirmTextWidth = 272f; public static GameObject? InputNamePanel { get; private set; } public static GameObject? InputDescPanel { get; private set; } public static InputField? RenameNameInput { get; private set; } public static InputField? RenameDescInput { get; private set; } public static GameObject? ActionMenuPanel { get; private set; } public static GameObject? InputCraftedByPanel { get; private set; } public static InputField? RenameCraftedByInput { get; private set; } internal static string? CraftedByLineLabelPendingToken => _craftedByLineLabelPendingToken; internal static void EnsureInputBlocked() { if (!_inputBlocked) { GUIManager.BlockInput(true); _inputBlocked = true; } } internal static void EnsureInputUnblocked() { if (_inputBlocked) { GUIManager.BlockInput(false); _inputBlocked = false; } } private static void SetButtonLabel(Button? button, string label) { if (!((Object)(object)button == (Object)null)) { Text componentInChildren = ((Component)button).GetComponentInChildren<Text>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.text = label; } } } private static void RefreshActionMenuLabels() { if ((Object)(object)_actionMenuTitleText != (Object)null) { _actionMenuTitleText.text = RenameItLocalization.T("menu_title"); } SetButtonLabel(_buttonMenuRename, RenameItLocalization.T("menu_rename")); SetButtonLabel(_buttonMenuDesc, RenameItLocalization.T("menu_description")); SetButtonLabel(_buttonMenuCraftedBy, RenameItLocalization.T("menu_crafted_by")); SetButtonLabel(_buttonMenuResetAll, RenameItLocalization.T("menu_reset_all")); SetButtonLabel(_buttonMenuCancel, RenameItLocalization.T("menu_ok")); } private static void RefreshUnlockPanelStaticLabels() { if ((Object)(object)_unlockPanelTitleText != (Object)null) { _unlockPanelTitleText.text = RenameItLocalization.T("unlock_panel_title"); } if ((Object)(object)_unlockCostLabelText != (Object)null) { _unlockCostLabelText.text = RenameItLocalization.T("unlock_cost_label"); } SetButtonLabel(_buttonConfirmUnlock, RenameItLocalization.T("unlock_pay_btn")); SetButtonLabel(_buttonConfirmCancel, RenameItLocalization.T("btn_cancel")); } public static void CloseAllRenameEditingUi() { if ((Object)(object)InputNamePanel != (Object)null) { InputNamePanel.SetActive(false); } if ((Object)(object)InputDescPanel != (Object)null) { InputDescPanel.SetActive(false); } if ((Object)(object)InputCraftedByPanel != (Object)null) { InputCraftedByPanel.SetActive(false); } CloseCraftedByLineLabelPopover(); if ((Object)(object)ActionMenuPanel != (Object)null) { ActionMenuPanel.SetActive(false); } if ((Object)(object)_unlockConfirmPanel != (Object)null) { _unlockConfirmPanel.SetActive(false); } if ((Object)(object)_resetAllConfirmPanel != (Object)null) { _resetAllConfirmPanel.SetActive(false); } DrakeRenameit.CurrentItem = null; EnsureInputUnblocked(); } public static void CancelNameEditor() { CancelEditor(delegate { if (DrakeRenameit.CurrentItem != null && (Object)(object)RenameNameInput != (Object)null) { RenameNameInput.text = DrakeRenameit.GetPropperName(DrakeRenameit.CurrentItem); } }, delegate { GameObject? inputNamePanel = InputNamePanel; if (inputNamePanel != null) { inputNamePanel.SetActive(false); } }); } public static void CancelDescEditor() { CancelEditor(delegate { if (DrakeRenameit.CurrentItem != null && (Object)(object)RenameDescInput != (Object)null) { RenameDescInput.text = DrakeRenameit.getPropperDesc(DrakeRenameit.CurrentItem); } }, delegate { GameObject? inputDescPanel = InputDescPanel; if (inputDescPanel != null) { inputDescPanel.SetActive(false); } }); } public static void CancelCraftedByEditor() { CancelEditor(delegate { if (DrakeRenameit.CurrentItem != null) { if ((Object)(object)RenameCraftedByInput != (Object)null) { RenameCraftedByInput.text = DrakeRenameit.getCraftedByDisplay(DrakeRenameit.CurrentItem); } RefreshCraftedByLineLabelPicker(DrakeRenameit.CurrentItem); CloseCraftedByLineLabelPopover(); } }, delegate { GameObject? inputCraftedByPanel = InputCraftedByPanel; if (inputCraftedByPanel != null) { inputCraftedByPanel.SetActive(false); } }); } private static void CancelEditor(Action revertFields, Action hidePanel) { revertFields(); hidePanel(); ItemData currentItem = DrakeRenameit.CurrentItem; if (currentItem != null && DrakeRenameit.IsItemInLocalPlayerInventory(currentItem)) { OpenActionMenu(currentItem); } else { CloseAllRenameEditingUi(); } } public static void OpenActionMenu(ItemData item) { if (GUIManager.Instance == null || !Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront)) { return; } if (!DrakeRenameit.IsItemInLocalPlayerInventory(item)) { CloseAllRenameEditingUi(); Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, RenameItLocalization.T("msg_item_not_in_inventory"), 0, (Sprite)null); } return; } EnsureActionMenu(); if ((Object)(object)ActionMenuPanel == (Object)null || (Object)(object)_buttonMenuRename == (Object)null || (Object)(object)_buttonMenuDesc == (Object)null || (Object)(object)_buttonMenuCraftedBy == (Object)null || (Object)(object)_buttonMenuResetAll == (Object)null || (Object)(object)_buttonMenuUnlock == (Object)null) { return; } DrakeRenameit.CurrentItem = item; bool flag = DrakeRenameit.ShowUnlockButton(item); ((Component)_buttonMenuUnlock).gameObject.SetActive(flag); if (flag) { Text componentInChildren = ((Component)_buttonMenuUnlock).GetComponentInChildren<Text>(); if ((Object)(object)componentInChildren != (Object)null) { string costDisplayShort = RenameUnlockCost.GetCostDisplayShort(); componentInChildren.text = (string.IsNullOrEmpty(costDisplayShort) ? RenameItLocalization.T("menu_unlock") : RenameItLocalization.T("menu_unlock_cost", costDisplayShort)); } ((Selectable)_buttonMenuRename).interactable = false; ((Selectable)_buttonMenuDesc).interactable = false; ((Selectable)_buttonMenuCraftedBy).interactable = false; ((Selectable)_buttonMenuResetAll).interactable = false; ((Selectable)_buttonMenuUnlock).interactable = true; } else { ((Selectable)_buttonMenuRename).interactable = DrakeRenameit.CanChangeName(item); ((Selectable)_buttonMenuDesc).interactable = DrakeRenameit.CanChangeDesc(item); ((Selectable)_buttonMenuCraftedBy).interactable = DrakeRenameit.CanChangeCraftedByLabel(item); ((Selectable)_buttonMenuResetAll).interactable = DrakeRenameit.CanResetAnyCustomization(item); } RefreshActionMenuLabels(); ApplyActionMenuLayout(); ActionMenuPanel.SetActive(true); ActionMenuPanel.transform.SetAsLastSibling(); EnsureInputBlocked(); } private static void EnsureActionMenu() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: 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_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Expected O, but got Unknown //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Expected O, but got Unknown //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Expected O, but got Unknown //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Expected O, but got Unknown //IL_0413: 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_0431: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Expected O, but got Unknown //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Expected O, but got Unknown if ((Object)(object)ActionMenuPanel != (Object)null || GUIManager.Instance == null || !Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront)) { return; } ActionMenuPanel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 320f, 280f, false); _actionMenuTitleText = GUIManager.Instance.CreateText(RenameItLocalization.T("menu_title"), ActionMenuPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -48f), GUIManager.Instance.AveriaSerifBold, 22, GUIManager.Instance.ValheimOrange, true, Color.black, 200f, 40f, false).GetComponent<Text>(); _actionMenuTitleText.alignment = (TextAnchor)4; _buttonMenuUnlock = GUIManager.Instance.CreateButton(RenameItLocalization.T("menu_unlock"), ActionMenuPanel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 72f), 220f, 30f).GetComponent<Button>(); ((Component)_buttonMenuUnlock).gameObject.SetActive(false); Button? buttonMenuUnlock = _buttonMenuUnlock; object obj = <>c.<>9__87_0; if (obj == null) { UnityAction val = delegate { ItemData currentItem5 = DrakeRenameit.CurrentItem; if (currentItem5 != null) { ActionMenuPanel.SetActive(false); OpenUnlockConfirmPanel(currentItem5); } }; <>c.<>9__87_0 = val; obj = (object)val; } buttonMenuUnlock.AddUniqueListener((UnityAction)obj); _buttonMenuRename = GUIManager.Instance.CreateButton(RenameItLocalization.T("menu_rename"), ActionMenuPanel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 40f), 200f, 32f).GetComponent<Button>(); Button? buttonMenuRename = _buttonMenuRename; object obj2 = <>c.<>9__87_1; if (obj2 == null) { UnityAction val2 = delegate { ItemData currentItem4 = DrakeRenameit.CurrentItem; CloseActionMenuOnly(); if (currentItem4 != null) { DrakeRenameit.OpenRename(currentItem4); } }; <>c.<>9__87_1 = val2; obj2 = (object)val2; } buttonMenuRename.AddUniqueListener((UnityAction)obj2); _buttonMenuDesc = GUIManager.Instance.CreateButton(RenameItLocalization.T("menu_description"), ActionMenuPanel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 200f, 32f).GetComponent<Button>(); Button? buttonMenuDesc = _buttonMenuDesc; object obj3 = <>c.<>9__87_2; if (obj3 == null) { UnityAction val3 = delegate { ItemData currentItem3 = DrakeRenameit.CurrentItem; CloseActionMenuOnly(); if (currentItem3 != null) { DrakeRenameit.OpenRewriteDesc(currentItem3); } }; <>c.<>9__87_2 = val3; obj3 = (object)val3; } buttonMenuDesc.AddUniqueListener((UnityAction)obj3); _buttonMenuCraftedBy = GUIManager.Instance.CreateButton(RenameItLocalization.T("menu_crafted_by"), ActionMenuPanel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, -40f), 200f, 32f).GetComponent<Button>(); Button? buttonMenuCraftedBy = _buttonMenuCraftedBy; object obj4 = <>c.<>9__87_3; if (obj4 == null) { UnityAction val4 = delegate { ItemData currentItem2 = DrakeRenameit.CurrentItem; CloseActionMenuOnly(); if (currentItem2 != null) { DrakeRenameit.OpenCraftedByEditor(currentItem2); } }; <>c.<>9__87_3 = val4; obj4 = (object)val4; } buttonMenuCraftedBy.AddUniqueListener((UnityAction)obj4); _buttonMenuResetAll = GUIManager.Instance.CreateButton(RenameItLocalization.T("menu_reset_all"), ActionMenuPanel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(-40f, -80f), 128f, 28f).GetComponent<Button>(); Button? buttonMenuResetAll = _buttonMenuResetAll; object obj5 = <>c.<>9__87_4; if (obj5 == null) { UnityAction val5 = delegate { ItemData currentItem = DrakeRenameit.CurrentItem; if (currentItem != null) { OpenResetAllConfirmPanel(currentItem); } }; <>c.<>9__87_4 = val5; obj5 = (object)val5; } buttonMenuResetAll.AddUniqueListener((UnityAction)obj5); _buttonMenuCancel = GUIManager.Instance.CreateButton(RenameItLocalization.T("menu_ok"), ActionMenuPanel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(40f, -80f), 64f, 28f).GetComponent<Button>(); Button? buttonMenuCancel = _buttonMenuCancel; object obj6 = <>O.<0>__CloseActionMenuOnly; if (obj6 == null) { UnityAction val6 = CloseActionMenuOnly; <>O.<0>__CloseActionMenuOnly = val6; obj6 = (object)val6; } buttonMenuCancel.AddUniqueListener((UnityAction)obj6); ApplyActionMenuLayout(); } private static void ApplyActionMenuLayout() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_actionMenuTitleText != (Object)null) { _actionMenuTitleText.alignment = (TextAnchor)4; RectTransform rectTransform = ((Graphic)_actionMenuTitleText).rectTransform; rectTransform.anchoredPosition = new Vector2(0f, -48f); rectTransform.sizeDelta = new Vector2(200f, 40f); } float num = 100f; float num2 = 64f; float num3 = 32f; float x = 0f - num + num2; float x2 = num - num3; SetButtonLayout(_buttonMenuRename, 0f, 40f, 200f, 32f); SetButtonLayout(_buttonMenuDesc, 0f, 0f, 200f, 32f); SetButtonLayout(_buttonMenuCraftedBy, 0f, -40f, 200f, 32f); SetButtonLayout(_buttonMenuResetAll, x, -80f, 128f, 28f); SetButtonLayout(_buttonMenuCancel, x2, -80f, 64f, 28f); SetButtonLayout(_buttonMenuUnlock, 0f, 72f, 220f, 30f); } private static void SetButtonLayout(Button? button, float x, float y, float width, float height) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)button == (Object)null)) { RectTransform component = ((Component)button).GetComponent<RectTransform>(); if (!((Object)(object)component == (Object)null)) { component.anchoredPosition = new Vector2(x, y); component.sizeDelta = new Vector2(width, height); } } } private static void CloseActionMenuOnly() { if ((Object)(object)ActionMenuPanel != (Object)null) { ActionMenuPanel.SetActive(false); } EnsureInputUnblocked(); } private static void OpenResetAllConfirmPanel(ItemData item) { if (GUIManager.Instance == null || !Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront)) { return; } if (!DrakeRenameit.IsItemInLocalPlayerInventory(item)) { CloseAllRenameEditingUi(); Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, RenameItLocalization.T("msg_item_not_in_inventory"), 0, (Sprite)null); } return; } EnsureResetAllConfirmPanel(); if (!((Object)(object)_resetAllConfirmPanel == (Object)null) && !((Object)(object)_buttonResetAllConfirmYes == (Object)null)) { DrakeRenameit.CurrentItem = item; _resetAllConfirmPanel.SetActive(true); _resetAllConfirmPanel.transform.SetAsLastSibling(); EnsureInputBlocked(); } } private static void EnsureResetAllConfirmPanel() { //IL_0047: 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_0065: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0154: 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_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Expected O, but got Unknown //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Expected O, but got Unknown if ((Object)(object)_resetAllConfirmPanel != (Object)null || GUIManager.Instance == null || !Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront)) { return; } _resetAllConfirmPanel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 300f, 178f, false); GUIManager.Instance.CreateText(RenameItLocalization.T("reset_all_title"), _resetAllConfirmPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -40f), GUIManager.Instance.AveriaSerifBold, 20, GUIManager.Instance.ValheimOrange, true, Color.black, 272f, 44f, false); GUIManager.Instance.CreateText(RenameItLocalization.T("reset_all_body"), _resetAllConfirmPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -108f), GUIManager.Instance.AveriaSerifBold, 14, Color.white, true, Color.black, 272f, 64f, false); _buttonResetAllConfirmYes = GUIManager.Instance.CreateButton(RenameItLocalization.T("btn_yes"), _resetAllConfirmPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(-55f, 35f), 110f, 30f).GetComponent<Button>(); Button? buttonResetAllConfirmYes = _buttonResetAllConfirmYes; object obj = <>c.<>9__95_0; if (obj == null) { UnityAction val = delegate { ItemData currentItem = DrakeRenameit.CurrentItem; if (currentItem != null) { DrakeRenameit.ResetAllCustomizations(currentItem); } CloseResetAllConfirmPanel(reopenActionMenu: false); }; <>c.<>9__95_0 = val; obj = (object)val; } buttonResetAllConfirmYes.AddUniqueListener((UnityAction)obj); _buttonResetAllConfirmNo = GUIManager.Instance.CreateButton(RenameItLocalization.T("btn_no"), _resetAllConfirmPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(55f, 35f), 110f, 30f).GetComponent<Button>(); Button? buttonResetAllConfirmNo = _buttonResetAllConfirmNo; object obj2 = <>c.<>9__95_1; if (obj2 == null) { UnityAction val2 = delegate { CloseResetAllConfirmPanel(reopenActionMenu: true); }; <>c.<>9__95_1 = val2; obj2 = (object)val2; } buttonResetAllConfirmNo.AddUniqueListener((UnityAction)obj2); } private static void CloseResetAllConfirmPanel(bool reopenActionMenu) { if ((Object)(object)_resetAllConfirmPanel != (Object)null) { _resetAllConfirmPanel.SetActive(false); } if (reopenActionMenu && DrakeRenameit.CurrentItem != null) { ItemData currentItem = DrakeRenameit.CurrentItem; GameObject? actionMenuPanel = ActionMenuPanel; if (actionMenuPanel != null) { actionMenuPanel.SetActive(false); } OpenActionMenu(currentItem); } else { if ((Object)(object)ActionMenuPanel != (Object)null) { ActionMenuPanel.SetActive(false); } DrakeRenameit.CurrentItem = null; EnsureInputUnblocked(); } } public static void OpenUnlockMenuFromInventory(ItemData item) { DrakeRenameit.CurrentItem = item; OpenUnlockConfirmPanel(item); } private static void OpenUnlockConfirmPanel(ItemData item) { if (GUIManager.Instance == null || !Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront)) { return; } if (!DrakeRenameit.IsItemInLocalPlayerInventory(item)) { CloseAllRenameEditingUi(); Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, RenameItLocalization.T("msg_item_not_in_inventory"), 0, (Sprite)null); } return; } EnsureUnlockConfirmPanel(); if (!((Object)(object)_unlockConfirmPanel == (Object)null) && !((Object)(object)_unlockCostListRoot == (Object)null) && !((Object)(object)_buttonConfirmUnlock == (Object)null)) { RefreshUnlockPanelStaticLabels(); RefreshUnlockConfirmBody(); bool interactable = RenameUnlockCost.CanPlayerAfford(Player.m_localPlayer); ((Selectable)_buttonConfirmUnlock).interactable = interactable; _unlockConfirmPanel.SetActive(true); _unlockConfirmPanel.transform.SetAsLastSibling(); EnsureInputBlocked(); } } private static void RefreshUnlockConfirmBody() { if ((Object)(object)_unlockCostListRoot == (Object)null) { return; } ClearUnlockCostListChildren(); List<(string, int, string)> costDisplayEntries = RenameUnlockCost.GetCostDisplayEntries(); bool flag = RenameUnlockCost.CanPlayerAfford(Player.m_localPlayer); if (costDisplayEntries.Count == 0) { AddUnlockPlainLine(_unlockCostListRoot, RenameItLocalization.T("unlock_prompt")); if ((Object)(object)_unlockAffordWarning != (Object)null) { _unlockAffordWarning.text = ""; ((Component)_unlockAffordWarning).gameObject.SetActive(false); } return; } foreach (var item4 in costDisplayEntries) { string item = item4.Item1; int item2 = item4.Item2; string item3 = item4.Item3; string itemTokenPublic = RenameUnlockCost.GetItemTokenPublic(item3); int num; if (!((Object)(object)Player.m_localPlayer != (Object)null)) { num = 0; }