2021-04-09 11:19:10 +02:00
|
|
|
extends Control
|
|
|
|
|
2021-04-25 00:30:26 +02:00
|
|
|
onready var panel := $MarginContainer/Panel
|
|
|
|
onready var background := $Background
|
|
|
|
onready var tween := $Tween
|
|
|
|
|
|
|
|
var animation_speed = 0.4
|
|
|
|
|
2021-04-10 18:29:03 +02:00
|
|
|
func load_main_menu():
|
2021-04-25 00:07:38 +02:00
|
|
|
Transit.change_scene("res://scenes/MainMenu.tscn", 0.5)
|
2021-04-10 18:29:03 +02:00
|
|
|
|
|
|
|
|
2021-04-09 11:19:10 +02:00
|
|
|
func pause():
|
2021-04-25 00:30:26 +02:00
|
|
|
if not get_tree().paused:
|
|
|
|
get_tree().paused = true
|
|
|
|
show()
|
|
|
|
tween.stop_all()
|
|
|
|
tween.interpolate_property(background, "modulate", null, Color(1, 1, 1, 1), 2*animation_speed/3, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
|
|
|
|
tween.interpolate_property(panel, "modulate", null, Color(1, 1, 1, 1), animation_speed, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
|
|
|
|
tween.start()
|
2021-04-09 11:19:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
func unpause():
|
2021-04-25 00:30:26 +02:00
|
|
|
if get_tree().paused:
|
|
|
|
get_tree().paused = false
|
|
|
|
tween.stop_all()
|
|
|
|
tween.interpolate_property(background, "modulate", null, Color(1, 1, 1, 0), animation_speed/2, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
|
|
|
|
tween.interpolate_property(panel, "modulate", null, Color(1, 1, 1, 0), animation_speed/2, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
|
|
|
|
tween.start()
|
2021-04-09 11:19:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
func _ready():
|
2021-04-25 00:30:26 +02:00
|
|
|
panel.modulate = Color(1, 1, 1, 0)
|
|
|
|
background.modulate = Color(1, 1, 1, 0)
|
2021-04-09 11:19:10 +02:00
|
|
|
connect("gui_input", self, '_on_gui_input')
|
2021-04-25 00:30:26 +02:00
|
|
|
tween.connect("tween_all_completed", self, "_on_Tween_tween_all_completed")
|
|
|
|
|
2021-04-09 11:19:10 +02:00
|
|
|
|
|
|
|
func _input(event: InputEvent):
|
|
|
|
if event.is_action_pressed("ui_cancel") and visible:
|
|
|
|
unpause()
|
|
|
|
get_tree().set_input_as_handled()
|
2021-04-09 11:33:19 +02:00
|
|
|
elif event.is_action_pressed("ui_cancel") and not visible:
|
|
|
|
pause()
|
|
|
|
get_tree().set_input_as_handled()
|
2021-04-09 11:19:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
func _on_BackgroundButton_pressed():
|
|
|
|
unpause()
|
|
|
|
|
|
|
|
|
|
|
|
func _on_ContinueButton_pressed():
|
|
|
|
unpause()
|
|
|
|
|
|
|
|
|
2021-04-10 18:29:03 +02:00
|
|
|
func _on_MenuButton_pressed():
|
|
|
|
unpause()
|
|
|
|
load_main_menu()
|
2021-04-25 00:30:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
func _on_Tween_tween_all_completed():
|
|
|
|
if panel.modulate == Color(1, 1, 1, 0):
|
|
|
|
hide()
|