Public repository for MUR pre alpha
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.2 KiB

  1. extends Control
  2. var LobbyMenu = preload("res://scenes/menus/LobbyMenu.tscn")
  3. func _ready():
  4. find_node("bots").set_pressed(config.get_value("game","bots", true))
  5. find_node("bot_difficulty").set_value(config.get_value("game","bot_difficulty", gamestate.DEFAULT_BOT_DIFFICULTY))
  6. find_node("bot_difficulty").set_editable(find_node("bots").is_pressed())
  7. find_node("bot_difficulty").set_tooltip(tr("BOT_DIFFICULTY"))
  8. func _draw():
  9. find_node("host").grab_focus()
  10. func _on_host_pressed():
  11. var port = find_node("port").get_value()
  12. var bots = find_node("bots").is_pressed()
  13. var bot_difficulty = find_node("bot_difficulty").get_value()
  14. var err = server.host_game(int(port), bots, bot_difficulty)
  15. if err == OK:
  16. var lobby_menu = LobbyMenu.instance()
  17. get_tree().get_root().add_child(lobby_menu)
  18. gamestate.set_player(get_tree().get_network_unique_id())
  19. queue_free()
  20. else:
  21. _on_back_pressed()
  22. get_tree().get_root().get_node("multiplayer_menu").show_error_dialog(tr("ERROR_SERVER_CREATION"))
  23. func _on_back_pressed():
  24. queue_free()
  25. get_tree().get_root().get_node("multiplayer_menu").show()
  26. func _on_bots_toggled(button_pressed):
  27. find_node("bot_difficulty").set_editable(button_pressed)