internal static void RefreshDirectConnectButton() { if (!GameObject.Find("RegionMenu")) { return; } if (DirectConnect) { DirectConnect.gameObject.Destroy(); } RegionMenu regionMenu = DestroyableSingleton <RegionMenu> .Instance; JoinGameButton joinGameButton = DestroyableSingleton <JoinGameButton> .Instance; DirectConnect = Object.Instantiate(joinGameButton.GameIdText, regionMenu.transform); DirectConnect.GetComponentInChildren <TextTranslatorTMP>().Destroy(); DirectConnect.GetComponent <JoinGameButton>().Destroy(); DirectConnect.outputText.text = "Enter IP"; DirectConnect.IpMode = true; DirectConnect.characterLimit = 15; DirectConnect.ClearOnFocus = false; DirectConnect.OnEnter = new Button.ButtonClickedEvent(); DirectConnect.OnEnter.AddListener((Action)UpdateRegion); int offset = NewRegions.Length + ModRegions.Count; DirectConnect.transform.localPosition = new Vector3(0, 1f - (offset / 2f), -100f); }
public static bool Prefix(ref RegionMenu __instance) { ClearOnClickAction(__instance.ButtonPool); CustomServerInfo customServer = new CustomServerInfo("FloofUs", "77.55.217.159", 22023); customServers.Add(customServer); if (ServerManager.DefaultRegions.Count != 3 + customServers.Count || forceReloadServers) { var regions = new IRegionInfo[3 + customServers.Count]; for (int i = 0; i < 3; i++) { regions[i] = _defaultRegions[i]; } for (int i = 0; i < customServers.Count; i++) { Il2CppReferenceArray <ServerInfo> servers = new [] { new ServerInfo(customServers[i].name, customServers[i].ip, (ushort)customServers[i].port) }; regions[i + 3] = new DnsRegionInfo(customServers[i].ip, customServers[i].name, StringNames.NoTranslation, servers).Cast <IRegionInfo>(); } ServerManager.DefaultRegions = regions; ServerManager.Instance.AvailableRegions = regions; ServerManager.Instance.SaveServers(); } return(true); }
public static bool Prefix(RegionMenu __instance, [HarmonyArgument(0)] IRegionInfo region) { if (region.PingServer == "Manage servers...") { if (_managementForm == null || _managementForm.IsDisposed) { _managementForm = new ServersManagementForm(); } _managementForm.regionMenu = __instance; if (_managementForm.Visible) { _managementForm.Focus(); } else { _managementForm.ShowDialog(); } return(false); } else { return(true); } }
/// <summary> /// region menu /// </summary> public void regionMenu_Click() { RegionMenu.InitializeWebElement(); RegionMenu.WaitUntilExists(); if (RegionMenu.Displayed) { RegionMenu.Click(); } }
public static bool Prefix(ref RegionMenu __instance) { ClearOnClickAction(__instance.ButtonPool); if (_firstRun) { for (int i = 0; i < 3; i++) { _defaultRegions[i] = ServerManager.DefaultRegions[i]; } _firstRun = false; } Directory.CreateDirectory(CustomServersPlugin.userDataPath); if (File.Exists(Path.Combine(CustomServersPlugin.userDataPath, CustomServersPlugin.customServersFilePath))) { customServers = JsonConvert.DeserializeObject <List <CustomServerInfo> >(File.ReadAllText(Path.Combine(CustomServersPlugin.userDataPath, CustomServersPlugin.customServersFilePath))); CustomServersPlugin.Logger.LogDebug("Loaded custom servers list from file!"); } else { CustomServersPlugin.Logger.LogWarning("Custom servers list file not found!"); } if (ServerManager.DefaultRegions.Count != 4 + customServers.Count || forceReloadServers) { var regions = new RegionInfo[4 + customServers.Count]; regions[0] = new RegionInfo("Manage servers...", "MANAGE_SERVERS", null); for (int i = 0; i < 3; i++) { regions[i + 1] = _defaultRegions[i]; } for (int i = 0; i < customServers.Count; i++) { Il2CppReferenceArray <ServerInfo> servers = new ServerInfo[1] { new ServerInfo(customServers[i].name, customServers[i].ToString(), (ushort)customServers[i].port) }; regions[i + 4] = new RegionInfo(customServers[i].name, "0", servers); } ServerManager.DefaultRegions = regions; } return(true); }
private static void UpdateRegion() { RegionMenu regionMenu = DestroyableSingleton <RegionMenu> .Instance; bool success = UnifyPlugin.SetDirectRegion(DirectConnect.text, out IRegionInfo newRegion); if (!success) { DirectConnect.StartCoroutine(Effects.SwayX(DirectConnect.transform, 0.75f, 0.25f)); return; } regionMenu.ChooseOption(newRegion); regionMenu.Close(); }
public static bool Prefix(ref RegionMenu __instance) { ClearOnClickAction(__instance.ButtonPool); Directory.CreateDirectory(CustomServersPlugin.userDataPath); if (File.Exists(Path.Combine(CustomServersPlugin.userDataPath, CustomServersPlugin.customServersFilePath))) { customServers = JsonConvert.DeserializeObject <List <CustomServerInfo> >(File.ReadAllText(Path.Combine(CustomServersPlugin.userDataPath, CustomServersPlugin.customServersFilePath))); CustomServersPlugin.Logger.LogDebug("Loaded custom servers list from file!"); } else { CustomServersPlugin.Logger.LogWarning("Custom servers list file not found!"); } if (ServerManager.DefaultRegions.Count != 4 + customServers.Count || forceReloadServers) { var regions = new IRegionInfo[4 + customServers.Count]; regions[0] = new DnsRegionInfo("Manage servers...", "Manage servers...", StringNames.NoTranslation, "Manage servers...").Cast <IRegionInfo>(); for (int i = 0; i < 3; i++) { regions[i + 1] = _defaultRegions[i]; } for (int i = 0; i < customServers.Count; i++) { Il2CppReferenceArray <ServerInfo> servers = new ServerInfo[1] { new ServerInfo(customServers[i].name, customServers[i].ip, (ushort)customServers[i].port) }; regions[i + 4] = new DnsRegionInfo(customServers[i].ip, customServers[i].name, StringNames.NoTranslation, servers).Cast <IRegionInfo>(); } ServerManager.DefaultRegions = regions; ServerManager.Instance.AvailableRegions = regions; ServerManager.Instance.SaveServers(); } return(true); }
public static void Postfix(RegionMenu __instance) { var template = DestroyableSingleton <JoinGameButton> .Instance; if (ipField == null || ipField.gameObject == null) { ipField = UnityEngine.Object.Instantiate(template.GameIdText, __instance.transform); ipField.gameObject.name = "IpTextBox"; UnityEngine.Object.DestroyImmediate(ipField.transform.FindChild("arrowEnter").gameObject); ipField.transform.localPosition = new Vector3(0, -1f, -100f); ipField.characterLimit = 30; ipField.AllowSymbols = true; ipField.ForceUppercase = false; ipField.SetText(StreamHatsPlugin.Ip.Value); __instance.StartCoroutine(Effects.Lerp(0.1f, new Action <float>((p) => { ipField.outputText.SetText(StreamHatsPlugin.Ip.Value); ipField.SetText(StreamHatsPlugin.Ip.Value); }))); ipField.ClearOnFocus = false; ipField.OnEnter = ipField.OnChange = new Button.ButtonClickedEvent(); ipField.OnFocusLost = new Button.ButtonClickedEvent(); ipField.OnChange.AddListener((UnityAction)onEnterOrIpChange); ipField.OnFocusLost.AddListener((UnityAction)onFocusLost); void onEnterOrIpChange() { StreamHatsPlugin.Ip.Value = ipField.text; } void onFocusLost() { StreamHatsPlugin.UpdateRegions(); __instance.ChooseOption(ServerManager.DefaultRegions[ServerManager.DefaultRegions.Length - 1]); } } if (portField == null || portField.gameObject == null) { portField = UnityEngine.Object.Instantiate(template.GameIdText, __instance.transform); portField.gameObject.name = "PortTextBox"; UnityEngine.Object.DestroyImmediate(portField.transform.FindChild("arrowEnter").gameObject); portField.transform.localPosition = new Vector3(0, -1.75f, -100f); portField.characterLimit = 5; portField.SetText(StreamHatsPlugin.Port.Value.ToString()); __instance.StartCoroutine(Effects.Lerp(0.1f, new Action <float>((p) => { portField.outputText.SetText(StreamHatsPlugin.Port.Value.ToString()); portField.SetText(StreamHatsPlugin.Port.Value.ToString()); }))); portField.ClearOnFocus = false; portField.OnEnter = portField.OnChange = new Button.ButtonClickedEvent(); portField.OnFocusLost = new Button.ButtonClickedEvent(); portField.OnChange.AddListener((UnityAction)onEnterOrPortFieldChange); portField.OnFocusLost.AddListener((UnityAction)onFocusLost); void onEnterOrPortFieldChange() { ushort port = 0; if (ushort.TryParse(portField.text, out port)) { StreamHatsPlugin.Port.Value = port; portField.outputText.color = Color.white; } else { portField.outputText.color = Color.red; } } void onFocusLost() { StreamHatsPlugin.UpdateRegions(); __instance.ChooseOption(ServerManager.DefaultRegions[ServerManager.DefaultRegions.Length - 1]); } } }
public static void Postfix(RegionMenu __instance) { var template = DestroyableSingleton <JoinGameButton> .Instance; if (ipField == null || ipField.gameObject == null) { ipField = UnityEngine.Object.Instantiate(template.GameIdText, __instance.transform); ipField.gameObject.name = "IpTextBox"; UnityEngine.Object.DestroyImmediate(ipField.transform.FindChild("arrowEnter").gameObject); ipField.transform.localPosition = new Vector3(0, -1f, -100f); ipField.characterLimit = 30; ipField.AllowSymbols = true; ipField.SetText(TheOtherRolesPlugin.Ip.Value); __instance.StartCoroutine(Effects.Lerp(0.1f, new Action <float>((p) => { ipField.outputText.SetText(TheOtherRolesPlugin.Ip.Value); ipField.SetText(TheOtherRolesPlugin.Ip.Value); }))); ipField.ClearOnFocus = false; ipField.OnFocusLost = ipField.OnEnter = ipField.OnChange = new Button.ButtonClickedEvent(); ipField.OnChange.AddListener((UnityAction)ipEvent); void ipEvent() { TheOtherRolesPlugin.Ip.Value = ipField.text; TheOtherRolesPlugin.CustomRegion.DefaultIp = ipField.text; } } if (portField == null || portField.gameObject == null) { portField = UnityEngine.Object.Instantiate(template.GameIdText, __instance.transform); portField.gameObject.name = "PortTextBox"; UnityEngine.Object.DestroyImmediate(portField.transform.FindChild("arrowEnter").gameObject); portField.transform.localPosition = new Vector3(0, -1.75f, -100f); portField.characterLimit = 5; portField.SetText(TheOtherRolesPlugin.Port.Value.ToString()); __instance.StartCoroutine(Effects.Lerp(0.1f, new Action <float>((p) => { portField.outputText.SetText(TheOtherRolesPlugin.Port.Value.ToString()); portField.SetText(TheOtherRolesPlugin.Port.Value.ToString()); }))); portField.ClearOnFocus = false; portField.OnFocusLost = portField.OnEnter = portField.OnChange = new Button.ButtonClickedEvent(); portField.OnChange.AddListener((UnityAction)portEvent); void portEvent() { ushort port = 0; if (ushort.TryParse(portField.text, out port)) { TheOtherRolesPlugin.Port.Value = port; TheOtherRolesPlugin.CustomRegion.Port = port; portField.outputText.color = Color.white; } else { portField.outputText.color = Color.red; } } } }
public void MouseDown(object sender, MouseEventArgs e) { if (state == ControlState.Cave && !MiniGameEnd) { minigame.Down(e); } if (state == ControlState.Cave && MiniGameEnd && view.IsEndAnimation()) { view.StopAnimation(); RegionCave rg = view.GetRegionCave(e.X, e.Y); if (rg >= 0 && (int)rg < 6 && map.isActive[map.Room][(int)rg]) { if (e.Button == MouseButtons.Left) { int WumpusRun = Utily.Next() % 8; if (WumpusRun < Difficulty) { map.WumpusGoAway(1); } int add = map.Move((int)rg); player.AddCoins(add); score.AddScores(5 * add); view.StartAddCoinAnimation(add); if (map.danger == Danger.Bat) { view.StartBatAnimation(); } view.StartMoveAnimation((int)rg); CheckDanger = false; } else { player.PushArrow(); map.PushArrow((int)rg); view.StartArrowAnimation((int)rg); List <string> achiv = new List <string>(); player.GetAchievement(achiv); score.getAchievement(achiv); } } if (rg == RegionCave.BuyArrow) { if (player.CanBuyArrow()) { StoryMiniGame = StoryMG.BuyArrow; MiniGameEnd = false; minigame = new MiniGame(Width, Height); minigame.HintText = Messages.ArrowHintText; minigame.InitializeMiniGame(ArroDiff[Difficulty]); UseMiniGame = true; player.BuyArrows(); } else { view.AddComand(string.Format(Messages.NotEnoughCoins, player.NeedForBuyArrows()), true, false); } } if (rg == RegionCave.BuyHint) { if (player.CanBuyHint()) { StoryMiniGame = StoryMG.BuyHint; MiniGameEnd = false; minigame = new MiniGame(Width, Height); minigame.HintText = Messages.HintHintText; minigame.InitializeMiniGame(HintDiff[Difficulty]); UseMiniGame = true; player.BuyHint(); } else { view.AddComand(string.Format(Messages.NotEnoughCoins, player.NeedForBuyHint()), true, false); } } if (rg == RegionCave.UpConsole) { view.ChangeIndex(1); } if (rg == RegionCave.DownConsole) { view.ChangeIndex(-1); } } if (state == ControlState.MainMenu) { RegionMenu rg = view.GetRegionMainMenu(e.X, e.Y); if (rg == RegionMenu.NewGame) { NewGame(); } if (rg == RegionMenu.Continue) { ContinueMenu(); } if (rg == RegionMenu.ScoreList) { score = new Scores(Width, Height); score.LoadLeaders(false); state = ControlState.ScoreList; } if (rg == RegionMenu.Exit) { Application.Exit(); } } if (state == ControlState.PickCave) { RegionPickCave rg = view.GetRegionPickCave(e.X, e.Y); int Intrg = (int)rg; if (Intrg < 5) { numPickCave = Intrg; } if (Intrg >= (int)RegionPickCave.Diff1 && Intrg <= (int)RegionPickCave.Diff3) { numDiff = Intrg - (int)RegionPickCave.Diff1; } if (rg == RegionPickCave.Play) { StartAfterPick(); } } }