This repository has been archived on 2020-09-30. You can view files and clone it, but cannot push or open issues or pull requests.
odyssey-old/Actors/Objects/Computer/UI/ControlComp.gd

28 lines
1.2 KiB
GDScript

extends Control
onready var scene = $"/root/scene" as GameInstance
func _physics_process(_delta):
var speed_str = str(round(scene.world.map.current_ship_speed * 10000)) + " u/s"
$Margin/Container/VelocityBox/HBoxContainer3/CurrentSpeed.text = speed_str
var dir_str = str(round(rad2deg(scene.world.map.current_ship_direction))) + " deg"
$Margin/Container/VelocityBox/HBoxContainer2/CurrentDirection.text = dir_str
var current_position_str = Coordinates.as_string(scene.world.map.current_ship_position, 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 _ship_velocity_changed(value):
scene.rpc("process_command", UICommand.new(UICommand.CommandType.SetShipSpeed, [value]))
func _ship_direction_changed(value):
scene.rpc("process_command", UICommand.new(UICommand.CommandType.SetShipDirection, [deg2rad(value)]))
func _map_button_pressed():
scene.ui.open_map_popup()
func force_close():
scene.ui.close_map_popup()