Make computer UI disappear when clicking elsewhere
This commit is contained in:
parent
97784eb24e
commit
958e91df75
3 changed files with 20 additions and 4 deletions
|
@ -44,14 +44,22 @@ func set_direction(dir):
|
||||||
$computer.region_rect.position = Vector2(32, 0)
|
$computer.region_rect.position = Vector2(32, 0)
|
||||||
$computer/screen.region_rect.position = screen_region_offset + Vector2(64, 0)
|
$computer/screen.region_rect.position = screen_region_offset + Vector2(64, 0)
|
||||||
|
|
||||||
func open_controls():
|
func manage_controls(show: bool):
|
||||||
match computer_type:
|
match computer_type:
|
||||||
ComputerType.ShipCommand:
|
ComputerType.ShipCommand:
|
||||||
$Control/ControlComp.visible = true
|
$Control/ControlComp.visible = show
|
||||||
|
|
||||||
|
func _input(event):
|
||||||
|
if event is InputEventMouseButton and event.pressed and not is_inside:
|
||||||
|
manage_controls(false)
|
||||||
|
|
||||||
func _input_event(viewport, event, shape_idx):
|
func _input_event(viewport, event, shape_idx):
|
||||||
if Engine.editor_hint:
|
if Engine.editor_hint:
|
||||||
return
|
return
|
||||||
if event is InputEventMouseButton and event.pressed:
|
if event is InputEventMouseButton and event.pressed:
|
||||||
print(event)
|
manage_controls(true)
|
||||||
open_controls()
|
|
||||||
|
var is_inside = false
|
||||||
|
func _ui_focus_changed(entered):
|
||||||
|
print(entered)
|
||||||
|
is_inside = entered
|
||||||
|
|
|
@ -76,3 +76,5 @@ margin_top = -78.3109
|
||||||
margin_right = 166.851
|
margin_right = 166.851
|
||||||
margin_bottom = 53.6891
|
margin_bottom = 53.6891
|
||||||
rect_scale = Vector2( 0.5, 0.5 )
|
rect_scale = Vector2( 0.5, 0.5 )
|
||||||
|
[connection signal="mouse_entered" from="Control/ControlComp" to="." method="_ui_focus_changed" binds= [ true ]]
|
||||||
|
[connection signal="mouse_exited" from="Control/ControlComp" to="." method="_ui_focus_changed" binds= [ false ]]
|
||||||
|
|
|
@ -7,6 +7,7 @@ margin_left = -100.0
|
||||||
margin_top = -150.0
|
margin_top = -150.0
|
||||||
margin_right = 100.0
|
margin_right = 100.0
|
||||||
margin_bottom = -20.0
|
margin_bottom = -20.0
|
||||||
|
mouse_filter = 1
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="Panel" type="Panel" parent="."]
|
[node name="Panel" type="Panel" parent="."]
|
||||||
|
@ -15,6 +16,7 @@ margin_top = 90.0
|
||||||
margin_right = 140.0
|
margin_right = 140.0
|
||||||
margin_bottom = 130.0
|
margin_bottom = 130.0
|
||||||
rect_rotation = 45.0
|
rect_rotation = 45.0
|
||||||
|
mouse_filter = 1
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
@ -47,12 +49,14 @@ __meta__ = {
|
||||||
margin_top = 5.0
|
margin_top = 5.0
|
||||||
margin_right = 180.0
|
margin_right = 180.0
|
||||||
margin_bottom = 19.0
|
margin_bottom = 19.0
|
||||||
|
mouse_filter = 1
|
||||||
text = "Ship velocity"
|
text = "Ship velocity"
|
||||||
|
|
||||||
[node name="HSlider" type="HSlider" parent="Container/VelocityBox"]
|
[node name="HSlider" type="HSlider" parent="Container/VelocityBox"]
|
||||||
margin_top = 23.0
|
margin_top = 23.0
|
||||||
margin_right = 180.0
|
margin_right = 180.0
|
||||||
margin_bottom = 39.0
|
margin_bottom = 39.0
|
||||||
|
mouse_filter = 1
|
||||||
max_value = 1000.0
|
max_value = 1000.0
|
||||||
value = 1000.0
|
value = 1000.0
|
||||||
tick_count = 10
|
tick_count = 10
|
||||||
|
@ -73,12 +77,14 @@ __meta__ = {
|
||||||
margin_top = 5.0
|
margin_top = 5.0
|
||||||
margin_right = 180.0
|
margin_right = 180.0
|
||||||
margin_bottom = 19.0
|
margin_bottom = 19.0
|
||||||
|
mouse_filter = 1
|
||||||
text = "Ship direction"
|
text = "Ship direction"
|
||||||
|
|
||||||
[node name="HSlider" type="HSlider" parent="Container/DirectionBox"]
|
[node name="HSlider" type="HSlider" parent="Container/DirectionBox"]
|
||||||
margin_top = 23.0
|
margin_top = 23.0
|
||||||
margin_right = 180.0
|
margin_right = 180.0
|
||||||
margin_bottom = 39.0
|
margin_bottom = 39.0
|
||||||
|
mouse_filter = 1
|
||||||
max_value = 360.0
|
max_value = 360.0
|
||||||
tick_count = 18
|
tick_count = 18
|
||||||
ticks_on_borders = true
|
ticks_on_borders = true
|
||||||
|
|
Reference in a new issue