-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenu.cs
More file actions
30 lines (24 loc) · 1.04 KB
/
Copy pathMainMenu.cs
File metadata and controls
30 lines (24 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using Godot;
public partial class MainMenu : CanvasLayer
{
private void _OnCreatePressed()
{
var network = GetNode<Network>("/root/Network");
network.serverInfo.Name = GetNode<LineEdit>("Control/BoxContainer/PanelHost/txtServerName").Text;
network.serverInfo.MaxPlayers = (int)GetNode<SpinBox>("Control/BoxContainer/PanelHost/txtMaxPlayers").Value - 1;
network.serverInfo.UsedPort = int.Parse(GetNode<LineEdit>("Control/BoxContainer/PanelHost/txtServerPort").Text);
network.CreateServer();
}
private void _OnJoinPressed()
{
var port = int.Parse(GetNode<LineEdit>("Control/BoxContainer/PanelJoin/txtJoinPort").Text);
var ip = GetNode<LineEdit>("Control/BoxContainer/PanelJoin/txtJoinIP").Text;
var network = GetNode<Network>("/root/Network");
network.JoinServer(ip, port);
}
private void _OnTxtPlayerNameTextChanged(string newText)
{
var client = GetNode<Client>("/root/Client");
client.clientInfo.Name = newText;
}
}