Decompiled source of BifrostConnect v1.2.0

BifrostConnect.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using BifrostConnect.Helpers;
using BifrostConnect.Models;
using BifrostConnect.Network;
using BifrostConnect.Patches;
using BifrostConnect.UI;
using HarmonyLib;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using NetworkingUtils;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
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: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("Jubaroo")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright © 2026 Jubaroo")]
[assembly: AssemblyDescription("Main menu dedicated server browser with auto-fill passwords and scrollable directory for Valheim")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0+3a796acb81b6e348afb8cee5990b2daab3cfd030")]
[assembly: AssemblyProduct("BifrostConnect")]
[assembly: AssemblyTitle("BifrostConnect")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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 BifrostConnect
{
	[BepInPlugin("com.jubaroo.bifrostconnect", "Bifrost Connect", "1.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static LogCallback <0>__OnLogMessageReceived;

			public static FileSystemEventHandler <1>__OnConfigFileChanged;
		}

		public const string ModGUID = "com.jubaroo.bifrostconnect";

		public const string ModName = "Bifrost Connect";

		public const string ModVersion = "1.2.0";

		private readonly Harmony _harmony = new Harmony("com.jubaroo.bifrostconnect");

		internal static ManualLogSource Log = null;

		public static List<ServerEntry> ServerList = new List<ServerEntry>();

		private static string _jsonConfigPath = null;

		private static FileSystemWatcher? _configWatcher;

		private static DateTime _lastConfigChange = DateTime.MinValue;

		private static volatile bool _reloadPending;

		public static string? LastDisconnectDetail;

		public static DateTime LastDisconnectTime = DateTime.MinValue;

		public static ConfigEntry<bool> CfgAutoSelectCharacter = null;

		public static ConfigEntry<bool> CfgAutoStartCharacter = null;

		private void Awake()
		{
			//IL_007a: 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_0085: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			_jsonConfigPath = Path.Combine(Paths.ConfigPath, "BifrostConnect_Servers.json");
			CfgAutoSelectCharacter = ((BaseUnityPlugin)this).Config.Bind<bool>("Character", "AutoSelectLastCharacter", true, "Pre-select the last character you used when joining a server through BifrostConnect.");
			CfgAutoStartCharacter = ((BaseUnityPlugin)this).Config.Bind<bool>("Character", "AutoStartLastCharacter", true, "Also skip the character selection screen automatically when a remembered character is found. Disable to only pre-select the character and press Start yourself.");
			LoadServerConfig();
			SetupConfigWatcher();
			object obj = <>O.<0>__OnLogMessageReceived;
			if (obj == null)
			{
				LogCallback val = OnLogMessageReceived;
				<>O.<0>__OnLogMessageReceived = val;
				obj = (object)val;
			}
			Application.logMessageReceived += (LogCallback)obj;
			Log.LogInfo((object)"Initializing Bifrost Connect hooks...");
			_harmony.PatchAll();
		}

		private void SetupConfigWatcher()
		{
			try
			{
				string directoryName = Path.GetDirectoryName(_jsonConfigPath);
				if (!string.IsNullOrEmpty(directoryName) && Directory.Exists(directoryName))
				{
					_configWatcher = new FileSystemWatcher(directoryName, Path.GetFileName(_jsonConfigPath))
					{
						NotifyFilter = (NotifyFilters.LastWrite | NotifyFilters.CreationTime),
						EnableRaisingEvents = true
					};
					_configWatcher.Changed += OnConfigFileChanged;
					_configWatcher.Created += OnConfigFileChanged;
					Log.LogInfo((object)("Config file watcher initialized for " + _jsonConfigPath));
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Failed to setup config file watcher: " + ex.Message));
			}
		}

		private static void OnConfigFileChanged(object sender, FileSystemEventArgs e)
		{
			if (!((DateTime.Now - _lastConfigChange).TotalSeconds < 2.0))
			{
				_lastConfigChange = DateTime.Now;
				Log.LogInfo((object)"Config file changed externally, scheduling reload on main thread...");
				_reloadPending = true;
			}
		}

		private void Update()
		{
			if (!_reloadPending)
			{
				return;
			}
			_reloadPending = false;
			try
			{
				LoadServerConfig();
				MenuBuilder.RefreshAfterConfigReload();
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Reload after external config change failed: " + ex.Message));
			}
		}

		private void OnDestroy()
		{
			//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_002b: Expected O, but got Unknown
			_configWatcher?.Dispose();
			object obj = <>O.<0>__OnLogMessageReceived;
			if (obj == null)
			{
				LogCallback val = OnLogMessageReceived;
				<>O.<0>__OnLogMessageReceived = val;
				obj = (object)val;
			}
			Application.logMessageReceived -= (LogCallback)obj;
		}

		private static void OnLogMessageReceived(string condition, string stackTrace, LogType type)
		{
			if (!string.IsNullOrEmpty(condition) && (condition.StartsWith("Disconnect:", StringComparison.OrdinalIgnoreCase) || condition.IndexOf("doesn't have the correct", StringComparison.OrdinalIgnoreCase) >= 0 || condition.IndexOf("version mismatch", StringComparison.OrdinalIgnoreCase) >= 0 || condition.IndexOf("not authorized", StringComparison.OrdinalIgnoreCase) >= 0 || condition.IndexOf("banned", StringComparison.OrdinalIgnoreCase) >= 0 || condition.IndexOf("kicked", StringComparison.OrdinalIgnoreCase) >= 0 || condition.IndexOf("Incompatible version", StringComparison.OrdinalIgnoreCase) >= 0))
			{
				LastDisconnectDetail = condition.Trim();
				LastDisconnectTime = DateTime.UtcNow;
			}
		}

		private static string StripComments(string text)
		{
			string[] array = text.Split(new string[3] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
			StringBuilder stringBuilder = new StringBuilder();
			string[] array2 = array;
			foreach (string text2 in array2)
			{
				string text3 = text2.Trim();
				if (!text3.StartsWith("//") && !text3.StartsWith("#"))
				{
					stringBuilder.AppendLine(text2);
				}
			}
			return stringBuilder.ToString();
		}

		internal static void LoadServerConfig()
		{
			if (!File.Exists(_jsonConfigPath) || new FileInfo(_jsonConfigPath).Length == 0L)
			{
				Log.LogInfo((object)("Server config not found at '" + _jsonConfigPath + "'. Generating default template with examples."));
				GenerateDefaultConfig();
			}
			try
			{
				string text = File.ReadAllText(_jsonConfigPath);
				ServerList = new List<ServerEntry>();
				string text2 = StripComments(text);
				try
				{
					ServerListWrapper serverListWrapper = JsonConvert.DeserializeObject<ServerListWrapper>(text2);
					if (serverListWrapper != null && serverListWrapper.Servers != null && serverListWrapper.Servers.Count > 0)
					{
						ServerList = serverListWrapper.Servers;
					}
					else
					{
						List<ServerEntry> list = JsonConvert.DeserializeObject<List<ServerEntry>>(text2);
						if (list != null && list.Count > 0)
						{
							ServerList = list;
						}
					}
				}
				catch (Exception ex)
				{
					Log.LogWarning((object)("JSON parse attempt failed: " + ex.Message + ". Proceeding to line-by-line fallback."));
				}
				if (ServerList.Count == 0)
				{
					string[] array = text.Split(new string[3] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
					for (int i = 0; i < array.Length; i++)
					{
						string text3 = array[i].Trim();
						if (string.IsNullOrEmpty(text3) || text3.StartsWith("{") || text3.StartsWith("}") || text3.StartsWith("[") || text3.StartsWith("]") || text3.StartsWith("//") || text3.StartsWith("#"))
						{
							continue;
						}
						string[] array2 = text3.Split(new char[1] { ':' });
						if (array2.Length >= 3)
						{
							string name = array2[0].Trim();
							string iP = array2[1].Trim();
							if (int.TryParse(array2[2].Trim(), out var result))
							{
								string password = ((array2.Length > 3) ? array2[3].Trim() : string.Empty);
								ServerList.Add(new ServerEntry
								{
									Name = name,
									IP = iP,
									Port = result,
									Password = password
								});
							}
						}
					}
				}
				Log.LogInfo((object)$"Loaded {ServerList.Count} servers from config: {_jsonConfigPath}");
				foreach (ServerEntry server in ServerList)
				{
					Log.LogInfo((object)$"  - Server: '{server.Name}' ({server.IP}:{server.Port})");
				}
			}
			catch (Exception ex2)
			{
				Log.LogError((object)("Failed to load server config: " + ex2.Message));
			}
		}

		internal static void SaveServerConfig()
		{
			try
			{
				string contents = JsonConvert.SerializeObject((object)new ServerListWrapper
				{
					Servers = ServerList
				}, (Formatting)1);
				_lastConfigChange = DateTime.Now;
				File.WriteAllText(_jsonConfigPath, contents);
				Log.LogInfo((object)$"Saved {ServerList.Count} servers to config");
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Failed to save server config: " + ex.Message));
			}
		}

		private static void GenerateDefaultConfig()
		{
			string contents = "// ====================================================================\n// BifrostConnect Server Configuration\n// ====================================================================\n// Add your Valheim dedicated servers to the 'Servers' list below.\n//\n// Fields:\n//   - Name:     The display name shown on the button in the main menu.\n//   - IP:       The server IPv4 address or domain (e.g. 192.168.1.50 or valheim.myserver.com).\n//   - Port:     The connection port (default Valheim server port is 2456).\n//   - Password: The server password (leave as \"\" if password is not required).\n//\n// You can add as many servers as you like to this list!\n// ====================================================================\n{\n  \"Servers\": [\n    {\n      \"Name\": \"My Survival Server\",\n      \"IP\": \"127.0.0.1\",\n      \"Port\": 2456,\n      \"Password\": \"\"\n    },\n    {\n      \"Name\": \"Community Dedicated Server\",\n      \"IP\": \"192.168.1.100\",\n      \"Port\": 2456,\n      \"Password\": \"secretpassword\"\n    },\n    {\n      \"Name\": \"Modded World\",\n      \"IP\": \"valheim.example.com\",\n      \"Port\": 2456,\n      \"Password\": \"valheim123\"\n    }\n  ]\n}\n";
			_lastConfigChange = DateTime.Now;
			File.WriteAllText(_jsonConfigPath, contents);
		}
	}
}
namespace BifrostConnect.UI
{
	public class MenuEscapeHandler : MonoBehaviour
	{
		public FejdStartup? Instance;

		private static readonly Queue<Action> _mainThreadQueue = new Queue<Action>();

		private static int _selectedIndex = -1;

		private static MenuEscapeHandler? _activeInstance;

		private void Awake()
		{
			_activeInstance = this;
		}

		private void OnDestroy()
		{
			if ((Object)(object)_activeInstance == (Object)(object)this)
			{
				_activeInstance = null;
			}
		}

		public static void RunOnMainThread(Action action)
		{
			lock (_mainThreadQueue)
			{
				_mainThreadQueue.Enqueue(action);
			}
		}

		public static void RunDelayed(float delaySeconds, Action action)
		{
			if ((Object)(object)_activeInstance != (Object)null && ((Component)_activeInstance).gameObject.activeInHierarchy)
			{
				((MonoBehaviour)_activeInstance).StartCoroutine(RunDelayedCoroutine(delaySeconds, action));
				return;
			}
			Task.Run(async delegate
			{
				await Task.Delay((int)(delaySeconds * 1000f));
				RunOnMainThread(action);
			});
		}

		private static IEnumerator RunDelayedCoroutine(float delay, Action action)
		{
			yield return (object)new WaitForSecondsRealtime(delay);
			action();
		}

		private void Update()
		{
			while (_mainThreadQueue.Count > 0)
			{
				Action action = null;
				lock (_mainThreadQueue)
				{
					if (_mainThreadQueue.Count > 0)
					{
						action = _mainThreadQueue.Dequeue();
					}
				}
				try
				{
					action?.Invoke();
				}
				catch (Exception arg)
				{
					Plugin.Log.LogError((object)$"Exception executing queued action on main thread: {arg}");
				}
			}
			bool flag = Input.GetKeyDown((KeyCode)27);
			if (!flag && ZInput.instance != null)
			{
				flag = ZInput.GetButtonDown("JoyButton1") || ZInput.GetButtonDown("JoyMenu");
			}
			if (flag && (Object)(object)Instance != (Object)null)
			{
				MenuBuilder.HandleEscape(Instance);
			}
			bool flag2 = false;
			GameObject val = (((Object)(object)EventSystem.current != (Object)null) ? EventSystem.current.currentSelectedGameObject : null);
			if ((Object)(object)val != (Object)null && ((Object)(object)val.GetComponent<InputField>() != (Object)null || (Object)(object)val.GetComponent<TMP_InputField>() != (Object)null))
			{
				flag2 = true;
			}
			bool flag3 = Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271);
			if (!flag3 && ZInput.instance != null)
			{
				flag3 = ZInput.GetButtonDown("JoyButton0");
			}
			if (!flag2 && flag3)
			{
				if (MenuBuilder.IsConfirmPanelOpen())
				{
					MenuBuilder.ConfirmCurrentServer();
				}
				else if (MenuBuilder.IsMenuOpen() && !MenuBuilder.IsAnyModalOpen() && _selectedIndex >= 0 && _selectedIndex < MenuBuilder.GetServerCount())
				{
					MenuBuilder.ConnectToSelectedServer(Instance, _selectedIndex);
				}
			}
			if (MenuBuilder.IsMenuOpen() && !MenuBuilder.IsAnyModalOpen() && MenuBuilder.GetServerCount() > 0 && !flag2)
			{
				if (Input.GetKeyDown((KeyCode)274))
				{
					_selectedIndex = Mathf.Min(_selectedIndex + 1, MenuBuilder.GetServerCount() - 1);
					MenuBuilder.HighlightServer(_selectedIndex);
				}
				else if (Input.GetKeyDown((KeyCode)273))
				{
					_selectedIndex = Mathf.Max(_selectedIndex - 1, 0);
					MenuBuilder.HighlightServer(_selectedIndex);
				}
			}
		}

		public static void ResetSelection()
		{
			_selectedIndex = -1;
			MenuBuilder.ClearHighlight();
		}
	}
	public static class MenuBuilder
	{
		private class ServerRowUI
		{
			public ServerEntry Server;

			public GameObject RowObject;

			public Image StatusDot;

			public Text CountText;

			public Image PasswordLock;

			public Text ModifierBadge;

			public UITooltip Tooltip;
		}

		private class PlayFabQueueItem
		{
			public ServerEntry Server;

			public int Generation;

			public Action? OnCompleted;
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction<string> <0>__FilterServerRows;

			public static UnityAction <1>__CloseConfirmation;

			public static Action <2>__ProcessNextPlayFabQuery;
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<ServerEntry, bool> <>9__30_9;

			public static Func<ServerEntry, long> <>9__30_10;

			public static UnityAction <>9__30_5;

			public static UnityAction <>9__30_7;

			public static Func<PluginInfo, string> <>9__33_1;

			public static UnityAction <>9__33_0;

			public static Func<ServerEntry, bool> <>9__42_0;

			public static Func<ServerEntry, long> <>9__42_1;

			public static UnityAction <>9__46_1;

			public static Func<string, string> <>9__49_3;

			public static Func<string, bool> <>9__49_4;

			public static Func<ServerEntry, bool> <>9__49_5;

			public static Func<ServerEntry, long> <>9__49_6;

			public static Func<ServerEntry, bool> <>9__54_0;

			public static Func<ServerEntry, long> <>9__54_1;

			public static Func<ServerEntry, bool> <>9__55_0;

			public static Func<ServerEntry, long> <>9__55_1;

			public static Action <>9__56_1;

			public static Func<IPAddress, bool> <>9__62_2;

			public static Func<ServerRowUI, bool> <>9__71_0;

			public static Func<ServerEntry, bool> <>9__81_0;

			public static Func<ServerEntry, long> <>9__81_1;

			public static Func<ServerEntry, bool> <>9__84_0;

			public static Func<ServerEntry, long> <>9__84_1;

			internal bool <BuildCustomPanel>b__30_9(ServerEntry s)
			{
				return s.IsFavorite;
			}

			internal long <BuildCustomPanel>b__30_10(ServerEntry s)
			{
				return s.LastPlayedTicks;
			}

			internal void <BuildCustomPanel>b__30_5()
			{
				ExportServerList();
			}

			internal void <BuildCustomPanel>b__30_7()
			{
				TriggerBackgroundQueries(force: true);
			}

			internal string <OpenModCheckModal>b__33_1(PluginInfo p)
			{
				return p.Metadata.Name;
			}

			internal void <OpenModCheckModal>b__33_0()
			{
				CloseModCheckModal();
				if ((Object)(object)_confirmPanel != (Object)null)
				{
					_confirmPanel.SetActive(true);
					Canvas.ForceUpdateCanvases();
				}
			}

			internal bool <CloseImportPreviewModal>b__42_0(ServerEntry s)
			{
				return s.IsFavorite;
			}

			internal long <CloseImportPreviewModal>b__42_1(ServerEntry s)
			{
				return s.LastPlayedTicks;
			}

			internal void <PromptDeleteServer>b__46_1()
			{
				CloseDeletePromptModal();
				if ((Object)(object)_confirmPanel != (Object)null)
				{
					_confirmPanel.SetActive(true);
					Canvas.ForceUpdateCanvases();
				}
			}

			internal string <OpenEditServerModal>b__49_3(string m)
			{
				return m.Trim();
			}

			internal bool <OpenEditServerModal>b__49_4(string m)
			{
				return !string.IsNullOrEmpty(m);
			}

			internal bool <OpenEditServerModal>b__49_5(ServerEntry s)
			{
				return s.IsFavorite;
			}

			internal long <OpenEditServerModal>b__49_6(ServerEntry s)
			{
				return s.LastPlayedTicks;
			}

			internal bool <OpenMenu>b__54_0(ServerEntry s)
			{
				return s.IsFavorite;
			}

			internal long <OpenMenu>b__54_1(ServerEntry s)
			{
				return s.LastPlayedTicks;
			}

			internal bool <RefreshAfterConfigReload>b__55_0(ServerEntry s)
			{
				return s.IsFavorite;
			}

			internal long <RefreshAfterConfigReload>b__55_1(ServerEntry s)
			{
				return s.LastPlayedTicks;
			}

			internal void <TriggerBackgroundQueries>b__56_1()
			{
				_isRefreshing = false;
				if ((Object)(object)_refreshButton != (Object)null)
				{
					((Selectable)_refreshButton).interactable = true;
				}
				if ((Object)(object)_refreshButtonText != (Object)null)
				{
					_refreshButtonText.text = "Refresh";
				}
			}

			internal bool <ProcessNextPlayFabQuery>b__62_2(IPAddress a)
			{
				return a.AddressFamily == AddressFamily.InterNetwork;
			}

			internal bool <GetVisibleRows>b__71_0(ServerRowUI r)
			{
				if ((Object)(object)r.RowObject != (Object)null)
				{
					return r.RowObject.activeSelf;
				}
				return false;
			}

			internal bool <ToggleFavorite>b__81_0(ServerEntry s)
			{
				return s.IsFavorite;
			}

			internal long <ToggleFavorite>b__81_1(ServerEntry s)
			{
				return s.LastPlayedTicks;
			}

			internal bool <ImportServerList>b__84_0(ServerEntry s)
			{
				return s.IsFavorite;
			}

			internal long <ImportServerList>b__84_1(ServerEntry s)
			{
				return s.LastPlayedTicks;
			}
		}

		private static readonly List<ServerRowUI> _serverRows = new List<ServerRowUI>();

		private static int _queryGeneration;

		private static FejdStartup? _startupInstance;

		private static Sprite? _dotSprite;

		private static Sprite? _lockSprite;

		private static RectTransform? _contentRect;

		private static ScrollRect? _scrollRect;

		private static GameObject _customMenuPanel = null;

		private static GameObject _confirmPanel = null;

		private static GameObject _editServerModal = null;

		private static GameObject _deletePromptModal = null;

		private static GameObject _importPreviewModal = null;

		private static GameObject _helpModal = null;

		private static bool _importAddedAny;

		private static int _lastEscapeFrame = -1;

		private static GameObject _charSelectModal = null;

		private static GameObject _modCheckModal = null;

		private static GameObject _directJoinModal = null;

		private static float _lastScrollPosition = 1f;

		private static ServerEntry? _activeConfirmServer;

		private static Text? _confirmStatusText;

		private static float _lastClickTime;

		private static ServerEntry? _lastClickedServer;

		private static bool _pendingOpenConfirmation;

		private static Button? _refreshButton;

		private static Text? _refreshButtonText;

		private static bool _isRefreshing;

		private static float _lastRefreshTime;

		private const string HelpText = "<color=#FFA500><b>Server List</b></color>\n• Click a server to open its Join window.\n• The star on the left pins a server to the top of the list.\n• A padlock on the right means a password is saved for that server.\n• The dot on the right shows status: green = online, red = offline, gray = checking.\n• The second line shows players, ping, game version, crossplay and mod status.\n\n<color=#FFA500><b>Search Bar</b></color>\n• Type to filter servers by name or IP. Keyboard selection follows the filtered list.\n\n<color=#FFA500><b>Add Server</b></color>\n• Manually add a server. Address is required; port defaults to 2456.\n• Duplicate address:port entries are rejected with a message.\n\n<color=#FFA500><b>Direct Join</b></color>\n• Connect to an IP:port once without saving it to your list.\n\n<color=#FFA500><b>Import Recent</b></color>\n• Opens a preview of servers from your Valheim history so you can add only the ones you want.\n\n<color=#FFA500><b>From Clipboard</b></color>\n• Copies \"ip:port\" or \"ip:port:password\" from your clipboard and adds it.\n\n<color=#FFA500><b>Export / Import</b></color>\n• Export writes a backup JSON next to your BepInEx config; Import restores one.\n\n<color=#FFA500><b>Refresh</b></color>\n• Re-queries every server's status, player count and ping.\n\n<color=#FFA500><b>Keyboard</b></color>\n• Up / Down arrows select a server, Enter opens its Join window, Esc goes back one step.\n\n<color=#FFA500><b>Character Selection</b></color>\n• BifrostConnect remembers the character last used for each server.\n• Click 'Connect' to join immediately with the remembered character.\n• Click 'Change Character' to join the server and open character selection.\n• Click 'Change' next to the character name to pick any profile or set 'Always Ask'.\n• Shift+Double Click or Shift+Enter also opens character selection directly.\n\n<color=#FFA500><b>Config File</b></color>\n• Servers live in BepInEx/configs/BifrostConnect_Servers.json.\n• Editing that file outside the game reloads the list automatically.";

		private static readonly Queue<PlayFabQueueItem> _playFabQueue = new Queue<PlayFabQueueItem>();

		private static bool _playFabSearchActive;

		private static int _activePlayFabSearchTimeoutId;

		public static void InjectMainMenuButton(FejdStartup instance)
		{
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Expected O, but got Unknown
			if ((Object)(object)instance.m_mainMenu == (Object)null || (Object)(object)Utils.FindChild(instance.m_mainMenu.transform, "Button_BifrostConnect", (IterativeSearchType)0) != (Object)null)
			{
				return;
			}
			Transform val = Utils.FindChild(instance.m_mainMenu.transform, "Settings", (IterativeSearchType)0);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, val.parent);
			((Object)val2).name = "Button_BifrostConnect";
			val2.transform.SetSiblingIndex(val.GetSiblingIndex());
			Localize[] componentsInChildren = val2.GetComponentsInChildren<Localize>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
			}
			TMP_Text[] componentsInChildren2 = val2.GetComponentsInChildren<TMP_Text>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				componentsInChildren2[i].text = "BIFROST CONNECT";
			}
			Text[] componentsInChildren3 = val2.GetComponentsInChildren<Text>(true);
			for (int i = 0; i < componentsInChildren3.Length; i++)
			{
				componentsInChildren3[i].text = "BIFROST CONNECT";
			}
			Button component = val2.GetComponent<Button>();
			if ((Object)(object)component != (Object)null)
			{
				for (int j = 0; j < ((UnityEventBase)component.onClick).GetPersistentEventCount(); j++)
				{
					((UnityEventBase)component.onClick).SetPersistentListenerState(j, (UnityEventCallState)0);
				}
				((UnityEventBase)component.onClick).RemoveAllListeners();
				((UnityEvent)component.onClick).AddListener((UnityAction)delegate
				{
					OpenMenu(instance);
				});
			}
			UIInputHandler[] componentsInChildren4 = val2.GetComponentsInChildren<UIInputHandler>(true);
			foreach (UIInputHandler obj in componentsInChildren4)
			{
				obj.m_onLeftClick = null;
				obj.m_onLeftDown = null;
				obj.m_onLeftUp = null;
			}
			if (!((Object)(object)instance.m_menuList != (Object)null))
			{
				return;
			}
			try
			{
				AccessTools.Field(typeof(FejdStartup), "m_menuButtons")?.SetValue(instance, instance.m_menuList.GetComponentsInChildren<Button>());
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not update m_menuButtons via reflection: " + ex.Message));
			}
		}

		public static void BuildCustomPanel(FejdStartup instance)
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_0107: 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)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: 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_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Expected O, but got Unknown
			//IL_01d7: 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_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Expected O, but got Unknown
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Expected O, but got Unknown
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Expected O, but got Unknown
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Expected O, but got Unknown
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			//IL_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_0492: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: Expected O, but got Unknown
			//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_050c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0460: Expected O, but got Unknown
			//IL_057f: Unknown result type (might be due to invalid IL or missing references)
			//IL_058e: Unknown result type (might be due to invalid IL or missing references)
			//IL_059d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cc: Expected O, but got Unknown
			//IL_0551: 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_055c: Expected O, but got Unknown
			//IL_06a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ae: Expected O, but got Unknown
			//IL_06d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0704: Unknown result type (might be due to invalid IL or missing references)
			//IL_071a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0730: Unknown result type (might be due to invalid IL or missing references)
			//IL_0755: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07da: Expected O, but got Unknown
			//IL_0802: Unknown result type (might be due to invalid IL or missing references)
			//IL_0818: Unknown result type (might be due to invalid IL or missing references)
			//IL_082e: Unknown result type (might be due to invalid IL or missing references)
			//IL_083a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0846: Unknown result type (might be due to invalid IL or missing references)
			//IL_086b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0875: Expected O, but got Unknown
			//IL_08ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f4: Expected O, but got Unknown
			//IL_091d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0932: Unknown result type (might be due to invalid IL or missing references)
			//IL_0947: Unknown result type (might be due to invalid IL or missing references)
			//IL_095c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0970: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_09aa: Expected O, but got Unknown
			//IL_09c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a0a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a0f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a22: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a2c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a38: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a44: Unknown result type (might be due to invalid IL or missing references)
			//IL_0619: Unknown result type (might be due to invalid IL or missing references)
			//IL_0628: Unknown result type (might be due to invalid IL or missing references)
			//IL_0637: Unknown result type (might be due to invalid IL or missing references)
			//IL_0648: Unknown result type (might be due to invalid IL or missing references)
			//IL_064e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b71: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b76: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b89: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b9a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0baf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bc4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bf7: Unknown result type (might be due to invalid IL or missing references)
			//IL_125b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c5f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c49: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c91: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c9b: Expected O, but got Unknown
			//IL_0cc0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cc5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ce9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cfe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d13: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d28: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d3c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d86: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d8b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d9e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0daf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dc4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dd9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e02: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e45: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e81: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e86: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e99: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eaa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ebf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ed4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ee9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0efd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f07: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f48: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f99: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f9e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fb1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fc2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fd7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fec: Unknown result type (might be due to invalid IL or missing references)
			//IL_1001: Unknown result type (might be due to invalid IL or missing references)
			//IL_1015: Unknown result type (might be due to invalid IL or missing references)
			//IL_108b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1090: Unknown result type (might be due to invalid IL or missing references)
			//IL_10a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_10b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_10c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_10de: Unknown result type (might be due to invalid IL or missing references)
			//IL_10f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_1107: Unknown result type (might be due to invalid IL or missing references)
			//IL_1111: Unknown result type (might be due to invalid IL or missing references)
			//IL_1136: Unknown result type (might be due to invalid IL or missing references)
			//IL_11f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_1200: Expected O, but got Unknown
			_startupInstance = instance;
			if ((Object)(object)_customMenuPanel != (Object)null)
			{
				Object.Destroy((Object)(object)_customMenuPanel);
			}
			object obj;
			if (!((Object)(object)GUIManager.CustomGUIFront != (Object)null))
			{
				GameObject mainMenu = instance.m_mainMenu;
				obj = ((mainMenu != null) ? mainMenu.transform.parent : null);
			}
			else
			{
				obj = GUIManager.CustomGUIFront.transform;
			}
			Transform val = (Transform)obj;
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)"No suitable GUI root/parent found for BifrostConnect panel.");
				return;
			}
			_customMenuPanel = GUIManager.Instance.CreateWoodpanel(val, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 600f, 700f);
			_customMenuPanel.AddComponent<MenuEscapeHandler>().Instance = instance;
			GUIManager.Instance.CreateText("Server Directory", _customMenuPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -35f), GUIManager.Instance.AveriaSerifBold, 24, GUIManager.Instance.ValheimOrange, true, Color.black, 400f, 40f, false);
			((UnityEvent)GUIManager.Instance.CreateButton("?", _customMenuPanel.transform, new Vector2(1f, 1f), new Vector2(1f, 1f), new Vector2(-28f, -32f), 36f, 36f).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				OpenHelpModal(instance);
			});
			_customMenuPanel.SetActive(false);
			((UnityEvent<string>)(object)GUIManager.Instance.CreateInputField(_customMenuPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -70f), (ContentType)0, "Search servers by name or IP...", 14, 460f, 28f).GetComponent<InputField>().onValueChanged).AddListener((UnityAction<string>)FilterServerRows);
			((UnityEvent)GUIManager.Instance.CreateButton("Add Server", _customMenuPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(-200f, 80f), 120f, 40f).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				OpenEditServerModal(instance, null);
			});
			((UnityEvent)GUIManager.Instance.CreateButton("Direct Join", _customMenuPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(-65f, 80f), 120f, 40f).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				OpenDirectJoinModal(instance);
			});
			((UnityEvent)GUIManager.Instance.CreateButton("Import Recent", _customMenuPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(70f, 80f), 120f, 40f).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				OpenImportPreviewModal(instance);
			});
			((UnityEvent)GUIManager.Instance.CreateButton("From Clipboard", _customMenuPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(205f, 80f), 130f, 40f).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				if (ImportFromClipboard() > 0)
				{
					Plugin.ServerList = (from s in Plugin.ServerList
						orderby s.IsFavorite descending, s.LastPlayedTicks descending
						select s).ToList();
					BuildCustomPanel(instance);
					_customMenuPanel.SetActive(true);
					Canvas.ForceUpdateCanvases();
					TriggerBackgroundQueries();
				}
			});
			ButtonClickedEvent onClick = GUIManager.Instance.CreateButton("Export", _customMenuPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(-180f, 32f), 110f, 38f).GetComponent<Button>().onClick;
			object obj2 = <>c.<>9__30_5;
			if (obj2 == null)
			{
				UnityAction val2 = delegate
				{
					ExportServerList();
				};
				<>c.<>9__30_5 = val2;
				obj2 = (object)val2;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj2);
			((UnityEvent)GUIManager.Instance.CreateButton("Import", _customMenuPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(-60f, 32f), 110f, 38f).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				ImportServerList(instance);
			});
			GameObject val3 = GUIManager.Instance.CreateButton("Refresh", _customMenuPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(60f, 32f), 110f, 38f);
			Button? obj3 = (_refreshButton = val3.GetComponent<Button>());
			_refreshButtonText = val3.GetComponentInChildren<Text>();
			ButtonClickedEvent onClick2 = obj3.onClick;
			object obj4 = <>c.<>9__30_7;
			if (obj4 == null)
			{
				UnityAction val4 = delegate
				{
					TriggerBackgroundQueries(force: true);
				};
				<>c.<>9__30_7 = val4;
				obj4 = (object)val4;
			}
			((UnityEvent)onClick2).AddListener((UnityAction)obj4);
			((UnityEvent)GUIManager.Instance.CreateButton("Close", _customMenuPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(180f, 32f), 110f, 38f).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				CloseMenu(instance);
			});
			Plugin.Log.LogInfo((object)$"BifrostConnect: Building directory UI for {Plugin.ServerList.Count} servers.");
			if (Plugin.ServerList.Count == 0)
			{
				GUIManager.Instance.CreateText("No servers configured.\nClick 'Add Server' or 'Import Recent' below!", _customMenuPanel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), GUIManager.Instance.AveriaSerif, 18, Color.gray, false, Color.black, 500f, 100f, false);
			}
			else
			{
				GameObject val5 = new GameObject("Bifrost_ScrollView", new Type[4]
				{
					typeof(RectTransform),
					typeof(Image),
					typeof(RectMask2D),
					typeof(ScrollRect)
				});
				val5.transform.SetParent(_customMenuPanel.transform, false);
				RectTransform component = val5.GetComponent<RectTransform>();
				component.anchorMin = new Vector2(0.5f, 0.5f);
				component.anchorMax = new Vector2(0.5f, 0.5f);
				component.pivot = new Vector2(0.5f, 0.5f);
				component.anchoredPosition = new Vector2(0f, 25f);
				component.sizeDelta = new Vector2(500f, 440f);
				Image component2 = val5.GetComponent<Image>();
				((Graphic)component2).color = new Color(0f, 0f, 0f, 0.25f);
				((Graphic)component2).raycastTarget = true;
				ScrollRect val6 = (_scrollRect = val5.GetComponent<ScrollRect>());
				val6.horizontal = false;
				val6.vertical = true;
				val6.scrollSensitivity = 35f;
				val6.movementType = (MovementType)2;
				val6.viewport = component;
				GameObject val7 = new GameObject("Content", new Type[3]
				{
					typeof(RectTransform),
					typeof(VerticalLayoutGroup),
					typeof(ContentSizeFitter)
				});
				val7.transform.SetParent(val5.transform, false);
				RectTransform component3 = val7.GetComponent<RectTransform>();
				component3.anchorMin = new Vector2(0f, 1f);
				component3.anchorMax = new Vector2(1f, 1f);
				component3.pivot = new Vector2(0.5f, 1f);
				component3.anchoredPosition = Vector2.zero;
				component3.sizeDelta = Vector2.zero;
				VerticalLayoutGroup component4 = val7.GetComponent<VerticalLayoutGroup>();
				((HorizontalOrVerticalLayoutGroup)component4).spacing = 10f;
				((LayoutGroup)component4).padding = new RectOffset(10, 10, 10, 10);
				((LayoutGroup)component4).childAlignment = (TextAnchor)1;
				((HorizontalOrVerticalLayoutGroup)component4).childControlWidth = true;
				((HorizontalOrVerticalLayoutGroup)component4).childControlHeight = true;
				((HorizontalOrVerticalLayoutGroup)component4).childForceExpandWidth = false;
				((HorizontalOrVerticalLayoutGroup)component4).childForceExpandHeight = false;
				ContentSizeFitter component5 = val7.GetComponent<ContentSizeFitter>();
				component5.horizontalFit = (FitMode)0;
				component5.verticalFit = (FitMode)2;
				val6.content = component3;
				_contentRect = component3;
				GameObject val8 = new GameObject("Bifrost_Scrollbar", new Type[3]
				{
					typeof(RectTransform),
					typeof(Image),
					typeof(Scrollbar)
				});
				val8.transform.SetParent(_customMenuPanel.transform, false);
				RectTransform component6 = val8.GetComponent<RectTransform>();
				component6.anchorMin = new Vector2(0.5f, 0.5f);
				component6.anchorMax = new Vector2(0.5f, 0.5f);
				component6.pivot = new Vector2(0.5f, 0.5f);
				component6.anchoredPosition = new Vector2(240f, 15f);
				component6.sizeDelta = new Vector2(12f, 490f);
				Scrollbar component7 = val8.GetComponent<Scrollbar>();
				component7.direction = (Direction)2;
				GameObject val9 = new GameObject("Sliding Area", new Type[1] { typeof(RectTransform) });
				val9.transform.SetParent(val8.transform, false);
				RectTransform component8 = val9.GetComponent<RectTransform>();
				component8.anchorMin = Vector2.zero;
				component8.anchorMax = Vector2.one;
				component8.sizeDelta = Vector2.zero;
				GameObject val10 = new GameObject("Handle", new Type[2]
				{
					typeof(RectTransform),
					typeof(Image)
				});
				val10.transform.SetParent(val9.transform, false);
				RectTransform component9 = val10.GetComponent<RectTransform>();
				component9.anchorMin = Vector2.zero;
				component9.anchorMax = Vector2.one;
				component9.sizeDelta = Vector2.zero;
				Image component10 = val10.GetComponent<Image>();
				component7.handleRect = component9;
				((Selectable)component7).targetGraphic = (Graphic)(object)component10;
				GUIManager.Instance.ApplyScrollbarStyle(component7);
				val6.verticalScrollbar = component7;
				val6.verticalScrollbarVisibility = (ScrollbarVisibility)1;
				_serverRows.Clear();
				foreach (ServerEntry server in Plugin.ServerList)
				{
					GameObject val11 = GUIManager.Instance.CreateButton("", val7.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), Vector2.zero, 440f, 50f);
					LayoutElement obj5 = val11.AddComponent<LayoutElement>();
					obj5.minWidth = 440f;
					obj5.preferredWidth = 440f;
					obj5.minHeight = 50f;
					obj5.preferredHeight = 50f;
					obj5.flexibleWidth = 0f;
					obj5.flexibleHeight = 0f;
					val11.GetComponent<RectTransform>();
					GameObject val12 = new GameObject("FavoriteStar", new Type[2]
					{
						typeof(RectTransform),
						typeof(Text)
					});
					val12.transform.SetParent(val11.transform, false);
					RectTransform component11 = val12.GetComponent<RectTransform>();
					component11.anchorMin = new Vector2(0f, 0.5f);
					component11.anchorMax = new Vector2(0f, 0.5f);
					component11.pivot = new Vector2(0f, 0.5f);
					component11.anchoredPosition = new Vector2(15f, 0f);
					component11.sizeDelta = new Vector2(30f, 30f);
					Text component12 = val12.GetComponent<Text>();
					component12.text = (server.IsFavorite ? "★" : "☆");
					component12.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
					component12.fontSize = 24;
					((Graphic)component12).color = (server.IsFavorite ? new Color(1f, 0.84f, 0f) : new Color(0.5f, 0.5f, 0.5f));
					component12.alignment = (TextAnchor)4;
					Button obj6 = val12.AddComponent<Button>();
					((Selectable)obj6).transition = (Transition)1;
					ServerEntry currentServerForStar = server;
					((UnityEvent)obj6.onClick).AddListener((UnityAction)delegate
					{
						ToggleFavorite(instance, currentServerForStar);
					});
					GameObject val13 = new GameObject("StatusDot", new Type[2]
					{
						typeof(RectTransform),
						typeof(Image)
					});
					val13.transform.SetParent(val11.transform, false);
					RectTransform component13 = val13.GetComponent<RectTransform>();
					component13.anchorMin = new Vector2(1f, 0.5f);
					component13.anchorMax = new Vector2(1f, 0.5f);
					component13.pivot = new Vector2(1f, 0.5f);
					component13.anchoredPosition = new Vector2(-15f, 0f);
					component13.sizeDelta = new Vector2(14f, 14f);
					Image component14 = val13.GetComponent<Image>();
					component14.sprite = GetDotSprite();
					((Graphic)component14).raycastTarget = false;
					GameObject val14 = new GameObject("ServerName", new Type[2]
					{
						typeof(RectTransform),
						typeof(Text)
					});
					val14.transform.SetParent(val11.transform, false);
					RectTransform component15 = val14.GetComponent<RectTransform>();
					component15.anchorMin = new Vector2(0f, 0.5f);
					component15.anchorMax = new Vector2(1f, 0.5f);
					component15.pivot = new Vector2(0.5f, 0.5f);
					component15.anchoredPosition = new Vector2(40f, 8f);
					component15.sizeDelta = new Vector2(-200f, 20f);
					Text component16 = val14.GetComponent<Text>();
					component16.text = server.Name;
					component16.font = GUIManager.Instance.AveriaSerifBold ?? Resources.GetBuiltinResource<Font>("Arial.ttf");
					component16.fontSize = 17;
					((Graphic)component16).color = Color.white;
					component16.alignment = (TextAnchor)3;
					((Graphic)component16).raycastTarget = false;
					GameObject val15 = new GameObject("ModifierBadge", new Type[2]
					{
						typeof(RectTransform),
						typeof(Text)
					});
					val15.transform.SetParent(val11.transform, false);
					RectTransform component17 = val15.GetComponent<RectTransform>();
					component17.anchorMin = new Vector2(1f, 0.5f);
					component17.anchorMax = new Vector2(1f, 0.5f);
					component17.pivot = new Vector2(1f, 0.5f);
					component17.anchoredPosition = new Vector2(-60f, 8f);
					component17.sizeDelta = new Vector2(150f, 20f);
					Text component18 = val15.GetComponent<Text>();
					component18.font = GUIManager.Instance.AveriaSerif ?? Resources.GetBuiltinResource<Font>("Arial.ttf");
					component18.fontSize = 13;
					((Graphic)component18).color = new Color(1f, 0.84f, 0f);
					component18.alignment = (TextAnchor)5;
					((Graphic)component18).raycastTarget = false;
					component18.text = "";
					val15.SetActive(false);
					GameObject val16 = new GameObject("PlayerCount", new Type[2]
					{
						typeof(RectTransform),
						typeof(Text)
					});
					val16.transform.SetParent(val11.transform, false);
					RectTransform component19 = val16.GetComponent<RectTransform>();
					component19.anchorMin = new Vector2(0f, 0.5f);
					component19.anchorMax = new Vector2(1f, 0.5f);
					component19.pivot = new Vector2(0.5f, 0.5f);
					component19.anchoredPosition = new Vector2(40f, -12f);
					component19.sizeDelta = new Vector2(-100f, 16f);
					Text component20 = val16.GetComponent<Text>();
					component20.font = GUIManager.Instance.AveriaSerif ?? Resources.GetBuiltinResource<Font>("Arial.ttf");
					component20.fontSize = 13;
					component20.supportRichText = true;
					component20.alignment = (TextAnchor)3;
					((Graphic)component20).raycastTarget = false;
					GameObject val17 = new GameObject("PasswordLock", new Type[2]
					{
						typeof(RectTransform),
						typeof(Image)
					});
					val17.transform.SetParent(val11.transform, false);
					RectTransform component21 = val17.GetComponent<RectTransform>();
					component21.anchorMin = new Vector2(1f, 0.5f);
					component21.anchorMax = new Vector2(1f, 0.5f);
					component21.pivot = new Vector2(1f, 0.5f);
					component21.anchoredPosition = new Vector2(-38f, 0f);
					component21.sizeDelta = new Vector2(16f, 16f);
					Image component22 = val17.GetComponent<Image>();
					component22.sprite = GetLockSprite();
					((Graphic)component22).color = new Color(0.9f, 0.9f, 0.9f);
					((Graphic)component22).raycastTarget = false;
					val17.SetActive(!string.IsNullOrEmpty(server.Password));
					UITooltip val18 = val11.AddComponent<UITooltip>();
					GameObject tooltipPrefab = WorldModifierHelper.GetTooltipPrefab(instance);
					if ((Object)(object)tooltipPrefab != (Object)null)
					{
						val18.m_tooltipPrefab = tooltipPrefab;
					}
					_serverRows.Add(new ServerRowUI
					{
						Server = server,
						RowObject = val11,
						StatusDot = component14,
						CountText = component20,
						PasswordLock = component22,
						ModifierBadge = component18,
						Tooltip = val18
					});
					UpdateServerRowUI(server);
					Button component23 = val11.GetComponent<Button>();
					ServerEntry currentServer = server;
					((UnityEvent)component23.onClick).AddListener((UnityAction)delegate
					{
						OnServerRowClicked(instance, currentServer);
					});
					Plugin.Log.LogInfo((object)("BifrostConnect: Added button for server '" + server.Name + "'"));
				}
				LayoutRebuilder.ForceRebuildLayoutImmediate(component3);
				val6.verticalNormalizedPosition = _lastScrollPosition;
				ManualLogSource log = Plugin.Log;
				Rect rect = component3.rect;
				log.LogInfo((object)$"BifrostConnect: Layout rebuilt. Total content height: {((Rect)(ref rect)).height}");
			}
			_customMenuPanel.SetActive(false);
		}

		private static void FilterServerRows(string query)
		{
			MenuEscapeHandler.ResetSelection();
			string value = query?.Trim();
			foreach (ServerRowUI serverRow in _serverRows)
			{
				if (!((Object)(object)serverRow.RowObject == (Object)null))
				{
					if (string.IsNullOrEmpty(value))
					{
						serverRow.RowObject.SetActive(true);
						continue;
					}
					bool active = (serverRow.Server.Name != null && serverRow.Server.Name.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0) || (serverRow.Server.IP != null && serverRow.Server.IP.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0) || (!string.IsNullOrEmpty(serverRow.Server.ModifierSummary) && serverRow.Server.ModifierSummary.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0);
					serverRow.RowObject.SetActive(active);
				}
			}
			if ((Object)(object)_contentRect != (Object)null)
			{
				LayoutRebuilder.ForceRebuildLayoutImmediate(_contentRect);
			}
		}

		public static void BuildConfirmationPanel(FejdStartup instance, ServerEntry server)
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Expected O, but got Unknown
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			//IL_0430: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_045f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0465: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f7: Expected O, but got Unknown
			//IL_0551: Unknown result type (might be due to invalid IL or missing references)
			//IL_0560: Unknown result type (might be due to invalid IL or missing references)
			//IL_057a: Unknown result type (might be due to invalid IL or missing references)
			//IL_059a: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0603: Unknown result type (might be due to invalid IL or missing references)
			//IL_0612: Unknown result type (might be due to invalid IL or missing references)
			//IL_0621: Unknown result type (might be due to invalid IL or missing references)
			//IL_0659: Unknown result type (might be due to invalid IL or missing references)
			//IL_0663: Expected O, but got Unknown
			//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_074c: Unknown result type (might be due to invalid IL or missing references)
			//IL_075b: Unknown result type (might be due to invalid IL or missing references)
			//IL_076a: Unknown result type (might be due to invalid IL or missing references)
			//IL_078f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0799: Expected O, but got Unknown
			//IL_0861: Unknown result type (might be due to invalid IL or missing references)
			//IL_0870: Unknown result type (might be due to invalid IL or missing references)
			//IL_087f: Unknown result type (might be due to invalid IL or missing references)
			//IL_089f: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_096f: Unknown result type (might be due to invalid IL or missing references)
			//IL_097e: Unknown result type (might be due to invalid IL or missing references)
			//IL_098d: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a24: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a33: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a42: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a62: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a68: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b14: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b1e: Expected O, but got Unknown
			//IL_0d13: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d22: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d31: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d71: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d7b: Expected O, but got Unknown
			//IL_0d99: Unknown result type (might be due to invalid IL or missing references)
			//IL_0da8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0db7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b54: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b63: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b72: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bb2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bbc: Expected O, but got Unknown
			//IL_0bda: Unknown result type (might be due to invalid IL or missing references)
			//IL_0be9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bf8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0de5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0df0: Expected O, but got Unknown
			//IL_0c5b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c65: Expected O, but got Unknown
			//IL_0c83: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c92: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ca1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e13: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e22: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e31: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e56: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e60: Expected O, but got Unknown
			//IL_0e7e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e8d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e9c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ec1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ecb: Expected O, but got Unknown
			//IL_0ccf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cda: Expected O, but got Unknown
			if ((Object)(object)_confirmPanel != (Object)null)
			{
				Object.Destroy((Object)(object)_confirmPanel);
			}
			object obj;
			if (!((Object)(object)GUIManager.CustomGUIFront != (Object)null))
			{
				GameObject mainMenu = instance.m_mainMenu;
				obj = ((mainMenu != null) ? mainMenu.transform.parent : null);
			}
			else
			{
				obj = GUIManager.CustomGUIFront.transform;
			}
			Transform val = (Transform)obj;
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)"No suitable GUI root/parent found for confirmation panel.");
				return;
			}
			ModCompatibilityHelper.UpdateServerModStatus(server);
			WorldModifierHelper.UpdateModifierStrings(server);
			_confirmPanel = GUIManager.Instance.CreateWoodpanel(val, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 500f, 550f);
			_confirmPanel.AddComponent<MenuEscapeHandler>().Instance = instance;
			GUIManager.Instance.CreateText("Join Server", _confirmPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -35f), GUIManager.Instance.AveriaSerifBold, 24, GUIManager.Instance.ValheimOrange, true, Color.black, 400f, 40f, false);
			GUIManager.Instance.CreateText(server.Name, _confirmPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -75f), GUIManager.Instance.AveriaSerifBold, 22, Color.white, true, Color.black, 460f, 35f, false);
			string text;
			if (server.IsQuerying)
			{
				text = "Status:  <color=#CCCCCC>Checking status...</color>";
			}
			else if (!server.IsOnline)
			{
				text = ((!server.StatusUncertain) ? "Status:  <color=#E07070>Offline</color>" : (server.IsQuerying ? "Status:  <color=#E0C060>Status unknown (Verifying...)</color>" : "Status:  <color=#E0C060>Status unknown (Direct connect available)</color>"));
			}
			else
			{
				string arg = ((server.PingMs >= 0) ? $", {server.PingMs}ms" : "");
				string text2 = (server.HasPlayerCount ? $" ({server.CurrentPlayers}/{server.MaxPlayers} players{arg})" : ((server.PingMs >= 0) ? $" ({server.PingMs}ms)" : ""));
				text = "Status:  <color=#70E070>Online</color>" + text2;
			}
			Text component = GUIManager.Instance.CreateText(text, _confirmPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(-40f, -112f), GUIManager.Instance.AveriaSerif, 18, new Color(0.9f, 0.9f, 0.9f), true, Color.black, 360f, 30f, false).GetComponent<Text>();
			if ((Object)(object)component != (Object)null)
			{
				component.supportRichText = true;
			}
			_confirmStatusText = component;
			GameObject val2 = GUIManager.Instance.CreateButton("Recheck", _confirmPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(185f, -112f), 65f, 26f);
			Button recheckBtn = val2.GetComponent<Button>();
			Text recheckBtnText = val2.GetComponentInChildren<Text>();
			((UnityEvent)recheckBtn.onClick).AddListener((UnityAction)delegate
			{
				if ((Object)(object)recheckBtnText != (Object)null)
				{
					recheckBtnText.text = "...";
				}
				((Selectable)recheckBtn).interactable = false;
				RecheckSingleServer(instance, server, delegate
				{
					if ((Object)(object)recheckBtnText != (Object)null)
					{
						recheckBtnText.text = "Recheck";
					}
					((Selectable)recheckBtn).interactable = true;
				});
			});
			GUIManager.Instance.CreateText($"Address:  {server.IP}:{server.Port}", _confirmPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(-40f, -147f), GUIManager.Instance.AveriaSerif, 18, new Color(0.9f, 0.9f, 0.9f), true, Color.black, 360f, 30f, false);
			GameObject val3 = GUIManager.Instance.CreateButton("Copy", _confirmPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(185f, -147f), 65f, 26f);
			Button component2 = val3.GetComponent<Button>();
			Text copyAddrText = val3.GetComponentInChildren<Text>();
			((UnityEvent)component2.onClick).AddListener((UnityAction)delegate
			{
				GUIUtility.systemCopyBuffer = $"{server.IP}:{server.Port}";
				if ((Object)(object)copyAddrText != (Object)null)
				{
					copyAddrText.text = "Copied!";
					MenuEscapeHandler.RunDelayed(1.5f, delegate
					{
						if ((Object)(object)copyAddrText != (Object)null)
						{
							copyAddrText.text = "Copy";
						}
					});
				}
			});
			string rawPass = server.Password ?? string.Empty;
			bool flag = !string.IsNullOrEmpty(rawPass);
			bool isPassRevealed = false;
			GameObject val4 = GUIManager.Instance.CreateText(flag ? "Password:  •••••••• (Saved)" : "Password:  None", _confirmPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(flag ? (-40f) : 0f, -182f), GUIManager.Instance.AveriaSerif, 18, new Color(0.9f, 0.9f, 0.9f), true, Color.black, flag ? 360f : 440f, 30f, false);
			Text passTextComp = val4.GetComponent<Text>();
			if (flag)
			{
				GameObject val5 = GUIManager.Instance.CreateButton("Show", _confirmPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(185f, -182f), 65f, 26f);
				Button component3 = val5.GetComponent<Button>();
				Text toggleText = val5.GetComponentInChildren<Text>();
				((UnityEvent)component3.onClick).AddListener((UnityAction)delegate
				{
					isPassRevealed = !isPassRevealed;
					if ((Object)(object)toggleText != (Object)null)
					{
						toggleText.text = (isPassRevealed ? "Hide" : "Show");
					}
					if ((Object)(object)passTextComp != (Object)null)
					{
						passTextComp.text = (isPassRevealed ? ("Password:  " + rawPass) : "Password:  •••••••• (Saved)");
					}
				});
			}
			string lastCharacterName = server.LastCharacterName;
			bool flag2 = !string.IsNullOrEmpty(lastCharacterName);
			Text component4 = GUIManager.Instance.CreateText(flag2 ? ("Character:  <color=#FFD700>" + lastCharacterName + "</color>") : "Character:  <color=#A0A0A0>None (Choose on connect)</color>", _confirmPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(-40f, -217f), GUIManager.Instance.AveriaSerif, 18, new Color(0.9f, 0.9f, 0.9f), true, Color.black, 360f, 30f, false).GetComponent<Text>();
			if ((Object)(object)component4 != (Object)null)
			{
				component4.supportRichText = true;
			}
			((UnityEvent)GUIManager.Instance.CreateButton(flag2 ? "Change" : "Select", _confirmPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(185f, -217f), 65f, 26f).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				OpenCharacterSelectModal(instance, server);
			});
			string text3;
			if (string.IsNullOrEmpty(server.ModifierSummary))
			{
				text3 = ((!server.IsOnline) ? "Modifiers:  <color=#A0A0A0>Unknown (Offline)</color>" : "Modifiers:  <color=#A0A0A0>Standard / Default</color>");
			}
			else
			{
				string text4 = ((!string.IsNullOrEmpty(server.ModifierDetails)) ? (" (" + server.ModifierDetails.Replace("\n", ", ") + ")") : "");
				text3 = "Modifiers:  <color=#FFD700>" + server.ModifierSummary + "</color><size=13><color=#CCCCCC>" + text4 + "</color></size>";
			}
			Text component5 = GUIManager.Instance.CreateText(text3, _confirmPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -252f), GUIManager.Instance.AveriaSerif, 17, new Color(0.9f, 0.9f, 0.9f), true, Color.black, 440f, 30f, false).GetComponent<Text>();
			if ((Object)(object)component5 != (Object)null)
			{
				component5.supportRichText = true;
			}
			string text5 = ((!server.HasModRequirements) ? "Mods:  <color=#A0A0A0>No required mods specified</color>" : ((server.MissingMods.Count != 0) ? $"Mods:  <color=#E07070>Missing {server.MissingMods.Count} Required Mod(s)</color>" : $"Mods:  <color=#70E070>Compatible ({server.MatchedMods.Count}/{server.RequiredMods.Count} installed)</color>"));
			Text component6 = GUIManager.Instance.CreateText(text5, _confirmPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -287f), GUIManager.Instance.AveriaSerif, 18, new Color(0.9f, 0.9f, 0.9f), true, Color.black, 440f, 30f, false).GetComponent<Text>();
			if ((Object)(object)component6 != (Object)null)
			{
				component6.supportRichText = true;
			}
			if (!string.IsNullOrEmpty(server.Notes))
			{
				Text component7 = GUIManager.Instance.CreateText("Notes:  " + server.Notes, _confirmPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -322f), GUIManager.Instance.AveriaSerif, 16, new Color(0.85f, 0.85f, 0.85f), true, Color.black, 440f, 40f, false).GetComponent<Text>();
				if ((Object)(object)component7 != (Object)null)
				{
					component7.fontStyle = (FontStyle)2;
				}
			}
			float num = (string.IsNullOrEmpty(server.Notes) ? (-327f) : (-362f));
			((UnityEvent)GUIManager.Instance.CreateButton("Check Mods", _confirmPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, num), 200f, 32f).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				OpenModCheckModal(instance, server);
			});
			if (flag2)
			{
				GameObject connectBtnObj = GUIManager.Instance.CreateButton("Connect", _confirmPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(-150f, 95f), 140f, 42f);
				Button connectBtn = connectBtnObj.GetComponent<Button>();
				((UnityEvent)connectBtn.onClick).AddListener((UnityAction)delegate
				{
					Text componentInChildren = connectBtnObj.GetComponentInChildren<Text>();
					if ((Object)(object)componentInChildren != (Object)null)
					{
						componentInChildren.text = "Connecting...";
					}
					((Selectable)connectBtn).interactable = false;
					ConnectToServer(instance, server);
				});
				GameObject val6 = GUIManager.Instance.CreateButton("Change Character", _confirmPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, 95f), 150f, 42f);
				Text changeCharText = val6.GetComponentInChildren<Text>();
				if ((Object)(object)changeCharText != (Object)null)
				{
					changeCharText.fontSize = 14;
				}
				Button changeCharBtn = val6.GetComponent<Button>();
				((UnityEvent)changeCharBtn.onClick).AddListener((UnityAction)delegate
				{
					if ((Object)(object)changeCharText != (Object)null)
					{
						changeCharText.text = "Connecting...";
					}
					((Selectable)changeCharBtn).interactable = false;
					ConnectToServer(instance, server, skipAutoStart: true);
				});
				ButtonClickedEvent onClick = GUIManager.Instance.CreateButton("Back", _confirmPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(150f, 95f), 140f, 42f).GetComponent<Button>().onClick;
				object obj2 = <>O.<1>__CloseConfirmation;
				if (obj2 == null)
				{
					UnityAction val7 = CloseConfirmation;
					<>O.<1>__CloseConfirmation = val7;
					obj2 = (object)val7;
				}
				((UnityEvent)onClick).AddListener((UnityAction)obj2);
			}
			else
			{
				GameObject connectBtnObj2 = GUIManager.Instance.CreateButton("Connect", _confirmPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(-105f, 95f), 170f, 42f);
				Button connectBtn2 = connectBtnObj2.GetComponent<Button>();
				((UnityEvent)connectBtn2.onClick).AddListener((UnityAction)delegate
				{
					Text componentInChildren = connectBtnObj2.GetComponentInChildren<Text>();
					if ((Object)(object)componentInChildren != (Object)null)
					{
						componentInChildren.text = "Connecting...";
					}
					((Selectable)connectBtn2).interactable = false;
					ConnectToServer(instance, server);
				});
				ButtonClickedEvent onClick2 = GUIManager.Instance.CreateButton("Back", _confirmPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(105f, 95f), 170f, 42f).GetComponent<Button>().onClick;
				object obj3 = <>O.<1>__CloseConfirmation;
				if (obj3 == null)
				{
					UnityAction val8 = CloseConfirmation;
					<>O.<1>__CloseConfirmation = val8;
					obj3 = (object)val8;
				}
				((UnityEvent)onClick2).AddListener((UnityAction)obj3);
			}
			((UnityEvent)GUIManager.Instance.CreateButton("Edit", _confirmPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(-105f, 45f), 170f, 38f).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				OpenEditServerModal(instance, server);
			});
			((UnityEvent)GUIManager.Instance.CreateButton("Delete", _confirmPanel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(105f, 45f), 170f, 38f).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				PromptDeleteServer(instance, server);
			});
			_confirmPanel.SetActive(false);
		}

		public static void OpenModCheckModal(FejdStartup instance, ServerEntry server)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: 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_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: 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_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Expected O, but got Unknown
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Expected O, but got Unknown
			//IL_0451: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_047d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0489: Unknown result type (might be due to invalid IL or missing references)
			//IL_0495: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Expected O, but got Unknown
			//IL_0533: Unknown result type (might be due to invalid IL or missing references)
			//IL_053a: Expected O, but got Unknown
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_0578: Unknown result type (might be due to invalid IL or missing references)
			//IL_058d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f0: Expected O, but got Unknown
			//IL_060c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0617: Unknown result type (might be due to invalid IL or missing references)
			//IL_0621: Unknown result type (might be due to invalid IL or missing references)
			//IL_0650: Unknown result type (might be due to invalid IL or missing references)
			//IL_0655: Unknown result type (might be due to invalid IL or missing references)
			//IL_0668: Unknown result type (might be due to invalid IL or missing references)
			//IL_0672: Unknown result type (might be due to invalid IL or missing references)
			//IL_067e: Unknown result type (might be due to invalid IL or missing references)
			//IL_068a: Unknown result type (might be due to invalid IL or missing references)
			//IL_072e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0735: Expected O, but got Unknown
			//IL_097f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0986: Expected O, but got Unknown
			//IL_09d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a00: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a05: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a18: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a2a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a3f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a53: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0789: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b0a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b19: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b28: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0812: Unknown result type (might be due to invalid IL or missing references)
			//IL_0826: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b5a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b5f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b65: Expected O, but got Unknown
			if ((Object)(object)_modCheckModal != (Object)null)
			{
				Object.Destroy((Object)(object)_modCheckModal);
			}
			if ((Object)(object)_confirmPanel != (Object)null)
			{
				_confirmPanel.SetActive(false);
			}
			object obj;
			if (!((Object)(object)GUIManager.CustomGUIFront != (Object)null))
			{
				GameObject mainMenu = instance.m_mainMenu;
				obj = ((mainMenu != null) ? mainMenu.transform.parent : null);
			}
			else
			{
				obj = GUIManager.CustomGUIFront.transform;
			}
			Transform val = (Transform)obj;
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)"No suitable GUI root/parent found for mod check modal.");
				return;
			}
			_modCheckModal = GUIManager.Instance.CreateWoodpanel(val, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 560f, 580f);
			_modCheckModal.AddComponent<MenuEscapeHandler>().Instance = instance;
			GUIManager.Instance.CreateText("Mod Compatibility", _modCheckModal.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -32f), GUIManager.Instance.AveriaSerifBold, 24, GUIManager.Instance.ValheimOrange, true, Color.black, 460f, 35f, false);
			GUIManager.Instance.CreateText("Server: " + server.Name, _modCheckModal.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -68f), GUIManager.Instance.AveriaSerifBold, 18, Color.white, true, Color.black, 460f, 25f, false);
			string text;
			if (server.HasModRequirements)
			{
				text = ((server.MissingMods.Count != 0) ? $"<color=#E07070>✖ Missing {server.MissingMods.Count} of {server.RequiredMods.Count} required mods!</color>\nInstall the missing mods in your mod manager before connecting." : $"<color=#70E070>✔ All {server.RequiredMods.Count} required mods are installed and ready to play!</color>");
			}
			else
			{
				int count = ModCompatibilityHelper.GetInstalledPlugins().Count;
				text = $"No specific required mods are configured for this server.\nTotal mods loaded in active profile: <color=#70E070>{count}</color>";
			}
			Text component = GUIManager.Instance.CreateText(text, _modCheckModal.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -108f), GUIManager.Instance.AveriaSerif, 14, new Color(0.9f, 0.9f, 0.9f), true, Color.black, 500f, 40f, false).GetComponent<Text>();
			if ((Object)(object)component != (Object)null)
			{
				component.supportRichText = true;
				component.alignment = (TextAnchor)4;
			}
			GameObject val2 = new GameObject("Mod_ScrollView", new Type[4]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(RectMask2D),
				typeof(ScrollRect)
			});
			val2.transform.SetParent(_modCheckModal.transform, false);
			RectTransform component2 = val2.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0.5f, 0.5f);
			component2.anchorMax = new Vector2(0.5f, 0.5f);
			component2.pivot = new Vector2(0.5f, 0.5f);
			component2.anchoredPosition = new Vector2(0f, -20f);
			component2.sizeDelta = new Vector2(480f, 320f);
			Image component3 = val2.GetComponent<Image>();
			((Graphic)component3).color = new Color(0f, 0f, 0f, 0.3f);
			((Graphic)component3).raycastTarget = true;
			ScrollRect component4 = val2.GetComponent<ScrollRect>();
			component4.horizontal = false;
			component4.vertical = true;
			component4.scrollSensitivity = 35f;
			component4.movementType = (MovementType)2;
			component4.viewport = component2;
			GameObject val3 = new GameObject("Content", new Type[3]
			{
				typeof(RectTransform),
				typeof(VerticalLayoutGroup),
				typeof(ContentSizeFitter)
			});
			val3.transform.SetParent(val2.transform, false);
			RectTransform component5 = val3.GetComponent<RectTransform>();
			component5.anchorMin = new Vector2(0f, 1f);
			component5.anchorMax = new Vector2(1f, 1f);
			component5.pivot = new Vector2(0.5f, 1f);
			component5.anchoredPosition = Vector2.zero;
			component5.sizeDelta = Vector2.zero;
			VerticalLayoutGroup component6 = val3.GetComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component6).spacing = 6f;
			((LayoutGroup)component6).padding = new RectOffset(10, 10, 8, 8);
			((LayoutGroup)component6).childAlignment = (TextAnchor)1;
			((HorizontalOrVerticalLayoutGroup)component6).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component6).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component6).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)component6).childForceExpandHeight = false;
			ContentSizeFitter component7 = val3.GetComponent<ContentSizeFitter>();
			component7.horizontalFit = (FitMode)0;
			component7.verticalFit = (FitMode)2;
			component4.content = component5;
			GameObject val4 = new GameObject("Mod_Scrollbar", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(Scrollbar)
			});
			val4.transform.SetParent(_modCheckModal.transform, false);
			RectTransform component8 = val4.GetComponent<RectTransform>();
			component8.anchorMin = new Vector2(0.5f, 0.5f);
			component8.anchorMax = new Vector2(0.5f, 0.5f);
			component8.pivot = new Vector2(0.5f, 0.5f);
			component8.anchoredPosition = new Vector2(245f, -20f);
			component8.sizeDelta = new Vector2(12f, 310f);
			Scrollbar component9 = val4.GetComponent<Scrollbar>();
			component9.direction = (Direction)2;
			GameObject val5 = new GameObject("Sliding Area", new Type[1] { typeof(RectTransform) });
			val5.transform.SetParent(val4.transform, false);
			RectTransform component10 = val5.GetComponent<RectTransform>();
			component10.anchorMin = Vector2.zero;
			component10.anchorMax = Vector2.one;
			component10.sizeDelta = Vector2.zero;
			GameObject val6 = new GameObject("Handle", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val6.transform.SetParent(val5.transform, false);
			RectTransform component11 = val6.GetComponent<RectTransform>();
			component11.anchorMin = Vector2.zero;
			component11.anchorMax = Vector2.one;
			component11.sizeDelta = Vector2.zero;
			Image component12 = val6.GetComponent<Image>();
			component9.handleRect = component11;
			((Selectable)component9).targetGraphic = (Graphic)(object)component12;
			GUIManager.Instance.ApplyScrollbarStyle(component9);
			component4.verticalScrollbar = component9;
			component4.verticalScrollbarVisibility = (ScrollbarVisibility)1;
			if (server.HasModRequirements)
			{
				foreach (ModCheckResult item in ModCompatibilityHelper.CheckServerMods(server))
				{
					GameObject val7 = new GameObject("Mod_" + item.RequiredModName, new Type[3]
					{
						typeof(RectTransform),
						typeof(Image),
						typeof(LayoutElement)
					});
					val7.transform.SetParent(val3.transform, false);
					LayoutElement component13 = val7.GetComponent<LayoutElement>();
					component13.minHeight = 36f;
					component13.preferredHeight = 36f;
					((Graphic)val7.GetComponent<Image>()).color = (item.IsInstalled ? new Color(0.1f, 0.35f, 0.1f, 0.4f) : new Color(0.35f, 0.1f, 0.1f, 0.4f));
					GameObject val8 = new GameObject("Label", new Type[2]
					{
						typeof(RectTransform),
						typeof(Text)
					});
					val8.transform.SetParent(val7.transform, false);
					RectTransform component14 = val8.GetComponent<RectTransform>();
					component14.anchorMin = Vector2.zero;
					component14.anchorMax = Vector2.one;
					component14.offsetMin = new Vector2(10f, 0f);
					component14.offsetMax = new Vector2(-10f, 0f);
					Text component15 = val8.GetComponent<Text>();
					component15.font = GUIManager.Instance.AveriaSerif ?? Resources.GetBuiltinResource<Font>("Arial.ttf");
					component15.fontSize = 14;
					component15.supportRichText = true;
					component15.alignment = (TextAnchor)3;
					if (item.IsInstalled)
					{
						component15.text = "<color=#70E070>✔ " + item.InstalledName + "</color>  <color=#A0E0A0>(v" + item.InstalledVersion + ")</color>";
					}
					else
					{
						component15.text = "<color=#E07070>✖ " + item.RequiredModName + "</color>  <color=#FF9090>[MISSING]</color>";
					}
				}
			}
			else
			{
				foreach (PluginInfo item2 in ModCompatibilityHelper.GetInstalledPlugins().Values.OrderBy((PluginInfo p) => p.Metadata.Name).ToList())
				{
					GameObject val9 = new GameObject("Mod_" + item2.Metadata.GUID, new Type[3]
					{
						typeof(RectTransform),
						typeof(Image),
						typeof(LayoutElement)
					});
					val9.transform.SetParent(val3.transform, false);
					LayoutElement component16 = val9.GetComponent<LayoutElement>();
					component16.minHeight = 34f;
					component16.preferredHeight = 34f;
					((Graphic)val9.GetComponent<Image>()).color = new Color(0.15f, 0.15f, 0.15f, 0.35f);
					GameObject val10 = new GameObject("Label", new Type[2]
					{
						typeof(RectTransform),
						typeof(Text)
					});
					val10.transform.SetParent(val9.transform, false);
					RectTransform component17 = val10.GetComponent<RectTransform>();
					component17.anchorMin = Vector2.zero;
					component17.anchorMax = Vector2.one;
					component17.offsetMin = new Vector2(10f, 0f);
					component17.offsetMax = new Vector2(-10f, 0f);
					Text component18 = val10.GetComponent<Text>();
					component18.font = GUIManager.Instance.AveriaSerif ?? Resources.GetBuiltinResource<Font>("Arial.ttf");
					component18.fontSize = 13;
					component18.supportRichText = true;
					component18.alignment = (TextAnchor)3;
					component18.text = $"<color=#E0E0E0>✔ {item2.Metadata.Name}</color>  <color=#888888>(v{item2.Metadata.Version})</color>";
				}
			}
			LayoutRebuilder.ForceRebuildLayoutImmediate(component5);
			component4.verticalNormalizedPosition = 1f;
			ButtonClickedEvent onClick = GUIManager.Instance.CreateButton("Back", _modCheckModal.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, 40f), 160f, 42f).GetComponent<Button>().onClick;
			object obj2 = <>c.<>9__33_0;
			if (obj2 == null)
			{
				UnityAction val11 = delegate
				{
					CloseModCheckModal();
					if ((Object)(object)_confirmPanel != (Object)null)
					{
						_confirmPanel.SetActive(true);
						Canvas.ForceUpdateCanvases();
					}
				};
				<>c.<>9__33_0 = val11;
				obj2 = (object)val11;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj2);
			_modCheckModal.SetActive(true);
		}

		public static void CloseModCheckModal()
		{
			if ((Object)(object)_modCheckModal != (Object)null)
			{
				Object.Destroy((Object)(object)_modCheckModal);
				_modCheckModal = null;
			}
		}

		public static void OpenCharacterSelectModal(FejdStartup instance, ServerEntry server)
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Expected O, but got Unknown
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: 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_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Expected O, but got Unknown
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ea: Expected O, but got Unknown
			//IL_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0460: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			//IL_0477: Unknown result type (might be due to invalid IL or missing references)
			//IL_05df: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e6: Expected O, but got Unknown
			//IL_060f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0624: Unknown result type (might be due to invalid IL or missing references)
			//IL_0639: Unknown result type (might be due to invalid IL or missing references)
			//IL_064e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0662: Unknown result type (might be due to invalid IL or missing references)
			//IL_0695: Unknown result type (might be due to invalid IL or missing references)
			//IL_069c: Expected O, but got Unknown
			//IL_06b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0701: Unknown result type (might be due to invalid IL or missing references)
			//IL_0714: Unknown result type (might be due to invalid IL or missing references)
			//IL_071e: Unknown result type (might be due to invalid IL or missing references)
			//IL_072a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0736: Unknown result type (might be due to invalid IL or missing references)
			//IL_0794: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e1: Expected O, but got Unknown
			//IL_07ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_080e: Unknown result type (might be due to invalid IL or missing references)
			//IL_081d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0842: Unknown result type (might be due to invalid IL or missing references)
			//IL_084c: Expected O, but got Unknown
			//IL_050c: Unknown result type (might be due to invalid IL or missing references)
			//IL_051b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_0580: Unknown result type (might be due to invalid IL or missing references)
			//IL_058a: Expected O, but got Unknown
			if ((Object)(object)_charSelectModal != (Object)null)
			{
				Object.Destroy((Object)(object)_charSelectModal);
			}
			if ((Object)(object)_confirmPanel != (Object)null)
			{