-
Notifications
You must be signed in to change notification settings - Fork 1
/
PlanetDetails.gd
54 lines (35 loc) · 1.21 KB
/
PlanetDetails.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
extends PanelContainer
var planet: Planet setget _set_planet
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if weakref(planet).get_ref():
if planet.mass != $VBoxContainer/Mass.value:
$VBoxContainer/Mass.value = planet.mass
$VBoxContainer/Mass/Label.text = "%0.2f" % planet.mass
else:
planet = null
hide()
func _set_planet(new_planet: Planet):
planet = new_planet
$VBoxContainer/Name.text = planet.id
$VBoxContainer/Color.color = planet.color
func _unhandled_input(event):
if event is InputEventMouseButton:
$VBoxContainer/Mass.release_focus()
$VBoxContainer/Name.release_focus()
$VBoxContainer/Color.release_focus()
func _on_Mass_value_changed(value):
if weakref(planet).get_ref():
planet.mass = value
$VBoxContainer/Mass/Label.text = "%0.2f" % planet.mass
$VBoxContainer/Mass.release_focus()
func _on_Color_color_changed(color):
if weakref(planet).get_ref():
planet.color = color
$VBoxContainer/Color.release_focus()
func _on_Name_text_changed(new_text):
if weakref(planet).get_ref():
planet.id = new_text