extends Control

onready var scene = $"/root/scene" as GameInstance

func _physics_process(_delta):
	if not visible:
		return
	var speed_str = "%.0f u/s" % (scene.world.map.current_ship_speed * 10000)
	$Margin/Container/VelocityBox/HBoxContainer3/CurrentSpeed.text = speed_str
	var dir_str = "%.0f deg" % rad2deg(scene.world.map.current_ship_direction)
	$Margin/Container/VelocityBox/HBoxContainer2/CurrentDirection.text = dir_str
	var current_position_str = Coordinates.as_string(scene.world.map.current_ship_position + scene.world.map.current_ship_subpos, true)
	$Margin/Container/VelocityBox/HBoxContainer4/CurrentPosition.text = current_position_str
	var current_target_str = scene.world.map.current_ship_target
	if current_target_str == null:
		$Margin/Container/VelocityBox/HBoxContainer/CurrentTarget.text = "None"
	else:
		$Margin/Container/VelocityBox/HBoxContainer/CurrentTarget.text = Coordinates.as_string(current_target_str, true)

func _map_button_pressed():
	scene.ui.open_popup(GameUI.PopupName.SpaceMap)

func force_close():
	scene.ui.close_popup(GameUI.PopupName.SpaceMap)
