aboutsummaryrefslogtreecommitdiff
path: root/client/gui/menus/transition
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-09-04 23:47:24 +0200
committermetamuffin <metamuffin@disroot.org>2025-09-05 23:07:07 +0200
commit81deaf81c800900e30046cb927be1c9d91ae61b8 (patch)
tree20ce9898465e8d4c49eeff12a9ea55572517ea7b /client/gui/menus/transition
parentfd80142282fcef628466a18e3ea62f0d1372d807 (diff)
downloadhurrycurry-81deaf81c800900e30046cb927be1c9d91ae61b8.tar
hurrycurry-81deaf81c800900e30046cb927be1c9d91ae61b8.tar.bz2
hurrycurry-81deaf81c800900e30046cb927be1c9d91ae61b8.tar.zst
reorganize client gui files
Diffstat (limited to 'client/gui/menus/transition')
-rw-r--r--client/gui/menus/transition/scene_transition.gd66
-rw-r--r--client/gui/menus/transition/scene_transition.gd.uid1
-rw-r--r--client/gui/menus/transition/scene_transition.tscn135
-rw-r--r--client/gui/menus/transition/text_loading_anim.gdshader13
-rw-r--r--client/gui/menus/transition/text_loading_anim.gdshader.uid1
5 files changed, 216 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")
diff --git a/client/gui/menus/transition/scene_transition.gd.uid b/client/gui/menus/transition/scene_transition.gd.uid
new file mode 100644
index 00000000..60f764ae
--- /dev/null
+++ b/client/gui/menus/transition/scene_transition.gd.uid
@@ -0,0 +1 @@
+uid://ciml1u2x4f1ci
diff --git a/client/gui/menus/transition/scene_transition.tscn b/client/gui/menus/transition/scene_transition.tscn
new file mode 100644
index 00000000..dab16084
--- /dev/null
+++ b/client/gui/menus/transition/scene_transition.tscn
@@ -0,0 +1,135 @@
+[gd_scene load_steps=11 format=3 uid="uid://bg2d78ycorcqk"]
+
+[ext_resource type="Script" uid="uid://ciml1u2x4f1ci" path="res://gui/menus/transition/scene_transition.gd" id="1_fpbwj"]
+[ext_resource type="Shader" uid="uid://bmxrbbw18xq7u" path="res://gui/menus/transition/text_loading_anim.gdshader" id="2_g21ck"]
+
+[sub_resource type="Animation" id="Animation_g21ck"]
+length = 0.001
+tracks/0/type = "value"
+tracks/0/imported = false
+tracks/0/enabled = true
+tracks/0/path = NodePath("black:color")
+tracks/0/interp = 1
+tracks/0/loop_wrap = false
+tracks/0/keys = {
+"times": PackedFloat32Array(0),
+"transitions": PackedFloat32Array(1),
+"update": 0,
+"values": [Color(0, 0, 0, 1)]
+}
+
+[sub_resource type="Animation" id="Animation_e6dcd"]
+resource_name = "fade"
+tracks/0/type = "value"
+tracks/0/imported = false
+tracks/0/enabled = true
+tracks/0/path = NodePath("black:color")
+tracks/0/interp = 1
+tracks/0/loop_wrap = true
+tracks/0/keys = {
+"times": PackedFloat32Array(0, 1),
+"transitions": PackedFloat32Array(1, 1),
+"update": 0,
+"values": [Color(0, 0, 0, 0), Color(0, 0, 0, 1)]
+}
+
+[sub_resource type="AnimationLibrary" id="AnimationLibrary_00tv0"]
+_data = {
+&"RESET": SubResource("Animation_g21ck"),
+&"fade": SubResource("Animation_e6dcd")
+}
+
+[sub_resource type="Animation" id="Animation_xgn2a"]
+length = 0.001
+tracks/0/type = "value"
+tracks/0/imported = false
+tracks/0/enabled = true
+tracks/0/path = NodePath("text_margin/text:modulate")
+tracks/0/interp = 1
+tracks/0/loop_wrap = true
+tracks/0/keys = {
+"times": PackedFloat32Array(0),
+"transitions": PackedFloat32Array(1),
+"update": 0,
+"values": [Color(1, 1, 1, 0)]
+}
+
+[sub_resource type="Animation" id="Animation_cq5i2"]
+resource_name = "fade"
+tracks/0/type = "value"
+tracks/0/imported = false
+tracks/0/enabled = true
+tracks/0/path = NodePath("text_margin/text:modulate")
+tracks/0/interp = 1
+tracks/0/loop_wrap = true
+tracks/0/keys = {
+"times": PackedFloat32Array(0, 1),
+"transitions": PackedFloat32Array(1, 1),
+"update": 0,
+"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
+}
+
+[sub_resource type="AnimationLibrary" id="AnimationLibrary_pea72"]
+_data = {
+&"RESET": SubResource("Animation_xgn2a"),
+&"fade": SubResource("Animation_cq5i2")
+}
+
+[sub_resource type="ShaderMaterial" id="ShaderMaterial_00tv0"]
+shader = ExtResource("2_g21ck")
+
+[sub_resource type="LabelSettings" id="LabelSettings_e6dcd"]
+font_size = 34
+
+[node name="SceneTransition" type="Control"]
+layout_mode = 3
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+script = ExtResource("1_fpbwj")
+
+[node name="black_fader" type="AnimationPlayer" parent="."]
+libraries = {
+&"": SubResource("AnimationLibrary_00tv0")
+}
+speed_scale = 4.0
+
+[node name="black" type="ColorRect" parent="."]
+visible = false
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+mouse_filter = 2
+color = Color(0, 0, 0, 1)
+
+[node name="text_fader" type="AnimationPlayer" parent="."]
+libraries = {
+&"": SubResource("AnimationLibrary_pea72")
+}
+speed_scale = 4.0
+
+[node name="text_margin" type="MarginContainer" parent="."]
+layout_mode = 1
+anchors_preset = 2
+anchor_top = 1.0
+anchor_bottom = 1.0
+offset_top = -107.0
+offset_right = 401.0
+grow_vertical = 0
+mouse_filter = 2
+theme_override_constants/margin_left = 50
+theme_override_constants/margin_top = 50
+theme_override_constants/margin_right = 50
+theme_override_constants/margin_bottom = 50
+
+[node name="text" type="Label" parent="text_margin"]
+modulate = Color(1, 1, 1, 0)
+material = SubResource("ShaderMaterial_00tv0")
+layout_mode = 2
+text = "Loading something..."
+label_settings = SubResource("LabelSettings_e6dcd")
diff --git a/client/gui/menus/transition/text_loading_anim.gdshader b/client/gui/menus/transition/text_loading_anim.gdshader
new file mode 100644
index 00000000..145dab78
--- /dev/null
+++ b/client/gui/menus/transition/text_loading_anim.gdshader
@@ -0,0 +1,13 @@
+shader_type canvas_item;
+
+varying vec4 vertex_color;
+void vertex() {
+ vertex_color = COLOR;
+}
+
+void fragment() {
+ vec4 tex = texture(TEXTURE, UV) * COLOR;
+ float wave = sin(VERTEX.x*0.01-TIME*10.) * 0.5 + 0.5;
+ wave = pow(wave, 3.);
+ COLOR = tex * (1. - wave * 0.2);
+}
diff --git a/client/gui/menus/transition/text_loading_anim.gdshader.uid b/client/gui/menus/transition/text_loading_anim.gdshader.uid
new file mode 100644
index 00000000..26730c73
--- /dev/null
+++ b/client/gui/menus/transition/text_loading_anim.gdshader.uid
@@ -0,0 +1 @@
+uid://bmxrbbw18xq7u