extends Node

onready var NetworkService = $"/root/NetworkService"
onready var ConsoleService = $"/root/ConsoleService"
onready var TaskService = $"/root/TaskService"

# Called when the node enters the scene tree for the first time.
func _ready():
	if NetworkService.NETWORK_MODE == 'server':
		$"TabContainer/Singleplayer".queue_free()

	ConsoleService.connect("on_log", self, "update_log")
	ConsoleService.connect("on_error", self, "update_log")
	$"TabContainer/Logs/LogList".text = PoolStringArray(ConsoleService.log_messages).join("\n")
	$"TabContainer/Singleplayer/Start Game".connect("button_down", self, "start_game");
	
func update_log(log_messages):
	$"TabContainer/Logs/LogList".text = PoolStringArray(log_messages).join("\n")
	
func start_game():
	var scene_root = $"/root/Main/Scene"
	scene_root.remove_child(self);
	TaskService.start('start_game', "Singleplayer pressed.")
