67 lines
1.3 KiB
GDScript
67 lines
1.3 KiB
GDScript
extends Control
|
|
|
|
var host : bool
|
|
var handle : String
|
|
func _on_host_game_button_pressed() -> void:
|
|
%Menu.visible = false
|
|
%Hosting.visible = true
|
|
host = true
|
|
|
|
|
|
func _on_join_game_button_pressed() -> void:
|
|
%Menu.visible = false
|
|
%Joining.visible = true
|
|
host = false
|
|
|
|
|
|
func _on_menu_back_button_pressed() -> void:
|
|
Game.go_to_title_screen()
|
|
|
|
|
|
func _on_start_hosting_button_pressed() -> void:
|
|
var host_name = %HostHandle.text
|
|
if len(host_name) < 3:
|
|
return
|
|
handle = host_name
|
|
Multiplayer.handle = handle
|
|
#Validate entries
|
|
%Hosting.visible = false
|
|
#Set fields
|
|
%ParticipantsText.text = "[color=FFFF00]*%s (HOST)[/color]\n" % handle
|
|
%"Host Waiting".visible = true
|
|
Multiplayer.become_host()
|
|
|
|
|
|
func _on_hosting_back_button_pressed() -> void:
|
|
%Hosting.visible = false
|
|
%Menu.visible = true
|
|
|
|
|
|
func _on_start_game_button_pressed() -> void:
|
|
Game.start_vs_com()
|
|
|
|
|
|
func _on_waiting_back_button_pressed() -> void:
|
|
%"Host Waiting".visible = false
|
|
if host:
|
|
%Hosting.visible = true
|
|
else:
|
|
%Joining.visible = true
|
|
|
|
|
|
func _on_join_button_pressed() -> void:
|
|
var host_name = %JoinHandle.text
|
|
if len(host_name) < 3:
|
|
return
|
|
handle = host_name
|
|
#Check for valid game
|
|
#If found
|
|
%Joining.visible = false
|
|
if Multiplayer.join_game(handle):
|
|
%"Host Waiting".visible = true
|
|
|
|
|
|
func _on_joining_back_button_pressed() -> void:
|
|
%Joining.visible = false
|
|
%Menu.visible = true
|