summaryrefslogtreecommitdiff
path: root/client/menu/scene_transition.gd
blob: b30897aa27aff723c953ff4787d1369a40c60377 (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
54
55
# Hurry Curry! - a game about cooking
# Copyright 2024 metamuffin
# Copyright 2024 tpart
#
# 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 Control

@onready var anim: AnimationPlayer = $AnimationPlayer

var black = true
var fading = false

var queue = []

func _ready():
	$ColorRect.visible = true

func next():
	if fading: return
	if queue.is_empty(): return
	fading = true
	if queue.pop_front():
		anim.play_backwards("fade")
		await anim.animation_finished
		self.mouse_filter = Control.MOUSE_FILTER_IGNORE
		black = false
	else:
		self.mouse_filter = Control.MOUSE_FILTER_STOP
		anim.play("fade")
		await anim.animation_finished
		black = false
	fading = false
	await next()

func fade_in():
	queue.push_back(true)
	await next()
func fade_out():
	queue.push_back(false)
	await next()

func _exit_tree():
	if fading: push_error("SceneTransition destroyed while fading")