blob: 8d9f38cf7f56c6fc4bcca21163604626196d3cea (
plain)
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
|
# Undercooked - a game about cooking
# Copyright 2024 metamuffin
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, version 3 of the License only.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
class_name SceneTransition
extends ColorRect
@onready var anim = $animation
@export var ingame = false
func _ready():
self.visible = true
anim.play("fade_in")
func transition_to(path: String):
await out()
get_tree().change_scene_to_file(path)
func instant_to(path: String):
get_tree().change_scene_to_file(path)
func quit():
await out()
get_tree().quit()
func out():
if menu.visible:
menu.anim.play_backwards("activate")
await menu.anim.animation_finished
anim.play("fade_out")
await anim.animation_finished
@onready var menu = $IngameMenu
func _process(_delta):
if ingame:
if not menu.visible and Input.is_action_just_pressed("pause"):
menu.visible = true
menu.anim.play("activate")
elif menu.visible and Input.is_action_just_pressed("pause"):
menu.anim.play_backwards("activate")
await menu.anim.animation_finished
menu.visible = false
|