Decompiled source of RoundsWithFriendSettingsUI v0.0.1

RWFSettingsUI.dll

Decompiled 2 years ago
using System;
using System.Collections;
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 DeckCustomization;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using PickNCards;
using RWF;
using RoundsVC;
using SetRoundsPlugin;
using SettingsUI.Patches;
using SettingsUI.Utils;
using TMPro;
using UnboundLib;
using UnboundLib.Networking;
using UnboundLib.Utils.UI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SettingsUI
{
	[BepInProcess("Rounds.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public abstract class CompatibilityHandler : BaseUnityPlugin
	{
		public abstract string MenuName { get; }

		public virtual bool HostOnly => true;

		public virtual void Start()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0039: Expected O, but got Unknown
			RWFSettingsUI.RegisterMenu(MenuName, GUI, HostOnly, new UnityAction(EnterMenuAction), new UnityAction(ReturnToLobbyAction));
		}

		public virtual void EnterMenuAction()
		{
		}

		public abstract void GUI(GameObject menu);

		public virtual void ReturnToLobbyAction()
		{
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.willuwontu.rounds.rwfsettingsui.compatibility.DeckCustomization", "Rounds With Friends Settings UI - Deck Customization Compatibility Handler", "0.0.0")]
	internal class DeckCustomCompat : CompatibilityHandler
	{
		private const string ModId = "com.willuwontu.rounds.rwfsettingsui.compatibility.DeckCustomization";

		private const string ModName = "Rounds With Friends Settings UI - Deck Customization Compatibility Handler";

		public const string Version = "0.0.0";

		public override string MenuName => "Deck Customization";

		public override void GUI(GameObject menu)
		{
			DeckCustomization component = ((Component)this).gameObject.GetComponent<DeckCustomization>();
			MethodInfo method = typeof(DeckCustomization).GetMethod("SetupGUI", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod);
			((MonoBehaviour)Unbound.Instance).StartCoroutine((IEnumerator)method.Invoke(component, new object[1] { menu }));
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.willuwontu.rounds.rwfsettingsui.compatibility.pickn", "Rounds With Friends Settings UI - Pick N Compatibility Handler", "0.0.0")]
	internal class PickNCompat : CompatibilityHandler
	{
		private const string ModId = "com.willuwontu.rounds.rwfsettingsui.compatibility.pickn";

		private const string ModName = "Rounds With Friends Settings UI - Pick N Compatibility Handler";

		public const string Version = "0.0.0";

		public override string MenuName => "Pick N Cards";

		public override void GUI(GameObject menu)
		{
			PickNCards component = ((Component)this).gameObject.GetComponent<PickNCards>();
			MethodInfo method = typeof(PickNCards).GetMethod("NewGUI", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod);
			method.Invoke(component, new object[1] { menu });
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.willuwontu.rounds.rwfsettingsui.compatibility.roundsvc", "Rounds With Friends Settings UI - Rounds VC Compatibility Handler", "0.0.0")]
	internal class RoundsVCCompat : CompatibilityHandler
	{
		private const string ModId = "com.willuwontu.rounds.rwfsettingsui.compatibility.roundsvc";

		private const string ModName = "Rounds With Friends Settings UI - Rounds VC Compatibility Handler";

		public const string Version = "0.0.0";

		public override string MenuName => "Rounds VC";

		public override bool HostOnly => false;

		public override void EnterMenuAction()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			RoundsVC component = ((Component)this).gameObject.GetComponent<RoundsVC>();
			FieldInfo field = typeof(RoundsVC).GetField("OptionsMenuDemoCO", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.SetField);
			Coroutine val = (Coroutine)field.GetValue(null);
			if (val != null)
			{
				((MonoBehaviour)component).StopCoroutine(val);
			}
			MethodInfo method = typeof(RoundsVC).GetMethod("DemoUI", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod);
			field.SetValue(null, ((MonoBehaviour)component).StartCoroutine((IEnumerator)method.Invoke(null, new object[0])));
		}

		public override void GUI(GameObject menu)
		{
			MethodInfo method = typeof(RoundsVC).GetMethod("GUI", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod);
			method.Invoke(null, new object[1] { menu });
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.willuwontu.rounds.rwfsettingsui.compatibility.setrounds", "Rounds With Friends Settings UI - Set Rounds Compatibility Handler", "0.0.0")]
	internal class SetRoundsCompat : CompatibilityHandler
	{
		private const string ModId = "com.willuwontu.rounds.rwfsettingsui.compatibility.setrounds";

		private const string ModName = "Rounds With Friends Settings UI - Set Rounds Compatibility Handler";

		public const string Version = "0.0.0";

		public override string MenuName => "Set Rounds";

		public override void GUI(GameObject menu)
		{
			SetRounds component = ((Component)this).gameObject.GetComponent<SetRounds>();
			MethodInfo method = typeof(SetRounds).GetMethod("NewGUI", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod);
			method.Invoke(component, new object[1] { menu });
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.willuwontu.rounds.rwfsettingsui", "Rounds With Friends Settings UI", "0.0.1")]
	[BepInProcess("Rounds.exe")]
	public class RWFSettingsUI : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction <0>__URPC_UnreadySelf;

			public static UnityAction <1>__BackActions;
		}

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

			public static Func<KeyValuePair<int, Player>, int> <>9__24_0;

			public static Func<KeyValuePair<int, Player>, int> <>9__24_1;

			public static UnityAction <>9__25_0;

			internal int <IDoBackActions>b__24_0(KeyValuePair<int, Player> kv)
			{
				return (int)kv.Value.CustomProperties[(object)"Ping"];
			}

			internal int <IDoBackActions>b__24_1(KeyValuePair<int, Player> kv)
			{
				return (int)kv.Value.CustomProperties[(object)"Ping"];
			}

			internal void <InjectUIElements>b__25_0()
			{
			}
		}

		private const string ModId = "com.willuwontu.rounds.rwfsettingsui";

		private const string ModName = "Rounds With Friends Settings UI";

		private const string ModConfigName = "RWFSettingsUI";

		public const string Version = "0.0.1";

		internal const string ModInitials = "RWFSUI";

		private static Type _RWFPrivateRoomHandler;

		internal static Type RWFPrivateRoomHandler
		{
			get
			{
				if (_RWFPrivateRoomHandler == null)
				{
					Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(typeof(RWFMod).Assembly);
					Type[] array = typesFromAssembly;
					foreach (Type type in array)
					{
						if (type.Name == "PrivateRoomHandler")
						{
							_RWFPrivateRoomHandler = type;
						}
					}
				}
				return _RWFPrivateRoomHandler;
			}
		}

		internal static Color disabledTextColor
		{
			get
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				Type rWFPrivateRoomHandler = RWFPrivateRoomHandler;
				return (Color)RWFPrivateRoomHandler.GetField("disabledTextColor", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.GetField).GetValue(null);
			}
		}

		internal static Color enabledTextColor
		{
			get
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				Type rWFPrivateRoomHandler = RWFPrivateRoomHandler;
				return (Color)RWFPrivateRoomHandler.GetField("enabledTextColor", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.GetField).GetValue(null);
			}
		}

		internal static RWFSettingsUI instance { get; private set; }

		private void Awake()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			instance = this;
			Harmony harmony = new Harmony("com.willuwontu.rounds.rwfsettingsui");
			PrivateRoomHandler_Patch.Initialize(harmony);
		}

		private void Start()
		{
			Unbound.RegisterCredits("Rounds With Friends Settings UI", new string[1] { "willuwontu" }, new string[2] { "github", "Ko-Fi" }, new string[2] { "https://github.com/willuwontu/wills-wacky-cards", "https://ko-fi.com/willuwontu" });
		}

		internal static void UnreadyAll()
		{
			Type rWFPrivateRoomHandler = RWFPrivateRoomHandler;
			object value = RWFPrivateRoomHandler.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.GetField).GetValue(null);
			MethodInfo method = RWFPrivateRoomHandler.GetMethod("UnreadyAllPlayers", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod);
			method.Invoke(value, new object[0]);
		}

		internal static void ResyncLobby()
		{
			if (!PhotonNetwork.IsMasterClient && !PhotonNetwork.OfflineMode)
			{
				return;
			}
			Type type = null;
			Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(typeof(Unbound).Assembly);
			Type[] array = typesFromAssembly;
			foreach (Type type2 in array)
			{
				if (type2.Name == "SyncModClients")
				{
					type = type2;
				}
			}
			NetworkingManager.RPC(type, "SyncLobby", new object[0]);
		}

		internal static void RequestJoinedRoom()
		{
			if (PhotonNetwork.IsMasterClient)
			{
				NetworkingManager.RPC(typeof(RWFSettingsUI), "URPC_JoinedRoom", new object[0]);
			}
		}

		[UnboundRPC]
		internal static void URPC_JoinedRoom()
		{
			NetworkEventCallbacks[] components = ((Component)Unbound.Instance).GetComponents<NetworkEventCallbacks>();
			for (int num = components.Length - 1; num >= 0; num--)
			{
				((MonoBehaviourPunCallbacks)components[num]).OnJoinedRoom();
			}
		}

		[UnboundRPC]
		internal static void URPC_UnreadySelf()
		{
			LobbyCharacter[] property = PhotonPlayerExtensions.GetProperty<LobbyCharacter[]>(PhotonNetwork.LocalPlayer, "players");
			for (int i = 0; i < property.Count(); i++)
			{
				LobbyCharacter obj = property[i];
				if (obj != null)
				{
					obj.SetReady(false);
				}
			}
			PhotonPlayerExtensions.SetProperty(PhotonNetwork.LocalPlayer, "players", (object)property);
		}

		internal static void BackActions()
		{
			((MonoBehaviour)instance).StartCoroutine(IDoBackActions());
		}

		internal static IEnumerator IDoBackActions()
		{
			RequestJoinedRoom();
			ResyncLobby();
			int syncTime = Mathf.Clamp(5 * ((int)PhotonNetwork.LocalPlayer.CustomProperties[(object)"Ping"] + PhotonNetwork.CurrentRoom.Players.Select((KeyValuePair<int, Player> kv) => (int)kv.Value.CustomProperties[(object)"Ping"]).Max()), 200, int.MaxValue);
			yield return (object)new WaitForSecondsRealtime((float)syncTime / 1000f);
			UnreadyAll();
			syncTime = Mathf.Clamp(5 * ((int)PhotonNetwork.LocalPlayer.CustomProperties[(object)"Ping"] + PhotonNetwork.CurrentRoom.Players.Select((KeyValuePair<int, Player> kv) => (int)kv.Value.CustomProperties[(object)"Ping"]).Max()), 200, int.MaxValue);
			yield return (object)new WaitForSecondsRealtime((float)syncTime / 1000f);
			UnreadyAll();
		}

		internal static void InjectUIElements()
		{
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Expected O, but got Unknown
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Expected O, but got Unknown
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Expected O, but got Unknown
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Expected O, but got Unknown
			GameObject val = GameObject.Find("/Game/UI");
			GameObject gameObject = ((Component)val.transform.Find("UI_Game").Find("Canvas")).gameObject;
			Transform val2 = gameObject.transform.Find("PrivateRoom");
			Transform val3 = ((Component)val2).transform.Find("Main").Find("Group");
			if (!Object.op_Implicit((Object)(object)val3.Find("Mod Settings")))
			{
				object obj = <>c.<>9__25_0;
				if (obj == null)
				{
					UnityAction val4 = delegate
					{
					};
					<>c.<>9__25_0 = val4;
					obj = (object)val4;
				}
				GameObject val5 = MenuHandler.CreateMenu("Mod Settings", (UnityAction)obj, ((Component)((Component)val3).transform.parent).gameObject, 60, true, true, ((Component)val2).gameObject, true, val3.childCount - 1);
				LobbySettingsHandler lobbySettingsHandler = val5.AddComponent<LobbySettingsHandler>();
				Transform val6 = val3.Find("Mod Settings");
				lobbySettingsHandler.settingsButton = ((Component)val6).gameObject;
				((Component)val6).GetComponent<LayoutElement>().minHeight = 92f;
				((Component)val6).GetComponent<LayoutElement>().minWidth = 5000f;
				((Component)val6).GetComponent<ListMenuButton>().setBarHeight = 92f;
				((Behaviour)((Component)val6).GetComponent<Button>()).enabled = false;
				((UnityEvent)((Component)val6).GetComponent<Button>().onClick).AddListener(new UnityAction(lobbySettingsHandler.Open));
				ButtonClickedEvent onClick = ((Component)val6).GetComponent<Button>().onClick;
				object obj2 = <>O.<0>__URPC_UnreadySelf;
				if (obj2 == null)
				{
					UnityAction val7 = URPC_UnreadySelf;
					<>O.<0>__URPC_UnreadySelf = val7;
					obj2 = (object)val7;
				}
				((UnityEvent)onClick).AddListener((UnityAction)obj2);
				lobbySettingsHandler.gameSettingsText = ((Component)val6).GetComponentInChildren<TextMeshProUGUI>();
				((TMP_Text)lobbySettingsHandler.gameSettingsText).enableAutoSizing = false;
				((TMP_Text)lobbySettingsHandler.gameSettingsText).fontSize = 60f;
				((Graphic)lobbySettingsHandler.gameSettingsText).color = ((PhotonNetwork.CurrentRoom != null) ? enabledTextColor : disabledTextColor);
				Transform val8 = val5.transform.Find("Group").Find("Back");
				Button component = ((Component)val8).GetComponent<Button>();
				((UnityEvent)component.onClick).AddListener(new UnityAction(lobbySettingsHandler.Close));
				ButtonClickedEvent onClick2 = component.onClick;
				object obj3 = <>O.<1>__BackActions;
				if (obj3 == null)
				{
					UnityAction val9 = BackActions;
					<>O.<1>__BackActions = val9;
					obj3 = (object)val9;
				}
				((UnityEvent)onClick2).AddListener((UnityAction)obj3);
				((UnityEvent)component.onClick).AddListener(new UnityAction(lobbySettingsHandler.DoReturnToLobbyActions));
			}
		}

		public static void RegisterMenu(string name, Action<GameObject> guiAction, bool hostOnly = true, UnityAction enterMenuAction = null, UnityAction returnToLobbyAction = null)
		{
			LobbySettingsHandler.RegisterMenu(name, guiAction, hostOnly, enterMenuAction, returnToLobbyAction);
		}
	}
}
namespace SettingsUI.Utils
{
	internal class LobbySettingsHandler : MonoBehaviourPunCallbacks
	{
		internal class ModMenu
		{
			public string menuName;

			public UnityAction enterMenuAction;

			public UnityAction returnToLobbyAction;

			public Action<GameObject> guiAction;

			public bool hostOnly;

			public ModMenu(string menuName, Action<GameObject> guiAction, bool hostOnly = true, UnityAction enterMenuAction = null, UnityAction returnToLobbyAction = null)
			{
				this.menuName = menuName;
				this.enterMenuAction = enterMenuAction;
				this.guiAction = guiAction;
				this.hostOnly = hostOnly;
				this.returnToLobbyAction = returnToLobbyAction;
			}
		}

		public static LobbySettingsHandler instance;

		internal GameObject settingsButton;

		internal TextMeshProUGUI gameSettingsText;

		private static List<ModMenu> modMenus = new List<ModMenu>();

		private Dictionary<ModMenu, GameObject> menuButtons = new Dictionary<ModMenu, GameObject>();

		private Dictionary<GameObject, bool> createdMenus = new Dictionary<GameObject, bool>();

		private GameObject _linksUi;

		private GameObject _pingUi;

		private GameObject _codeUi;

		private GameObject _timerUi;

		private GameObject _roundUi;

		private Transform ButtonContainer => ((Component)this).transform.Find("Group/Grid/Scroll View/Viewport/Content");

		private bool IsOpen
		{
			get
			{
				bool? obj;
				if (this == null)
				{
					obj = null;
				}
				else
				{
					GameObject obj2 = settingsButton;
					if (obj2 == null)
					{
						obj = null;
					}
					else
					{
						Transform transform = obj2.transform;
						if (transform == null)
						{
							obj = null;
						}
						else
						{
							Transform parent = transform.parent;
							if (parent == null)
							{
								obj = null;
							}
							else
							{
								GameObject gameObject = ((Component)parent).gameObject;
								obj = ((gameObject != null) ? new bool?(gameObject.activeSelf) : null);
							}
						}
					}
				}
				bool? flag = obj;
				return flag.GetValueOrDefault();
			}
		}

		private void Awake()
		{
			instance = this;
		}

		private void Start()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)gameSettingsText).color = ((PhotonNetwork.CurrentRoom != null) ? RWFSettingsUI.enabledTextColor : RWFSettingsUI.disabledTextColor);
		}

		public override void OnJoinedRoom()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (IsOpen)
			{
				((Graphic)gameSettingsText).color = RWFSettingsUI.enabledTextColor;
				((Behaviour)settingsButton.GetComponent<Button>()).enabled = true;
			}
		}

		public void Open()
		{
			if (!Object.op_Implicit((Object)(object)_linksUi))
			{
				_linksUi = GameObject.Find("Links(Clone)");
			}
			if (!Object.op_Implicit((Object)(object)_pingUi))
			{
				_pingUi = GameObject.Find("UIHolder");
			}
			if (!Object.op_Implicit((Object)(object)_codeUi))
			{
				_codeUi = GameObject.Find("LobbyImprovementsBG");
			}
			if (!Object.op_Implicit((Object)(object)_timerUi))
			{
				_timerUi = GameObject.Find("TimerLobbyUI(Clone)");
			}
			if (!Object.op_Implicit((Object)(object)_roundUi))
			{
				_roundUi = GameObject.Find("RoundCounterSmall");
			}
			if (Object.op_Implicit((Object)(object)_linksUi))
			{
				_linksUi.gameObject.SetActive(false);
			}
			if (Object.op_Implicit((Object)(object)_pingUi))
			{
				_pingUi.gameObject.SetActive(false);
			}
			if (Object.op_Implicit((Object)(object)_codeUi))
			{
				_codeUi.gameObject.SetActive(false);
			}
			if (Object.op_Implicit((Object)(object)_timerUi))
			{
				_timerUi.gameObject.SetActive(false);
			}
			if (Object.op_Implicit((Object)(object)_roundUi))
			{
				_roundUi.gameObject.SetActive(false);
			}
			GameObject val = default(GameObject);
			foreach (ModMenu item in modMenus.OrderBy((ModMenu modMenu) => modMenu.menuName))
			{
				if (!menuButtons.ContainsKey(item))
				{
					GameObject obj = MenuHandler.CreateMenu(item.menuName, item.enterMenuAction, ((Component)this).gameObject, ref val, 60, true, false, ((Component)((Component)this).transform.parent).gameObject, true, -1);
					createdMenus.Add(val, item.hostOnly);
					menuButtons.Add(item, val);
					try
					{
						item.guiAction(obj);
					}
					catch (Exception ex)
					{
						Debug.LogError((object)("Exception thrown when attempting to build menu '" + item.menuName + "', see log below for details."));
						Debug.LogException(ex);
					}
				}
			}
			foreach (KeyValuePair<GameObject, bool> createdMenu in createdMenus)
			{
				bool flag = !createdMenu.Value || PhotonNetwork.OfflineMode || PhotonNetwork.IsMasterClient;
				createdMenu.Key.SetActive(flag);
				((Behaviour)createdMenu.Key.GetComponent<Button>()).enabled = flag;
			}
		}

		public void Close()
		{
			if (Object.op_Implicit((Object)(object)_linksUi))
			{
				_linksUi.gameObject.SetActive(true);
			}
			if (Object.op_Implicit((Object)(object)_pingUi))
			{
				_pingUi.gameObject.SetActive(true);
			}
			if (Object.op_Implicit((Object)(object)_codeUi))
			{
				_codeUi.gameObject.SetActive(true);
			}
			if (Object.op_Implicit((Object)(object)_timerUi))
			{
				_timerUi.gameObject.SetActive(true);
			}
			if (Object.op_Implicit((Object)(object)_roundUi))
			{
				_roundUi.gameObject.SetActive(true);
			}
		}

		public void DoReturnToLobbyActions()
		{
			foreach (KeyValuePair<ModMenu, GameObject> menuButton in menuButtons)
			{
				try
				{
					UnityAction returnToLobbyAction = menuButton.Key.returnToLobbyAction;
					if (returnToLobbyAction != null)
					{
						returnToLobbyAction.Invoke();
					}
				}
				catch (Exception ex)
				{
					Debug.LogError((object)("The menu " + menuButton.Key.menuName + " threw an exception when executing it's 'Return To Lobby Action'. See Log Below."));
					Debug.LogException(ex);
				}
			}
		}

		public static void RegisterMenu(string name, Action<GameObject> guiAction, bool hostOnly = true, UnityAction enterMenuAction = null, UnityAction returnToLobbyAction = null)
		{
			modMenus.Add(new ModMenu(name, guiAction, hostOnly, enterMenuAction, returnToLobbyAction));
		}
	}
}
namespace SettingsUI.Patches
{
	internal class PrivateRoomHandler_Patch
	{
		public static void Initialize(Harmony harmony)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			MethodBase method = RWFSettingsUI.RWFPrivateRoomHandler.GetMethod("BuildUI", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod);
			harmony.Patch(method, (HarmonyMethod)null, new HarmonyMethod(typeof(PrivateRoomHandler_Patch), "OnBuildUI", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		[HarmonyPostfix]
		[HarmonyPatch("BuildUI")]
		private static void OnBuildUI()
		{
			RWFSettingsUI.InjectUIElements();
		}
	}
}