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/main_menu.gd

51 lines
1.1 KiB
GDScript3
Raw Permalink Normal View History

extends Control
var MultiplayerMenu = preload("res://scenes/menus/MultiplayerMenu.tscn")
var LocalGameMenu = preload("res://scenes/menus/LocalGameMenu.tscn")
var SettingsMenu = preload("res://scenes/menus/SettingsMenu.tscn")
func _ready():
gamestate.connect("server_disconnected", self, "_server_disconnected")
func _draw():
find_node("multiplayer").grab_focus()
func _on_multiplayer_pressed():
var multiplayer_menu = MultiplayerMenu.instance()
get_tree().get_root().add_child(multiplayer_menu)
hide()
func _on_practice_pressed():
var local_game_menu = LocalGameMenu.instance()
get_tree().get_root().add_child(local_game_menu)
hide()
func _on_settings_pressed():
var settings_menu = SettingsMenu.instance()
get_tree().get_root().add_child(settings_menu)
hide()
func _on_quit_pressed():
get_tree().quit()
func _server_disconnected():
show_error_dialog(tr("SERVER_DISCONNECTED"))
func show_error_dialog(text:String):
var dialog = get_node("error_dialog")
dialog.set_text(text)
dialog.popup_centered()
func _on_info_pressed():
var dialog = get_node("info_popup")
dialog.popup_centered()