Decompiled source of Campfire v1.1.0

plugins/Campfire.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using NetworkingUtils;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Campfire")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+283ecd9d1961bdac4798edb2a0d50b0d23e43208")]
[assembly: AssemblyProduct("Campfire")]
[assembly: AssemblyTitle("Campfire")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Jatify
{
	internal static class JatifyLook
	{
		private const string Guid = "jatify.ui";

		private static Type _look;

		private static Assembly _from;

		private static readonly Dictionary<string, string> Plain = new Dictionary<string, string>
		{
			["glass"] = "#141416EB",
			["glassLine"] = "#FFFFFF26",
			["line2"] = "#FFFFFF29",
			["raised"] = "#2A2B30F2",
			["raised2"] = "#2C2C32E6",
			["text"] = "#ECEEED",
			["dim"] = "#B4B4BA",
			["mute"] = "#80808A",
			["accent"] = "#22D67E",
			["accentSoft"] = "#22D67E24",
			["ember"] = "#F2703A",
			["emberSoft"] = "#F2703A29",
			["health"] = "#E5484D",
			["stamina"] = "#F5B942",
			["eitr"] = "#5AA9FF"
		};

		private static TMP_FontAsset _valheim;

		internal static bool On => Look() != null;

		private static Type Look()
		{
			if (!Chainloader.PluginInfos.TryGetValue("jatify.ui", out var value) || (Object)(object)value.Instance == (Object)null)
			{
				return null;
			}
			Assembly assembly = ((object)value.Instance).GetType().Assembly;
			if (assembly != _from)
			{
				_from = assembly;
				_look = assembly.GetType("Jatify.UI.Look");
			}
			return _look;
		}

		private static object Call(string method, object arg)
		{
			Type type = Look();
			if (type == null)
			{
				return null;
			}
			try
			{
				return type.GetMethod(method)?.Invoke(null, new object[1] { arg });
			}
			catch
			{
				return null;
			}
		}

		internal static Color C(string token)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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)
			if (Call("Color", token) is Color val && val.a > 0f)
			{
				return val;
			}
			Color result = default(Color);
			if (!Plain.TryGetValue(token, out var value) || !ColorUtility.TryParseHtmlString(value, ref result))
			{
				return Color.white;
			}
			return result;
		}

		internal static Color Color(string token, Color fallback)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (!(Call("Color", token) is Color val) || !(val.a > 0f))
			{
				return fallback;
			}
			return val;
		}

		internal static TMP_FontAsset Font(string kind)
		{
			object obj = Call("Font", kind);
			return (TMP_FontAsset)(((obj is TMP_FontAsset) ? obj : null) ?? ((kind == "title") ? Game("Valheim-Norsebold") : ((kind == "lore") ? Game("Valheim-AveriaSerifLibre") : null)) ?? Valheim());
		}

		private static TMP_FontAsset Game(string name)
		{
			TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
			foreach (TMP_FontAsset val in array)
			{
				if (((Object)val).name == name)
				{
					return val;
				}
			}
			return null;
		}

		internal static TMP_FontAsset Font(string kind, TMP_FontAsset fallback)
		{
			object obj = Call("Font", kind);
			return (TMP_FontAsset)(((obj is TMP_FontAsset) ? obj : null) ?? fallback);
		}

		private static TMP_FontAsset Valheim()
		{
			if ((Object)(object)_valheim != (Object)null)
			{
				return _valheim;
			}
			TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
			foreach (TMP_FontAsset val in array)
			{
				if (((Object)val).name.StartsWith("Valheim-AveriaSansLibre"))
				{
					return _valheim = val;
				}
			}
			return _valheim = TMP_Settings.defaultFontAsset;
		}

		internal static Sprite Rounded(int radius)
		{
			object obj = Call("Rounded", radius);
			return (Sprite)((obj is Sprite) ? obj : null);
		}

		internal static Sprite Ring(int radius)
		{
			object obj = Call("Ring", radius);
			return (Sprite)((obj is Sprite) ? obj : null);
		}

		internal static Sprite Icon(string name)
		{
			object obj = Call("Icon", name);
			return (Sprite)((obj is Sprite) ? obj : null);
		}

		internal static RectTransform Node(Transform parent, string name)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			if ((Object)(object)parent != (Object)null)
			{
				val.transform.SetParent(parent, false);
			}
			return (RectTransform)val.transform;
		}

		internal static RectTransform Place(RectTransform r, float x, float y, float w, float h)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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)
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0f, 1f);
			r.pivot = val;
			Vector2 anchorMin = (r.anchorMax = val);
			r.anchorMin = anchorMin;
			r.anchoredPosition = new Vector2(x, 0f - y);
			r.sizeDelta = new Vector2(w, h);
			return r;
		}

		internal static RectTransform Fill(RectTransform r, float inset = 0f)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			r.anchorMin = Vector2.zero;
			r.anchorMax = Vector2.one;
			r.pivot = new Vector2(0.5f, 0.5f);
			r.offsetMin = new Vector2(inset, inset);
			r.offsetMax = new Vector2(0f - inset, 0f - inset);
			return r;
		}

		internal static Image Img(Transform parent, Sprite s, Color c, string name = "Image")
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			Image obj = ((Component)Node(parent, name)).gameObject.AddComponent<Image>();
			obj.sprite = s;
			((Graphic)obj).color = c;
			((Graphic)obj).raycastTarget = false;
			return obj;
		}

		internal static Image Box(Transform parent, string name, Color fill, Color line, int radius)
		{
			//IL_0030: 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)
			RectTransform val = Node(parent, name);
			Sprite val2 = Ring(radius);
			Image obj = ((Component)val).gameObject.AddComponent<Image>();
			obj.sprite = Rounded(radius);
			obj.type = (Type)1;
			((Graphic)obj).color = fill;
			((Graphic)obj).raycastTarget = true;
			if ((Object)(object)val2 != (Object)null)
			{
				Image obj2 = Img((Transform)(object)val, val2, line, "Line");
				obj2.type = (Type)1;
				Fill(((Graphic)obj2).rectTransform);
			}
			return obj;
		}

		internal static TextMeshProUGUI Text(Transform parent, string s, string font, float size, Color c, TextAlignmentOptions align = (TextAlignmentOptions)4097)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI obj = ((Component)Node(parent, "Text")).gameObject.AddComponent<TextMeshProUGUI>();
			((TMP_Text)obj).font = Font(font);
			((TMP_Text)obj).fontSize = size;
			((Graphic)obj).color = c;
			((TMP_Text)obj).text = s;
			((TMP_Text)obj).alignment = align;
			((Graphic)obj).raycastTarget = false;
			((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)obj).overflowMode = (TextOverflowModes)1;
			((TMP_Text)obj).richText = true;
			return obj;
		}

		internal static float Width(TMP_Text t)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return t.GetPreferredValues(t.text).x;
		}

		internal static Button Click(Graphic target, Action on)
		{
			//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_0037: 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_005e: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			Button obj = ((Component)target).gameObject.AddComponent<Button>();
			((Selectable)obj).targetGraphic = target;
			ColorBlock colors = ((Selectable)obj).colors;
			((ColorBlock)(ref colors)).highlightedColor = new Color(1.2f, 1.2f, 1.2f);
			((ColorBlock)(ref colors)).pressedColor = new Color(0.85f, 0.85f, 0.85f);
			((ColorBlock)(ref colors)).selectedColor = Color.white;
			((Selectable)obj).colors = colors;
			((UnityEvent)obj.onClick).AddListener((UnityAction)delegate
			{
				on();
			});
			return obj;
		}

		internal static RectTransform Scroll(Transform parent, string name, float x, float y, float w, float h)
		{
			//IL_003d: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			RectTransform obj = Place(Node(parent, name), x, y, w, h);
			((Component)obj).gameObject.AddComponent<RectMask2D>();
			((Graphic)((Component)obj).gameObject.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0f);
			RectTransform val = Node((Transform)(object)obj, "Content");
			val.anchorMin = new Vector2(0f, 1f);
			val.anchorMax = Vector2.one;
			val.pivot = new Vector2(0.5f, 1f);
			val.anchoredPosition = Vector2.zero;
			val.sizeDelta = Vector2.zero;
			ScrollRect obj2 = ((Component)obj).gameObject.AddComponent<ScrollRect>();
			obj2.content = val;
			obj2.horizontal = false;
			obj2.movementType = (MovementType)2;
			obj2.scrollSensitivity = 1500f;
			obj2.inertia = false;
			return val;
		}

		internal static TMP_InputField Field(Transform parent, string placeholder, float x, float y, float w, Action<string> changed)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			Image val = Box(parent, "Field", C("raised"), C("line2"), 8);
			Place(((Graphic)val).rectTransform, x, y, w, 34f);
			Sprite val2 = Icon("search");
			float num = 12f;
			if ((Object)(object)val2 != (Object)null)
			{
				Place(((Graphic)Img(((Component)val).transform, val2, C("mute"), "Search")).rectTransform, 10f, 8.5f, 17f, 17f);
				num = 34f;
			}
			RectTransform val3 = Node(((Component)val).transform, "Area");
			Fill(val3);
			val3.offsetMin = new Vector2(num, 4f);
			val3.offsetMax = new Vector2(-10f, -4f);
			((Component)val3).gameObject.AddComponent<RectMask2D>();
			TextMeshProUGUI val4 = Text((Transform)(object)val3, "", "medium", 14f, Color.white, (TextAlignmentOptions)4097);
			Fill(((TMP_Text)val4).rectTransform);
			TextMeshProUGUI val5 = Text((Transform)(object)val3, placeholder, "medium", 14f, C("mute"), (TextAlignmentOptions)4097);
			Fill(((TMP_Text)val5).rectTransform);
			TMP_InputField obj = ((Component)val).gameObject.AddComponent<TMP_InputField>();
			obj.textViewport = val3;
			obj.textComponent = (TMP_Text)(object)val4;
			obj.placeholder = (Graphic)(object)val5;
			obj.fontAsset = ((TMP_Text)val4).font;
			obj.pointSize = 14f;
			obj.customCaretColor = true;
			obj.caretColor = Color.white;
			obj.caretWidth = 2;
			((Behaviour)obj).enabled = false;
			((Behaviour)obj).enabled = true;
			((UnityEvent<string>)(object)obj.onValueChanged).AddListener((UnityAction<string>)delegate(string s)
			{
				changed(s ?? "");
			});
			return obj;
		}

		internal static void Bar(Transform parent, float x, float y, float w, float h, float k, Color fill)
		{
			//IL_001a: 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_007e: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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)
			Image val = Box(parent, "Bar", new Color(1f, 1f, 1f, 0.08f), new Color(0f, 0f, 0f, 0f), (int)Mathf.Max(2f, h / 2f));
			((Graphic)val).raycastTarget = false;
			Place(((Graphic)val).rectTransform, x, y, w, h);
			if (!(k <= 0f))
			{
				Image obj = Box(((Component)val).transform, "Fill", fill, new Color(0f, 0f, 0f, 0f), (int)Mathf.Max(2f, h / 2f));
				((Graphic)obj).raycastTarget = false;
				RectTransform rectTransform = ((Graphic)obj).rectTransform;
				rectTransform.anchorMin = Vector2.zero;
				rectTransform.anchorMax = new Vector2(Mathf.Clamp01(k), 1f);
				Vector2 offsetMin = (rectTransform.offsetMax = Vector2.zero);
				rectTransform.offsetMin = offsetMin;
			}
		}

		internal static void Clear(Transform t)
		{
			for (int num = t.childCount - 1; num >= 0; num--)
			{
				Object.Destroy((Object)(object)((Component)t.GetChild(num)).gameObject);
			}
		}
	}
}
namespace Jatify.Campfire
{
	internal static class AchView
	{
		private sealed class Ach
		{
			public string Id;

			public string Name;

			public string Desc;

			public bool Hidden;

			public bool Done;

			public DateTime When;

			public float Percent = -1f;

			public Sprite Icon;
		}

		private static CampfireUi.Window _win;

		private static RectTransform _head;

		private static RectTransform _filter;

		private static RectTransform _list;

		private static int _mode;

		private static List<Ach> _all = new List<Ach>();

		private static CallResult<GlobalAchievementPercentagesReady_t> _percents;

		private static Callback<UserAchievementIconFetched_t> _iconFetched;

		private static bool _percentsAsked;

		internal static bool Shown
		{
			get
			{
				if (_win != null)
				{
					return _win.Shown;
				}
				return false;
			}
		}

		internal static void Hide()
		{
			if (_win != null)
			{
				_win.Show(on: false);
			}
		}

		internal static void Open()
		{
			if (_win == null || (Object)(object)_win.Root == (Object)null)
			{
				Build();
			}
			_win.Show(on: true);
			Load();
			Paint();
		}

		private static void Build()
		{
			_win = new CampfireUi.Window((Transform)(object)CharScreen.Root, "achievements", 780f, 860f, delegate
			{
				_win.Show(on: false);
			});
			_win.SetTitle("Achievements");
			_win.Buttons("Close");
			_head = CampfireUi.Place(CampfireUi.Node((Transform)(object)_win.Body, "head"), 0f, 0f, _win.BodyW, 62f);
			_filter = CampfireUi.Place(CampfireUi.Node((Transform)(object)_win.Body, "filter"), 0f, 70f, _win.BodyW, 30f);
			_list = JatifyLook.Scroll((Transform)(object)_win.Body, "grid", 0f, 112f, _win.BodyW, _win.BodyH - 112f);
		}

		private static bool SteamReady()
		{
			try
			{
				return SteamAPI.IsSteamRunning() && SteamUser.BLoggedOn();
			}
			catch
			{
				return false;
			}
		}

		private static void Load()
		{
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			_all.Clear();
			if (!SteamReady())
			{
				return;
			}
			if (_iconFetched == null)
			{
				_iconFetched = Callback<UserAchievementIconFetched_t>.Create((DispatchDelegate<UserAchievementIconFetched_t>)delegate
				{
					foreach (Ach item in _all)
					{
						if ((Object)(object)item.Icon == (Object)null)
						{
							item.Icon = Icon(item.Id);
						}
					}
					if (Shown)
					{
						Paint();
					}
				});
			}
			uint numAchievements = SteamUserStats.GetNumAchievements();
			bool flag = default(bool);
			uint num2 = default(uint);
			for (uint num = 0u; num < numAchievements; num++)
			{
				string achievementName = SteamUserStats.GetAchievementName(num);
				SteamUserStats.GetAchievementAndUnlockTime(achievementName, ref flag, ref num2);
				_all.Add(new Ach
				{
					Id = achievementName,
					Done = flag,
					When = (flag ? DateTimeOffset.FromUnixTimeSeconds(num2).LocalDateTime : DateTime.MinValue),
					Name = SteamUserStats.GetAchievementDisplayAttribute(achievementName, "name"),
					Desc = SteamUserStats.GetAchievementDisplayAttribute(achievementName, "desc"),
					Hidden = (SteamUserStats.GetAchievementDisplayAttribute(achievementName, "hidden") == "1"),
					Icon = Icon(achievementName)
				});
			}
			if (!_percentsAsked)
			{
				_percentsAsked = true;
				_percents = CallResult<GlobalAchievementPercentagesReady_t>.Create((APIDispatchDelegate<GlobalAchievementPercentagesReady_t>)delegate(GlobalAchievementPercentagesReady_t r, bool fail)
				{
					if (!fail)
					{
						float percent2 = default(float);
						foreach (Ach item2 in _all)
						{
							if (SteamUserStats.GetAchievementAchievedPercent(item2.Id, ref percent2))
							{
								item2.Percent = percent2;
							}
						}
						if (Shown)
						{
							Paint();
						}
					}
				});
				_percents.Set(SteamUserStats.RequestGlobalAchievementPercentages(), (APIDispatchDelegate<GlobalAchievementPercentagesReady_t>)null);
				return;
			}
			float percent = default(float);
			foreach (Ach item3 in _all)
			{
				if (SteamUserStats.GetAchievementAchievedPercent(item3.Id, ref percent))
				{
					item3.Percent = percent;
				}
			}
		}

		private static Sprite Icon(string id)
		{
			//IL_0071: 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_0085: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			int achievementIcon = SteamUserStats.GetAchievementIcon(id);
			uint num = default(uint);
			uint num2 = default(uint);
			if (achievementIcon == 0 || !SteamUtils.GetImageSize(achievementIcon, ref num, ref num2) || num == 0)
			{
				return null;
			}
			byte[] array = new byte[num * num2 * 4];
			if (!SteamUtils.GetImageRGBA(achievementIcon, array, array.Length))
			{
				return null;
			}
			byte[] array2 = new byte[array.Length];
			int num3 = (int)(num * 4);
			for (int i = 0; i < num2; i++)
			{
				Buffer.BlockCopy(array, i * num3, array2, ((int)(num2 - 1) - i) * num3, num3);
			}
			Texture2D val = new Texture2D((int)num, (int)num2, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)1
			};
			val.LoadRawTextureData(array2);
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num2), new Vector2(0.5f, 0.5f));
		}

		private static void Paint()
		{
			//IL_0049: 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_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0556: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			CampfireUi.Clear((Transform)(object)_head);
			CampfireUi.Clear((Transform)(object)_filter);
			CampfireUi.Clear((Transform)(object)_list);
			float bodyW = _win.BodyW;
			if (!SteamReady())
			{
				CampfireUi.Para((Transform)(object)_head, "Achievements need Steam: start Valheim through Steam while signed in.", "lore", 15f, CampfireUi.C("dim"), 0f, 0f, bodyW, 60f);
				return;
			}
			CampfireUi.Seg((Transform)(object)_filter, 0f, 0f, 0f, new string[3] { "All", "Unlocked", "Locked" }, _mode, delegate(int i)
			{
				_mode = i;
				Paint();
			});
			int num = _all.Count((Ach a) => a.Done);
			CampfireUi.Text((Transform)(object)_head, $"{num} / {_all.Count} unlocked", "title", 22f, CampfireUi.White, 0f, 0f, 260f, 30f, (TextAlignmentOptions)4097);
			JatifyLook.Bar((Transform)(object)_head, 270f, 11f, bodyW - 270f, 8f, (_all.Count > 0) ? ((float)num / (float)_all.Count) : 0f, CampfireUi.C("accent"));
			CharacterLine(bodyW);
			List<Ach> list = (from a in _all
				where _mode == 0 || _mode == 1 == a.Done
				orderby a.Done descending, a.When descending, a.Percent descending
				select a).ToList();
			float num2 = (bodyW - 10f) / 2f;
			float num3 = 0f;
			for (int num4 = 0; num4 < list.Count; num4++)
			{
				Ach ach = list[num4];
				bool flag = ach.Done && ach.Percent >= 0f && ach.Percent < 10f;
				Image val = CampfireUi.Box((Transform)(object)_list, ach.Id, CampfireUi.C("raised"), flag ? CampfireUi.C("stamina") : CampfireUi.LineSoft, 10);
				((Graphic)val).raycastTarget = false;
				CampfireUi.Place(((Graphic)val).rectTransform, (float)(num4 % 2) * (num2 + 10f), num3, num2, 96f);
				if (flag)
				{
					Image obj = CampfireUi.Box(((Component)val).transform, "rare", CampfireUi.C("raised2"), CampfireUi.NoColor, 4);
					((Graphic)obj).raycastTarget = false;
					CampfireUi.Place(((Graphic)obj).rectTransform, num2 - 10f - 44f, 8f, 44f, 18f);
					CampfireUi.Fill(((TMP_Text)CampfireUi.Text(((Component)obj).transform, "RARE", "mono", 10f, CampfireUi.C("stamina"), 0f, 0f, 44f, 18f, (TextAlignmentOptions)514)).rectTransform);
				}
				Image obj2 = CampfireUi.Img(((Component)val).transform, ach.Icon, (Color)((!((Object)(object)ach.Icon != (Object)null)) ? CampfireUi.NoColor : (ach.Done ? CampfireUi.White : new Color(0.45f, 0.45f, 0.45f, 0.8f))), "i");
				obj2.preserveAspect = true;
				CampfireUi.Place(((Graphic)obj2).rectTransform, 12f, 19f, 58f, 58f);
				bool flag2 = ach.Hidden && !ach.Done;
				CampfireUi.Text(((Component)val).transform, flag2 ? "Hidden achievement" : ach.Name, "title", 17f, ach.Done ? CampfireUi.White : CampfireUi.C("dim"), 82f, 4f, num2 - (flag ? 146f : 92f), 30f, (TextAlignmentOptions)4097);
				TextMeshProUGUI obj3 = CampfireUi.Para(((Component)val).transform, flag2 ? "Keep playing to find out." : ach.Desc, "lore", 13f, CampfireUi.C("mute"), 82f, 32f, num2 - 92f, 36f);
				((TMP_Text)obj3).maxVisibleLines = 2;
				((TMP_Text)obj3).overflowMode = (TextOverflowModes)1;
				string text = (ach.Done ? $"Unlocked {ach.When:yyyy-MM-dd}" : "Locked");
				if (ach.Percent > 0f)
				{
					text += $" · {ach.Percent:0.#}% of players";
				}
				CampfireUi.Text(((Component)val).transform, text, "mono", 11f, ach.Done ? CampfireUi.C("dim") : CampfireUi.C("mute"), 82f, 70f, num2 - 92f, 20f, (TextAlignmentOptions)4097);
				if (num4 % 2 == 1 || num4 == list.Count - 1)
				{
					num3 += 106f;
				}
			}
			_list.sizeDelta = new Vector2(0f, num3);
		}

		private static void CharacterLine(float w)
		{
			//IL_005e: 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)
			PlayerProfile selected = CharScreen.Selected;
			if (selected != null)
			{
				bool usedCheats = selected.m_usedCheats;
				CampfireUi.Text((Transform)(object)_head, usedCheats ? ("Achievements are off for " + selected.GetName() + ": Valheim flagged this character for cheats.") : (selected.GetName() + " can earn achievements."), "medium", 14f, usedCheats ? CampfireUi.C("health") : CampfireUi.C("accent"), 0f, 34f, w, 24f, (TextAlignmentOptions)4097);
			}
		}
	}
	internal static class CampfireUi
	{
		internal sealed class Clicks : MonoBehaviour, IPointerClickHandler, IEventSystemHandler
		{
			public Action Left;

			public Action Double;

			public Action Right;

			public void OnPointerClick(PointerEventData e)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Invalid comparison between Unknown and I4
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				if ((int)e.button == 1)
				{
					Right?.Invoke();
				}
				else if ((int)e.button == 0)
				{
					if (e.clickCount >= 2 && Double != null)
					{
						Double();
					}
					else
					{
						Left?.Invoke();
					}
				}
			}
		}

		internal sealed class Hover : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
		{
			public Action Enter;

			public Action Exit;

			private bool _inside;

			public void OnPointerEnter(PointerEventData e)
			{
				_inside = true;
				Enter?.Invoke();
			}

			public void OnPointerExit(PointerEventData e)
			{
				_inside = false;
				Exit?.Invoke();
			}

			private void OnDisable()
			{
				if (_inside)
				{
					_inside = false;
					Exit?.Invoke();
				}
			}
		}

		private sealed class FocusLine : MonoBehaviour
		{
			private TMP_InputField _f;

			private Image _line;

			private Image _fill;

			private bool _was;

			internal void Init(TMP_InputField f, Image fill)
			{
				_f = f;
				_fill = fill;
				Transform obj = ((Component)fill).transform.Find("Line");
				_line = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null);
				Paint(on: false);
			}

			private void Update()
			{
				bool flag = (Object)(object)_f != (Object)null && _f.isFocused;
				if (flag != _was)
				{
					Paint(flag);
				}
			}

			private void Paint(bool on)
			{
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: 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)
				_was = on;
				if ((Object)(object)_line != (Object)null)
				{
					((Graphic)_line).color = (on ? C("accent") : LineSoft);
				}
				else
				{
					((Graphic)_fill).color = (on ? C("raised2") : C("raised"));
				}
			}
		}

		internal sealed class OnOff
		{
			private readonly Image _track;

			private readonly Image _knob;

			private readonly Image _line;

			private readonly Action<bool> _changed;

			private bool _on;

			private bool _enabled = true;

			internal bool Value => _on;

			internal RectTransform Root => ((Graphic)_track).rectTransform;

			internal OnOff(Transform parent, float x, float y, bool on, Action<bool> changed)
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0096: 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)
				_changed = changed;
				_track = Box(parent, "OnOff", C("raised2"), C("line2"), 11);
				Place(((Graphic)_track).rectTransform, x, y, 38f, 22f);
				Transform obj = ((Component)_track).transform.Find("Line");
				_line = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null);
				_knob = Box(((Component)_track).transform, "Knob", C("dim"), NoColor, 8);
				((Graphic)_knob).raycastTarget = false;
				On((Graphic)(object)_track, Toggle);
				Set(on);
			}

			internal void Toggle()
			{
				if (_enabled)
				{
					Set(!_on);
					_changed?.Invoke(_on);
				}
			}

			internal void Set(bool on)
			{
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0093: Unknown result type (might be due to invalid IL or missing references)
				//IL_008c: 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)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				_on = on;
				float a = (_enabled ? 1f : 0.4f);
				((Graphic)_track).color = Alpha(on ? C("accent") : C("raised2"), a);
				if ((Object)(object)_line != (Object)null)
				{
					((Graphic)_line).color = Alpha(on ? C("accent") : C("line2"), a);
				}
				((Graphic)_knob).color = Alpha(on ? Ink : C("dim"), a);
				Place(((Graphic)_knob).rectTransform, on ? 19f : 3f, 3f, 16f, 16f);
			}

			internal void SetEnabled(bool e)
			{
				_enabled = e;
				Set(_on);
			}

			private static Color Alpha(Color c, float a)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				return new Color(c.r, c.g, c.b, c.a * a);
			}
		}

		internal sealed class Window
		{
			private static readonly List<Window> _open = new List<Window>();

			internal const float Side = 24f;

			internal const float Top = 68f;

			internal const float Bottom = 72f;

			internal readonly RectTransform Root;

			internal readonly RectTransform Panel;

			internal readonly RectTransform Body;

			internal readonly RectTransform Foot;

			private readonly TextMeshProUGUI _title;

			private readonly Action _close;

			internal static bool AnyOpen
			{
				get
				{
					_open.RemoveAll((Window w) => (Object)(object)w.Root == (Object)null || !((Component)w.Root).gameObject.activeSelf);
					return _open.Count > 0;
				}
			}

			internal float W { get; private set; }

			internal float H { get; private set; }

			internal float BodyW => W - 48f;

			internal float BodyH => H - 68f - 72f;

			internal bool Shown
			{
				get
				{
					if ((Object)(object)Root != (Object)null)
					{
						return ((Component)Root).gameObject.activeSelf;
					}
					return false;
				}
			}

			internal Window(Transform parent, string name, float w, float h, Action close)
			{
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: Unknown result type (might be due to invalid IL or missing references)
				_close = close;
				Root = Fill(Node(parent, name));
				Image obj = Img((Transform)(object)Root, null, new Color(0.02f, 0.02f, 0.024f, 0.62f), "Scrim");
				Fill(((Graphic)obj).rectTransform);
				((Graphic)obj).raycastTarget = true;
				Panel = ((Graphic)Glass((Transform)(object)Root, "Panel")).rectTransform;
				_title = Text((Transform)(object)Panel, "", "title", 28f, White, 24f, 16f, w - 48f, 46f, (TextAlignmentOptions)4097);
				Body = Node((Transform)(object)Panel, "Body");
				Foot = Node((Transform)(object)Panel, "Foot");
				SetSize(w, h);
				((Component)Root).gameObject.SetActive(false);
			}

			internal void SetSize(float w, float h)
			{
				W = w;
				H = h;
				At(Panel, 0.5f, 0.5f, 0f, 0f, w, h);
				Place(((TMP_Text)_title).rectTransform, 24f, 16f, w - 48f, 46f);
				Place(Body, 24f, 68f, BodyW, BodyH);
				Place(Foot, 24f, h - 20f - 40f, BodyW, 40f);
			}

			internal void SetTitle(string s)
			{
				Set((TMP_Text)(object)_title, s);
			}

			internal void Show(bool on)
			{
				if ((Object)(object)Root == (Object)null)
				{
					return;
				}
				if (!on && ((Component)Root).gameObject.activeSelf)
				{
					EnterUsed = Time.frameCount;
				}
				((Component)Root).gameObject.SetActive(on);
				if (on)
				{
					((Transform)Root).SetAsLastSibling();
					if (!_open.Contains(this))
					{
						_open.Add(this);
					}
				}
				else
				{
					_open.Remove(this);
				}
			}

			internal void Buttons(string cancel, string action = null, Action act = null, bool danger = false, string extra = null, Action onExtra = null)
			{
				Clear((Transform)(object)Foot);
				float num = BodyW;
				if (action != null)
				{
					float num2 = Mathf.Max(110f, BtnW(action, 14f, 22f));
					num -= num2;
					Primary((Transform)(object)Foot, action, num, 0f, num2, 40f, act, enabled: true, danger);
					num -= 8f;
				}
				float num3 = Mathf.Max(96f, BtnW(cancel, 13f, 22f));
				num -= num3;
				Secondary((Transform)(object)Foot, cancel, num, 0f, num3, 40f, delegate
				{
					_close?.Invoke();
				});
				if (extra != null)
				{
					Secondary((Transform)(object)Foot, extra, 0f, 0f, Mathf.Max(96f, BtnW(extra, 13f, 22f)), 40f, onExtra);
				}
			}
		}

		internal const float RefW = 1920f;

		internal const float RefH = 1080f;

		internal static readonly Color NoColor = new Color(0f, 0f, 0f, 0f);

		internal static readonly Color White = Color.white;

		internal static readonly Color Ink = new Color(0.024f, 0.082f, 0.051f);

		internal static readonly Color SegInk = new Color(0.067f, 0.067f, 0.067f);

		internal static readonly Color LineSoft = new Color(1f, 1f, 1f, 0.09f);

		internal static readonly Color Shade = new Color(0f, 0f, 0f, 0.75f);

		internal static TMP_FontAsset Fallback;

		internal static int EnterUsed = -10;

		private static readonly Dictionary<string, Sprite> _gradients = new Dictionary<string, Sprite>();

		private static readonly (char ch, string alt)[] Alts = new(char, string)[3]
		{
			('·', "-"),
			('…', "..."),
			('×', "x")
		};

		private static RectTransform _tipBox;

		private static TextMeshProUGUI _tipText;

		internal static bool EnterFresh => Time.frameCount - EnterUsed < 3;

		internal static Color C(string token)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return JatifyLook.C(token);
		}

		internal static RectTransform Node(Transform parent, string name)
		{
			return JatifyLook.Node(parent, name);
		}

		internal static RectTransform Place(RectTransform r, float x, float y, float w, float h)
		{
			return JatifyLook.Place(r, x, y, w, h);
		}

		internal static RectTransform Fill(RectTransform r, float inset = 0f)
		{
			return JatifyLook.Fill(r, inset);
		}

		internal static void Clear(Transform t)
		{
			JatifyLook.Clear(t);
		}

		internal static RectTransform At(RectTransform r, float ax, float ay, float x, float y, float w, float h)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(ax, ay);
			r.pivot = val;
			Vector2 anchorMin = (r.anchorMax = val);
			r.anchorMin = anchorMin;
			r.anchoredPosition = new Vector2(x, y);
			r.sizeDelta = new Vector2(w, h);
			return r;
		}

		internal static RectTransform MakeCanvas(string name, int order, bool clicks = true)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = (clicks ? new GameObject(name, new Type[3]
			{
				typeof(Canvas),
				typeof(CanvasScaler),
				typeof(GraphicRaycaster)
			}) : new GameObject(name, new Type[2]
			{
				typeof(Canvas),
				typeof(CanvasScaler)
			}));
			Canvas component = val.GetComponent<Canvas>();
			component.renderMode = (RenderMode)0;
			component.sortingOrder = order;
			CanvasScaler component2 = val.GetComponent<CanvasScaler>();
			component2.uiScaleMode = (ScaleMode)1;
			component2.referenceResolution = new Vector2(1920f, 1080f);
			component2.matchWidthOrHeight = 1f;
			return Fill(Node(val.transform, name + "Root"));
		}

		internal static Image Img(Transform parent, Sprite s, Color c, string name = "Image")
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return JatifyLook.Img(parent, s, c, name);
		}

		internal static Image Box(Transform parent, string name, Color fill, Color line, int radius)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return JatifyLook.Box(parent, name, fill, line, radius);
		}

		internal static Image Glass(Transform parent, string name)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			return Box(parent, name, C("glass"), C("glassLine"), 12);
		}

		internal static void Rule(Transform parent, float x, float y, float w)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			Place(((Graphic)Img(parent, null, LineSoft, "Rule")).rectTransform, x, y, w, 1f);
		}

		internal static Sprite Gradient(string name, bool vertical, params (float at, Color c)[] stops)
		{
			//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_0048: 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_0057: Expected O, but got Unknown
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			if (_gradients.TryGetValue(name, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Texture2D val = new Texture2D(vertical ? 1 : 128, (!vertical) ? 1 : 128, (TextureFormat)4, false)
			{
				name = "campfire-" + name,
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)1
			};
			for (int i = 0; i < 128; i++)
			{
				float num = (float)i / 127f;
				if (vertical)
				{
					num = 1f - num;
				}
				Color val2 = stops[0].c;
				for (int j = 1; j < stops.Length; j++)
				{
					if (num <= stops[j].at)
					{
						val2 = Color.Lerp(stops[j - 1].c, stops[j].c, Mathf.InverseLerp(stops[j - 1].at, stops[j].at, num));
						break;
					}
					val2 = stops[j].c;
				}
				if (vertical)
				{
					val.SetPixel(0, i, val2);
				}
				else
				{
					val.SetPixel(i, 0, val2);
				}
			}
			val.Apply();
			return _gradients[name] = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
		}

		internal static void Vignette(Transform parent)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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)
			//IL_0090: 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_00d9: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			Color item = default(Color);
			((Color)(ref item))..ctor(0.02f, 0.02f, 0.024f, 0.7f);
			Color item2 = default(Color);
			((Color)(ref item2))..ctor(0.02f, 0.02f, 0.024f, 0.25f);
			Fill(((Graphic)Img(parent, Gradient("vig-h", false, (0f, item), (0.28f, item2), (0.72f, item2), (1f, item)), White, "Vignette")).rectTransform);
			Fill(((Graphic)Img(parent, Gradient("vig-v", true, (0f, NoColor), (0.65f, NoColor), (1f, item)), White, "VignetteLow")).rectTransform);
		}

		internal static TextMeshProUGUI Text(Transform parent, string s, string font, float size, Color c, float x, float y, float w, float h, TextAlignmentOptions align = (TextAlignmentOptions)4097)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI val = JatifyLook.Text(parent, "", font, size, c, align);
			Place(((TMP_Text)val).rectTransform, x, y, w, h);
			if ((Object)(object)((TMP_Text)val).font == (Object)null && (Object)(object)Fallback != (Object)null)
			{
				((TMP_Text)val).font = Fallback;
			}
			if (font == "lore")
			{
				((TMP_Text)val).fontStyle = (FontStyles)2;
			}
			if (font == "title")
			{
				((TMP_Text)val).characterSpacing = 3f;
			}
			Set((TMP_Text)(object)val, s);
			return val;
		}

		internal static TextMeshProUGUI Para(Transform parent, string s, string font, float size, Color c, float x, float y, float w, float h)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI obj = Text(parent, s, font, size, c, x, y, w, h, (TextAlignmentOptions)257);
			((TMP_Text)obj).textWrappingMode = (TextWrappingModes)1;
			((TMP_Text)obj).overflowMode = (TextOverflowModes)0;
			return obj;
		}

		internal static void Set(TMP_Text t, string s)
		{
			if (!string.IsNullOrEmpty(s) && (Object)(object)t.font != (Object)null)
			{
				(char, string)[] alts = Alts;
				for (int i = 0; i < alts.Length; i++)
				{
					var (c, newValue) = alts[i];
					if (s.IndexOf(c) >= 0 && !t.font.HasCharacter(c, true, true))
					{
						s = s.Replace(c.ToString(), newValue);
					}
				}
			}
			t.text = s ?? "";
		}

		internal static TextMeshProUGUI Shadowed(Transform parent, string s, string font, float size, Color c, float x, float y, float w, float h, TextAlignmentOptions align)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			((Object)Text(parent, s, font, size, Shade, x + 1f, y + 2f, w, h, align)).name = "Shadow";
			return Text(parent, s, font, size, c, x, y, w, h, align);
		}

		internal static void SetShadowed(TMP_Text t, string s)
		{
			Set(t, s);
			int siblingIndex = t.transform.GetSiblingIndex();
			if (siblingIndex > 0 && ((Object)t.transform.parent.GetChild(siblingIndex - 1)).name == "Shadow")
			{
				Set(((Component)t.transform.parent.GetChild(siblingIndex - 1)).GetComponent<TMP_Text>(), s);
			}
		}

		internal static float Width(TMP_Text t)
		{
			return JatifyLook.Width(t);
		}

		internal static float Measure(string s, string font, float size)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI obj = JatifyLook.Text(null, "", font, size, White, (TextAlignmentOptions)4097);
			Set((TMP_Text)(object)obj, s);
			float result = Width((TMP_Text)(object)obj);
			Object.Destroy((Object)(object)((Component)obj).gameObject);
			return result;
		}

		internal static TextMeshProUGUI Label(Transform parent, string text, float x, float y, float w)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI obj = Text(parent, text.ToUpperInvariant(), "mono", 11f, C("mute"), x, y, w, 18f, (TextAlignmentOptions)4097);
			((TMP_Text)obj).characterSpacing = 8f;
			return obj;
		}

		internal static Clicks On(Graphic g, Action left, Action dbl = null, Action right = null)
		{
			g.raycastTarget = true;
			Clicks clicks = ((Component)g).gameObject.AddComponent<Clicks>();
			clicks.Left = left;
			clicks.Double = dbl;
			clicks.Right = right;
			return clicks;
		}

		internal static Hover OnHover(Graphic g, Action enter, Action exit)
		{
			g.raycastTarget = true;
			Hover hover = ((Component)g).gameObject.AddComponent<Hover>();
			hover.Enter = enter;
			hover.Exit = exit;
			return hover;
		}

		internal static void Tip(Graphic g, string text)
		{
			if (string.IsNullOrEmpty(text))
			{
				return;
			}
			OnHover(g, delegate
			{
				ShowTip(g, text);
			}, delegate
			{
				if ((Object)(object)_tipBox != (Object)null)
				{
					((Component)_tipBox).gameObject.SetActive(false);
				}
			});
		}

		private static void ShowTip(Graphic g, string text)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_00a3: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: 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_0167: 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_0178: 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_0181: 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_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: 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_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			Canvas val = (((Object)(object)g.canvas != (Object)null) ? g.canvas.rootCanvas : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			RectTransform val2 = (RectTransform)((Component)val).transform;
			if ((Object)(object)_tipBox == (Object)null || (Object)(object)((Transform)_tipBox).parent != (Object)(object)val2)
			{
				if ((Object)(object)_tipBox != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)_tipBox).gameObject);
				}
				Image obj = Glass((Transform)(object)val2, "CampfireTip");
				((Graphic)obj).raycastTarget = false;
				_tipBox = ((Graphic)obj).rectTransform;
				_tipText = Para((Transform)(object)_tipBox, "", "medium", 13f, C("dim"), 12f, 8f, 336f, 20f);
			}
			Set((TMP_Text)(object)_tipText, text);
			Vector2 preferredValues = ((TMP_Text)_tipText).GetPreferredValues(((TMP_Text)_tipText).text, 336f, 0f);
			float num = Mathf.Min(336f, preferredValues.x) + 24f;
			float num2 = preferredValues.y + 16f;
			((TMP_Text)_tipText).rectTransform.sizeDelta = new Vector2(num - 24f, num2 - 16f);
			Vector2 val3 = default(Vector2);
			RectTransformUtility.ScreenPointToLocalPointInRectangle(val2, Vector2.op_Implicit(Input.mousePosition), (Camera)null, ref val3);
			Rect rect = val2.rect;
			Vector2 val4 = ((Rect)(ref rect)).size / 2f;
			Vector2 val5 = val3 + new Vector2(14f, 14f);
			val5.x = Mathf.Min(val5.x, val4.x - num - 8f);
			val5.y = Mathf.Min(val5.y, val4.y - num2 - 8f);
			RectTransform tipBox = _tipBox;
			RectTransform tipBox2 = _tipBox;
			Vector2 val6 = default(Vector2);
			((Vector2)(ref val6))..ctor(0.5f, 0.5f);
			tipBox2.anchorMax = val6;
			tipBox.anchorMin = val6;
			_tipBox.pivot = Vector2.zero;
			_tipBox.anchoredPosition = val5;
			_tipBox.sizeDelta = new Vector2(num, num2);
			((Component)_tipBox).gameObject.SetActive(true);
			((Transform)_tipBox).SetAsLastSibling();
		}

		internal static void HoverLine(Image box, Color hot)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			Transform obj = ((Component)box).transform.Find("Line");
			Image line = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null);
			if ((Object)(object)line != (Object)null)
			{
				Color idle = ((Graphic)line).color;
				OnHover((Graphic)(object)box, delegate
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					((Graphic)line).color = hot;
				}, delegate
				{
					//IL_000c: Unknown result type (might be due to invalid IL or missing references)
					((Graphic)line).color = idle;
				});
			}
			else
			{
				Color idle2 = ((Graphic)box).color;
				OnHover((Graphic)(object)box, delegate
				{
					//IL_000c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0016: Unknown result type (might be due to invalid IL or missing references)
					((Graphic)box).color = idle2 * 1.25f;
				}, delegate
				{
					//IL_000c: Unknown result type (might be due to invalid IL or missing references)
					((Graphic)box).color = idle2;
				});
			}
		}

		internal static TMP_InputField Field(Transform parent, string placeholder, float x, float y, float w, float h, string icon, Action<string> changed = null, Action submit = null, bool password = false, int limit = 0, float size = 14f)
		{
			//IL_0021: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: 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)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			Image val = Box(parent, "Field", C("raised"), LineSoft, 9);
			Place(((Graphic)val).rectTransform, x, y, w, h);
			Sprite val2 = ((icon != null) ? JatifyLook.Icon(icon) : null);
			float num = 12f;
			if ((Object)(object)val2 != (Object)null)
			{
				Place(((Graphic)Img(((Component)val).transform, val2, C("mute"), "Icon")).rectTransform, 10f, (h - 18f) / 2f, 18f, 18f);
				num = 36f;
			}
			RectTransform val3 = Node(((Component)val).transform, "Area");
			Fill(val3);
			val3.offsetMin = new Vector2(num, 2f);
			val3.offsetMax = new Vector2(-10f, -2f);
			((Component)val3).gameObject.AddComponent<RectMask2D>();
			TextMeshProUGUI val4 = JatifyLook.Text((Transform)(object)val3, "", "medium", size, White, (TextAlignmentOptions)4097);
			Fill(((TMP_Text)val4).rectTransform);
			if ((Object)(object)((TMP_Text)val4).font == (Object)null)
			{
				((TMP_Text)val4).font = Fallback;
			}
			TextMeshProUGUI val5 = JatifyLook.Text((Transform)(object)val3, placeholder, "medium", size, C("mute"), (TextAlignmentOptions)4097);
			Fill(((TMP_Text)val5).rectTransform);
			if ((Object)(object)((TMP_Text)val5).font == (Object)null)
			{
				((TMP_Text)val5).font = Fallback;
			}
			TMP_InputField val6 = ((Component)val).gameObject.AddComponent<TMP_InputField>();
			val6.textViewport = val3;
			val6.textComponent = (TMP_Text)(object)val4;
			val6.placeholder = (Graphic)(object)val5;
			val6.fontAsset = ((TMP_Text)val4).font;
			val6.pointSize = size;
			val6.lineType = (LineType)0;
			if (password)
			{
				val6.contentType = (ContentType)7;
				val6.inputType = (InputType)2;
			}
			if (limit > 0)
			{
				val6.characterLimit = limit;
			}
			val6.customCaretColor = true;
			val6.caretColor = White;
			val6.caretWidth = 2;
			((Behaviour)val6).enabled = false;
			((Behaviour)val6).enabled = true;
			if (changed != null)
			{
				((UnityEvent<string>)(object)val6.onValueChanged).AddListener((UnityAction<string>)delegate(string s)
				{
					changed(s ?? "");
				});
			}
			((UnityEvent<string>)(object)val6.onSubmit).AddListener((UnityAction<string>)delegate
			{
				EnterUsed = Time.frameCount;
				submit?.Invoke();
			});
			((Component)val).gameObject.AddComponent<FocusLine>().Init(val6, val);
			return val6;
		}

		internal static TMP_InputField LabelledField(Transform parent, string label, string placeholder, float y, float w, string icon = null, Action submit = null, bool password = false, int limit = 0)
		{
			Label(parent, label, 0f, y, w);
			return Field(parent, placeholder, 0f, y + 22f, w, 40f, icon, null, submit, password, limit, 15f);
		}

		internal static void Focus(TMP_InputField f)
		{
			if (!((Object)(object)f == (Object)null))
			{
				((Selectable)f).Select();
				f.ActivateInputField();
			}
		}

		internal static float Seg(Transform parent, float x, float y, float w, string[] labels, int on, Action<int> pick, float size = 13.5f)
		{
			//IL_0019: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			Image val = Box(parent, "Seg", C("raised"), LineSoft, 8);
			((Graphic)val).raycastTarget = false;
			float num = 2f;
			float num2 = ((w > 0f) ? ((w - 4f - 2f * (float)(labels.Length - 1)) / (float)labels.Length) : 0f);
			for (int i = 0; i < labels.Length; i++)
			{
				int k = i;
				bool flag = i == on;
				float num3 = ((num2 > 0f) ? num2 : Mathf.Max(32f, Measure(labels[i], "medium", size) + 20f));
				Image val2 = Box(((Component)val).transform, "B", flag ? White : NoColor, NoColor, 6);
				Place(((Graphic)val2).rectTransform, num, 2f, num3, 26f);
				Fill(((TMP_Text)Text(((Component)val2).transform, labels[i], "medium", size, flag ? SegInk : C("dim"), 0f, 0f, num3, 26f, (TextAlignmentOptions)514)).rectTransform);
				if (!flag)
				{
					On((Graphic)(object)val2, delegate
					{
						pick(k);
					});
				}
				num += num3 + 2f;
			}
			Place(((Graphic)val).rectTransform, x, y, num, 30f);
			return num;
		}

		internal static OnOff SwitchRow(Transform parent, string label, float x, float y, bool on, Action<bool> changed, float w = 160f)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			OnOff onOff = new OnOff(parent, x, y, on, changed);
			On((Graphic)(object)Text(parent, label, "medium", 13f, C("dim"), x + 47f, y - 3f, w - 47f, 28f, (TextAlignmentOptions)4097), onOff.Toggle);
			return onOff;
		}

		internal static Slider SliderBar(Transform parent, float x, float y, float w, float value, Action<float> changed)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			RectTransform obj = Place(Node(parent, "Slider"), x, y, w, 20f);
			((Graphic)((Component)obj).gameObject.AddComponent<Image>()).color = NoColor;
			Image obj2 = Box((Transform)(object)obj, "Track", C("raised2"), NoColor, 3);
			((Graphic)obj2).raycastTarget = false;
			At(((Graphic)obj2).rectTransform, 0f, 0.5f, 0f, 0f, 0f, 6f);
			((Graphic)obj2).rectTransform.anchorMax = new Vector2(1f, 0.5f);
			RectTransform obj3 = Node((Transform)(object)obj, "FillArea");
			At(obj3, 0f, 0.5f, 0f, 0f, 0f, 6f);
			obj3.anchorMax = new Vector2(1f, 0.5f);
			Image val = Box((Transform)(object)obj3, "Fill", C("accent"), NoColor, 3);
			((Graphic)val).raycastTarget = false;
			((Graphic)val).rectTransform.sizeDelta = Vector2.zero;
			RectTransform obj4 = Fill(Node((Transform)(object)obj, "HandleArea"));
			obj4.offsetMin = new Vector2(8f, 0f);
			obj4.offsetMax = new Vector2(-8f, 0f);
			Image val2 = Box((Transform)(object)obj4, "Knob", White, NoColor, 8);
			((Graphic)val2).rectTransform.sizeDelta = new Vector2(16f, -4f);
			Slider obj5 = ((Component)obj).gameObject.AddComponent<Slider>();
			obj5.fillRect = ((Graphic)val).rectTransform;
			obj5.handleRect = ((Graphic)val2).rectTransform;
			((Selectable)obj5).targetGraphic = (Graphic)(object)val2;
			obj5.direction = (Direction)0;
			obj5.minValue = 0f;
			obj5.maxValue = 1f;
			obj5.value = value;
			((UnityEvent<float>)(object)obj5.onValueChanged).AddListener((UnityAction<float>)delegate(float v)
			{
				changed(v);
			});
			return obj5;
		}

		internal static Image Primary(Transform parent, string label, float x, float y, float w, float h, Action a, bool enabled = true, bool danger = false, float size = 14f)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			Color fill = ((!enabled) ? C("raised2") : (danger ? C("health") : C("accent")));
			Image b = Box(parent, "Primary", fill, NoColor, 10);
			Place(((Graphic)b).rectTransform, x, y, w, h);
			Fill(((TMP_Text)Text(((Component)b).transform, label, "bold", size, (!enabled) ? C("mute") : (danger ? White : Ink), 0f, 0f, w, h, (TextAlignmentOptions)514)).rectTransform);
			if (enabled)
			{
				On((Graphic)(object)b, a);
				OnHover((Graphic)(object)b, delegate
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					//IL_0011: Unknown result type (might be due to invalid IL or missing references)
					((Graphic)b).color = fill * 1.12f;
				}, delegate
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					((Graphic)b).color = fill;
				});
			}
			return b;
		}

		internal static Image Secondary(Transform parent, string label, float x, float y, float w, float h, Action a, bool enabled = true, float size = 13f, Sprite icon = null, float iconTurn = 0f)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_019c: 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_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			Image val = Box(parent, "Secondary", C("raised"), C("line2"), 8);
			Place(((Graphic)val).rectTransform, x, y, w, h);
			Color c = (enabled ? White : C("mute"));
			if ((Object)(object)icon != (Object)null && string.IsNullOrEmpty(label))
			{
				Image obj = Img(((Component)val).transform, icon, c, "Icon");
				At(((Graphic)obj).rectTransform, 0.5f, 0.5f, 0f, 0f, 14f, 14f);
				((Transform)((Graphic)obj).rectTransform).localEulerAngles = new Vector3(0f, 0f, iconTurn);
			}
			else if ((Object)(object)icon != (Object)null)
			{
				float num = Measure(label, "medium", size);
				float num2 = 16f + num;
				float num3 = (w - num2) / 2f;
				Image obj2 = Img(((Component)val).transform, icon, c, "Icon");
				At(((Graphic)obj2).rectTransform, 0f, 0.5f, num3 + 5f, 0f, 10f, 10f);
				((Graphic)obj2).rectTransform.pivot = new Vector2(0.5f, 0.5f);
				((Transform)((Graphic)obj2).rectTransform).localEulerAngles = new Vector3(0f, 0f, iconTurn);
				Text(((Component)val).transform, label, "medium", size, c, num3 + 16f, 0f, num + 4f, h, (TextAlignmentOptions)4097);
			}
			else
			{
				Fill(((TMP_Text)Text(((Component)val).transform, label, "medium", size, c, 0f, 0f, w, h, (TextAlignmentOptions)514)).rectTransform);
			}
			if (enabled)
			{
				On((Graphic)(object)val, a);
				HoverLine(val, C("accent"));
			}
			return val;
		}

		internal static float BtnW(string label, float size, float pad)
		{
			return Mathf.Ceil(Measure(label, "medium", size)) + 2f * pad;
		}

		internal static void Acts(Transform parent, float y, float w, bool flexFirst, params (string label, Action a, bool enabled)[] items)
		{
			float[] array = new float[items.Length];
			float num = 0f;
			for (int i = 0; i < items.Length; i++)
			{
				array[i] = BtnW(items[i].label, 12.5f, 10f);
				if (i > 0 || !flexFirst)
				{
					num += array[i];
				}
			}
			if (flexFirst)
			{
				array[0] = Mathf.Max(array[0], w - num - 6f * (float)(items.Length - 1));
			}
			float num2 = 0f;
			Sprite[] array2 = (Sprite[])(object)new Sprite[items.Length];
			for (int j = 1; j < items.Length; j++)
			{
				if ((Object)(object)(array2[j] = JatifyLook.Icon(IconFor(items[j].label))) != (Object)null)
				{
					array[j] = 34f;
				}
			}
			if (flexFirst)
			{
				num = 0f;
				for (int k = 1; k < items.Length; k++)
				{
					num += array[k];
				}
				array[0] = Mathf.Max(BtnW(items[0].label, 12.5f, 10f), w - num - 6f * (float)(items.Length - 1));
			}
			for (int l = 0; l < items.Length; l++)
			{
				if (l == 0)
				{
					Secondary(parent, items[l].label, num2, y, array[l], 34f, items[l].a, items[l].enabled, 12.5f);
				}
				else
				{
					Quiet(parent, items[l].label, num2, y, array[l], 34f, items[l].a, items[l].enabled, 12.5f, array2[l]);
				}
				num2 += array[l] + 6f;
			}
		}

		private static string IconFor(string label)
		{
			switch (label)
			{
			default:
				return null;
			case "Delete":
			case "Remove":
				return "trash_icon";
			case "Saves":
				return "save";
			}
		}

		internal static Image Quiet(Transform parent, string label, float x, float y, float w, float h, Action a, bool enabled = true, float size = 12.5f, Sprite icon = null)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			Image b = Box(parent, "Quiet", NoColor, NoColor, 8);
			Place(((Graphic)b).rectTransform, x, y, w, h);
			Graphic t;
			if ((Object)(object)icon != (Object)null)
			{
				Image val = Img(((Component)b).transform, icon, enabled ? C("dim") : C("mute"), "Icon");
				val.preserveAspect = true;
				t = (Graphic)(object)val;
				float num = (((Object)icon).name.StartsWith("trash") ? 24f : 18f);
				At(t.rectTransform, 0.5f, 0.5f, 0f, 0f, num, num);
				Tip((Graphic)(object)b, label);
			}
			else
			{
				t = (Graphic)(object)Text(((Component)b).transform, label, "medium", size, enabled ? C("dim") : C("mute"), 0f, 0f, w, h, (TextAlignmentOptions)514);
				Fill(t.rectTransform);
			}
			if (enabled)
			{
				On((Graphic)(object)b, a);
				OnHover((Graphic)(object)b, delegate
				{
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					//IL_001b: Unknown result type (might be due to invalid IL or missing references)
					((Graphic)b).color = C("raised");
					t.color = White;
				}, delegate
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_001b: Unknown result type (might be due to invalid IL or missing references)
					((Graphic)b).color = NoColor;
					t.color = C("dim");
				});
			}
			return b;
		}
	}
	internal static class CharScreen
	{
		private const float Pad = 12f;

		private const float LW = 320f;

		private const float LH = 974f;

		private const float LI = 296f;

		private const float RW = 320f;

		private const float RH = 974f;

		private const float RI = 296f;

		private const float ListTop = 100f;

		private const float RowH = 44f;

		private const float WorldOpts = 152f;

		private const float ServerOpts = 122f;

		private static RectTransform _left;

		private static RectTransform _right;

		private static RectTransform _rightActs;

		private static RectTransform _root;

		private static RectTransform _plates;

		private static RectTransform _tabs;

		private static RectTransform _worldsOpts;

		private static RectTransform _serversOpts;

		private static RectTransform _rot;

		private static RectTransform _enterBox;

		private static RectTransform _toastBox;

		private static RectTransform _chars;

		private static RectTransform _worlds;

		private static RectTransform _statsList;

		private static TMP_InputField _charSearch;

		private static TMP_InputField _worldSearch;

		private static TMP_InputField _password;

		private static CampfireUi.OnOff _host;

		private static CampfireUi.OnOff _cross;

		private static CampfireUi.OnOff _community;

		private static CampfireUi.OnOff _remember;

		private static TextMeshProUGUI _selName;

		private static TextMeshProUGUI _selWorld;

		private static TextMeshProUGUI _toast;

		private static CampfireUi.Window _dialog;

		private static CampfireUi.Window _statsDialog;

		private static Action _dialogAction;

		private static float _toastUntil;

		private static float _foreignAt;

		private static bool _builtOn;

		private static PlayerProfile _sel;

		private static World _world;

		private static ServerJoinData _server = ServerJoinData.None;

		private static bool _serversTab;

		private static bool _restored;

		private static List<ServerJoinData> _servers = new List<ServerJoinData>();

		private static readonly List<(PlayerProfile p, RectTransform rt)> _plateList = new List<(PlayerProfile, RectTransform)>();

		private static readonly List<(PlayerProfile p, float mid)> _cardMids = new List<(PlayerProfile, float)>();

		private static readonly List<GameObject> _hiddenForeign = new List<GameObject>();

		private static readonly HashSet<string> Foreign = new HashSet<string> { "StatsPanel", "PlayerStatsPanel", "StatsButton" };

		private static volatile string _pendingToast;

		internal static RectTransform Root => _root;

		internal static PlayerProfile Selected => _sel;

		internal static World SelectedWorld => _world;

		internal static bool Visible
		{
			get
			{
				if ((Object)(object)_root != (Object)null)
				{
					return ((Component)_root).gameObject.activeSelf;
				}
				return false;
			}
		}

		internal static RectTransform CharContent => _chars;

		internal unsafe static void Show()
		{
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_root != (Object)null && _builtOn != JatifyLook.On)
			{
				Object.Destroy((Object)(object)((Component)((Transform)_root).root).gameObject);
				_root = null;
			}
			if ((Object)(object)_root == (Object)null)
			{
				Build();
			}
			Passwords.Reset();
			Fejd.Reload();
			List<PlayerProfile> profiles = Fejd.Profiles;
			if (!_restored)
			{
				_serversTab = Plugin.LastTab.Value == "servers";
				_sel = ((IEnumerable<PlayerProfile>)profiles).FirstOrDefault((Func<PlayerProfile, bool>)((PlayerProfile p) => p.GetFilename() == Plugin.LastCharacter.Value));
			}
			if (_sel == null || !profiles.Contains(_sel))
			{
				_sel = profiles.ElementAtOrDefault(Mathf.Clamp(Fejd.ProfileIndex, 0, profiles.Count - 1));
			}
			List<World> worlds = Fejd.Worlds;
			_world = ((_world == null) ? null : ((IEnumerable<World>)worlds).FirstOrDefault((Func<World, bool>)((World w) => w.m_worldName == _world.m_worldName)));
			if (_world == null && !_restored)
			{
				_world = ((IEnumerable<World>)worlds).FirstOrDefault((Func<World, bool>)((World w) => w.m_worldName == Plugin.LastWorld.Value));
			}
			if (_world == null)
			{
				_world = ((IEnumerable<World>)worlds).FirstOrDefault((Func<World, bool>)((World w) => w.m_worldName == PlatformPrefs.GetString("world", ""))) ?? worlds.FirstOrDefault();
			}
			_servers = Fejd.FavoriteServers();
			if (!_restored)
			{
				_server = ((IEnumerable<ServerJoinData>)_servers).FirstOrDefault((Func<ServerJoinData, bool>)((ServerJoinData s) => ((object)(*(ServerJoinData*)(&s))/*cast due to .constrained prefix*/).ToString() == Plugin.LastServer.Value));
			}
			if (!_servers.Contains(_server))
			{
				_server = _servers.FirstOrDefault();
			}
			_restored = true;
			((Component)_root).gameObject.SetActive(true);
			_foreignAt = 0f;
			Fejd.HideVanillaPreview();
			Repaint();
		}

		internal static void Hide()
		{
			if ((Object)(object)_root != (Object)null)
			{
				((Component)_root).gameObject.SetActive(false);
			}
			if (_dialog != null)
			{
				_dialog.Show(on: false);
				_statsDialog.Show(on: false);
				AchView.Hide();
				SavesView.Hide();
				ModsView.Hide();
			}
			if (_sel != null && Fejd.Profiles.Contains(_sel))
			{
				Fejd.ProfileIndex = Fejd.Profiles.IndexOf(_sel);
			}
		}

		internal static void Unload()
		{
			Hide();
			Party.Unload();
			Fejd.ShowVanillaPreview(_sel);
			RestoreForeign();
			if ((Object)(object)_root != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)((Transform)_root).root).gameObject);
			}
			_root = null;
		}

		internal static void RestoreForeign()
		{
			foreach (GameObject item in _hiddenForeign)
			{
				if ((Object)(object)item != (Object)null)
				{
					item.SetActive(true);
				}
			}
			_hiddenForeign.Clear();
		}

		internal static void HideForeign()
		{
			if (Time.unscaledTime < _foreignAt)
			{
				return;
			}
			_foreignAt = Time.unscaledTime + 0.5f;
			RectTransform[] array = Object.FindObjectsOfType<RectTransform>();
			foreach (RectTransform val in array)
			{
				if (Foreign.Contains(((Object)val).name) && (!((Object)(object)_root != (Object)null) || !((Transform)val).IsChildOf(((Transform)_root).root)))
				{
					((Component)val).gameObject.SetActive(false);
					if (!_hiddenForeign.Contains(((Component)val).gameObject))
					{
						_hiddenForeign.Add(((Component)val).gameObject);
						Log.Info("hid " + ((Object)val).name + " (" + ((Object)((Transform)val).root).name + ")");
					}
				}
			}
		}

		private static void Build()
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			_builtOn = JatifyLook.On;
			_root = CampfireUi.MakeCanvas("CampfireCanvas", 5);
			((Object)_root).name = "Campfire";
			CampfireUi.Vignette((Transform)(object)_root);
			_plates = CampfireUi.Fill(CampfireUi.Node((Transform)(object)_root, "plates"));
			BuildTopStrip();
			BuildLeft();
			BuildRight();
			BuildBottom();
			_toastBox = ((Graphic)CampfireUi.Glass((Transform)(object)_root, "toast")).rectTransform;
			((Graphic)((Component)_toastBox).GetComponent<Image>()).raycastTarget = false;
			CampfireUi.At(_toastBox, 0.5f, 1f, 0f, -76f, 400f, 38f);
			_toast = CampfireUi.Text((Transform)(object)_toastBox, "", "medium", 14f, CampfireUi.White, 0f, 0f, 400f, 38f, (TextAlignmentOptions)514);
			CampfireUi.Fill(((TMP_Text)_toast).rectTransform);
			((Component)_toastBox).gameObject.SetActive(false);
			_dialog = new CampfireUi.Window((Transform)(object)_root, "dialog", 480f, 270f, delegate
			{
				_dialog.Show(on: false);
			});
			_statsDialog = new CampfireUi.Window((Transform)(object)_root, "stats", 540f, 760f, delegate
			{
				_statsDialog.Show(on: false);
			});
			_statsDialog.Buttons("Close");
			_statsList = JatifyLook.Scroll((Transform)(object)_statsDialog.Body, "list", 0f, 0f, _statsDialog.BodyW, _statsDialog.BodyH);
		}

		private static void BuildTopStrip()
		{
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			(string, Action)[] array = new(string, Action)[2]
			{
				("Achievements", AchView.Open),
				("Stats", OpenStats)
			};
			RectTransform rectTransform = ((Graphic)CampfireUi.Glass((Transform)(object)_root, "topbar")).rectTransform;
			float num = 4f;
			for (int i = 0; i < array.Length; i++)
			{
				if (i > 0)
				{
					CampfireUi.Place(((Graphic)CampfireUi.Img((Transform)(object)rectTransform, null, CampfireUi.C("line2"), "sep")).rectTransform, num, 12f, 1f, 18f);
					num += 5f;
				}
				(string label, Action a) e = array[i];
				float num2 = CampfireUi.BtnW(e.label, 14f, 18f);
				Image b = CampfireUi.Box((Transform)(object)rectTransform, e.label, CampfireUi.NoColor, CampfireUi.NoColor, 8);
				CampfireUi.Place(((Graphic)b).rectTransform, num, 4f, num2, 34f);
				TextMeshProUGUI t = CampfireUi.Text(((Component)b).transform, e.label, "medium", 14f, CampfireUi.C("dim"), 0f, 0f, num2, 34f, (TextAlignmentOptions)514);
				CampfireUi.On((Graphic)(object)b, delegate
				{
					e.a();
				});
				CampfireUi.OnHover((Graphic)(object)b, delegate
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_001b: Unknown result type (might be due to invalid IL or missing references)
					((Graphic)t).color = CampfireUi.White;
					((Graphic)b).color = CampfireUi.C("raised");
				}, delegate
				{
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					//IL_001b: Unknown result type (might be due to invalid IL or missing references)
					((Graphic)t).color = CampfireUi.C("dim");
					((Graphic)b).color = CampfireUi.NoColor;
				});
				num += num2 + 4f;
			}
			CampfireUi.At(rectTransform, 0.5f, 1f, 0f, -22f, num, 42f);
		}

		private static void OpenStats()
		{
			_statsDialog.Show(on: true);
			PaintStats();
		}

		private static void BuildLeft()
		{
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = (_left = ((Graphic)CampfireUi.Glass((Transform)(object)_root, "left")).rectTransform);
			CampfireUi.Place(val, 24f, 24f, 320f, 974f);
			_tabs = CampfireUi.Place(CampfireUi.Node((Transform)(object)val, "tabs"), 12f, 12f, 296f, 30f);
			_worldSearch = CampfireUi.Field((Transform)(object)val, "Search", 12f, 54f, 296f, 36f, "search", delegate
			{
				PaintLeftList();
			});
			_worlds = JatifyLook.Scroll((Transform)(object)val, "list", 12f, 100f, 296f, 700f);
			_worldsOpts = CampfireUi.Place(CampfireUi.Node((Transform)(object)val, "opts"), 12f, 810f, 296f, 152f);
			CampfireUi.Rule((Transform)(object)_worldsOpts, 0f, 0f, 296f);
			_host = CampfireUi.SwitchRow((Transform)(object)_worldsOpts, "Host server", 0f, 10f, Plugin.HostServer.Value, delegate(bool on)
			{
				Plugin.HostServer.Value = on;
				Repaint();
			});
			_cross = CampfireUi.SwitchRow((Transform)(object)_worldsOpts, "Crossplay", 152f, 10f, Plugin.Crossplay.Value, delegate(bool on)
			{
				Plugin.Crossplay.Value = on;
			});
			_community = CampfireUi.SwitchRow((Transform)(object)_worldsOpts, "Community", 0f, 40f, Plugin.Community.Value, delegate(bool on)
			{
				Plugin.Community.Value = on;
			});
			_password = CampfireUi.Field((Transform)(object)_worldsOpts, "Server password", 0f, 72f, 296f, 36f, "lock", null, null, password: true);
			CampfireUi.Acts((Transform)(object)_worldsOpts, 118f, 296f, true, ("+ New world", NewWorldDialog, true), ("Modifiers", delegate
			{
				ModsView.Open(_world);
			}, true), ("Saves", delegate
			{
				SavesView.Open(worlds: true);
			}, true), ("Delete", DeleteWorldDialog, true));
			_serversOpts = CampfireUi.Place(CampfireUi.Node((Transform)(object)val, "sopts"), 12f, 840f, 296f, 122f);
			CampfireUi.Rule((Transform)(object)_serversOpts, 0f, 0f, 296f);
			CampfireUi.Para((Transform)(object)_serversOpts, "Your favourite servers. Joining an online server puts your character at risk.", "medium", 12.5f, CampfireUi.C("mute"), 0f, 10f, 296f, 36f);
			_remember = CampfireUi.SwitchRow((Transform)(object)_serversOpts, "Remember passwords", 0f, 56f, Plugin.RememberPasswords.Value, delegate(bool on)
			{
				Plugin.RememberPasswords.Value = on;
			}, 220f);
			_remember.SetEnabled(Passwords.Available);
			CampfireUi.Acts((Transform)(object)_serversOpts, 88f, 296f, true, ("+ Add server", AddServerDialog, true), ("Refresh", delegate
			{
				_servers = Fejd.FavoriteServers();
				Repaint();
				Toast($"{_servers.Count} favourite servers");
			}, true), ("Remove", RemoveServerDialog, true));
			float w = CampfireUi.BtnW("Back", 13f, 16f) + 16f;
			CampfireUi.Secondary((Transform)(object)_root, "Back", 24f, 1016f, w, 40f, Fejd.Back, enabled: true, 13f, Glyphs.Triangle, 90f);
		}

		private static void BuildRight()
		{
			RectTransform obj = (_right = ((Graphic)CampfireUi.Glass((Transform)(object)_root, "right")).rectTransform);
			CampfireUi.At(obj, 1f, 1f, -24f, -24f, 320f, 974f);
			_charSearch = CampfireUi.Field((Transform)(object)obj, "Search characters", 12f, 12f, 296f, 36f, "search", delegate
			{
				PaintChars();
			});
			_chars = JatifyLook.Scroll((Transform)(object)obj, "list", 12f, 60f, 296f, 858f);
			CampfireUi.Acts((Transform)(object)(_rightActs = CampfireUi.Place(CampfireUi.Node((Transform)(object)obj, "actions"), 12f, 928f, 296f, 34f)), 0f, 296f, true, ("+ New character", Fejd.NewCharacter, true), ("Saves", delegate
			{
				SavesView.Open(worlds: false);
			}, true), ("Delete", DeleteCharacterDialog, true));
		}

		private static void BuildBottom()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			RectTransform parent = CampfireUi.At(CampfireUi.Node((Transform)(object)_root, "bottom"), 0.5f, 0f, 0f, 30f, 800f, 150f);
			_selWorld = CampfireUi.Shadowed((Transform)(object)parent, "", "lore", 15f, CampfireUi.C("dim"), 0f, 4f, 800f, 26f, (TextAlignmentOptions)514);
			_selName = CampfireUi.Shadowed((Transform)(object)parent, "", "title", 44f, CampfireUi.White, 0f, 28f, 800f, 68f, (TextAlignmentOptions)514);
			_enterBox = CampfireUi.Place(CampfireUi.Node((Transform)(object)parent, "enter"), 270f, 100f, 260f, 50f);
			_rot = CampfireUi.Node((Transform)(object)_root, "rotate");
			_rot.sizeDelta = new Vector2(78f, 36f);
			Sprite val = JatifyLook.Icon("undo");
			Image val2 = CampfireUi.Secondary((Transform)(object)_rot, null, 0f, 0f, 36f, 36f, delegate
			{
				Party.Turn(_sel, -30f);
			}, enabled: true, 13f, val ?? Glyphs.Triangle, ((Object)(object)val != (Object)null) ? 0f : 90f);
			Image val3 = CampfireUi.Secondary((Transform)(object)_rot, null, 42f, 0f, 36f, 36f, delegate
			{
				Party.Turn(_sel, 30f);
			}, enabled: true, 13f, val ?? Glyphs.Triangle, ((Object)(object)val != (Object)null) ? 0f : (-90f));
			CampfireUi.Tip((Graphic)(object)val2, "Turn");
			CampfireUi.Tip((Graphic)(object)val3, "Turn");
			if ((Object)(object)val != (Object)null)
			{
				((Component)val3).transform.Find("Icon").localScale = new Vector3(-1f, 1f, 1f);
			}
			if ((Object)(object)val != (Object)null)
			{
				RectTransform component = ((Component)((Component)val2).transform.Find("Icon")).GetComponent<RectTransform>();
				RectTransform component2 = ((Component)((Component)val3).transform.Find("Icon")).GetComponent<RectTransform>();
				Vector2 sizeDelta = default(Vector2);
				((Vector2)(ref sizeDelta))..ctor(18f, 18f);
				component2.sizeDelta = sizeDelta;
				component.sizeDelta = sizeDelta;
			}
		}

		internal static void Repaint()
		{
			if (Visible)
			{
				List<PlayerProfile> list = Party.Chosen(Fejd.Profiles, _sel);
				Party.Show(list);
				Party.Select(_sel);
				Fejd.HideVanillaPreview();
				PaintPlates(list);
				PaintChars();
				CampfireUi.Clear((Transform)(object)_tabs);
				CampfireUi.Seg((Transform)(object)_tabs, 0f, 0f, 296f, new string[2] { "Worlds", "Servers" }, _serversTab ? 1 : 0, delegate(int i)
				{
					_serversTab = i == 1;
					_worldSearch.text = "";
					Repaint();
				});
				((Component)_worldsOpts).gameObject.SetActive(!_serversTab);
				((Component)_serversOpts).gameObject.SetActive(_serversTab);
				_host.Set(Plugin.HostServer.Value);
				_cross.Set(Plugin.Crossplay.Value);
				_community.Set(Plugin.Community.Value);
				_remember.Set(Plugin.RememberPasswords.Value && Passwords.Available);
				PaintLeftList();
				CampfireUi.SetShadowed((TMP_Text)(object)_selName, (_sel != null) ? _sel.GetName() : "");
				CampfireUi.SetShadowed((TMP_Text)(object)_selWorld, (!_serversTab) ? ((_world != null) ? (_world.m_name + (Plugin.HostServer.Value ? " · hosted for friends" : " · just you")) : "") : (((ServerJoinData)(ref _server)).IsValid ? ((object)Unsafe.As<ServerJoinData, ServerJoinData>(ref _server)/*cast due to .constrained prefix*/).ToString() : ""));
				CampfireUi.Clear((Transform)(object)_enterBox);
				CampfireUi.Primary((Transform)(object)_enterBox, _serversTab ? "Join server" : "Enter world", 0f, 0f, 260f, 50f, Enter, _sel != null && (_serversTab ? ((ServerJoinData)(ref _server)).IsValid : (_world != null)), danger: false, 16f);
				PaintStats();
			}
		}

		internal static Image Row(Transform parent, string name, float y, float w, float h, bool on, Action click)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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)
			Image row = CampfireUi.Box(parent, name, on ? CampfireUi.C("accentSoft") : CampfireUi.NoColor, CampfireUi.NoColor, 8);
			CampfireUi.Place(((Graphic)row).rectTransform, 0f, y, w, h);
			CampfireUi.On((Graphic)(object)row, click);
			if (!on)
			{
				CampfireUi.OnHover((Graphic)(object)row, delegate
				{
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					((Graphic)row).color = CampfireUi.C("raised");
				}, delegate
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					((Graphic)row).color = CampfireUi.NoColor;
				});
			}
			return row;
		}

		private static float RowText(Transform row, string name, string sub, float w, bool on)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			CampfireUi.Text(row, name, "bold", 14.5f, on ? CampfireUi.C("accent") : CampfireUi.White, 10f, 4f, w - 20f, 20f, (TextAlignmentOptions)4097);
			TextMeshProUGUI val = CampfireUi.Text(row, sub, "medium", 12f, CampfireUi.C("mute"), 10f, 23f, w - 20f, 18f, (TextAlignmentOptions)257);
			((TMP_Text)val).textWrappingMode = (TextWrappingModes)1;
			((TMP_Text)val).overflowMode = (TextOverflowModes)0;
			float num = Mathf.Max(16f, Mathf.Ceil(((TMP_Text)val).GetPreferredValues(((TMP_Text)val).text, w - 20f, 0f).y));
			((TMP_Text)val).rectTransform.sizeDelta = new Vector2(w - 20f, num + 2f);
			RectTransform val2 = (RectTransform)row;
			float num2 = Mathf.Max(44f, 23f + num + 6f);
			val2.sizeDelta = new Vector2(val2.sizeDelta.x, num2);
			return num2;
		}

		private static void Fit()
		{
			//IL_002d: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_00d1: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			float num = (_serversTab ? 122f : 152f);
			float num2 = 962f - num - 10f - 100f;
			float num3 = Mathf.Min(Mathf.Max(_worlds.sizeDelta.y, 44f), num2);
			((RectTransform)((Transform)_worlds).parent).sizeDelta = new Vector2(296f, num3);
			_worldsOpts.anchoredPosition = new Vector2(12f, 0f - (100f + num3 + 10f));
			_serversOpts.anchoredPosition = _worldsOpts.anchoredPosition;
			_left.sizeDelta = new Vector2(320f, 100f + num3 + 10f + num + 12f);
			float num4 = 858f;
			float num5 = Mathf.Min(Mathf.Max(_chars.sizeDelta.y, 44f), num4);
			((RectTransform)((Transform)_chars).parent).sizeDelta = new Vector2(296f, num5);
			_rightActs.anchoredPosition = new Vector2(12f, 0f - (60f + num5 + 10f));
			_right.sizeDelta = new Vector2(320f, 60f + num5 + 10f + 34f + 12f);
		}

		private static void PaintChars()
		{
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			CampfireUi.Clear((Transform)(object)_chars);
			_cardMids.Clear();
			List<PlayerProfile> list = Party.Ordered(Fejd.Profiles);
			string text = (_charSearch.text ?? "").Trim().ToLowerInvariant();
			float num = 0f;
			for (int i = 0; i < list.Count; i++)
			{
				if (i == 0 || i == 4)
				{
					CampfireUi.Label((Transform)(object)_chars, (i == 0) ? "At the fire" : "Others", 2f, num + 6f, 296f);
					num += 28f;
				}
				PlayerProfile p = list[i];
				if (text.Length <= 0 || p.GetName().ToLowerInvariant().Contains(text))
				{
					int index = i;
					Image val = Row((Transform)(object)_chars, p.GetFilename(), num, 296f, 44f, p == _sel, delegate
					{
						_sel = p;
						Repaint();
					});
					float num2 = RowText(((Component)val).transform, p.GetName(), Describe(p), 266f, p == _sel);
					RectTransform moves = CampfireUi.Place(CampfireUi.Node(((Component)val).transform, "moves"), 266f, 3f, 22f, 38f);
					Move((Transform)(object)moves, 0f, 0f, (index == 4) ? "Move to the fire" : "Move up", delegate
					{
						Party.Move(p, index - 1, Fejd.Profiles);
						Party.Rebuild();
					});
					Move((Transform)(object)moves, 20f, 180f, (index == 3) ? "Leave the fire" : "Move down", delegate
					{
						Party.Move(p, index + 1, Fejd.Profiles);
						Party.Rebuild();
					});
					((Component)moves).gameObject.SetActive(false);
					CampfireUi.OnHover((Graphic)(object)val, delegate
					{
						((Component)moves).gameObject.SetActive(true);
					}, delegate
					{
						((Component)moves).gameObject.SetActive(false);
					});
					((Component)val).gameObject.AddComponent<CardDrag>().Init(p, ((Graphic)val).rectTransform);
					_cardMids.Add((p, num + num2 / 2f));
					num += num2 + 1f;
				}
			}
			_chars.sizeDelta = new Vector2(0f, num);
			Fit();
		}

		private static void Move(Transform parent, float y, float turn, string tip, Action a)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			Image val = CampfireUi.Box(parent, "move", CampfireUi.C("raised2"), CampfireUi.NoColor, 5);
			CampfireUi.Place(((Graphic)val).rectTransform, 0f, y, 22f, 18f);
			Image g = CampfireUi.Img(((Component)val).transform, Glyphs.Triangle, CampfireUi.C("dim"), "g");
			CampfireUi.At(((Graphic)g).rectTransform, 0.5f, 0.5f, 0f, 0f, 9f, 9f);
			((Transform)((Graphic)g).rectTransform).localEulerAngles = new Vector3(0f, 0f, turn);
			CampfireUi.On((Graphic)(object)val, a);
			CampfireUi.OnHover((Graphic)(object)val, delegate
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				((Graphic)g).color = CampfireUi.White;
			}, delegate
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				((Graphic)g).color = CampfireUi.C("dim");
			});
			CampfireUi.Tip((Graphic)(object)val, tip);
		}

		internal static void Dropped(PlayerProfile p, float contentY)
		{
			int num = _cardMids.Count;
			for (int i = 0; i < _cardMids.Count; i++)
			{
				if (contentY < _cardMids[i].mid)
				{
					num = i;
					break;
				}
			}
			List<PlayerProfile> list = Party.Ordered(Fejd.Profiles);
			int num2 = list.IndexOf(p);
			int num3 = ((num < _cardMids.Count) ? list.IndexOf(_cardMids[num].p) : list.Count);
			if (num2 < num3)
			{
				num3--;
			}
			Party.Move(p, num3, Fejd.Profiles);
			Party.Rebuild();
		}

		private static string Describe(PlayerProfile p)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			string text = (((int)p.m_fileSource == 4) ? "Cloud" : "Local") + (p.m_usedCheats ? " · no achievements" : "");
			try
			{
				HashSet<string> names = new HashSet<string>(Fejd.Worlds.Select((World w) => w.m_name));
				PlayerStats[] playerStats = p.m_playerStats;
				KeyValuePair<string, float>? keyValuePair = (from kv in ((playerStats == null) ? null : playerStats[0]?.m_knownWorlds)?.Where((KeyValuePair<string, float> kv) => names.Contains(kv.Key))
					orderby kv.Value descending
					select kv).FirstOrDefault();
				if (keyValuePair?.Key != null)
				{
					return text + " · most played " + keyValuePair.Value.Key;
				}
			}
			catch
			{
			}
			return text + " save";
		}

		private unsafe static void PaintLeftList()
		{
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Invalid comparison between Unknown and I4
			CampfireUi.Clear((Transform)(object)_worlds);
			string q = (_worldSearch.text ?? "").Trim().ToLowerInvariant();
			float num = 0f;
			if (!_serversTab)
			{
				foreach (World w in Fejd.Worlds.Where((World val3) => q.Length == 0 || val3.m_name.ToLowerInvariant().Contains(q)))
				{
					bool flag = _world != null && w.m_worldName == _world.m_worldName;
					Image obj = Row((Transform)(object)_worlds, "w" + w.m_worldName, num, 296f, 44f, flag, delegate
					{
						_world = w;
						Repaint();
					});
					string text = ((w.m_startingGlobalKeys != null && w.m_startingGlobalKeys.Count > 0) ? "Custom · " : "");
					float num2 = RowText(((Component)obj).transform, w.m_name, text + ((w.m_worldName != w.m_name) ? (w.m_worldName + " · ") : "") + w.m_seedName + " · " + (((int)w.m_fileSource == 4) ? "cloud" : "local"), 296f, flag);
					num += num2 + 1f;
				}
				if (num == 0f)
				{
					None((Fejd.Worlds.Count == 0) ? "No worlds yet. Make one below." : "Nothing matches.");
				}
			}
			else
			{
				foreach (ServerJoinData item in _servers.Where((ServerJoinData val3) => q.Length == 0 || ((object)(*(ServerJoinData*)(&val3))/*cast due to .constrained prefix*/).ToString().ToLowerInvariant().Contains(q)))
				{
					ServerJoinData s = item;
					bool flag2 = ((ServerJoinData)(ref s)).Equals(_server);
					bool flag3 = Passwords.Has(((object)Unsafe.As<ServerJoinData, ServerJoinData>(ref s)/*cast due to .constrained prefix*/).ToString());
					RectTransform worlds = _worlds;