# 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 . # class_name SceneTransition extends ColorRect @onready var anim = $animation @export var ingame = false @export var auto_fade_in := true func _ready(): if auto_fade_in: fade_in() else: visible = false func fade_in(): 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(): visible = true 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.act() elif menu.visible and Input.is_action_just_pressed("pause"): menu.deact()