Decompiled source of BigWalk Public Lobbies v1.0.2

BigWalkPublicLobbies.dll

Decompiled 3 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Epic.OnlineServices.Lobby;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Threading.Tasks;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BigWalkPublicLobbies")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+914e14154fb5064a739fcebed9b6462f70dbef73")]
[assembly: AssemblyProduct("BigWalkPublicLobbies")]
[assembly: AssemblyTitle("BigWalkPublicLobbies")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BigWalkPublicLobbies;

public static class LobbyScanner
{
	private static readonly Dictionary<string, RoomInfo> Cache = new Dictionary<string, RoomInfo>();

	private static Task<List<LobbyInfo>> _lobbyTask;

	private static Task<List<HouseSessionInfo>> _sessionTask;

	public static void StartRound(bool clearCache, bool includeSession)
	{
		if (clearCache)
		{
			Cache.Clear();
		}
		try
		{
			EOSLobbyManager instance = EOSLobbyManager.Instance;
			_lobbyTask = (((Object)(object)instance != (Object)null) ? instance.FindPublicLobbies() : null);
		}
		catch (Exception ex)
		{
			DebugLog.Warn("发起 Lobby 搜索失败: " + ex.Message);
			_lobbyTask = null;
		}
		try
		{
			object sessionTask;
			if (!includeSession)
			{
				sessionTask = null;
			}
			else
			{
				EOSSessionManager instance2 = EOSSessionManager.Instance;
				sessionTask = ((instance2 != null) ? instance2.FindAllPublicSessions() : null);
			}
			_sessionTask = (Task<List<HouseSessionInfo>>)sessionTask;
		}
		catch (Exception ex2)
		{
			DebugLog.Warn("发起 Session 搜索失败: " + ex2.Message);
			_sessionTask = null;
		}
	}

	public static bool TryFinishRound()
	{
		Task<List<LobbyInfo>> lobbyTask = _lobbyTask;
		if (lobbyTask == null)
		{
			_sessionTask = null;
			return true;
		}
		if (!((Task)lobbyTask).IsCompleted)
		{
			return false;
		}
		if (_sessionTask != null && !((Task)_sessionTask).IsCompleted)
		{
			return false;
		}
		if (((Task)lobbyTask).IsFaulted)
		{
			AggregateException exception = ((Task)lobbyTask).Exception;
			object obj;
			if (exception == null)
			{
				obj = null;
			}
			else
			{
				Exception innerException = ((Exception)exception).InnerException;
				obj = ((innerException != null) ? innerException.Message : null);
			}
			if (obj == null)
			{
				AggregateException exception2 = ((Task)lobbyTask).Exception;
				obj = ((exception2 != null) ? ((Exception)exception2).Message : null);
			}
			DebugLog.Warn("Lobby 公开房间搜索失败: " + (string?)obj);
		}
		else
		{
			try
			{
				List<LobbyInfo> result = lobbyTask.Result;
				if (result != null)
				{
					DebugLog.Debug($"[LobbyScanner] Lobby 返回 {result.Count} 条");
					for (int i = 0; i < result.Count; i++)
					{
						LobbyInfo val = result[i];
						if (val != null)
						{
							AddOrMerge(new RoomInfo
							{
								JoinCode = val.joinCode,
								WorldName = val.worldName,
								HostName = val.userName,
								FromSession = false
							});
						}
					}
				}
			}
			catch (Exception ex)
			{
				DebugLog.Warn("处理 Lobby 搜索结果失败: " + ex.Message);
			}
		}
		Task<List<HouseSessionInfo>> sessionTask = _sessionTask;
		if (sessionTask != null)
		{
			if (((Task)sessionTask).IsFaulted)
			{
				AggregateException exception3 = ((Task)sessionTask).Exception;
				object obj2;
				if (exception3 == null)
				{
					obj2 = null;
				}
				else
				{
					Exception innerException2 = ((Exception)exception3).InnerException;
					obj2 = ((innerException2 != null) ? innerException2.Message : null);
				}
				if (obj2 == null)
				{
					AggregateException exception4 = ((Task)sessionTask).Exception;
					obj2 = ((exception4 != null) ? ((Exception)exception4).Message : null);
				}
				DebugLog.Warn("Session 公开房间搜索失败: " + (string?)obj2);
			}
			else
			{
				try
				{
					List<HouseSessionInfo> result2 = sessionTask.Result;
					if (result2 != null)
					{
						DebugLog.Debug($"[LobbyScanner] Session 返回 {result2.Count} 条");
						for (int j = 0; j < result2.Count; j++)
						{
							HouseSessionInfo val2 = result2[j];
							if (val2 != null)
							{
								AddOrMerge(new RoomInfo
								{
									JoinCode = val2.joinCode,
									WorldName = val2.worldName,
									HostName = val2.userName,
									FromSession = true
								});
							}
						}
					}
				}
				catch (Exception ex2)
				{
					DebugLog.Warn("处理 Session 搜索结果失败: " + ex2.Message);
				}
			}
			_sessionTask = null;
		}
		_lobbyTask = null;
		return true;
	}

	public static List<RoomInfo> GetRoomsSnapshot()
	{
		List<RoomInfo> list = (from r in Cache.Values
			where !string.IsNullOrEmpty(r.JoinCode)
			select new RoomInfo
			{
				JoinCode = r.JoinCode,
				WorldName = r.WorldName,
				HostName = r.HostName,
				FromSession = r.FromSession
			}).OrderBy<RoomInfo, string>((RoomInfo r) => r.WorldName, StringComparer.OrdinalIgnoreCase).ToList();
		DebugLog.Debug($"[LobbyScanner] 当前缓存累计 {list.Count} 个公开房间");
		return list;
	}

	private static void AddOrMerge(RoomInfo room)
	{
		if (string.IsNullOrEmpty(room.JoinCode))
		{
			return;
		}
		if (Cache.TryGetValue(room.JoinCode, out var value))
		{
			if (string.IsNullOrEmpty(value.HostName) && !string.IsNullOrEmpty(room.HostName))
			{
				value.HostName = room.HostName;
				value.WorldName = (string.IsNullOrEmpty(value.WorldName) ? room.WorldName : value.WorldName);
			}
		}
		else
		{
			Cache[room.JoinCode] = room;
		}
	}
}
internal static class LobbyScanPatch
{
	public const uint MaxResults = 200u;

	public static void Prefix(ref uint maxResults)
	{
		if (maxResults < 200)
		{
			maxResults = 200u;
		}
	}

	public static void Apply(Harmony harmony)
	{
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Expected O, but got Unknown
		try
		{
			MethodInfo methodInfo = AccessTools.Method(typeof(EOSLobbyManager), "FindLobbies", new Type[2]
			{
				typeof(uint),
				typeof(Action<LobbySearch>)
			}, (Type[])null);
			if (methodInfo == null)
			{
				DebugLog.Error("[Patch] 找不到 EOSLobbyManager.FindLobbies(uint, Action<LobbySearch>),房间上限保持游戏默认 16(请反馈模组作者)");
				return;
			}
			harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(LobbyScanPatch).GetMethod("Prefix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			DebugLog.Info($"[Patch] 已 patch EOSLobbyManager.FindLobbies:maxResults → {200}");
		}
		catch (Exception ex)
		{
			DebugLog.Error("[Patch] Apply 失败: " + ex);
		}
	}
}
internal static class ModState
{
	public static PublicLobbyPanel Panel;

	public static TitleMenu TitleMenu;

	public static GameObject StartButtons;

	public static int SearchRounds = 3;
}
internal static class ModText
{
	public static bool IsChinese;

	private static bool _init;

	private static TMP_Text _cachedSettingsTmp;

	public static bool Poll()
	{
		bool flag = DetectChinese();
		if (!_init || flag != IsChinese)
		{
			_init = true;
			IsChinese = flag;
			DebugLog.Info("[本地化] 主菜单语言 → 中文=" + (flag ? "是" : "否"));
			return true;
		}
		return false;
	}

	public static string T(string zh, string en)
	{
		if (!IsChinese)
		{
			return en;
		}
		return zh;
	}

	private static bool DetectChinese()
	{
		try
		{
			if ((Object)(object)ModState.TitleMenu == (Object)null)
			{
				return IsChinese;
			}
			if ((Object)(object)_cachedSettingsTmp == (Object)null)
			{
				Transform val = FindChildByName(((Component)ModState.TitleMenu).transform, "SettingsButton");
				if ((Object)(object)val == (Object)null)
				{
					return IsChinese;
				}
				_cachedSettingsTmp = ((Component)val).GetComponentInChildren<TMP_Text>(true);
				if ((Object)(object)_cachedSettingsTmp == (Object)null)
				{
					return IsChinese;
				}
			}
			return ContainsChinese(_cachedSettingsTmp.text);
		}
		catch (Exception)
		{
			_cachedSettingsTmp = null;
			return IsChinese;
		}
	}

	public static bool ContainsChinese(string s)
	{
		if (string.IsNullOrEmpty(s))
		{
			return false;
		}
		foreach (char c in s)
		{
			if (c >= '一' && c <= '鿿')
			{
				return true;
			}
		}
		return false;
	}

	private static Transform FindChildByName(Transform root, string name)
	{
		if ((Object)(object)root == (Object)null)
		{
			return null;
		}
		if (((Object)root).name == name)
		{
			return root;
		}
		for (int i = 0; i < root.childCount; i++)
		{
			Transform val = FindChildByName(root.GetChild(i), name);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
		}
		return null;
	}
}
[BepInPlugin("com.bigwalk.publiclobbies", "BigWalk Public Lobbies", "1.0.2")]
public class Plugin : BasePlugin
{
	public const string GUID = "com.bigwalk.publiclobbies";

	public const string Name = "BigWalk Public Lobbies";

	public const string Version = "1.0.2";

	internal static ManualLogSource Log;

	public override void Load()
	{
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Expected O, but got Unknown
		Log = ((BasePlugin)this).Log;
		DebugLog.Verbose = ((BasePlugin)this).Config.Bind<bool>("Debug", "Verbose", false, "打印详细诊断日志(EOS 搜索、UI 结构探测、布局等)").Value;
		ModState.SearchRounds = ((BasePlugin)this).Config.Bind<int>("Search", "SearchRounds", 3, "点击一次刷新后自动执行的搜索轮数(最高上限,防死循环;轮间无人为等待,间隔仅取决于 EOS 搜索自身耗时)").Value;
		((BasePlugin)this).AddComponent<PublicLobbyMod>();
		try
		{
			LobbyScanPatch.Apply(new Harmony("com.bigwalk.publiclobbies"));
		}
		catch (Exception ex)
		{
			DebugLog.Error("Harmony 初始化失败: " + ex);
		}
		ModState.Panel = new PublicLobbyPanel();
		ModState.Panel.Hide();
		DebugLog.Info($"{"BigWalk Public Lobbies"} v{"1.0.2"} 已加载(Verbose 日志={DebugLog.Verbose})。");
	}
}
public class PublicLobbyMod : MonoBehaviour
{
	private TitleMenu _titleMenu;

	private bool _buttonInjected;

	private bool _layoutLogged;

	private bool _structureLogged;

	private GameObject _buttonTemplate;

	private GameObject _injectedButton;

	private TMP_Text _injectedTmp;

	private float _titleRetryTime;

	private float _templateRetryTime;

	private void Update()
	{
		if (ModText.Poll())
		{
			ModState.Panel?.RefreshAllTexts();
			RefreshMainButtonText();
		}
		if (ModState.Panel != null)
		{
			ModState.Panel.Tick();
		}
		if (ModState.Panel != null && ModState.Panel.IsShown && Input.GetKeyDown((KeyCode)27))
		{
			ModState.Panel.Hide();
		}
		if (_buttonInjected)
		{
			if ((Object)(object)_injectedButton == (Object)null)
			{
				DebugLog.Info("[模组] 公开房间按钮已被销毁(场景切换),等待重新注入");
				_buttonInjected = false;
			}
			return;
		}
		if ((Object)(object)_titleMenu == (Object)null)
		{
			if (Time.time < _titleRetryTime)
			{
				return;
			}
			_titleRetryTime = Time.time + 0.5f;
			_titleMenu = Object.FindObjectOfType<TitleMenu>();
			if ((Object)(object)_titleMenu == (Object)null)
			{
				ModState.TitleMenu = null;
				ModState.StartButtons = null;
				return;
			}
		}
		ModState.TitleMenu = _titleMenu;
		if ((Object)(object)ModState.StartButtons == (Object)null)
		{
			Transform val = FindChildByName(((Component)_titleMenu).transform, "StartButtons");
			if ((Object)(object)val != (Object)null)
			{
				ModState.StartButtons = ((Component)val).gameObject;
				DebugLog.Debug("[页面] 找到主菜单按钮容器 StartButtons");
			}
		}
		if (!_layoutLogged)
		{
			LogLayout();
			_layoutLogged = true;
		}
		if ((Object)(object)_buttonTemplate == (Object)null)
		{
			if (Time.time < _templateRetryTime)
			{
				return;
			}
			_templateRetryTime = Time.time + 1f;
			try
			{
				_buttonTemplate = FindJoinMenuButton(_titleMenu);
			}
			catch (Exception ex)
			{
				DebugLog.Warn("[模组] 查找「加入游戏」模板按钮失败: " + ex.Message);
				_buttonTemplate = null;
			}
		}
		if (!((Object)(object)_buttonTemplate == (Object)null))
		{
			if (!_structureLogged)
			{
				DumpUiStructure();
				_structureLogged = true;
			}
			TryInjectButton();
		}
	}

	private void DumpUiStructure()
	{
		if (!DebugLog.Verbose)
		{
			return;
		}
		try
		{
			Canvas componentInParent = ((Component)_titleMenu).GetComponentInParent<Canvas>(true);
			DebugLog.Info("[结构] 主菜单 Canvas: '" + ((componentInParent != null) ? ((Object)componentInParent).name : null) + "'(所有菜单共享)");
			DumpTree((componentInParent != null) ? ((Component)componentInParent).transform : null, 0, 4);
			GameObject buttonTemplate = _buttonTemplate;
			DumpButtonInfo((buttonTemplate != null) ? buttonTemplate.transform : null, "JoinButton模板");
		}
		catch (Exception ex)
		{
			DebugLog.Warn("[结构] 打印失败: " + ex.Message);
		}
	}

	private void DumpTree(Transform t, int depth, int maxDepth)
	{
		if (!((Object)(object)t == (Object)null) && depth <= maxDepth)
		{
			GameObject gameObject = ((Component)t).gameObject;
			DebugLog.Info($"[结构] {new string(' ', depth * 2)}{((Object)t).name} active={gameObject.activeInHierarchy} type={((object)t).GetType().Name}");
			int childCount = t.childCount;
			for (int i = 0; i < childCount; i++)
			{
				DumpTree(t.GetChild(i), depth + 1, maxDepth);
			}
		}
	}

	private void DumpButtonInfo(Transform t, string label)
	{
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0221: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: 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_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_045c: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)t == (Object)null)
		{
			return;
		}
		try
		{
			foreach (Component component5 in ((Component)t).GetComponents<Component>())
			{
				DebugLog.Info("[结构] " + label + " 组件: " + ((object)component5).GetType().FullName);
			}
			Button component = ((Component)t).GetComponent<Button>();
			if ((Object)(object)component != (Object)null)
			{
				int persistentEventCount = ((UnityEventBase)component.onClick).GetPersistentEventCount();
				for (int i = 0; i < persistentEventCount; i++)
				{
					DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(35, 4);
					defaultInterpolatedStringHandler.AppendLiteral("[结构] ");
					defaultInterpolatedStringHandler.AppendFormatted(label);
					defaultInterpolatedStringHandler.AppendLiteral(" onClick[");
					defaultInterpolatedStringHandler.AppendFormatted(i);
					defaultInterpolatedStringHandler.AppendLiteral("] target='");
					Object persistentTarget = ((UnityEventBase)component.onClick).GetPersistentTarget(i);
					defaultInterpolatedStringHandler.AppendFormatted((persistentTarget != null) ? persistentTarget.name : null);
					defaultInterpolatedStringHandler.AppendLiteral("' method='");
					defaultInterpolatedStringHandler.AppendFormatted(((UnityEventBase)component.onClick).GetPersistentMethodName(i));
					defaultInterpolatedStringHandler.AppendLiteral("'");
					DebugLog.Info(defaultInterpolatedStringHandler.ToStringAndClear());
				}
			}
			Image component2 = ((Component)t).GetComponent<Image>();
			if ((Object)(object)component2 != (Object)null)
			{
				DefaultInterpolatedStringHandler defaultInterpolatedStringHandler2 = new DefaultInterpolatedStringHandler(34, 4);
				defaultInterpolatedStringHandler2.AppendLiteral("[结构] ");
				defaultInterpolatedStringHandler2.AppendFormatted(label);
				defaultInterpolatedStringHandler2.AppendLiteral(" Image sprite='");
				Sprite sprite = component2.sprite;
				defaultInterpolatedStringHandler2.AppendFormatted((sprite != null) ? ((Object)sprite).name : null);
				defaultInterpolatedStringHandler2.AppendLiteral("' color=");
				defaultInterpolatedStringHandler2.AppendFormatted<Color>(((Graphic)component2).color);
				defaultInterpolatedStringHandler2.AppendLiteral(" type=");
				defaultInterpolatedStringHandler2.AppendFormatted<Type>(component2.type);
				DebugLog.Info(defaultInterpolatedStringHandler2.ToStringAndClear());
			}
			RectTransform component3 = ((Component)t).GetComponent<RectTransform>();
			if ((Object)(object)component3 != (Object)null)
			{
				DefaultInterpolatedStringHandler defaultInterpolatedStringHandler3 = new DefaultInterpolatedStringHandler(61, 10);
				defaultInterpolatedStringHandler3.AppendLiteral("[结构] ");
				defaultInterpolatedStringHandler3.AppendFormatted(label);
				defaultInterpolatedStringHandler3.AppendLiteral(" RectTransform anchor=(");
				defaultInterpolatedStringHandler3.AppendFormatted(component3.anchorMin.x, "F2");
				defaultInterpolatedStringHandler3.AppendLiteral(",");
				defaultInterpolatedStringHandler3.AppendFormatted(component3.anchorMin.y, "F2");
				defaultInterpolatedStringHandler3.AppendLiteral(")-(");
				defaultInterpolatedStringHandler3.AppendFormatted(component3.anchorMax.x, "F2");
				defaultInterpolatedStringHandler3.AppendLiteral(",");
				defaultInterpolatedStringHandler3.AppendFormatted(component3.anchorMax.y, "F2");
				defaultInterpolatedStringHandler3.AppendLiteral(") ");
				defaultInterpolatedStringHandler3.AppendLiteral("size=(");
				defaultInterpolatedStringHandler3.AppendFormatted(component3.sizeDelta.x, "F0");
				defaultInterpolatedStringHandler3.AppendLiteral(",");
				defaultInterpolatedStringHandler3.AppendFormatted(component3.sizeDelta.y, "F0");
				defaultInterpolatedStringHandler3.AppendLiteral(") pos=(");
				defaultInterpolatedStringHandler3.AppendFormatted(component3.anchoredPosition.x, "F0");
				defaultInterpolatedStringHandler3.AppendLiteral(",");
				defaultInterpolatedStringHandler3.AppendFormatted(component3.anchoredPosition.y, "F0");
				defaultInterpolatedStringHandler3.AppendLiteral(") parent='");
				Transform parent = ((Transform)component3).parent;
				defaultInterpolatedStringHandler3.AppendFormatted((parent != null) ? ((Object)parent).name : null);
				defaultInterpolatedStringHandler3.AppendLiteral("'");
				DebugLog.Info(defaultInterpolatedStringHandler3.ToStringAndClear());
			}
			CanvasGroup component4 = ((Component)t).GetComponent<CanvasGroup>();
			if ((Object)(object)component4 != (Object)null)
			{
				DebugLog.Info($"[结构] {label} CanvasGroup alpha={component4.alpha}");
			}
			Il2CppArrayBase<TMP_Text> componentsInChildren = ((Component)t).GetComponentsInChildren<TMP_Text>(true);
			for (int j = 0; j < componentsInChildren.Length; j++)
			{
				TMP_Text val = componentsInChildren[j];
				DefaultInterpolatedStringHandler defaultInterpolatedStringHandler4 = new DefaultInterpolatedStringHandler(40, 6);
				defaultInterpolatedStringHandler4.AppendLiteral("[结构] ");
				defaultInterpolatedStringHandler4.AppendFormatted(label);
				defaultInterpolatedStringHandler4.AppendLiteral(" TMP[");
				defaultInterpolatedStringHandler4.AppendFormatted(j);
				defaultInterpolatedStringHandler4.AppendLiteral("] text='");
				defaultInterpolatedStringHandler4.AppendFormatted(val.text);
				defaultInterpolatedStringHandler4.AppendLiteral("' font='");
				TMP_FontAsset font = val.font;
				defaultInterpolatedStringHandler4.AppendFormatted((font != null) ? ((Object)font).name : null);
				defaultInterpolatedStringHandler4.AppendLiteral("' size=");
				defaultInterpolatedStringHandler4.AppendFormatted(val.fontSize);
				defaultInterpolatedStringHandler4.AppendLiteral(" align=");
				defaultInterpolatedStringHandler4.AppendFormatted<TextAlignmentOptions>(val.alignment);
				DebugLog.Info(defaultInterpolatedStringHandler4.ToStringAndClear());
			}
		}
		catch (Exception ex)
		{
			DebugLog.Warn("[结构] " + label + " 组件解析失败: " + ex.Message);
		}
	}

	private void LogLayout()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Expected O, but got Unknown
		//IL_00ea: 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_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_0232: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Il2CppArrayBase<Button> componentsInChildren = ((Component)_titleMenu).GetComponentsInChildren<Button>(true);
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			if (log != null)
			{
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(30, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UI探测] TitleMenu 下共 ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(componentsInChildren.Length);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" 个 Button:");
				}
				log.LogInfo(val);
			}
			foreach (Button item in componentsInChildren)
			{
				RectTransform component = ((Component)item).GetComponent<RectTransform>();
				if ((Object)(object)component == (Object)null)
				{
					continue;
				}
				log = Plugin.Log;
				if (log != null)
				{
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(76, 13, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UI探测]   name='");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)((Component)item).gameObject).name);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' active=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(((Component)item).gameObject.activeInHierarchy);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("anchor=(");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(component.anchorMin.x, "F2");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(",");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(component.anchorMin.y, "F2");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")-(");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(component.anchorMax.x, "F2");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(",");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(component.anchorMax.y, "F2");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") ");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("pivot=(");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(component.pivot.x, "F2");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(",");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(component.pivot.y, "F2");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") pos=(");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(component.anchoredPosition.x, "F1");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(",");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(component.anchoredPosition.y, "F1");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") ");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("size=(");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(component.sizeDelta.x, "F0");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(",");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(component.sizeDelta.y, "F0");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") parent='");
						BepInExInfoLogInterpolatedStringHandler obj = val;
						Transform parent = ((Transform)component).parent;
						((BepInExLogInterpolatedStringHandler)obj).AppendFormatted<string>((parent != null) ? ((Object)parent).name : null);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
					}
					log.LogInfo(val);
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource log2 = Plugin.Log;
			if (log2 != null)
			{
				log2.LogWarning((object)("[UI探测] 打印布局失败: " + ex.Message));
			}
		}
	}

	private static Transform FindChildByName(Transform root, string name)
	{
		if ((Object)(object)root == (Object)null)
		{
			return null;
		}
		if (((Object)root).name == name)
		{
			return root;
		}
		int childCount = root.childCount;
		for (int i = 0; i < childCount; i++)
		{
			Transform val = FindChildByName(root.GetChild(i), name);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
		}
		return null;
	}

	private static GameObject FindJoinMenuButton(TitleMenu titleMenu)
	{
		Il2CppArrayBase<Button> componentsInChildren = ((Component)titleMenu).GetComponentsInChildren<Button>(true);
		foreach (Button item in componentsInChildren)
		{
			if (item.onClick != null && ((UnityEventBase)item.onClick).GetPersistentEventCount() != 0 && ((UnityEventBase)item.onClick).GetPersistentMethodName(0) == "GoToJoinMenu")
			{
				Object persistentTarget = ((UnityEventBase)item.onClick).GetPersistentTarget(0);
				if (persistentTarget != (Object)null && persistentTarget is TitleMenu)
				{
					return ((Component)item).gameObject;
				}
			}
		}
		foreach (Button item2 in componentsInChildren)
		{
			if (((Component)item2).gameObject.activeSelf)
			{
				return ((Component)item2).gameObject;
			}
		}
		return null;
	}

	private void TryInjectButton()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		UiStyle.Capture(_buttonTemplate);
		GameObject val = UiStyle.CreateTextButton(((Component)_titleMenu).transform, "PublicLobbiesButton", ModText.T("公开房间", "Public Lobbies"), 26f, UiStyle.TextNormal, delegate
		{
			ModState.Panel.Show();
		});
		if ((Object)(object)val == (Object)null)
		{
			DebugLog.Error("创建主菜单「公开房间」按钮失败");
			return;
		}
		_injectedButton = val;
		_injectedTmp = val.GetComponentInChildren<TMP_Text>(true);
		if ((Object)(object)_injectedTmp != (Object)null)
		{
			UiStyle.ButtonTextTemplate = ((Component)_injectedTmp).gameObject;
		}
		RectTransform component = val.GetComponent<RectTransform>();
		if ((Object)(object)component != (Object)null)
		{
			component.anchorMin = new Vector2(1f, 0.5f);
			component.anchorMax = new Vector2(1f, 0.5f);
			component.pivot = new Vector2(1f, 0.5f);
			component.sizeDelta = new Vector2(320f, 76f);
			component.anchoredPosition = new Vector2(-230f, -60f);
		}
		_buttonInjected = true;
		DebugLog.Info("[模组] 已注入「公开房间」按钮(右侧,挂在 TitleMenu 下)");
	}

	private void RefreshMainButtonText()
	{
		if ((Object)(object)_injectedTmp != (Object)null)
		{
			_injectedTmp.text = ModText.T("公开房间", "Public Lobbies");
		}
	}
}
public class PublicLobbyPanel
{
	private GameObject _root;

	private RectTransform _content;

	private TMP_InputField _searchInput;

	private TMP_Text _statusText;

	private TMP_Text _titleTmp;

	private TMP_Text _chineseOnlyTmp;

	private TMP_Text _refreshTmp;

	private TMP_Text _joinTmp;

	private TMP_Text _backTmp;

	private TMP_Text _searchPh;

	private TMP_Text _searchingText;

	private string _statusZh;

	private string _statusEn;

	private GameObject _joinButton;

	private GameObject _chineseOnlyButton;

	private GameObject _windowGo;

	private readonly List<RoomInfo> _rooms = new List<RoomInfo>();

	private readonly Dictionary<string, GameObject> _cardByKey = new Dictionary<string, GameObject>();

	private readonly List<GameObject> _hiddenMenuButtons = new List<GameObject>();

	private string _filter = "";

	private bool _chineseOnly;

	private bool _scanning;

	private int _totalRounds;

	private int _roundsDone;

	private bool _needsFinalRender;

	private RoomInfo _selected;

	private bool _uiBuilt;

	private bool _buttonsHidden;

	public bool IsShown
	{
		get
		{
			if ((Object)(object)_root != (Object)null)
			{
				return _root.activeSelf;
			}
			return false;
		}
	}

	public void Show()
	{
		EnsureUi();
		_root.SetActive(true);
		HideMainMenuButtons();
		LogLayoutProbe();
		StartScan();
	}

	public void Hide()
	{
		if ((Object)(object)_root != (Object)null)
		{
			_root.SetActive(false);
		}
		RestoreMainMenuButtons();
	}

	private void HideMainMenuButtons()
	{
		if (_buttonsHidden)
		{
			return;
		}
		_buttonsHidden = true;
		try
		{
			if ((Object)(object)ModState.StartButtons != (Object)null && ModState.StartButtons.activeSelf)
			{
				ModState.StartButtons.SetActive(false);
				DebugLog.Debug("[页面] 已隐藏 StartButtons(背景保留)");
			}
			else
			{
				if (!((Object)(object)ModState.TitleMenu != (Object)null))
				{
					return;
				}
				_hiddenMenuButtons.Clear();
				foreach (Button componentsInChild in ((Component)ModState.TitleMenu).GetComponentsInChildren<Button>(true))
				{
					if ((Object)(object)componentsInChild != (Object)null && ((Component)componentsInChild).gameObject.activeSelf && !IsOurButton(componentsInChild))
					{
						((Component)componentsInChild).gameObject.SetActive(false);
						_hiddenMenuButtons.Add(((Component)componentsInChild).gameObject);
					}
				}
				if (_hiddenMenuButtons.Count > 0)
				{
					DebugLog.Debug($"[页面] fallback:隐藏了 {_hiddenMenuButtons.Count} 个主菜单按钮");
				}
			}
		}
		catch (Exception ex)
		{
			DebugLog.Warn("[页面] 隐藏主菜单按钮失败: " + ex.Message);
		}
	}

	private static bool IsOurButton(Button b)
	{
		Canvas componentInParent = ((Component)b).GetComponentInParent<Canvas>(true);
		if ((Object)(object)componentInParent != (Object)null)
		{
			return ((Object)componentInParent).name == "PublicLobbyPanel";
		}
		return false;
	}

	private void RestoreMainMenuButtons()
	{
		if (!_buttonsHidden)
		{
			return;
		}
		_buttonsHidden = false;
		try
		{
			if ((Object)(object)ModState.StartButtons != (Object)null)
			{
				ModState.StartButtons.SetActive(true);
				DebugLog.Debug("[页面] 已恢复 StartButtons");
				return;
			}
			foreach (GameObject hiddenMenuButton in _hiddenMenuButtons)
			{
				if ((Object)(object)hiddenMenuButton != (Object)null)
				{
					hiddenMenuButton.SetActive(true);
				}
			}
			_hiddenMenuButtons.Clear();
		}
		catch (Exception ex)
		{
			DebugLog.Warn("[页面] 恢复主菜单按钮失败: " + ex.Message);
		}
	}

	private void LogLayoutProbe()
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		if (!DebugLog.Verbose || (Object)(object)_windowGo == (Object)null)
		{
			return;
		}
		try
		{
			RectTransform component = _windowGo.GetComponent<RectTransform>();
			DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(46, 10);
			defaultInterpolatedStringHandler.AppendLiteral("[布局探测] 窗口 anchor=(");
			defaultInterpolatedStringHandler.AppendFormatted(component.anchorMin.x, "F2");
			defaultInterpolatedStringHandler.AppendLiteral(",");
			defaultInterpolatedStringHandler.AppendFormatted(component.anchorMin.y, "F2");
			defaultInterpolatedStringHandler.AppendLiteral(")-(");
			defaultInterpolatedStringHandler.AppendFormatted(component.anchorMax.x, "F2");
			defaultInterpolatedStringHandler.AppendLiteral(",");
			defaultInterpolatedStringHandler.AppendFormatted(component.anchorMax.y, "F2");
			defaultInterpolatedStringHandler.AppendLiteral(") ");
			defaultInterpolatedStringHandler.AppendLiteral("offset=(");
			defaultInterpolatedStringHandler.AppendFormatted(component.offsetMin.x, "F0");
			defaultInterpolatedStringHandler.AppendLiteral(",");
			defaultInterpolatedStringHandler.AppendFormatted(component.offsetMin.y, "F0");
			defaultInterpolatedStringHandler.AppendLiteral(")-(");
			defaultInterpolatedStringHandler.AppendFormatted(component.offsetMax.x, "F0");
			defaultInterpolatedStringHandler.AppendLiteral(",");
			defaultInterpolatedStringHandler.AppendFormatted(component.offsetMax.y, "F0");
			defaultInterpolatedStringHandler.AppendLiteral(") size=");
			Rect rect = component.rect;
			defaultInterpolatedStringHandler.AppendFormatted(((Rect)(ref rect)).width, "F0");
			defaultInterpolatedStringHandler.AppendLiteral("x");
			rect = component.rect;
			defaultInterpolatedStringHandler.AppendFormatted(((Rect)(ref rect)).height, "F0");
			DebugLog.Debug(defaultInterpolatedStringHandler.ToStringAndClear());
			if ((Object)(object)_content != (Object)null)
			{
				DebugLog.Debug($"[布局探测] 列表 anchor=({_content.anchorMin.x:F2},{_content.anchorMin.y:F2})-({_content.anchorMax.x:F2},{_content.anchorMax.y:F2})");
			}
		}
		catch (Exception ex)
		{
			DebugLog.Warn("[布局探测] 失败: " + ex.Message);
		}
	}

	private void EnsureUi()
	{
		if (_uiBuilt)
		{
			return;
		}
		try
		{
			BuildUi();
			_uiBuilt = true;
		}
		catch (Exception ex)
		{
			DebugLog.Error("构建公开房间页面失败: " + ex);
			if ((Object)(object)_root != (Object)null)
			{
				Object.Destroy((Object)(object)_root);
				_root = null;
				_windowGo = null;
			}
		}
	}

	private void BuildUi()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0263: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0302: Unknown result type (might be due to invalid IL or missing references)
		//IL_0317: Unknown result type (might be due to invalid IL or missing references)
		//IL_0321: Unknown result type (might be due to invalid IL or missing references)
		//IL_0366: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0468: Unknown result type (might be due to invalid IL or missing references)
		UiStyle.Capture(null);
		GameObject val = (_root = new GameObject("PublicLobbyPanel"));
		Object.DontDestroyOnLoad((Object)(object)val);
		val.AddComponent<Canvas>().renderMode = (RenderMode)0;
		val.AddComponent<CanvasScaler>().uiScaleMode = (ScaleMode)1;
		val.AddComponent<GraphicRaycaster>();
		_windowGo = ((Component)NewImage("Window", val.transform, UiStyle.PanelBackground)).gameObject;
		_windowGo.GetComponent<Image>().sprite = UiStyle.ButtonSprite;
		_windowGo.GetComponent<Image>().type = (Type)1;
		SetAnchors(_windowGo.GetComponent<RectTransform>(), 0.08f, 0.05f, 0.92f, 0.95f);
		SetAnchors((_titleTmp = UiStyle.CreateLabel("Title", _windowGo.transform, ModText.T("公开房间", "Public Lobbies"), 26f, (TextAlignmentOptions)514, UiStyle.TextNormal)).rectTransform, 0.06f, 0.87f, 0.94f, 0.94f);
		_searchInput = UiStyle.CreateInput(_windowGo.transform, ModText.T("搜索:世界名 / 房主名", "Search: world / host"));
		Graphic placeholder = _searchInput.placeholder;
		TMP_Text val2 = (TMP_Text)(object)((placeholder is TMP_Text) ? placeholder : null);
		if (val2 != null)
		{
			_searchPh = val2;
		}
		SetAnchors(((Component)_searchInput).GetComponent<RectTransform>(), 0.06f, 0.8f, 0.5f, 0.86f);
		((UnityEventBase)_searchInput.onValueChanged).RemoveAllListeners();
		((UnityEvent<string>)(object)_searchInput.onValueChanged).AddListener(UiDelegates.Ua1(OnSearchChanged));
		_chineseOnlyButton = UiStyle.CreateOverlayButton(_windowGo.transform, "BtnChineseOnly", ToggleChineseOnly);
		SetAnchors(_chineseOnlyButton.GetComponent<RectTransform>(), 0.52f, 0.8f, 0.64f, 0.86f);
		_chineseOnlyTmp = UiStyle.OverlayLabel(_chineseOnlyButton, ModText.T("仅中文: 关", "CN only: OFF"), 16f, UiStyle.TextNormal);
		GameObject val3 = UiStyle.CreateOverlayButton(_windowGo.transform, "BtnRefresh", StartScan);
		SetAnchors(val3.GetComponent<RectTransform>(), 0.66f, 0.8f, 0.78f, 0.86f);
		_refreshTmp = UiStyle.OverlayLabel(val3, ModText.T("刷新", "Refresh"), 16f, UiStyle.TextNormal);
		_content = BuildScrollView(_windowGo.transform);
		_searchingText = UiStyle.CreateLabel("SearchingHint", _windowGo.transform, ModText.T("搜索中…", "Searching…"), 24f, (TextAlignmentOptions)514, UiStyle.TextNormal);
		RectTransform rectTransform = _searchingText.rectTransform;
		rectTransform.anchorMin = new Vector2(0.5f, 0.45f);
		rectTransform.anchorMax = new Vector2(0.5f, 0.45f);
		rectTransform.pivot = new Vector2(0.5f, 0.5f);
		rectTransform.sizeDelta = new Vector2(700f, 60f);
		rectTransform.anchoredPosition = Vector2.zero;
		((Component)_searchingText).gameObject.SetActive(false);
		_statusText = UiStyle.CreateLabel("Status", _windowGo.transform, ModText.T("加载中…", "Loading…"), 15f, (TextAlignmentOptions)513, UiStyle.TextDim);
		SetAnchors(_statusText.rectTransform, 0.06f, 0.02f, 0.66f, 0.075f);
		_joinButton = UiStyle.CreateOverlayButton(_windowGo.transform, "BtnJoin", JoinSelected);
		SetAnchors(_joinButton.GetComponent<RectTransform>(), 0.68f, 0.015f, 0.84f, 0.075f);
		_joinTmp = UiStyle.OverlayLabel(_joinButton, ModText.T("加入房间", "Join Room"), 18f, UiStyle.TextNormal);
		GameObject val4 = UiStyle.CreateOverlayButton(_windowGo.transform, "BtnBack", Hide);
		SetAnchors(val4.GetComponent<RectTransform>(), 0.86f, 0.015f, 0.97f, 0.075f);
		_backTmp = UiStyle.OverlayLabel(val4, ModText.T("返回", "Back"), 16f, UiStyle.TextNormal);
		DumpButtonTextProbe();
		Hide();
	}

	private void DumpButtonTextProbe()
	{
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		if (!DebugLog.Verbose)
		{
			return;
		}
		(string, TMP_Text)[] array = new(string, TMP_Text)[7]
		{
			("标题", _titleTmp),
			("仅中文", _chineseOnlyTmp),
			("刷新", _refreshTmp),
			("加入", _joinTmp),
			("返回", _backTmp),
			("状态", _statusText),
			("搜索占位", _searchPh)
		};
		for (int i = 0; i < array.Length; i++)
		{
			(string, TMP_Text) tuple = array[i];
			TMP_Text item = tuple.Item2;
			Rect val = (Rect)(((Object)(object)item != (Object)null && (Object)(object)item.rectTransform != (Object)null) ? item.rectTransform.rect : new Rect(0f, 0f, 0f, 0f));
			DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(45, 7);
			defaultInterpolatedStringHandler.AppendLiteral("[UI探测] ");
			defaultInterpolatedStringHandler.AppendFormatted(tuple.Item1);
			defaultInterpolatedStringHandler.AppendLiteral(": text='");
			defaultInterpolatedStringHandler.AppendFormatted((item != null) ? item.text : null);
			defaultInterpolatedStringHandler.AppendLiteral("' font=");
			defaultInterpolatedStringHandler.AppendFormatted(((Object)(object)((item != null) ? item.font : null) != (Object)null) ? "ok" : "NULL");
			defaultInterpolatedStringHandler.AppendLiteral(" size=");
			defaultInterpolatedStringHandler.AppendFormatted((item != null) ? new float?(item.fontSize) : ((float?)null));
			defaultInterpolatedStringHandler.AppendLiteral(" active=");
			bool? value;
			if (item == null)
			{
				value = null;
			}
			else
			{
				GameObject gameObject = ((Component)item).gameObject;
				value = ((gameObject != null) ? new bool?(gameObject.activeSelf) : ((bool?)null));
			}
			defaultInterpolatedStringHandler.AppendFormatted(value);
			defaultInterpolatedStringHandler.AppendLiteral(" rect=(");
			defaultInterpolatedStringHandler.AppendFormatted(((Rect)(ref val)).width, "F0");
			defaultInterpolatedStringHandler.AppendLiteral("x");
			defaultInterpolatedStringHandler.AppendFormatted(((Rect)(ref val)).height, "F0");
			defaultInterpolatedStringHandler.AppendLiteral(")");
			DebugLog.Info(defaultInterpolatedStringHandler.ToStringAndClear());
		}
	}

	public void RefreshAllTexts()
	{
		if ((Object)(object)_titleTmp != (Object)null)
		{
			_titleTmp.text = ModText.T("公开房间", "Public Lobbies");
		}
		if ((Object)(object)_chineseOnlyTmp != (Object)null)
		{
			_chineseOnlyTmp.text = ModText.T(_chineseOnly ? "仅中文: 开" : "仅中文: 关", _chineseOnly ? "CN only: ON" : "CN only: OFF");
		}
		if ((Object)(object)_refreshTmp != (Object)null)
		{
			_refreshTmp.text = ModText.T("刷新", "Refresh");
		}
		if ((Object)(object)_joinTmp != (Object)null)
		{
			_joinTmp.text = ModText.T("加入房间", "Join Room");
		}
		if ((Object)(object)_backTmp != (Object)null)
		{
			_backTmp.text = ModText.T("返回", "Back");
		}
		if ((Object)(object)_searchPh != (Object)null)
		{
			_searchPh.text = ModText.T("搜索:世界名 / 房主名", "Search: world / host");
		}
		ApplyStatus();
	}

	private Image NewImage(string name, Transform parent, Color color)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		val.AddComponent<RectTransform>();
		Image val2 = val.AddComponent<Image>();
		val.transform.SetParent(parent, false);
		((Graphic)val2).color = color;
		((Graphic)val2).raycastTarget = true;
		return val2;
	}

	private RectTransform BuildScrollView(Transform parent)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: 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_0121: 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_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Expected O, but got Unknown
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: 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_02b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02de: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_032e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0343: Unknown result type (might be due to invalid IL or missing references)
		//IL_0358: Unknown result type (might be due to invalid IL or missing references)
		//IL_036d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0381: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("ScrollView");
		val.AddComponent<RectTransform>();
		val.transform.SetParent(parent, false);
		Image obj = val.AddComponent<Image>();
		((Graphic)obj).color = new Color(0.03f, 0.035f, 0.05f, 1f);
		obj.sprite = UiStyle.ButtonSprite;
		obj.type = (Type)1;
		ScrollRect obj2 = val.AddComponent<ScrollRect>();
		GameObject val2 = new GameObject("Viewport");
		val2.AddComponent<RectTransform>();
		val2.transform.SetParent(val.transform, false);
		Image val3 = val2.AddComponent<Image>();
		((Graphic)val3).color = new Color(0f, 0f, 0f, 0.25f);
		val2.AddComponent<RectMask2D>();
		UiStyle.Stretch(((Graphic)val3).rectTransform, 0f, 22f, 0f, 0f);
		GameObject val4 = new GameObject("Content");
		val4.AddComponent<RectTransform>();
		val4.transform.SetParent(val2.transform, false);
		VerticalLayoutGroup obj3 = val4.AddComponent<VerticalLayoutGroup>();
		((HorizontalOrVerticalLayoutGroup)obj3).spacing = 5f;
		((LayoutGroup)obj3).childAlignment = (TextAnchor)1;
		((HorizontalOrVerticalLayoutGroup)obj3).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj3).childControlHeight = false;
		((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandHeight = false;
		val4.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
		RectTransform component = val4.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0f, 1f);
		component.anchorMax = new Vector2(1f, 1f);
		component.pivot = new Vector2(0.5f, 1f);
		component.sizeDelta = new Vector2(0f, 0f);
		obj2.viewport = ((Graphic)val3).rectTransform;
		obj2.content = component;
		obj2.horizontal = false;
		obj2.vertical = true;
		obj2.movementType = (MovementType)2;
		obj2.scrollSensitivity = 30f;
		GameObject val5 = new GameObject("Scrollbar");
		val5.AddComponent<RectTransform>();
		val5.transform.SetParent(val.transform, false);
		Image obj4 = val5.AddComponent<Image>();
		((Graphic)obj4).color = new Color(0.07f, 0.08f, 0.1f, 1f);
		obj4.sprite = UiStyle.ButtonSprite;
		obj4.type = (Type)1;
		Scrollbar val6 = val5.AddComponent<Scrollbar>();
		val6.direction = (Direction)2;
		GameObject val7 = new GameObject("Handle");
		val7.AddComponent<RectTransform>();
		val7.transform.SetParent(val5.transform, false);
		Image val8 = val7.AddComponent<Image>();
		((Graphic)val8).color = new Color(0.5f, 0.55f, 0.65f, 1f);
		val8.sprite = UiStyle.ButtonSprite;
		val8.type = (Type)1;
		RectTransform component2 = val7.GetComponent<RectTransform>();
		component2.anchorMin = new Vector2(0f, 0f);
		component2.anchorMax = new Vector2(1f, 1f);
		component2.pivot = new Vector2(0.5f, 0.5f);
		component2.offsetMin = new Vector2(2f, 2f);
		component2.offsetMax = new Vector2(-2f, -2f);
		((Selectable)val6).targetGraphic = (Graphic)(object)val8;
		val6.handleRect = component2;
		val6.value = 1f;
		RectTransform component3 = val5.GetComponent<RectTransform>();
		component3.anchorMin = new Vector2(1f, 0f);
		component3.anchorMax = new Vector2(1f, 1f);
		component3.pivot = new Vector2(1f, 0.5f);
		component3.offsetMin = new Vector2(-20f, 0f);
		component3.offsetMax = new Vector2(-4f, 0f);
		obj2.verticalScrollbar = val6;
		obj2.verticalScrollbarVisibility = (ScrollbarVisibility)0;
		SetAnchors(val.GetComponent<RectTransform>(), 0.06f, 0.09f, 0.94f, 0.78f);
		return component;
	}

	private static void SetAnchors(RectTransform rt, float minX, float minY, float maxX, float maxY)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		rt.anchorMin = new Vector2(minX, minY);
		rt.anchorMax = new Vector2(maxX, maxY);
		rt.offsetMin = Vector2.zero;
		rt.offsetMax = Vector2.zero;
		rt.pivot = new Vector2(0.5f, 0.5f);
	}

	public void Tick()
	{
		UpdateSearchingAnimation();
		if (!_scanning)
		{
			return;
		}
		if (LobbyScanner.TryFinishRound())
		{
			_roundsDone++;
			if (_roundsDone >= _totalRounds)
			{
				_scanning = false;
				_needsFinalRender = true;
			}
			else
			{
				LobbyScanner.StartRound(clearCache: false, includeSession: false);
			}
		}
		if (_needsFinalRender && !_scanning)
		{
			_needsFinalRender = false;
			if ((Object)(object)_searchingText != (Object)null)
			{
				((Component)_searchingText).gameObject.SetActive(false);
			}
			_rooms.Clear();
			_rooms.AddRange(LobbyScanner.GetRoomsSnapshot());
			int num = RebuildCards();
			if (num == 0)
			{
				SetStatus("未找到公开房间,试试稍后刷新。", "No public rooms found. Try refreshing later.");
				return;
			}
			SetStatus($"共 {num} 个公开房间(单击卡片选中,点「加入房间」进房)", $"{num} public rooms (click a card to select, then Join Room)");
		}
	}

	private void UpdateSearchingAnimation()
	{
		if (!((Object)(object)_searchingText == (Object)null) && ((Component)_searchingText).gameObject.activeSelf)
		{
			int count = (int)(Time.time * 2f) % 3 + 1;
			_searchingText.text = ModText.T("搜索中" + new string('.', count), "Searching" + new string('.', count));
		}
	}

	private void StartScan()
	{
		if (!_scanning)
		{
			_scanning = true;
			_selected = null;
			_rooms.Clear();
			RebuildCards();
			if ((Object)(object)_searchingText != (Object)null)
			{
				((Component)_searchingText).gameObject.SetActive(true);
			}
			SetStatus("", "");
			_needsFinalRender = true;
			_totalRounds = Math.Max(1, ModState.SearchRounds);
			_roundsDone = 0;
			DebugLog.Info($"[页面] 刷新:开始扫描公开房间(共 {_totalRounds} 轮,首轮清空旧缓存)");
			LobbyScanner.StartRound(clearCache: true, includeSession: true);
		}
	}

	private int RebuildCards()
	{
		if ((Object)(object)_content == (Object)null)
		{
			return 0;
		}
		for (int num = ((Transform)_content).childCount - 1; num >= 0; num--)
		{
			Transform child = ((Transform)_content).GetChild(num);
			child.SetParent((Transform)null);
			Object.Destroy((Object)(object)((Component)child).gameObject);
		}
		_cardByKey.Clear();
		string text = (_filter ?? "").Trim().ToLowerInvariant();
		int num2 = 0;
		foreach (RoomInfo room in _rooms)
		{
			if ((text.Length <= 0 || (room.WorldName ?? "").ToLowerInvariant().Contains(text) || (room.HostName ?? "").ToLowerInvariant().Contains(text)) && (!_chineseOnly || ModText.ContainsChinese(room.WorldName ?? "") || ModText.ContainsChinese(room.HostName ?? "")))
			{
				CreateCard(room);
				num2++;
			}
		}
		DebugLog.Debug($"[页面] 重建列表:显示 {num2}/{_rooms.Count} 条(搜索='{_filter}')");
		return num2;
	}

	private void CreateCard(RoomInfo room)
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		Image val = NewImage("Card_" + room.JoinCode, (Transform)(object)_content, UiStyle.CardBackground);
		val.sprite = UiStyle.ButtonSprite;
		val.type = (Type)1;
		((Graphic)val).rectTransform.sizeDelta = new Vector2(0f, 44f);
		GameObject gameObject = ((Component)val).gameObject;
		TMP_Text obj = UiStyle.CreateLabel("Info", gameObject.transform, RoomCardLine(room), 15f, (TextAlignmentOptions)513, UiStyle.TextNormal);
		obj.enableWordWrapping = false;
		obj.overflowMode = (TextOverflowModes)1;
		obj.verticalAlignment = (VerticalAlignmentOptions)512;
		UiStyle.Stretch(obj.rectTransform, 14f, 14f, 4f, 4f);
		Button obj2 = gameObject.AddComponent<Button>();
		((Selectable)obj2).targetGraphic = (Graphic)(object)val;
		((UnityEvent)obj2.onClick).AddListener(UiDelegates.Ua(delegate
		{
			SelectRoom(room);
		}));
		_cardByKey[room.Key] = gameObject;
	}

	private static string RoomCardLine(RoomInfo room)
	{
		List<string> list = new List<string>();
		list.Add(string.IsNullOrEmpty(room.WorldName) ? "未命名世界" : room.WorldName);
		list.Add(string.IsNullOrEmpty(room.HostName) ? "未知房主" : room.HostName);
		if (!string.IsNullOrEmpty(room.JoinCode))
		{
			list.Add("码 " + room.JoinCode);
		}
		return string.Join("   ", list);
	}

	private void SelectRoom(RoomInfo room)
	{
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		_selected = room;
		foreach (KeyValuePair<string, GameObject> item in _cardByKey)
		{
			Image component = item.Value.GetComponent<Image>();
			if ((Object)(object)component != (Object)null)
			{
				((Graphic)component).color = ((item.Key == room.Key) ? UiStyle.CardSelected : UiStyle.CardBackground);
			}
		}
		SetStatus($"已选中:{room.DisplayName}(码 {room.JoinCode})。点「加入房间」进房。", $"Selected: {room.DisplayName} (code {room.JoinCode}). Press Join Room.");
	}

	private void JoinSelected()
	{
		if (_selected == null)
		{
			SetStatus("请先单击选中一个房间。", "Select a room first.");
			return;
		}
		try
		{
			string joinCode = _selected.JoinCode;
			DebugLog.Info("正在加入公开房间 " + joinCode + "(复用原版 NetworkMinder.SetTransportAndConnect 流程)…");
			NetworkMinder.SetTransportAndConnect(joinCode);
			Hide();
		}
		catch (Exception ex)
		{
			DebugLog.Error("加入房间失败: " + ex);
			SetStatus("加入失败:" + ex.Message, "Join failed: " + ex.Message);
		}
	}

	private void ToggleChineseOnly()
	{
		_chineseOnly = !_chineseOnly;
		DebugLog.Info($"[页面] 仅中文开关 → {_chineseOnly}");
		RefreshAllTexts();
		int value = RebuildCards();
		SetStatus($"显示 {value}/{_rooms.Count} 个房间(仅中文 {(_chineseOnly ? "" : "")})", $"Showing {value}/{_rooms.Count} rooms (CN-only {(_chineseOnly ? "ON" : "OFF")})");
	}

	private void OnSearchChanged(string value)
	{
		_filter = value ?? "";
		int value2 = RebuildCards();
		if (_rooms.Count > 0)
		{
			SetStatus($"显示 {value2}/{_rooms.Count} 个房间", $"Showing {value2}/{_rooms.Count} rooms");
		}
	}

	private void SetStatus(string zh, string en)
	{
		_statusZh = zh;
		_statusEn = en;
		ApplyStatus();
	}

	private void ApplyStatus()
	{
		if ((Object)(object)_statusText != (Object)null)
		{
			_statusText.text = (ModText.IsChinese ? _statusZh : _statusEn);
		}
	}
}
public class RoomInfo
{
	public string JoinCode;

	public string WorldName;

	public string HostName;

	public bool FromSession;

	public string DisplayName
	{
		get
		{
			if (!string.IsNullOrEmpty(WorldName))
			{
				return WorldName;
			}
			if (!string.IsNullOrEmpty(HostName))
			{
				return HostName + " 的房间";
			}
			return "房间 " + JoinCode;
		}
	}

	public string Key => JoinCode ?? HostName;
}
internal static class UiDelegates
{
	public static UnityAction Ua(Action action)
	{
		return DelegateSupport.ConvertDelegate<UnityAction>((Delegate)action);
	}

	public static UnityAction<string> Ua1(Action<string> action)
	{
		return DelegateSupport.ConvertDelegate<UnityAction<string>>((Delegate)action);
	}
}
internal static class UiStyle
{
	public static Sprite ButtonSprite;

	public static TMP_FontAsset Font;

	public static GameObject ButtonTextTemplate;

	public static readonly Color PanelBackground = new Color(0.055f, 0.06f, 0.075f, 0.94f);

	public static readonly Color CardBackground = new Color(0.15f, 0.16f, 0.19f, 1f);

	public static readonly Color CardSelected = new Color(0.28f, 0.4f, 0.6f, 1f);

	public static readonly Color InputBackground = new Color(0.1f, 0.11f, 0.14f, 1f);

	public static readonly Color TextNormal = new Color(1f, 1f, 1f, 1f);

	public static readonly Color TextDim = new Color(0.85f, 0.85f, 0.85f, 1f);

	public static void Capture(GameObject templateButton)
	{
		try
		{
			if ((Object)(object)templateButton != (Object)null)
			{
				Image component = templateButton.GetComponent<Image>();
				if ((Object)(object)component != (Object)null && (Object)(object)component.sprite != (Object)null)
				{
					ButtonSprite = component.sprite;
				}
			}
			if ((Object)(object)Font == (Object)null)
			{
				TMP_Text val = null;
				if ((Object)(object)templateButton != (Object)null)
				{
					val = templateButton.GetComponentInChildren<TMP_Text>(true);
				}
				if ((Object)(object)val == (Object)null)
				{
					val = Object.FindObjectOfType<TMP_Text>(true);
				}
				if ((Object)(object)val != (Object)null && (Object)(object)val.font != (Object)null)
				{
					Font = val.font;
				}
			}
		}
		catch (Exception ex)
		{
			DebugLog.Error("UiStyle.Capture 失败: " + ex.Message);
		}
	}

	public static GameObject CreateTextButton(Transform parent, string name, string label, float fontSize, Color textColor, Action onClick)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: 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_017d: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		val.AddComponent<RectTransform>();
		val.transform.SetParent(parent, false);
		Image val2 = val.AddComponent<Image>();
		((Graphic)val2).color = new Color(0.18f, 0.2f, 0.26f, 0.85f);
		if ((Object)(object)ButtonSprite != (Object)null)
		{
			val2.sprite = ButtonSprite;
			val2.type = (Type)1;
		}
		Button obj = val.AddComponent<Button>();
		((Selectable)obj).targetGraphic = (Graphic)(object)val2;
		((Selectable)obj).transition = (Transition)1;
		ColorBlock colors = ((Selectable)obj).colors;
		((ColorBlock)(ref colors)).normalColor = Color.white;
		((ColorBlock)(ref colors)).highlightedColor = new Color(0.9f, 0.95f, 1f, 1f);
		((ColorBlock)(ref colors)).pressedColor = new Color(0.62f, 0.72f, 0.85f, 1f);
		((ColorBlock)(ref colors)).selectedColor = Color.white;
		((ColorBlock)(ref colors)).disabledColor = new Color(0.45f, 0.45f, 0.45f, 0.6f);
		((Selectable)obj).colors = colors;
		((UnityEvent)obj.onClick).AddListener(UiDelegates.Ua(onClick));
		TextMeshProUGUI val3 = null;
		if ((Object)(object)ButtonTextTemplate != (Object)null)
		{
			try
			{
				GameObject obj2 = Object.Instantiate<GameObject>(ButtonTextTemplate, val.transform);
				((Object)obj2).name = "Text";
				val3 = obj2.GetComponent<TextMeshProUGUI>();
				DebugLog.Debug("[UI] 按钮文字:克隆主菜单 Text 模板(渲染配置与主菜单按钮一致)");
			}
			catch (Exception ex)
			{
				DebugLog.Warn("[UI] 克隆文本模板失败,改用自建: " + ex.Message);
				val3 = null;
			}
		}
		if ((Object)(object)val3 == (Object)null)
		{
			GameObject val4 = new GameObject("Text");
			val4.AddComponent<RectTransform>();
			val4.transform.SetParent(val.transform, false);
			val3 = val4.AddComponent<TextMeshProUGUI>();
			if ((Object)(object)Font != (Object)null)
			{
				((TMP_Text)val3).font = Font;
			}
		}
		((TMP_Text)val3).text = label;
		((TMP_Text)val3).fontSize = fontSize;
		((TMP_Text)val3).alignment = (TextAlignmentOptions)514;
		((TMP_Text)val3).verticalAlignment = (VerticalAlignmentOptions)512;
		((TMP_Text)val3).enableWordWrapping = false;
		((TMP_Text)val3).overflowMode = (TextOverflowModes)1;
		((Graphic)val3).color = textColor;
		Stretch(((TMP_Text)val3).rectTransform, 8f, 8f, 4f, 4f);
		((Graphic)val3).SetAllDirty();
		return val;
	}

	public static GameObject CreateOverlayButton(Transform parent, string name, Action onClick)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Expected O, but got Unknown
		GameObject val = new GameObject(name);
		val.AddComponent<RectTransform>();
		val.transform.SetParent(parent, false);
		Image val2 = val.AddComponent<Image>();
		((Graphic)val2).color = new Color(0.18f, 0.2f, 0.26f, 0.85f);
		if ((Object)(object)ButtonSprite != (Object)null)
		{
			val2.sprite = ButtonSprite;
			val2.type = (Type)1;
		}
		Button obj = val.AddComponent<Button>();
		((Selectable)obj).targetGraphic = (Graphic)(object)val2;
		((Selectable)obj).transition = (Transition)1;
		ColorBlock colors = ((Selectable)obj).colors;
		((ColorBlock)(ref colors)).normalColor = Color.white;
		((ColorBlock)(ref colors)).highlightedColor = new Color(0.9f, 0.95f, 1f, 1f);
		((ColorBlock)(ref colors)).pressedColor = new Color(0.62f, 0.72f, 0.85f, 1f);
		((ColorBlock)(ref colors)).selectedColor = Color.white;
		((ColorBlock)(ref colors)).disabledColor = new Color(0.45f, 0.45f, 0.45f, 0.6f);
		((Selectable)obj).colors = colors;
		((UnityEvent)obj.onClick).AddListener(UiDelegates.Ua(onClick));
		return val;
	}

	public static TMP_Text OverlayLabel(GameObject button, string label, float fontSize, Color color)
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)button == (Object)null)
		{
			return null;
		}
		RectTransform component = button.GetComponent<RectTransform>();
		if ((Object)(object)component == (Object)null || (Object)(object)((Transform)component).parent == (Object)null)
		{
			return null;
		}
		TMP_Text obj = CreateLabel("Text", ((Transform)component).parent, label, fontSize, (TextAlignmentOptions)514, color);
		((Graphic)obj).raycastTarget = false;
		obj.verticalAlignment = (VerticalAlignmentOptions)512;
		RectTransform rectTransform = obj.rectTransform;
		rectTransform.anchorMin = component.anchorMin;
		rectTransform.anchorMax = component.anchorMax;
		rectTransform.pivot = component.pivot;
		rectTransform.offsetMin = component.offsetMin;
		rectTransform.offsetMax = component.offsetMax;
		((Transform)rectTransform).SetAsLastSibling();
		return obj;
	}

	public static TMP_InputField CreateInput(Transform parent, string placeholderText)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("SearchInput");
		val.AddComponent<RectTransform>();
		val.transform.SetParent(parent, false);
		Image obj = val.AddComponent<Image>();
		((Graphic)obj).color = InputBackground;
		obj.sprite = ButtonSprite;
		obj.type = (Type)1;
		TMP_InputField val2 = val.AddComponent<TMP_InputField>();
		GameObject val3 = new GameObject("Text");
		val3.AddComponent<RectTransform>();
		val3.transform.SetParent(val.transform, false);
		TextMeshProUGUI val4 = val3.AddComponent<TextMeshProUGUI>();
		if ((Object)(object)Font != (Object)null)
		{
			((TMP_Text)val4).font = Font;
		}
		((TMP_Text)val4).fontSize = 18f;
		((Graphic)val4).color = Color.white;
		((TMP_Text)val4).alignment = (TextAlignmentOptions)513;
		((Graphic)val4).raycastTarget = false;
		Stretch(((TMP_Text)val4).rectTransform, 10f, 10f, 10f, 10f);
		val2.textComponent = (TMP_Text)(object)val4;
		GameObject val5 = new GameObject("Placeholder");
		val5.AddComponent<RectTransform>();
		val5.transform.SetParent(val.transform, false);
		TextMeshProUGUI val6 = val5.AddComponent<TextMeshProUGUI>();
		if ((Object)(object)Font != (Object)null)
		{
			((TMP_Text)val6).font = Font;
		}
		((TMP_Text)val6).text = placeholderText;
		((TMP_Text)val6).fontSize = 18f;
		((Graphic)val6).color = new Color(0.55f, 0.55f, 0.58f, 1f);
		((TMP_Text)val6).alignment = (TextAlignmentOptions)513;
		((Graphic)val6).raycastTarget = false;
		Stretch(((TMP_Text)val6).rectTransform, 10f, 10f, 10f, 10f);
		val2.placeholder = (Graphic)(object)val6;
		if ((Object)(object)Font != (Object)null)
		{
			val2.fontAsset = Font;
		}
		val2.pointSize = 18f;
		val2.lineType = (LineType)0;
		return val2;
	}

	public static TMP_Text CreateLabel(string name, Transform parent, string content, float size, TextAlignmentOptions align, Color color)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		val.AddComponent<RectTransform>();
		val.transform.SetParent(parent, false);
		TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
		if ((Object)(object)Font != (Object)null)
		{
			((TMP_Text)val2).font = Font;
		}
		((TMP_Text)val2).text = content;
		((TMP_Text)val2).fontSize = size;
		((TMP_Text)val2).alignment = align;
		((Graphic)val2).color = color;
		((Graphic)val2).raycastTarget = false;
		((Graphic)val2).SetAllDirty();
		return (TMP_Text)(object)val2;
	}

	public static void Stretch(RectTransform rt, float left, float right, float top, float bottom)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		rt.anchorMin = Vector2.zero;
		rt.anchorMax = Vector2.one;
		rt.offsetMin = new Vector2(left, bottom);
		rt.offsetMax = new Vector2(0f - right, 0f - top);
	}
}
internal static class DebugLog
{
	public static bool Verbose;

	public static void Info(string msg)
	{
		ManualLogSource log = Plugin.Log;
		if (log != null)
		{
			log.LogInfo((object)msg);
		}
	}

	public static void Warn(string msg)
	{
		ManualLogSource log = Plugin.Log;
		if (log != null)
		{
			log.LogWarning((object)msg);
		}
	}

	public static void Error(string msg)
	{
		ManualLogSource log = Plugin.Log;
		if (log != null)
		{
			log.LogError((object)msg);
		}
	}

	public static void Debug(string msg)
	{
		if (Verbose)
		{
			ManualLogSource log = Plugin.Log;
			if (log != null)
			{
				log.LogInfo((object)("[DEBUG] " + msg));
			}
		}
	}
}