Link back button to quit code main menu

This commit is contained in:
VAILLANT Jeremy
2021-05-15 17:17:12 +02:00
parent 1265684c53
commit 890931faa8
5 changed files with 11 additions and 45 deletions
Binary file not shown.
+1
View File
@@ -13,6 +13,7 @@ __meta__ = {
[node name="TextureButton" type="TextureButton" parent="."]
margin_right = 40.0
margin_bottom = 40.0
mouse_default_cursor_shape = 2
texture_normal = ExtResource( 1 )
texture_hover = ExtResource( 2 )
texture_focused = ExtResource( 2 )
+1 -23
View File
@@ -18,15 +18,9 @@ func _ready():
_load_meshes()
func _process(_delta):
_check_quit_scene()
_check_dissolve_mesh()
_check_change_angle_camera()
func _check_quit_scene():
# Event key "escape" and "godot event" ui_end
if Input.is_action_just_pressed("ui_end"):
_confirm_before_quit()
func _check_dissolve_mesh():
# Event dissolve in object searched by gamer
for key in meshes:
@@ -109,29 +103,13 @@ func _gyroscope_changed_up(gyroscope):
(gyroscope.abs().x - gyroscope_value_old.abs().x) > GYROSCOPE_MAX_DIFF and \
gyroscope.x < gyroscope_value_old.x
func _notification(what):
# Notification for android back action
if what == MainLoop.NOTIFICATION_WM_GO_BACK_REQUEST:
_confirm_before_quit()
func _confirm_before_quit():
$Dialog/ConfirmEscape.popup()
# Back to main scene
func _quit_to_menu():
Global.goto_scene("res://scenes/main.tscn")
func _start_dissolve(key):
if meshes[key].lock() == false:
meshes[key].set_lock(true)
func _on_ConfirmEscape_confirmed():
_quit_to_menu()
## PRIVATE
func _load_translations():
$Dialog/ConfirmEscape.set_title(tr("SCENE_WARCRAFT_DIALOG_QUIT_TITLE"))
$Dialog/ConfirmEscape.set_text(tr("SCENE_WARCRAFT_DIALOG_QUIT_QUESTION"))
pass
func _load_meshes():
var scene_detail = null
+4 -2
View File
@@ -1,4 +1,6 @@
extends "res://scenes/levels/levels.gd"
func _ready():
pass
# Back to main scene
func _on_TextureButton_pressed():
print("[levels#_on_TextureButton_pressed] quit to menu")
Global.goto_scene("res://scenes/main.tscn")
+5 -20
View File
@@ -544,23 +544,6 @@ use_in_baked_light = true
mesh = ExtResource( 9 )
material/0 = null
[node name="Dialog" type="Control" parent="."]
margin_right = 40.0
margin_bottom = 40.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ConfirmEscape" type="ConfirmationDialog" parent="Dialog"]
visible = true
margin_right = 200.0
margin_bottom = 70.0
rect_min_size = Vector2( 400, 140 )
window_title = "Veuillez confirmer…"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="sm_gabarit_male" type="MeshInstance" parent="."]
transform = Transform( 0.534795, 0, 0.844982, 0, 1, 0, -0.844982, 0, 0.534795, -4.02751, 0.0561329, -0.889434 )
mesh = ExtResource( 20 )
@@ -754,8 +737,10 @@ collision_mask = 2
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0358186, 0, 0.0109152 )
shape = SubResource( 18 )
[node name="Control" parent="." instance=ExtResource( 44 )]
[node name="ListObjects" parent="." instance=ExtResource( 44 )]
[node name="Control2" parent="." instance=ExtResource( 45 )]
[node name="Quit" parent="." instance=ExtResource( 45 )]
[connection signal="confirmed" from="Dialog/ConfirmEscape" to="." method="_on_ConfirmEscape_confirmed"]
[connection signal="pressed" from="Quit/TextureButton" to="." method="_on_TextureButton_pressed"]
[editable path="Quit"]