diff options
Diffstat (limited to 'Client/Assembly-CSharp/ServerSelector.cs')
-rw-r--r-- | Client/Assembly-CSharp/ServerSelector.cs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/ServerSelector.cs b/Client/Assembly-CSharp/ServerSelector.cs new file mode 100644 index 0000000..b29aa30 --- /dev/null +++ b/Client/Assembly-CSharp/ServerSelector.cs @@ -0,0 +1,53 @@ +using System; +using System.Net; +using UnityEngine; +using UnityEngine.Events; + +public class ServerSelector : MonoBehaviour +{ + public ServerSelectUi Parent { get; set; } + + public ServerInfo MyServer = new ServerInfo(); + + public TextRenderer Text; + + public ButtonRolloverHandler Background; + + public TextBox ipInput; + + public void Start() + { + if (this.ipInput) + { + this.ipInput.SetText(this.MyServer.Ip, ""); + this.ipInput.OnChange.AddListener(new UnityAction(this.OnIpChange)); + return; + } + this.Text.Text = this.MyServer.Name; + } + + private void OnIpChange() + { + IPAddress ipaddress; + if (!IPAddress.TryParse(this.ipInput.text, out ipaddress)) + { + return; + } + this.MyServer.Name = "Custom"; + this.MyServer.Ip = this.ipInput.text; + this.Select(); + } + + public void Select() + { + this.Background.OutColor = Color.green; + this.Background.DoMouseOut(); + this.Parent.SelectServer(this); + } + + internal void Unselect() + { + this.Background.OutColor = Color.white; + this.Background.DoMouseOut(); + } +} |