diff options
Diffstat (limited to 'UI/Start.gd')
-rw-r--r-- | UI/Start.gd | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/UI/Start.gd b/UI/Start.gd new file mode 100644 index 0000000..c9a0342 --- /dev/null +++ b/UI/Start.gd @@ -0,0 +1,35 @@ +extends Control + + +func _ready(): + if OS.has_environment("USER"): + %Name.text = OS.get_environment("USER") + elif OS.has_environment("USERNAME"): + %Name.text = OS.get_environment("USERNAME") + + +func get_ip(): + var ip := "127.0.0.1" + if %IP.text: + ip = %IP.text + + return ip + + +func get_port(): + var port := 1234 + if %Port.text: + port = %Port.text + + return port + +func _on_host_pressed() -> void: + Client.player.username = %Name.text + Network.host_game(get_port()) + get_tree().change_scene_to_file("res://UI/Lobby.tscn") + + +func _on_join_pressed() -> void: + Client.player.username = %Name.text + Network.join_game(get_ip(), get_port()) + get_tree().change_scene_to_file("res://UI/Lobby.tscn") |