diff options
author | metamuffin <metamuffin@disroot.org> | 2025-09-04 23:47:24 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-09-05 23:07:07 +0200 |
commit | 81deaf81c800900e30046cb927be1c9d91ae61b8 (patch) | |
tree | 20ce9898465e8d4c49eeff12a9ea55572517ea7b /client/gui/menus/transition/scene_transition.gd | |
parent | fd80142282fcef628466a18e3ea62f0d1372d807 (diff) | |
download | hurrycurry-81deaf81c800900e30046cb927be1c9d91ae61b8.tar hurrycurry-81deaf81c800900e30046cb927be1c9d91ae61b8.tar.bz2 hurrycurry-81deaf81c800900e30046cb927be1c9d91ae61b8.tar.zst |
reorganize client gui files
Diffstat (limited to 'client/gui/menus/transition/scene_transition.gd')
-rw-r--r-- | client/gui/menus/transition/scene_transition.gd | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/client/gui/menus/transition/scene_transition.gd b/client/gui/menus/transition/scene_transition.gd new file mode 100644 index 00000000..330d67d6 --- /dev/null +++ b/client/gui/menus/transition/scene_transition.gd @@ -0,0 +1,66 @@ +# Hurry Curry! - a game about cooking +# Copyright (C) 2025 Hurry Curry! contributors +# +# 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 black_anim: AnimationPlayer = $black_fader +@onready var text_anim: AnimationPlayer = $text_fader +@onready var text: Label = $text_margin/text + +var s_current = false +var s_target = false +var fading = false + +func _ready(): + $black.visible = true + text.visible = true + text.text = "" + +func set_loading_text(s: String): + text.text = s + text_anim.play("fade") + +func next(): + while fading: await black_anim.animation_finished + if s_target == s_current: return + fading = true + if s_target: + if text.text != "": + text_anim.play_backwards("fade") + await text_anim.animation_finished + black_anim.play_backwards("fade") + await black_anim.animation_finished + self.mouse_filter = Control.MOUSE_FILTER_IGNORE + set_loading_text("") + s_current = true + else: + self.mouse_filter = Control.MOUSE_FILTER_STOP + black_anim.play("fade") + await black_anim.animation_finished + await get_tree().process_frame # animation finishes one frame early + s_current = false + fading = false + await next() + +func fade_in(): + s_target = true + await next() +func fade_out(): + s_target = false + await next() + +func _exit_tree(): + if fading: push_error("SceneTransition destroyed while fading") |