2021-11-15 15:43:33 -06:00
|
|
|
extends Node
|
|
|
|
|
2021-12-10 12:31:48 -06:00
|
|
|
const SignalledWebRTCMultiplayer = preload("./signalled_webrtc_multiplayer.gd")
|
2021-11-15 15:43:33 -06:00
|
|
|
|
2021-12-10 12:31:48 -06:00
|
|
|
onready var client = SignalledWebRTCMultiplayer.new()
|
2021-12-08 23:39:56 -06:00
|
|
|
|
|
|
|
onready var onetime_cmd_flags = {
|
2021-12-15 16:14:36 -06:00
|
|
|
"--singleplayer": false,
|
2021-12-08 23:39:56 -06:00
|
|
|
"--multiplayer": false,
|
|
|
|
"--create-lobby": false,
|
|
|
|
"--join-first-available-lobby": false,
|
|
|
|
}
|
|
|
|
|
|
|
|
func _ready():
|
2021-12-15 16:14:36 -06:00
|
|
|
get_tree().use_font_oversampling = true
|
2021-12-10 12:31:48 -06:00
|
|
|
add_child(client)
|
2021-12-08 23:39:56 -06:00
|
|
|
for flag in onetime_cmd_flags.keys():
|
|
|
|
if flag in OS.get_cmdline_args():
|
|
|
|
onetime_cmd_flags[flag] = true
|
2021-12-06 21:56:37 -06:00
|
|
|
|
2021-12-10 12:31:48 -06:00
|
|
|
func check_onetime_flag(flag):
|
|
|
|
var result = onetime_cmd_flags["--%s" % flag]
|
|
|
|
onetime_cmd_flags["--%s" % flag] = false
|
|
|
|
return result
|
|
|
|
|
2021-11-17 08:18:12 -06:00
|
|
|
func goto_scene(scene_resource_name):
|
2021-12-07 16:43:37 -06:00
|
|
|
var _result = get_tree().change_scene("res://screens/%s.tscn" % scene_resource_name)
|
2021-11-15 16:25:13 -06:00
|
|
|
|
2021-11-17 08:18:12 -06:00
|
|
|
func main_menu():
|
2021-12-10 12:31:48 -06:00
|
|
|
client.close()
|
2021-12-07 16:43:37 -06:00
|
|
|
goto_scene("main_menu")
|
2021-11-15 16:25:13 -06:00
|
|
|
|
2021-11-17 08:18:12 -06:00
|
|
|
func start_singleplayer_game():
|
2021-12-15 16:14:36 -06:00
|
|
|
client.singleplayer()
|
2021-12-08 23:39:56 -06:00
|
|
|
goto_game()
|
|
|
|
|
|
|
|
func goto_game():
|
2021-11-17 08:18:12 -06:00
|
|
|
goto_scene("game")
|
2021-11-15 15:43:33 -06:00
|
|
|
|
2021-11-17 13:57:45 -06:00
|
|
|
func lobby_browser():
|
2021-12-10 12:53:13 -06:00
|
|
|
goto_scene("lobby_browser")
|
2021-11-15 16:25:13 -06:00
|
|
|
|
2021-11-17 13:57:45 -06:00
|
|
|
func lobby():
|
2021-12-07 16:43:37 -06:00
|
|
|
goto_scene("multiplayer_lobby")
|
2021-11-17 13:57:45 -06:00
|
|
|
|
2021-11-17 08:18:12 -06:00
|
|
|
func quit():
|
2021-12-10 12:31:48 -06:00
|
|
|
client.close()
|
2021-11-17 08:18:12 -06:00
|
|
|
get_tree().quit()
|
2021-12-09 21:10:17 -06:00
|
|
|
|
|
|
|
func key_shortcut(code):
|
|
|
|
var sc = ShortCut.new()
|
|
|
|
sc.shortcut = InputEventKey.new()
|
|
|
|
sc.shortcut.scancode = code
|
|
|
|
return sc
|