# 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: AnimationPlayer = $animation @export var ingame = false @export var auto_fade_in := true var black = true var fading = false func _ready(): visible = true if auto_fade_in: fade_in() func fade_in(): if black: anim.play("fade_in"); fading = true black = false if fading: await anim.animation_finished fading = false self.mouse_filter = Control.MOUSE_FILTER_IGNORE func fade_out(): self.mouse_filter = Control.MOUSE_FILTER_STOP if not black: anim.play("fade_out"); fading = true black = true if fading: await anim.animation_finished fading = false 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()