This repository has been archived on 2023-12-19. You can view files and clone it, but cannot push or open issues or pull requests.
MUR/scripts/menus/direct_host_menu.gd

33 lines
775 B
GDScript3
Raw Normal View History

extends Control
var LobbyMenu = preload("res://scenes/menus/LobbyMenu.tscn")
func _ready():
find_node("bots").set_pressed(config.get_value("game","bots", true))
func _draw():
find_node("host").grab_focus()
func _on_host_pressed():
var port = find_node("port").get_value()
var bots = find_node("bots").is_pressed()
var err = server.host_game(int(port), bots)
if err == OK:
var lobby_menu = LobbyMenu.instance()
get_tree().get_root().add_child(lobby_menu)
gamestate.set_player(get_tree().get_network_unique_id())
queue_free()
else:
_on_back_pressed()
get_tree().get_root().get_node("multiplayer_menu").show_error_dialog(tr("ERROR_SERVER_CREATION"))
func _on_back_pressed():
queue_free()
get_tree().get_root().get_node("multiplayer_menu").show()