20 lines
580 B
C#
20 lines
580 B
C#
using Godot;
|
|
|
|
public partial class ConnectButtonUI : Button
|
|
{
|
|
[Export] public TextEdit AddressField;
|
|
[Export] public Label ErrorLabel;
|
|
private const string BRACKET_SCENE_PATH = "res://scenes/bracket_view.tscn";
|
|
|
|
public override void _Ready()
|
|
{
|
|
Connection.Instance.OnWsConnectionSuccess += () => GetTree().ChangeSceneToFile(BRACKET_SCENE_PATH);
|
|
Connection.Instance.OnWsConnectionFailed += () => ErrorLabel.Text = "Couldn't connect to server! " + Connection.Instance.LastError;
|
|
}
|
|
|
|
public override void _Pressed()
|
|
{
|
|
Connection.Instance.Connect(AddressField.Text);
|
|
}
|
|
}
|