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 EquipmentAndQuickSlots v3.2.0
plugins/EquipmentAndQuickSlots.dll
Decompiled 4 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using Auga; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Common; using EquipmentAndQuickSlots.src.MultiUtility; using HarmonyLib; using ItemFavoriteFrameworkAPI; using JetBrains.Annotations; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Extensions; using Jotunn.Managers; using Jotunn.Utils; using SimpleJson; using TMPro; using UnityEngine; using UnityEngine.Audio; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("EquipmentAndQuickSlots")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Randy Knapp Mods")] [assembly: AssemblyProduct("EquipmentAndQuickSlots")] [assembly: AssemblyCopyright("Copyright © Randy Knapp 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("08ed5bc9-9e0c-4343-90a5-92497be6e216")] [assembly: AssemblyFileVersion("3.0.1")] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: IgnoresAccessChecksTo("Splatform")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("3.0.1.0")] [module: UnverifiableCode] public static class PlayerExtensions { public static ZDO GetZDO(this Player player) { return ((Character)player).m_nview.GetZDO(); } } namespace Common { public class ConfigPositionedElement : MonoBehaviour { public ConfigEntry<TextAnchor> AnchorConfig; public ConfigEntry<Vector2> PositionConfig; protected RectTransform _rt; protected TextAnchor _currentAnchor; public virtual void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown _rt = (RectTransform)((Component)this).transform; EnsureCorrectPosition(); } public virtual void Update() { EnsureCorrectPosition(); } public virtual void EnsureCorrectPosition() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_0083: Expected I4, but got Unknown //IL_0029: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_019b: 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_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) if (AnchorConfig != null && PositionConfig != null && (_currentAnchor != AnchorConfig.Value || !(_rt.anchoredPosition == PositionConfig.Value))) { _currentAnchor = AnchorConfig.Value; TextAnchor currentAnchor = _currentAnchor; Vector2 val = default(Vector2); switch ((int)currentAnchor) { case 0: { RectTransform rt25 = _rt; RectTransform rt26 = _rt; RectTransform rt27 = _rt; ((Vector2)(ref val))..ctor(0f, 1f); rt27.anchorMax = val; Vector2 pivot = (rt26.anchorMin = val); rt25.pivot = pivot; break; } case 1: { RectTransform rt22 = _rt; RectTransform rt23 = _rt; RectTransform rt24 = _rt; ((Vector2)(ref val))..ctor(0.5f, 1f); rt24.anchorMax = val; Vector2 pivot = (rt23.anchorMin = val); rt22.pivot = pivot; break; } case 2: { RectTransform rt19 = _rt; RectTransform rt20 = _rt; RectTransform rt21 = _rt; ((Vector2)(ref val))..ctor(1f, 1f); rt21.anchorMax = val; Vector2 pivot = (rt20.anchorMin = val); rt19.pivot = pivot; break; } case 3: { RectTransform rt16 = _rt; RectTransform rt17 = _rt; RectTransform rt18 = _rt; ((Vector2)(ref val))..ctor(0f, 0.5f); rt18.anchorMax = val; Vector2 pivot = (rt17.anchorMin = val); rt16.pivot = pivot; break; } case 4: { RectTransform rt13 = _rt; RectTransform rt14 = _rt; RectTransform rt15 = _rt; ((Vector2)(ref val))..ctor(0.5f, 0.5f); rt15.anchorMax = val; Vector2 pivot = (rt14.anchorMin = val); rt13.pivot = pivot; break; } case 5: { RectTransform rt10 = _rt; RectTransform rt11 = _rt; RectTransform rt12 = _rt; ((Vector2)(ref val))..ctor(1f, 0.5f); rt12.anchorMax = val; Vector2 pivot = (rt11.anchorMin = val); rt10.pivot = pivot; break; } case 6: { RectTransform rt7 = _rt; RectTransform rt8 = _rt; RectTransform rt9 = _rt; ((Vector2)(ref val))..ctor(0f, 0f); rt9.anchorMax = val; Vector2 pivot = (rt8.anchorMin = val); rt7.pivot = pivot; break; } case 7: { RectTransform rt4 = _rt; RectTransform rt5 = _rt; RectTransform rt6 = _rt; ((Vector2)(ref val))..ctor(0.5f, 0f); rt6.anchorMax = val; Vector2 pivot = (rt5.anchorMin = val); rt4.pivot = pivot; break; } case 8: { RectTransform rt = _rt; RectTransform rt2 = _rt; RectTransform rt3 = _rt; ((Vector2)(ref val))..ctor(1f, 0f); rt3.anchorMax = val; Vector2 pivot = (rt2.anchorMin = val); rt.pivot = pivot; break; } } _rt.anchoredPosition = PositionConfig.Value; } } } internal static class ConfigUI { internal class ConfigUIInputGuard : MonoBehaviour { private bool held; internal void Hold() { if (!held) { held = true; PushInputBlock(); } } public void OnDestroy() { if (held) { held = false; PopInputBlock(); } } } internal const float RowHeight = 34f; internal const float SubRowHeight = 26f; internal const float RowGap = 4f; internal const float CloseXSize = 28f; private static int inputBlockDepth; internal static void PushInputBlock() { if (!((Object)(object)Player.m_localPlayer == (Object)null)) { inputBlockDepth++; if (inputBlockDepth == 1) { GUIManager.BlockInput(true); } } } internal static void PopInputBlock() { if (inputBlockDepth > 0) { inputBlockDepth--; if (inputBlockDepth == 0) { GUIManager.BlockInput(false); } } } internal static GameObject NewUI(string name, Transform parent, params Type[] components) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown GameObject val = new GameObject(name, components) { layer = 5 }; if ((Object)(object)val.GetComponent<RectTransform>() == (Object)null) { val.AddComponent<RectTransform>(); } val.transform.SetParent(parent, false); return val; } internal static GameObject NewRect(string name, Transform parent, float x, float y, float w, float h) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) GameObject obj = NewUI(name, parent, typeof(RectTransform)); RectTransform val = (RectTransform)obj.transform; val.anchorMin = new Vector2(0f, 1f); val.anchorMax = new Vector2(0f, 1f); val.pivot = new Vector2(0f, 1f); val.sizeDelta = new Vector2(w, h); val.anchoredPosition = new Vector2(x, 0f - y); return obj; } internal static GameObject NewRow(Transform parent, float width, float height) { return NewRect("Row", parent, 0f, 0f, width, height); } internal static GameObject NewLayoutRow(Transform content, float width, float height) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) GameObject obj = NewUI("LayoutRow", content, typeof(RectTransform), typeof(LayoutElement)); RectTransform val = (RectTransform)obj.transform; val.anchorMin = new Vector2(0f, 1f); val.anchorMax = new Vector2(0f, 1f); val.pivot = new Vector2(0f, 1f); val.sizeDelta = new Vector2(width, height); LayoutElement component = obj.GetComponent<LayoutElement>(); component.minHeight = height; component.preferredHeight = height; component.minWidth = width; component.preferredWidth = width; return obj; } internal static void LayoutColumn(List<GameObject> rows, float x, float startY, float gap = 4f) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) float num = startY; foreach (GameObject row in rows) { if (!((Object)(object)row == (Object)null) && row.activeSelf) { RectTransform val = (RectTransform)row.transform; val.anchoredPosition = new Vector2(x, 0f - num); num += val.sizeDelta.y + gap; } } } internal static void PositionRow(GameObject row, float x, float y) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)row == (Object)null)) { ((RectTransform)row.transform).anchoredPosition = new Vector2(x, 0f - y); } } internal static GameObject CreatePanel(string title, float w, float h, out Transform body) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) GameObject val = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), w, h, true); val.AddComponent<ConfigUIInputGuard>().Hold(); AddText(val.transform, 0f, 16f, w, 34f, title, 22, (TextAnchor)4, GUIManager.Instance.ValheimYellow); body = val.transform; return val; } internal static GameObject CreateScroll(Transform parent, float x, float y, float w, float h, out Transform content, out float contentWidth) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) GameObject val = NewRect("ScrollHolder", parent, x, y, w, h); GameObject val2 = GUIManager.Instance.CreateScrollView(val.transform, false, true, 8f, 4f, GUIManager.Instance.ValheimScrollbarHandleColorBlock, new Color(0f, 0f, 0f, 0.5f), w, h); content = val2.transform.Find("Scroll View/Viewport/Content"); contentWidth = w - 16f; ScrollRect componentInChildren = val2.GetComponentInChildren<ScrollRect>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.scrollSensitivity = 200f; } return val2; } internal static string L(string text) { if (string.IsNullOrEmpty(text)) { return ""; } if (Localization.instance == null) { return text; } return Localization.instance.Localize(text); } internal static string L(string token, string english) { string text = L(token); if (text.Length == 0 || text == token || text == "[" + token.TrimStart(new char[1] { '$' }) + "]") { return english; } return text; } internal static Text AddText(Transform parent, float x, float y, float w, float h, string text, int fontSize, TextAnchor anchor, Color? color = null) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GUIManager.Instance.CreateText(L(text), parent, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(x, 0f - y), GUIManager.Instance.AveriaSerifBold, fontSize, (Color)(((??)color) ?? GUIManager.Instance.ValheimBeige), true, Color.black, w, h, false); RectTransform val = (RectTransform)obj.transform; val.pivot = new Vector2(0f, 1f); val.anchoredPosition = new Vector2(x, 0f - y); Text component = obj.GetComponent<Text>(); component.alignment = anchor; component.horizontalOverflow = (HorizontalWrapMode)0; component.verticalOverflow = (VerticalWrapMode)0; return component; } internal static GameObject AddHeaderRow(Transform parent, float colWidth, string text, TextAnchor anchor = (TextAnchor)3) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) GameObject obj = NewRow(parent, colWidth, 34f); AddText(obj.transform, 0f, 0f, colWidth, 34f, text, 18, anchor, GUIManager.Instance.ValheimYellow); return obj; } internal static GameObject AddTextRow(Transform parent, float colWidth, float height, string text, int fontSize, Color color, TextAnchor anchor = (TextAnchor)0) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) GameObject obj = NewRow(parent, colWidth, height); AddText(obj.transform, 0f, 0f, colWidth, height, text, fontSize, anchor, color); return obj; } internal static GameObject AddSpacerRow(Transform parent, float colWidth, float height) { return NewRow(parent, colWidth, height); } internal static GameObject AddDividerRow(Transform parent, float colWidth, float height = 12f) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) GameObject val = NewRow(parent, colWidth, height); GameObject obj = NewUI("Divider", val.transform, typeof(Image)); RectTransform val2 = (RectTransform)obj.transform; val2.anchorMin = new Vector2(0f, 1f); val2.anchorMax = new Vector2(0f, 1f); val2.pivot = new Vector2(0f, 1f); val2.sizeDelta = new Vector2(colWidth, 2f); val2.anchoredPosition = new Vector2(0f, 0f - height * 0.5f); Image component = obj.GetComponent<Image>(); ((Graphic)component).color = new Color(0.6f, 0.5f, 0.35f, 0.6f); ((Graphic)component).raycastTarget = false; return val; } internal static void SetMessages(Text target, IList<string> errors, IList<string> warnings) { if ((Object)(object)target == (Object)null) { return; } List<string> list = new List<string>(); if (errors != null) { foreach (string error in errors) { list.Add("<color=#F87171>" + error + "</color>"); } } if (warnings != null) { foreach (string warning in warnings) { list.Add("<color=#FBBF24>" + warning + "</color>"); } } target.text = string.Join("\n", list.ToArray()); } internal static GameObject AddButton(Transform parent, float x, float y, float w, string text, UnityAction onClick, float h = 40f) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) GameObject val = GUIManager.Instance.CreateButton(L(text), parent, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(x, 0f - y), w, h); RectTransform val2 = (RectTransform)val.transform; val2.pivot = new Vector2(0f, 1f); val2.anchoredPosition = new Vector2(x, 0f - y); if (onClick != null) { ((UnityEvent)val.GetComponent<Button>().onClick).AddListener(onClick); } return val; } internal static GameObject AddCloseX(Transform panel, float panelWidth, UnityAction onClick) { return AddButton(panel, panelWidth - 28f - 16f, 12f, 28f, "X", onClick, 28f); } internal static Toggle AddToggle(Transform parent, float x, float y, float size, bool value, Action<bool> onChange) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GUIManager.Instance.CreateToggle(parent, size, size); obj.transform.SetParent(parent, false); RectTransform val = (RectTransform)obj.transform; ((Transform)val).localScale = Vector3.one; val.anchorMin = new Vector2(0f, 1f); val.anchorMax = new Vector2(0f, 1f); val.pivot = new Vector2(0f, 1f); val.anchoredPosition = new Vector2(x, 0f - y); Toggle component = obj.GetComponent<Toggle>(); component.isOn = value; if (onChange != null) { ((UnityEvent<bool>)(object)component.onValueChanged).AddListener((UnityAction<bool>)delegate(bool b) { onChange(b); }); } return component; } internal static GameObject AddToggleRow(Transform parent, float colWidth, float labelW, string label, bool value, Action<bool> onChange, bool toggleOnLeft = false) { GameObject obj = NewRow(parent, colWidth, 34f); float x = (toggleOnLeft ? 0f : (labelW + 6f)); float x2 = (toggleOnLeft ? 34f : 0f); AddText(obj.transform, x2, 0f, labelW, 34f, label, 15, (TextAnchor)3); AddToggle(obj.transform, x, 3f, 26f, value, onChange); return obj; } internal static string Fmt(float v, bool whole) { if (!whole) { return v.ToString("0.00", CultureInfo.InvariantCulture); } return ((int)Mathf.Round(v)).ToString(CultureInfo.InvariantCulture); } internal static Slider BuildSlider(Transform parent, float x, float y, float width, float min, float max, float value, bool wholeNumbers) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0188: 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_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Expected O, but got Unknown //IL_01d6: 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_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023d: 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_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Expected O, but got Unknown //IL_02a3: Unknown result type (might be due to invalid IL or missing references) GameObject val = NewUI("Slider", parent, typeof(RectTransform), typeof(Slider)); RectTransform val2 = (RectTransform)val.transform; val2.anchorMin = new Vector2(0f, 1f); val2.anchorMax = new Vector2(0f, 1f); val2.pivot = new Vector2(0f, 1f); val2.sizeDelta = new Vector2(width, 20f); val2.anchoredPosition = new Vector2(x, 0f - y); GameObject obj = NewUI("Background", val.transform, typeof(Image)); RectTransform val3 = (RectTransform)obj.transform; val3.anchorMin = new Vector2(0f, 0.25f); val3.anchorMax = new Vector2(1f, 0.75f); val3.sizeDelta = Vector2.zero; val3.anchoredPosition = Vector2.zero; ((Graphic)obj.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.6f); GameObject val4 = NewUI("Fill Area", val.transform, typeof(RectTransform)); RectTransform val5 = (RectTransform)val4.transform; val5.anchorMin = new Vector2(0f, 0.25f); val5.anchorMax = new Vector2(1f, 0.75f); val5.sizeDelta = new Vector2(-20f, 0f); val5.anchoredPosition = Vector2.zero; GameObject obj2 = NewUI("Fill", val4.transform, typeof(Image)); RectTransform val6 = (RectTransform)obj2.transform; val6.sizeDelta = new Vector2(10f, 0f); ((Graphic)obj2.GetComponent<Image>()).color = new Color(0.7f, 0.6f, 0.4f, 0.9f); GameObject val7 = NewUI("Handle Slide Area", val.transform, typeof(RectTransform)); RectTransform val8 = (RectTransform)val7.transform; val8.anchorMin = Vector2.zero; val8.anchorMax = Vector2.one; val8.sizeDelta = new Vector2(-20f, 0f); val8.anchoredPosition = Vector2.zero; GameObject obj3 = NewUI("Handle", val7.transform, typeof(Image)); RectTransform val9 = (RectTransform)obj3.transform; val9.sizeDelta = new Vector2(20f, 0f); Image component = obj3.GetComponent<Image>(); component.sprite = GUIManager.Instance.GetSprite("checkbox_marker"); component.type = (Type)1; Slider component2 = val.GetComponent<Slider>(); component2.fillRect = val6; component2.handleRect = val9; ((Selectable)component2).targetGraphic = (Graphic)(object)component; component2.direction = (Direction)0; component2.minValue = min; component2.maxValue = max; component2.wholeNumbers = wholeNumbers; component2.value = Mathf.Clamp(value, min, max); GUIManager.Instance.ApplySliderStyle(component2); return component2; } internal static GameObject AddSliderRow(Transform parent, float colWidth, float labelW, float sliderW, float valueW, string label, float min, float max, float value, bool wholeNumbers, Action<float> onChange) { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) GameObject val = NewRow(parent, colWidth, 34f); AddText(val.transform, 0f, 0f, labelW, 34f, label, 15, (TextAnchor)3); Slider slider = BuildSlider(val.transform, labelW, 7f, sliderW, min, max, value, wholeNumbers); float num = labelW + sliderW + 10f; GameObject val2 = GUIManager.Instance.CreateInputField(val.transform, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(num, -3f), (ContentType)(wholeNumbers ? 2 : 3), (string)null, 15, valueW, 28f); RectTransform val3 = (RectTransform)val2.transform; val3.pivot = new Vector2(0f, 1f); val3.anchoredPosition = new Vector2(num, -3f); InputField box = val2.GetComponent<InputField>(); box.SetTextWithoutNotify(Fmt(slider.value, wholeNumbers)); ((UnityEvent<float>)(object)slider.onValueChanged).AddListener((UnityAction<float>)delegate(float v) { if (wholeNumbers) { v = Mathf.Round(v); } box.SetTextWithoutNotify(Fmt(v, wholeNumbers)); onChange?.Invoke(v); }); ((UnityEvent<string>)(object)box.onEndEdit).AddListener((UnityAction<string>)delegate(string str) { if (!float.TryParse(str.Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { result = slider.value; } result = Mathf.Clamp(result, min, max); if (wholeNumbers) { result = Mathf.Round(result); } box.SetTextWithoutNotify(Fmt(result, wholeNumbers)); if (slider.value != result) { slider.value = result; } else { onChange?.Invoke(result); } }); return val; } internal static InputField AddTextField(Transform parent, float x, float y, float w, string value, Action<string> onCommit, ContentType contentType = (ContentType)0, string placeholder = null, int charLimit = 0) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0051: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GUIManager.Instance.CreateInputField(parent, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(x, 0f - y), contentType, placeholder, 15, w, 28f); RectTransform val = (RectTransform)obj.transform; val.pivot = new Vector2(0f, 1f); val.anchoredPosition = new Vector2(x, 0f - y); InputField component = obj.GetComponent<InputField>(); if (charLimit > 0) { component.characterLimit = charLimit; } component.SetTextWithoutNotify(value ?? ""); if (onCommit != null) { ((UnityEvent<string>)(object)component.onEndEdit).AddListener((UnityAction<string>)delegate(string s) { onCommit(s); }); } return component; } internal static GameObject AddTextFieldRow(Transform parent, float colWidth, float labelW, float fieldW, string label, string value, Action<string> onCommit, string placeholder = null, int charLimit = 0) { GameObject obj = NewRow(parent, colWidth, 34f); AddText(obj.transform, 0f, 0f, labelW, 34f, label, 15, (TextAnchor)3); AddTextField(obj.transform, labelW + 6f, 3f, fieldW, value, onCommit, (ContentType)0, placeholder, charLimit); return obj; } internal static GameObject AddEnumCycleRow(Transform parent, float colWidth, float labelW, float ctrlW, string label, string[] options, int currentIndex, Action<int> onChange) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown GameObject val = NewRow(parent, colWidth, 34f); AddText(val.transform, 0f, 0f, labelW, 34f, label, 15, (TextAnchor)3); int idx = Mathf.Clamp(currentIndex, 0, Math.Max(0, options.Length - 1)); GameObject val2 = GUIManager.Instance.CreateButton((options.Length != 0) ? options[idx] : "", val.transform, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(labelW + 6f, -2f), ctrlW, 28f); RectTransform val3 = (RectTransform)val2.transform; val3.pivot = new Vector2(0f, 1f); val3.anchoredPosition = new Vector2(labelW + 6f, -2f); Text caption = val2.GetComponentInChildren<Text>(); ((UnityEvent)val2.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { if (options.Length != 0) { idx = (idx + 1) % options.Length; caption.text = options[idx]; onChange?.Invoke(idx); } }); return val; } internal static GameObject AddEnumFlagsRow(Transform parent, float colWidth, float labelW, string label, string[] names, Func<int, bool> isOn, Action<int, bool> set) { GameObject val = NewRow(parent, colWidth, 34f); AddText(val.transform, 0f, 0f, labelW, 34f, label, 15, (TextAnchor)3); float num = labelW + 6f; for (int i = 0; i < names.Length; i++) { int index = i; AddToggle(val.transform, num, 4f, 22f, isOn(index), delegate(bool on) { set(index, on); }); AddText(val.transform, num + 26f, 0f, 90f, 34f, names[index], 13, (TextAnchor)3); num += 120f; } return val; } internal static GameObject AddPickerRow(Transform parent, float colWidth, float labelW, float ctrlW, string label, string current, Func<IList<string>> options, Action<string> onPick, Func<string, bool> isKnown = null) { //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown GameObject val = NewRow(parent, colWidth, 34f); AddText(val.transform, 0f, 0f, labelW, 34f, label, 15, (TextAnchor)3); float num = ctrlW - 40f; InputField field = AddTextField(val.transform, labelW + 6f, 3f, num, current, delegate(string s) { onPick?.Invoke(s); }, (ContentType)0); Text marker = AddText(val.transform, labelW + 6f + num + 44f, 0f, 20f, 34f, "", 15, (TextAnchor)3, (Color?)new Color(0.98f, 0.75f, 0.14f)); Action refreshMarker = delegate { bool flag = isKnown != null && !string.IsNullOrEmpty(field.text) && !isKnown(field.text); marker.text = (flag ? "!" : ""); }; refreshMarker(); ((UnityEvent<string>)(object)field.onEndEdit).AddListener((UnityAction<string>)delegate { refreshMarker(); }); AddButton(val.transform, labelW + 6f + num + 4f, 3f, 34f, "...", (UnityAction)delegate { string title = label; IList<string> options2; if (options == null) { IList<string> list = new List<string>(); options2 = list; } else { options2 = options(); } ConfigUIPicker.ShowPicker(title, options2, field.text, delegate(string picked) { field.SetTextWithoutNotify(picked); refreshMarker(); onPick?.Invoke(picked); }); }, 28f); return val; } internal static GameObject AddStringListEditor(Transform content, float width, string label, List<string> items, Action onChanged, Func<IList<string>> options = null, Func<string, bool> isKnown = null) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Expected O, but got Unknown //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Expected O, but got Unknown GameObject val = NewLayoutRow(content, width, 26f); AddText(val.transform, 0f, 0f, width - 90f, 26f, label, 14, (TextAnchor)3, GUIManager.Instance.ValheimOrange); AddButton(val.transform, width - 84f, 0f, 80f, L("$piece_smelter_add", "Add"), (UnityAction)delegate { items.Add(""); onChanged?.Invoke(); }, 24f); for (int num = 0; num < items.Count; num++) { int index = num; GameObject val2 = NewLayoutRow(content, width, 26f); InputField field = AddTextField(val2.transform, 12f, 0f, width - 92f, items[index], delegate(string s) { items[index] = s; }, (ContentType)0); Text marker = AddText(val2.transform, width - 74f, 0f, 16f, 26f, "", 14, (TextAnchor)3, (Color?)new Color(0.98f, 0.75f, 0.14f)); Action refreshMarker = delegate { bool flag = isKnown != null && !string.IsNullOrEmpty(field.text) && !isKnown(field.text); marker.text = (flag ? "!" : ""); }; refreshMarker(); ((UnityEvent<string>)(object)field.onEndEdit).AddListener((UnityAction<string>)delegate { refreshMarker(); }); if (options != null) { AddButton(val2.transform, width - 56f, 0f, 26f, "...", (UnityAction)delegate { ConfigUIPicker.ShowPicker(label, options(), field.text, delegate(string picked) { field.SetTextWithoutNotify(picked); items[index] = picked; refreshMarker(); }); }, 24f); } AddButton(val2.transform, width - 26f, 0f, 24f, "x", (UnityAction)delegate { items.RemoveAt(index); onChanged?.Invoke(); }, 24f); } return val; } } internal enum FirstRunMode { Auto, ShowNextLaunch, Never } internal static class ConfigUIFirstRun { internal const string FolderName = "ModQuickConfig"; internal const string FileName = "FirstRun.cfg"; internal const string Section = "FirstRun"; internal const string QueueKeySuffix = ".FirstRun"; private const string LegacyPlaceholder = "\u0001"; private static string recordPath; private static readonly char[] InvalidKeyChars = new char[8] { '=', '\n', '\t', '\\', '"', '\'', '[', ']' }; internal static string RecordPath { get { if (recordPath == null) { recordPath = Path.Combine(Path.Combine(Application.persistentDataPath, "ModQuickConfig"), "FirstRun.cfg"); } return recordPath; } } internal static bool ShouldShow(string modKey, int revision, ConfigEntry<FirstRunMode> mode) { if (GUIManager.IsHeadless()) { return false; } return ModeOf(mode) switch { FirstRunMode.Never => false, FirstRunMode.ShowNextLaunch => true, _ => SeenRevision(modKey) < revision, }; } internal static int SeenRevision(string modKey) { if (GUIManager.IsHeadless() || !IsValidKey(modKey)) { return int.MaxValue; } string text = null; try { text = RecordPath; if (!File.Exists(text)) { return 0; } return Math.Max(0, BindSeen(OpenRecord(), modKey).Value); } catch (Exception ex) { ModLogger.LogWarning("Could not read the first-run record at " + text + ", so the '" + modKey + "' first-run popup is treated as seen: " + ex.Message); return int.MaxValue; } } internal static void MarkSeen(string modKey, int revision) { if (GUIManager.IsHeadless() || !IsValidKey(modKey) || revision <= 0) { return; } string text = null; try { text = RecordPath; ConfigFile val = OpenRecord(); ConfigEntry<int> val2 = BindSeen(val, modKey); if (val2.Value < revision) { val2.Value = revision; val.Save(); } } catch (Exception ex) { ModLogger.LogWarning("Could not write the first-run record at " + text + ": " + ex.Message); } } internal static bool QueueFirstRunPopup(string modKey, int revision, ConfigEntry<FirstRunMode> mode, int order, Func<bool> open, Func<bool> isOpen) { if (open == null || isOpen == null || !ShouldShow(modKey, revision, mode)) { return false; } return ConfigUIStartupPopups.Enqueue(modKey + ".FirstRun", order, () => OpenFirstRun(modKey, revision, mode, open), isOpen); } private static bool OpenFirstRun(string modKey, int revision, ConfigEntry<FirstRunMode> mode, Func<bool> open) { if (!ShouldShow(modKey, revision, mode)) { return false; } bool flag = false; if (mode != null && mode.Value == FirstRunMode.ShowNextLaunch) { mode.Value = FirstRunMode.Auto; flag = true; } bool flag2 = false; try { flag2 = open(); } finally { if (!flag2 && flag) { mode.Value = FirstRunMode.ShowNextLaunch; } } return flag2; } internal static bool TakeLegacyEntry(ConfigFile cfg, string section, string key, out string raw) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown raw = null; if (cfg == null || string.IsNullOrEmpty(section) || string.IsNullOrEmpty(key)) { return false; } bool saveOnConfigSet = cfg.SaveOnConfigSet; cfg.SaveOnConfigSet = false; try { ConfigDefinition val = new ConfigDefinition(section, key); if (cfg.ContainsKey(val)) { raw = cfg[val].GetSerializedValue(); } else { string value = cfg.Bind<string>(val, "\u0001", new ConfigDescription("Retired.", (AcceptableValueBase)null, Array.Empty<object>())).Value; raw = ((value == "\u0001") ? null : value); } cfg.Remove(val); if (saveOnConfigSet) { cfg.Save(); } } catch (Exception ex) { ModLogger.LogWarning("Could not read the retired setting [" + section + "] " + key + ": " + ex.Message); raw = null; } finally { cfg.SaveOnConfigSet = saveOnConfigSet; } return raw != null; } private static ConfigFile OpenRecord() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown BepInPlugin val = new BepInPlugin("ModQuickConfig.FirstRun", "ModQuickConfig first-run record - delete this file to see every mod's first-run popup again", "1.0.0"); return new ConfigFile(RecordPath, false, val) { SaveOnConfigSet = false }; } private static ConfigEntry<int> BindSeen(ConfigFile record, string modKey) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown return record.Bind<int>("FirstRun", modKey, 0, new ConfigDescription("The newest revision of this mod's first-run popup you have seen. 0 has not seen it; delete the line to see it again.", (AcceptableValueBase)null, Array.Empty<object>())); } private static FirstRunMode ModeOf(ConfigEntry<FirstRunMode> mode) { if (mode == null) { return FirstRunMode.Auto; } FirstRunMode value = mode.Value; if (!Enum.IsDefined(typeof(FirstRunMode), value)) { return FirstRunMode.Auto; } return value; } private static bool IsValidKey(string modKey) { if (string.IsNullOrEmpty(modKey) || modKey.Trim() != modKey || modKey.IndexOfAny(InvalidKeyChars) >= 0) { ModLogger.LogError("'" + modKey + "' cannot be a first-run record key; use a plain identifier."); return false; } return true; } } internal static class ConfigUILauncher { private static Component cachedBroker; private static MethodInfo cachedRegister; private static MethodInfo cachedUnregister; private static bool loggedOwner; internal static bool IsAvailable => (Object)(object)Resolve() != (Object)null; internal static void Init() { Resolve(); } internal static bool Register(string displayName, Action openPanel) { if (string.IsNullOrEmpty(displayName) || openPanel == null) { return false; } Component val = Resolve(); if ((Object)(object)val == (Object)null) { return false; } if (cachedRegister == null) { ModLogger.LogError("The QuickConfig launcher on this machine has no compatible Register method; '" + displayName + "' will not appear in it."); return false; } try { cachedRegister.Invoke(val, new object[2] { displayName, openPanel }); return true; } catch (Exception ex) { ModLogger.LogError("Could not register '" + displayName + "' with the QuickConfig launcher: " + ex.Message); return false; } } internal static void Unregister(string displayName) { if (string.IsNullOrEmpty(displayName)) { return; } Component val = Resolve(); if ((Object)(object)val == (Object)null || cachedUnregister == null) { return; } try { cachedUnregister.Invoke(val, new object[1] { displayName }); } catch (Exception ex) { ModLogger.LogWarning("Could not unregister '" + displayName + "' from the QuickConfig launcher: " + ex.Message); } } private static Component Resolve() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown if ((Object)(object)cachedBroker != (Object)null) { return cachedBroker; } cachedRegister = null; cachedUnregister = null; GameObject val = null; try { val = GameObject.Find("ModQuickConfigLauncher"); } catch (Exception) { } if ((Object)(object)val == (Object)null) { try { val = new GameObject("ModQuickConfigLauncher"); Object.DontDestroyOnLoad((Object)(object)val); val.AddComponent<QuickConfigBroker>(); } catch (Exception ex2) { ModLogger.LogError("Could not create the QuickConfig launcher: " + ex2.Message); return null; } } Component val2 = null; Component[] components = val.GetComponents<Component>(); foreach (Component val3 in components) { if ((Object)(object)val3 != (Object)null && ((object)val3).GetType().Name == "QuickConfigBroker") { val2 = val3; break; } } if ((Object)(object)val2 == (Object)null) { return null; } Type type = ((object)val2).GetType(); cachedRegister = type.GetMethod("Register", BindingFlags.Instance | BindingFlags.Public, null, new Type[2] { typeof(string), typeof(Action) }, null); cachedUnregister = type.GetMethod("Unregister", BindingFlags.Instance | BindingFlags.Public, null, new Type[1] { typeof(string) }, null); if (!loggedOwner) { loggedOwner = true; int num = 1; try { PropertyInfo property = type.GetProperty("BrokerVersion", BindingFlags.Instance | BindingFlags.Public); if (property != null) { num = (int)property.GetValue(val2, null); } } catch (Exception) { } ModLogger.LogInfo($"QuickConfig launcher v{num} owned by " + $"{type.Assembly.GetName().Name}; this mod carries v{2}."); if (num < 2) { ModLogger.LogInfo("That copy is older than this one. Registration still works; the launcher UI is whatever the owning mod shipped."); } } cachedBroker = val2; return cachedBroker; } } internal static class ConfigUIPicker { private const float PanelW = 420f; private const float PanelH = 520f; private const float RowH = 30f; private const int MaxRows = 400; private static GameObject overlay; internal static bool IsOpen => (Object)(object)overlay != (Object)null; internal static void ShowPicker(string title, IList<string> options, string current, Action<string> onPick) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0178: 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_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Expected O, but got Unknown Close(); if (GUIManager.Instance == null || (Object)(object)GUIManager.CustomGUIFront == (Object)null) { return; } List<string> all = new List<string>(); if (options != null) { foreach (string option in options) { if (!string.IsNullOrEmpty(option)) { all.Add(option); } } } all.Sort(StringComparer.OrdinalIgnoreCase); overlay = ConfigUI.NewUI("ConfigUIPickerOverlay", GUIManager.CustomGUIFront.transform, typeof(Image)); RectTransform val = (RectTransform)overlay.transform; val.anchorMin = Vector2.zero; val.anchorMax = Vector2.one; val.offsetMin = Vector2.zero; val.offsetMax = Vector2.zero; ((Graphic)overlay.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.35f); Button obj = overlay.AddComponent<Button>(); ((Selectable)obj).transition = (Transition)0; ((UnityEvent)obj.onClick).AddListener(new UnityAction(Close)); overlay.AddComponent<ConfigUI.ConfigUIInputGuard>().Hold(); GameObject obj2 = GUIManager.Instance.CreateWoodpanel(overlay.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 420f, 520f, true); ConfigUI.AddText(obj2.transform, 0f, 14f, 420f, 30f, title, 18, (TextAnchor)4, GUIManager.Instance.ValheimYellow); InputField val2 = ConfigUI.AddTextField(obj2.transform, 16f, 52f, 320f, "", null, (ContentType)0, ConfigUI.L("$menu_filter", "Filter") + "..."); ConfigUI.AddButton(obj2.transform, 344f, 52f, 60f, ConfigUI.L("$menu_close", "Close"), new UnityAction(Close), 28f); ConfigUI.CreateScroll(obj2.transform, 16f, 92f, 388f, 404f, out var content, out var contentW); if ((Object)(object)content == (Object)null) { return; } Action<string> rebuild = null; rebuild = delegate(string needle) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown foreach (Transform item in content) { Object.Destroy((Object)(object)((Component)item).gameObject); } int num = 0; foreach (string item2 in all) { if (string.IsNullOrEmpty(needle) || item2.IndexOf(needle, StringComparison.OrdinalIgnoreCase) >= 0) { if (num >= 400) { break; } num++; string picked = item2; ConfigUI.AddButton(ConfigUI.NewLayoutRow(content, contentW, 30f).transform, 0f, 0f, contentW, picked, (UnityAction)delegate { Close(); onPick?.Invoke(picked); }, 28f); } } if (num == 0) { ConfigUI.AddText(ConfigUI.NewLayoutRow(content, contentW, 30f).transform, 4f, 0f, contentW, 30f, ConfigUI.L("$modquickconfig_no_matches", "No matches"), 14, (TextAnchor)3); } else if (num >= 400) { GameObject obj3 = ConfigUI.NewLayoutRow(content, contentW, 30f); ConfigUI.AddText(text: ConfigUI.L("$modquickconfig_more_matches", "... $1 more, type to narrow").Replace("$1", (all.Count - num).ToString()), parent: obj3.transform, x: 4f, y: 0f, w: contentW, h: 30f, fontSize: 13, anchor: (TextAnchor)3); } }; ((UnityEvent<string>)(object)val2.onValueChanged).AddListener((UnityAction<string>)delegate(string needle) { rebuild(needle); }); rebuild(""); } internal static void Close() { if (!((Object)(object)overlay == (Object)null)) { Object.Destroy((Object)(object)overlay); overlay = null; } } } internal static class ConfigUIPrompt { private const float PanelW = 460f; private static GameObject overlay; internal static void Show(string title, string label, string initial, string warning, Action<string> onAccept) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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_0244: Expected O, but got Unknown //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) Close(); if (GUIManager.Instance != null && !((Object)(object)GUIManager.CustomGUIFront == (Object)null)) { bool flag = !string.IsNullOrEmpty(warning); float num = (flag ? 96f : 0f); float num2 = 190f + num; overlay = ConfigUI.NewUI("ConfigUIPromptOverlay", GUIManager.CustomGUIFront.transform, typeof(Image)); RectTransform val = (RectTransform)overlay.transform; val.anchorMin = Vector2.zero; val.anchorMax = Vector2.one; val.offsetMin = Vector2.zero; val.offsetMax = Vector2.zero; ((Graphic)overlay.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.45f); overlay.AddComponent<ConfigUI.ConfigUIInputGuard>().Hold(); GameObject val2 = GUIManager.Instance.CreateWoodpanel(overlay.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 460f, num2, true); ConfigUI.AddText(val2.transform, 0f, 14f, 460f, 30f, title, 18, (TextAnchor)4, GUIManager.Instance.ValheimYellow); float num3 = 56f; if (flag) { ConfigUI.AddText(val2.transform, 20f, num3, 420f, num - 8f, warning, 13, (TextAnchor)0, (Color?)new Color(0.98f, 0.75f, 0.14f)); num3 += num; } ConfigUI.AddText(val2.transform, 20f, num3, 120f, 28f, label, 15, (TextAnchor)3); InputField field = ConfigUI.AddTextField(val2.transform, 140f, num3, 300f, initial, null, (ContentType)0, null, 64); num3 += 46f; ConfigUI.AddButton(val2.transform, 20f, num3, 190f, ConfigUI.L("$menu_cancel", "Cancel"), new UnityAction(Close), 34f); ConfigUI.AddButton(val2.transform, 250f, num3, 190f, ConfigUI.L("$menu_ok", "OK"), (UnityAction)delegate { string text = field.text; Close(); onAccept?.Invoke(text); }, 34f); ((Selectable)field).Select(); field.ActivateInputField(); } } internal static void Close() { if (!((Object)(object)overlay == (Object)null)) { Object.Destroy((Object)(object)overlay); overlay = null; } } } internal static class ConfigUIStartupPopups { internal const int OrderWelcome = 100; internal const int OrderNotice = 200; private static Component cachedQueue; private static MethodInfo cachedEnqueue; private static MethodInfo cachedCancel; private static bool loggedOwner; internal static bool Enqueue(string key, int order, Func<bool> tryOpen, Func<bool> isOpen) { if (string.IsNullOrEmpty(key) || tryOpen == null || isOpen == null) { return false; } if (GUIManager.IsHeadless()) { return false; } Component val = Resolve(); if ((Object)(object)val == (Object)null) { return false; } if (cachedEnqueue == null) { ModLogger.LogError("The startup popup queue on this machine has no compatible Enqueue method; '" + key + "' will not be shown."); return false; } try { return (bool)cachedEnqueue.Invoke(val, new object[4] { key, order, tryOpen, isOpen }); } catch (Exception ex) { ModLogger.LogError("Could not queue the startup popup '" + key + "': " + ex.Message); return false; } } internal static void Cancel(string key) { if (string.IsNullOrEmpty(key) || GUIManager.IsHeadless()) { return; } Component val = Resolve(); if ((Object)(object)val == (Object)null || cachedCancel == null) { return; } try { cachedCancel.Invoke(val, new object[1] { key }); } catch (Exception ex) { ModLogger.LogWarning("Could not cancel the startup popup '" + key + "': " + ex.Message); } } private static Component Resolve() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown if ((Object)(object)cachedQueue != (Object)null) { return cachedQueue; } cachedEnqueue = null; cachedCancel = null; GameObject val = null; try { val = GameObject.Find("ModStartupPopupQueue"); } catch (Exception) { } if ((Object)(object)val == (Object)null) { try { val = new GameObject("ModStartupPopupQueue"); Object.DontDestroyOnLoad((Object)(object)val); val.AddComponent<StartupPopupQueue>(); } catch (Exception ex2) { ModLogger.LogError("Could not create the startup popup queue: " + ex2.Message); return null; } } Component val2 = null; Component[] components = val.GetComponents<Component>(); foreach (Component val3 in components) { if ((Object)(object)val3 != (Object)null && ((object)val3).GetType().Name == "StartupPopupQueue") { val2 = val3; break; } } if ((Object)(object)val2 == (Object)null) { try { val2 = (Component)(object)val.AddComponent<StartupPopupQueue>(); } catch (Exception ex3) { ModLogger.LogError("Could not create the startup popup queue: " + ex3.Message); return null; } } Type type = ((object)val2).GetType(); cachedEnqueue = type.GetMethod("Enqueue", BindingFlags.Instance | BindingFlags.Public, null, new Type[4] { typeof(string), typeof(int), typeof(Func<bool>), typeof(Func<bool>) }, null); cachedCancel = type.GetMethod("Cancel", BindingFlags.Instance | BindingFlags.Public, null, new Type[1] { typeof(string) }, null); if (!loggedOwner) { loggedOwner = true; int num = 0; try { PropertyInfo property = type.GetProperty("QueueVersion", BindingFlags.Instance | BindingFlags.Public); if (property != null) { num = (int)property.GetValue(val2, null); } } catch (Exception) { } ModLogger.LogInfo($"Startup popup queue v{num} owned by " + $"{type.Assembly.GetName().Name}; this mod carries v{1}."); } cachedQueue = val2; return cachedQueue; } } internal class QuickConfigBroker : MonoBehaviour { internal const string BrokerObjectName = "ModQuickConfigLauncher"; internal const string BrokerTypeName = "QuickConfigBroker"; internal const string ButtonObjectName = "ModQuickConfigButton"; internal const int ContractVersion = 2; private const float ButtonW = 150f; private const float ButtonH = 38f; private const float PanelW = 320f; private static QuickConfigBroker Instance; private static Harmony harmony; private readonly Dictionary<string, Action> entries = new Dictionary<string, Action>(StringComparer.Ordinal); private readonly List<string> order = new List<string>(); private GameObject mainMenuButton; private GameObject pauseButton; private GameObject listPanel; public int BrokerVersion => 2; public void Register(string modName, Action openPanel) { if (!string.IsNullOrEmpty(modName) && openPanel != null) { if (!entries.ContainsKey(modName)) { order.Add(modName); } entries[modName] = openPanel; RefreshVisibility(); } } public void Unregister(string modName) { if (!string.IsNullOrEmpty(modName)) { if (entries.Remove(modName)) { order.Remove(modName); } if ((Object)(object)listPanel != (Object)null) { CloseList(); } RefreshVisibility(); } } public bool IsRegistered(string modName) { if (!string.IsNullOrEmpty(modName)) { return entries.ContainsKey(modName); } return false; } public void Awake() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown Instance = this; GUIManager.OnCustomGUIAvailable += OnCustomGUIAvailable; SynchronizationManager.OnAdminStatusChanged += OnAdminStatusChanged; SynchronizationManager.OnConfigurationSynchronized += OnConfigurationSynchronized; Localization.OnLanguageChange = (Action)Delegate.Combine(Localization.OnLanguageChange, new Action(RelabelButtons)); LocalizationManager.OnLocalizationAdded += RelabelButtons; try { if (harmony == null) { harmony = new Harmony("ModQuickConfigLauncher.broker"); harmony.Patch((MethodBase)AccessTools.Method(typeof(Menu), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(QuickConfigBroker), "OnMenuStart", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(Menu), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(QuickConfigBroker), "OnMenuUpdate", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } catch (Exception ex) { ModLogger.LogWarning("QuickConfig launcher could not patch Menu: " + ex.Message); } TryBuildButtons(); } public void OnDestroy() { GUIManager.OnCustomGUIAvailable -= OnCustomGUIAvailable; SynchronizationManager.OnAdminStatusChanged -= OnAdminStatusChanged; SynchronizationManager.OnConfigurationSynchronized -= OnConfigurationSynchronized; Localization.OnLanguageChange = (Action)Delegate.Remove(Localization.OnLanguageChange, new Action(RelabelButtons)); LocalizationManager.OnLocalizationAdded -= RelabelButtons; if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } private void OnAdminStatusChanged() { RefreshVisibility(); } private void OnConfigurationSynchronized(object sender, EventArgs e) { RefreshVisibility(); } private static void OnMenuStart(Menu __instance) { if (!((Object)(object)Instance == (Object)null)) { Instance.EnsurePauseButton(__instance); } } private static bool OnMenuUpdate() { if ((Object)(object)Instance == (Object)null || (Object)(object)Instance.listPanel == (Object)null) { return true; } if (!ZInput.GetKeyDown((KeyCode)27, true)) { return true; } Instance.CloseList(); return false; } public void Update() { if (!((Object)(object)listPanel == (Object)null) && !((Object)(object)Menu.instance != (Object)null) && Input.GetKeyDown((KeyCode)27)) { CloseList(); } } private void OnCustomGUIAvailable() { TryBuildButtons(); } private void TryBuildButtons() { if (!GUIManager.IsHeadless() && GUIManager.Instance != null) { if ((Object)(object)FejdStartup.instance != (Object)null && (Object)(object)GUIManager.CustomGUIFront != (Object)null) { mainMenuButton = EnsureCornerButton(mainMenuButton, GUIManager.CustomGUIFront.transform); } if ((Object)(object)Menu.instance != (Object)null) { EnsurePauseButton(Menu.instance); } RefreshVisibility(); } } private void EnsurePauseButton(Menu menu) { if (!((Object)(object)menu == (Object)null) && !((Object)(object)menu.m_root == (Object)null)) { pauseButton = EnsureCornerButton(pauseButton, menu.m_root); RefreshVisibility(); } } private GameObject EnsureCornerButton(GameObject existing, Transform parent) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown if (GUIManager.IsHeadless() || GUIManager.Instance == null || (Object)(object)parent == (Object)null) { return existing; } if ((Object)(object)existing != (Object)null && (Object)(object)existing.transform.parent == (Object)(object)parent) { return existing; } Transform val = parent.Find("ModQuickConfigButton"); if ((Object)(object)val != (Object)null) { return ((Component)val).gameObject; } GameObject obj = GUIManager.Instance.CreateButton(ButtonLabel(), parent, new Vector2(1f, 0f), new Vector2(1f, 0f), new Vector2(-20f, 20f), 150f, 38f); ((Object)obj).name = "ModQuickConfigButton"; RectTransform val2 = (RectTransform)obj.transform; val2.pivot = new Vector2(1f, 0f); val2.anchoredPosition = new Vector2(-20f, 20f); ((UnityEvent)obj.GetComponent<Button>().onClick).AddListener(new UnityAction(OpenList)); return obj; } private void RelabelButtons() { try { string label = ButtonLabel(); SetLabel(mainMenuButton, label); SetLabel(pauseButton, label); } catch (Exception ex) { ModLogger.LogWarning("QuickConfig launcher could not update its button label: " + ex.Message); } } private static void SetLabel(GameObject button, string label) { if (!((Object)(object)button == (Object)null)) { Text componentInChildren = button.GetComponentInChildren<Text>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.text = label; } } } private string ButtonLabel() { if (Localization.instance != null) { Localization.instance.ReLocalizeAll(((Component)this).transform); } return ConfigUI.L("$modquickconfig_button", "Mod Config"); } private static bool CanConfigure() { if (GUIManager.IsHeadless() || GUIManager.Instance == null) { return false; } if ((Object)(object)ZNet.instance == (Object)null) { return true; } if (ZNet.instance.IsServer()) { return true; } if (SynchronizationManager.Instance != null) { return SynchronizationManager.Instance.PlayerIsAdmin; } return false; } private void RefreshVisibility() { bool flag = entries.Count > 0 && CanConfigure(); if ((Object)(object)mainMenuButton != (Object)null) { mainMenuButton.SetActive(flag && (Object)(object)FejdStartup.instance != (Object)null); } if ((Object)(object)pauseButton != (Object)null) { pauseButton.SetActive(flag); } if (!flag && (Object)(object)listPanel != (Object)null) { CloseList(); } } private void OpenList() { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown CloseList(); if (!CanConfigure()) { return; } if (order.Count == 1) { Invoke(order[0]); return; } float h = Mathf.Clamp(80f + 42f * (float)order.Count, 122f, 560f); listPanel = ConfigUI.CreatePanel(ConfigUI.L("$modquickconfig_list_title", "Configure a mod"), 320f, h, out var body); ConfigUI.AddCloseX(body, 320f, new UnityAction(CloseList)); float num = 64f; foreach (string item in order) { string entry = item; ConfigUI.AddButton(body, 20f, num, 280f, entry, (UnityAction)delegate { CloseList(); Invoke(entry); }); num += 42f; } } private void CloseList() { if (!((Object)(object)listPanel == (Object)null)) { Object.Destroy((Object)(object)listPanel); listPanel = null; } } private void Invoke(string modName) { if (!entries.TryGetValue(modName, out var value) || value == null) { return; } try { value(); } catch (Exception arg) { ModLogger.LogError($"The config panel for '{modName}' failed to open: {arg}"); } } } internal class StartupPopupQueue : MonoBehaviour { private sealed class Entry { internal string Key; internal int Order; internal long Sequence; internal Func<bool> TryOpen; internal Func<bool> IsOpen; } internal const string QueueObjectName = "ModStartupPopupQueue"; internal const string QueueTypeName = "StartupPopupQueue"; internal const string PanelGuardTypeName = "ConfigUIInputGuard"; internal const int ContractVersion = 1; private const float FirstPopupDelay = 1f; private const float BetweenPopupsDelay = 0.5f; private readonly List<Entry> pending = new List<Entry>(); private readonly List<MonoBehaviour> componentBuffer = new List<MonoBehaviour>(); private Entry current; private long nextSequence; private float readySince = -1f; private bool shownThisVisit; private FejdStartup visit; public int QueueVersion => 1; public bool Enqueue(string key, int order, Func<bool> tryOpen, Func<bool> isOpen) { if (string.IsNullOrEmpty(key) || tryOpen == null || isOpen == null) { return false; } if (current != null && string.Equals(current.Key, key, StringComparison.Ordinal)) { return false; } Entry entry = FindPending(key); if (entry != null) { entry.Order = order; entry.TryOpen = tryOpen; entry.IsOpen = isOpen; return true; } pending.Add(new Entry { Key = key, Order = order, Sequence = nextSequence++, TryOpen = tryOpen, IsOpen = isOpen }); return true; } public void Cancel(string key) { Entry entry = FindPending(key); if (entry != null) { pending.Remove(entry); } } public bool IsQueued(string key) { if (string.IsNullOrEmpty(key)) { return false; } if (current != null && string.Equals(current.Key, key, StringComparison.Ordinal)) { return true; } return FindPending(key) != null; } public void Update() { if (current == null && pending.Count == 0) { return; } FejdStartup instance = FejdStartup.instance; if ((Object)(object)instance == (Object)null) { current = null; readySince = -1f; return; } if ((Object)(object)instance != (Object)(object)visit) { visit = instance; shownThisVisit = false; readySince = -1f; } if (current != null) { if (StillOpen(current)) { return; } current = null; readySince = -1f; } if (pending.Count == 0) { return; } if (!MainMenuReady(instance)) { readySince = -1f; return; } float unscaledTime = Time.unscaledTime; if (readySince < 0f) { readySince = unscaledTime; } else { if (unscaledTime - readySince < (shownThisVisit ? 0.5f : 1f)) { return; } while (pending.Count > 0) { Entry entry = TakeFirst(); if (TryOpen(entry)) { current = entry; shownThisVisit = true; readySince = -1f; break; } } } } private bool MainMenuReady(FejdStartup startup) { if (!CinematicsManager.IsStartedPlaying() && (Object)(object)startup.m_mainMenu != (Object)null && startup.m_mainMenu.activeInHierarchy && (Object)(object)startup.m_menuList != (Object)null && startup.m_menuList.activeInHierarchy && ((Object)(object)startup.m_connectionFailedPanel == (Object)null || !startup.m_connectionFailedPanel.activeInHierarchy) && !UnifiedPopup.IsVisible() && (Object)(object)GUIManager.CustomGUIFront != (Object)null) { return !KitPanelOpen(); } return false; } private bool KitPanelOpen() { Transform transform = GUIManager.CustomGUIFront.transform; for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); if (!((Component)child).gameObject.activeSelf) { continue; } ((Component)child).GetComponents<MonoBehaviour>(componentBuffer); foreach (MonoBehaviour item in componentBuffer) { if ((Object)(object)item != (Object)null && ((object)item).GetType().Name == "ConfigUIInputGuard") { return true; } } } return false; } private Entry FindPending(string key) { if (string.IsNullOrEmpty(key)) { return null; } foreach (Entry item in pending) { if (string.Equals(item.Key, key, StringComparison.Ordinal)) { return item; } } return null; } private Entry TakeFirst() { Entry entry = pending[0]; foreach (Entry item in pending) { if (item.Order < entry.Order || (item.Order == entry.Order && item.Sequence < entry.Sequence)) { entry = item; } } pending.Remove(entry); return entry; } private static bool TryOpen(Entry entry) { bool flag = false; try { flag = entry.TryOpen(); } catch (Exception arg) { ModLogger.LogError($"The startup popup '{entry.Key}' failed to open: {arg}"); } if (flag) { return true; } return StillOpen(entry); } private static bool StillOpen(Entry entry) { try { return entry.IsOpen(); } catch (Exception ex) { ModLogger.LogWarning("Could not tell whether the startup popup '" + entry.Key + "' is still open, treating it as closed: " + ex.Message); return false; } } } [Serializable] public class RecipeRequirementConfig { public string item = ""; public int amount = 1; } [Serializable] public class RecipeConfig { public string name = ""; public string item = ""; public int amount = 1; public string craftingStation = ""; public int minStationLevel = 1; public bool enabled = true; public string repairStation = ""; public List<RecipeRequirementConfig> resources = new List<RecipeRequirementConfig>(); } [Serializable] public class RecipesConfig { public List<RecipeConfig> recipes = new List<RecipeConfig>(); } public static class GameObjectExtensions { public static RectTransform RectTransform(this GameObject go) { Transform transform = go.transform; return (RectTransform)(object)((transform is RectTransform) ? transform : null); } public static T RequireComponent<T>(this GameObject go) where T : Component { T component = go.GetComponent<T>(); if (!((Object)(object)component == (Object)null)) { return component; } return go.AddComponent<T>(); } } public class GotDestroyed : MonoBehaviour { public void OnDisable() { Debug.LogError((object)("I got destroyed! (" + ((Object)((Component)this).gameObject).name + ")")); Debug.Log((object)Environment.StackTrace); } } public static class AssetBundleLoader { private static readonly List<Stream> _liveStreams = new List<Stream>(); public static AssetBundle LoadFromResources(string filename, Assembly assembly) { if (assembly == null) { throw new ArgumentNullException("assembly"); } string text = assembly.GetName().Name + "." + filename; try { Stream manifestResourceStream = assembly.GetManifestResourceStream(text); if (manifestResourceStream == null) { ModLogger.LogError("Embedded asset bundle '" + text + "' not found in " + assembly.GetName().Name + "."); return null; } AssetBundle val = AssetBundle.LoadFromStream(manifestResourceStream); if ((Object)(object)val == (Object)null) { manifestResourceStream.Dispose(); ModLogger.LogError("Embedded asset bundle '" + text + "' failed to load."); return null; } _liveStreams.Add(manifestResourceStream); MetalShaderSidecar.Apply(val, filename, assembly); return val; } catch (Exception ex) { ModLogger.LogError("Failed to load embedded asset bundle '" + text + "': " + ex.Message); return null; } } public static AssetBundle LoadFromResourcesInMemory(string filename, Assembly assembly) { if (assembly == null) { throw new ArgumentNullException("assembly"); } string text = assembly.GetName().Name + "." + filename; try { Stopwatch stopwatch = Stopwatch.StartNew(); byte[] array; using (Stream stream = assembly.GetManifestResourceStream(text)) { if (stream == null) { ModLogger.LogError("Embedded asset bundle '" + text + "' not found in " + assembly.GetName().Name + "."); return null; } array = new byte[stream.Length]; int i; int num; for (i = 0; i < array.Length; i += num) { num = stream.Read(array, i, array.Length - i); if (num <= 0) { break; } } if (i < array.Length) { ModLogger.LogError($"Embedded asset bundle '{text}' ended after {i} of {array.Length} bytes."); return null; } } AssetBundle val = AssetBundle.LoadFromMemory(array); if ((Object)(object)val == (Object)null) { ModLogger.LogError("Embedded asset bundle '" + text + "' failed to load."); return null; } ModLogger.LogDebug($"Loaded embedded asset bundle '{text}' ({array.Length / 1024} KB) from memory in {stopwatch.Elapsed.TotalMilliseconds:0} ms."); MetalShaderSidecar.Apply(val, filename, assembly); return val; } catch (Exception ex) { ModLogger.LogError("Failed to load embedded asset bundle '" + text + "': " + ex.Message); return null; } } public static AssetBundle LoadIntoContext(string filename, Assembly assembly) { AssetBundle val = LoadFromResources(filename, assembly); if ((Object)(object)val != (Object)null) { ModContext.AssetBundle = val; } return val; } } public static class AudioMixerMocks { public static void Resolve(GameObject root, string fallbackGroup = null) { if ((Object)(object)root == (Object)null) { return; } AudioSource[] componentsInChildren = root.GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val in componentsInChildren) { PrefabExtension.FixReferences((object)val); if ((Object)(object)val.outputAudioMixerGroup == (Object)null && fallbackGroup != null) { val.outputAudioMixerGroup = Cache.GetPrefab<AudioMixerGroup>(fallbackGroup); } } } } public static class ConfigBinder { private static ConfigFile Cfg => ModContext.Cfg; public static ConfigEntry<bool> BindServerConfig(string category, string key, bool value, string description, AcceptableValueBase acceptableValues = null, bool advanced = false) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown return Cfg.Bind<bool>(category, key, value, new ConfigDescription(description, acceptableValues, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } public static ConfigEntry<int> BindServerConfig(string category, string key, int value, string description, bool advanced = false, int valMin = 0, int valMax = 150) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown return Cfg.Bind<int>(category, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<int>(valMin, valMax), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } public static ConfigEntry<float> BindServerConfig(string category, string key, float value, string description, bool advanced = false, float valMin = 0f, float valMax = 150f) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown return Cfg.Bind<float>(category, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(valMin, valMax), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } public static ConfigEntry<string> BindServerConfig(string category, string key, string value, string description, AcceptableValueList<string> acceptableValues = null, bool advanced = false) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown return Cfg.Bind<string>(category, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)acceptableValues, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } public static ConfigEntry<T> BindServerConfig<T>(string category, string key, T value, string description, AcceptableValueBase acceptableValues, bool advanced = false) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown return Cfg.Bind<T>(category, key, value, new ConfigDescription(description, acceptableValues, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } public static ConfigEntry<T> BindClientConfig<T>(string category, string key, T value, string description, AcceptableValueBase acceptableValues = null, bool advanced = false) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown return Cfg.Bind<T>(category, key, value, new ConfigDescription(description, acceptableValues, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = false, IsAdvanced = advanced } })); } public static ConfigEntry<T> BindServerConfigInOrder<T>(string category, string key, T value, string description, AcceptableValueBase acceptableValues = null, bool advanced = false) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown return ConfigFileExtensions.BindConfigInOrder<T>(Cfg, category, key, value, description, true, true, true, acceptableValues, (Action<ConfigEntryBase>)null, new ConfigurationManagerAttributes { IsAdvanced = advanced }); } public static ConfigEntry<T> BindClientConfigInOrder<T>(string category, string key, T value, string description, AcceptableValueBase acceptableValues = null, bool advanced = false) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown return ConfigFileExtensions.BindConfigInOrder<T>(Cfg, category, key, value, description, false, true, true, acceptableValues, (Action<ConfigEntryBase>)null, new ConfigurationManagerAttributes { IsAdvanced = advanced }); } } public static class ConfigChangeDebouncer { private static readonly Dictionary<object, Action> pendingActions = new Dictionary<object, Action>(); private static readonly Dictionary<object, float> fireAt = new Dictionary<object, float>(); private static readonly HashSet<object> running = new HashSet<object>(); public static void Schedule(object key, Action action) { float num = ((ModContext.ConfigApplyDelay != null) ? ModContext.ConfigApplyDelay.Value : 0f); if (num <= 0f) { action(); return; } ThreadingHelper instance = ThreadingHelper.Instance; if (!((Object)(object)instance == (Object)null)) { pendingActions[key] = action; fireAt[key] = Time.realtimeSinceStartup + num; if (!running.Contains(key)) { running.Add(key); ((MonoBehaviour)instance).StartCoroutine(Run(key)); } } } private static IEnumerator Run(object key) { float value; while (fireAt.TryGetValue(key, out value) && Time.realtimeSinceStartup < value) { yield return null; } pendingActions.TryGetValue(key, out var value2); pendingActions.Remove(key); fireAt.Remove(key); running.Remove(key); value2?.Invoke(); } } internal static class ConfigDrawHelpers { private static readonly Dictionary<object, string> TextBuffer = new Dictionary<object, string>(); private static readonly Dictionary<object, float> SliderPending = new Dictionary<object, float>(); private static GUIStyle _headerButton; private static GUIStyle _groupLabel; private static GUIStyle _dim; internal static GUIStyle HeaderButton => _headerButton; internal static GUIStyle Dim => _dim; internal static void EnsureStyles() { //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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown if (_headerButton == null) { _headerButton = new GUIStyle(GUI.skin.button) { alignment = (TextAnchor)3, fontStyle = (FontStyle)1 }; _groupLabel = new GUIStyle(GUI.skin.label) { fontStyle = (FontStyle)1 }; _dim = new GUIStyle(GUI.skin.label) { fontStyle = (FontStyle)2, fontSize = 11 }; } } internal static ConfigurationManagerAttributes GetAttributes(ConfigEntryBase entry) { if (entry == null) { return null; } ConfigDescription description = entry.Description; if (description == null) { return null; } return description.Tags?.OfType<ConfigurationManagerAttributes>().FirstOrDefault(); } internal static void Hide(ConfigEntryBase entry) { ConfigurationManagerAttributes attributes = GetAttributes(entry); if (attributes != null) { attributes.Browsable = false; } } internal static void GroupHeader(string text) { GUILayout.Space(4f); GUILayout.Label(text, _groupLabel, Array.Empty<GUILayoutOption>()); } private static bool EnterPressed() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 if ((int)Event.current.type == 4) { if ((int)Event.current.keyCode != 13) { return (int)Event.current.keyCode == 271; } return true; } return false; } internal static void DrawBool(string label, ConfigEntry<bool> cfg) { bool flag = GUILayout.Toggle(cfg.Value, " " + label, Array.Empty<GUILayoutOption>()); if (flag != cfg.Value) { cfg.Value = flag; } } internal static void DrawString(string label, ConfigEntry<string> cfg) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(230f) }); string text = "str_" + ((object)cfg).GetHashCode(); GUI.SetNextControlName(text); bool flag = GUI.GetNameOfFocusedControl() == text; string value; string text2 = GUILayout.TextField((flag && TextBuffer.TryGetValue(cfg, out value)) ? value : cfg.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(230f) }); string value2; if (flag) { TextBuffer[cfg] = text2; if (EnterPressed() && cfg.Value != text2) { cfg.Value = text2; } } else if (TextBuffer.TryGetValue(cfg, out value2)) { if (cfg.Value != value2) { cfg.Value = value2; } TextBuffer.Remove(cfg); } GUILayout.EndHorizontal(); } internal static void DrawChoice(string label, ConfigEntry<string> cfg) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(230f) }); if (((ConfigEntryBase)cfg).Description.AcceptableValues is AcceptableValueList<string> val && val.AcceptableValues.Length != 0) { string[] acceptableValues = val.AcceptableValues; int num = Array.IndexOf(acceptableValues, cfg.Value); if (num < 0) { num = 0; } if (GUILayout.Button("◄", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(26f) })) { cfg.Value = acceptableValues[(num - 1 + acceptableValues.Length) % acceptableValues.Length]; } GUILayout.Label(cfg.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(160f) }); if (GUILayout.Button("►", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(26f) })) { cfg.Value = acceptableValues[(num + 1) % acceptableValues.Length]; } } else { GUILayout.Label(cfg.Value, Array.Empty<GUILayoutOption>()); } GUILayout.EndHorizontal(); } internal static void DrawFloat(string label, ConfigEntry<float> cfg) { float num = 0f; float num2 = Mathf.Max(100f, cfg.Value); if (((ConfigEntryBase)cfg).Description.AcceptableValues is AcceptableValueRange<float> val) { num = val.MinValue; num2 = val.MaxValue; } float num3 = DrawSliderRow(label, cfg, cfg.Value, num, num2, isInt: false); if (num3 != cfg.Value) { cfg.Value = Mathf.Clamp(num3, num, num2); } } internal static void DrawInt(string label, ConfigEntry<int> cfg) { float num = 0f; float num2 = Mathf.Max(100f, (float)cfg.Value); if (((ConfigEntryBase)cfg).Description.AcceptableValues is AcceptableValueRange<int> val) { num = val.MinValue; num2 = val.MaxValue; } int num3 = Mathf.Clamp(Mathf.RoundToInt(DrawSliderRow(label, cfg, cfg.Value, num, num2, isInt: true)), (int)num, (int)num2); if (num3 != cfg.Value) { cfg.Value = num3; } } private static float DrawSliderRow(string label, object key, float current, float min, float max, bool isInt) { float num = current; GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(230f) }); float value; float num2 = (SliderPending.TryGetValue(key, out value) ? value : current); float num3 = GUILayout.HorizontalSlider(num2, min, max, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }); if (Mathf.Abs(num3 - num2) > Mathf.Epsilon) { SliderPending[key] = num3; } if (SliderPending.TryGetValue(key, out var value2) && !Input.GetMouseButton(0)) { SliderPending.Remove(key); num = value2; } float value3; float num4 = (SliderPending.TryGetValue(key, out value3) ? value3 : num); string text = "num_" + key.GetHashCode(); GUI.SetNextControlName(text); bool flag = GUI.GetNameOfFocusedControl() == text; string text2 = (isInt ? Mathf.RoundToInt(num4).ToString() : num4.ToString("0.###")); string value4; string text3 = GUILayout.TextField((flag && TextBuffer.TryGetValue(key, out value4)) ? value4 : text2, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }); string value5; if (flag) { TextBuffer[key] = text3; if (EnterPressed() && float.TryParse(text3, out var result)) { num = result; } } else if (TextBuffer.TryGetValue(key, out value5)) { if (float.TryParse(value5, out var result2)) { num = result2; } TextBuffer.Remove(key); } GUILayout.Label("[" + (isInt ? min.ToString() : min.ToString("0.#")) + " - " + (isInt ? max.ToString() : max.ToString("0.#")) + "]", _dim, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }); GUILayout.EndHorizontal(); return num; } } internal static class ItemConfigDrawer { private static readonly Dictionary<string, bool> Expanded = new Dictionary<string, bool>(); private static readonly Dictionary<object, List<string[]>> RecipeRows = new Dictionary<object, List<string[]>>(); private static int _order = 0; private static readonly KeyValuePair<string, ItemStat[]>[] StatGroups = new KeyValuePair<string, ItemStat[]>[5] { new KeyValuePair<string, ItemStat[]>("Damage", new ItemStat[20] { ItemStat.slash, ItemStat.slash_per_level, ItemStat.bl