summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-06-07 16:42:12 +0200
committermetamuffin <metamuffin@disroot.org>2025-06-07 16:42:12 +0200
commit1cfdcfbe354178c216fabcad8ff862d8a89dbc61 (patch)
tree7eb6ff3fb4ba99a69d2657ca24361d1524825c75
parent4d90f8ce6860ef94413854e9b2fb9ebbb26ffb43 (diff)
downloadhurrycurry-1cfdcfbe354178c216fabcad8ff862d8a89dbc61.tar
hurrycurry-1cfdcfbe354178c216fabcad8ff862d8a89dbc61.tar.bz2
hurrycurry-1cfdcfbe354178c216fabcad8ff862d8a89dbc61.tar.zst
add loading text on connecting transition
-rw-r--r--client/menu/game.gd1
-rw-r--r--client/menu/scene_transition.gd23
-rw-r--r--client/menu/scene_transition.tscn93
-rw-r--r--client/menu/text_loading_anim.gdshader13
-rw-r--r--client/menu/text_loading_anim.gdshader.uid1
5 files changed, 118 insertions, 13 deletions
diff --git a/client/menu/game.gd b/client/menu/game.gd
index 70f28636..e0a89c6e 100644
--- a/client/menu/game.gd
+++ b/client/menu/game.gd
@@ -26,6 +26,7 @@ class_name GameMenu
func _ready():
get_tree().get_root().connect("go_back_requested", open_ingame_menu)
super()
+ transition.set_loading_text("Connecting...")
func _input(_event):
if Input.is_action_just_pressed("ui_menu"):
diff --git a/client/menu/scene_transition.gd b/client/menu/scene_transition.gd
index a10fccfd..b086f726 100644
--- a/client/menu/scene_transition.gd
+++ b/client/menu/scene_transition.gd
@@ -17,28 +17,37 @@
class_name SceneTransition
extends Control
-@onready var anim: AnimationPlayer = $AnimationPlayer
+@onready var black_anim: AnimationPlayer = $black_fader
+@onready var text_anim: AnimationPlayer = $text_fader
var s_current = false
var s_target = false
var fading = false
func _ready():
- $ColorRect.visible = true
+ $black.visible = true
+ $text_margin/text.visible = true
+ $text_margin/text.text = ""
+
+func set_loading_text(s: String):
+ $text_margin/text.text = s
+ text_anim.play("fade")
func next():
- while fading: await anim.animation_finished
+ while fading: await black_anim.animation_finished
if s_target == s_current: return
fading = true
if s_target:
- anim.play_backwards("fade")
- await anim.animation_finished
+ text_anim.play_backwards("fade")
+ 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
- anim.play("fade")
- await anim.animation_finished
+ black_anim.play("fade")
+ await black_anim.animation_finished
s_current = false
fading = false
await next()
diff --git a/client/menu/scene_transition.tscn b/client/menu/scene_transition.tscn
index 63ae9c2e..59956ac6 100644
--- a/client/menu/scene_transition.tscn
+++ b/client/menu/scene_transition.tscn
@@ -1,23 +1,72 @@
-[gd_scene load_steps=5 format=3 uid="uid://bg2d78ycorcqk"]
+[gd_scene load_steps=11 format=3 uid="uid://bg2d78ycorcqk"]
[ext_resource type="Script" uid="uid://ciml1u2x4f1ci" path="res://menu/scene_transition.gd" id="1_fpbwj"]
+[ext_resource type="Shader" uid="uid://bmxrbbw18xq7u" path="res://menu/text_loading_anim.gdshader" id="2_g21ck"]
+
+[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="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="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("ColorRect:color")
+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(0, 0, 0, 0), Color(0, 0, 0, 1)]
+"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_pea72"]
@@ -26,6 +75,12 @@ _data = {
&"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
@@ -35,13 +90,13 @@ grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_fpbwj")
-[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
+[node name="black_fader" type="AnimationPlayer" parent="."]
libraries = {
-"": SubResource("AnimationLibrary_pea72")
+&"": SubResource("AnimationLibrary_00tv0")
}
speed_scale = 4.0
-[node name="ColorRect" type="ColorRect" parent="."]
+[node name="black" type="ColorRect" parent="."]
visible = false
layout_mode = 1
anchors_preset = 15
@@ -51,3 +106,29 @@ 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
+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/menu/text_loading_anim.gdshader b/client/menu/text_loading_anim.gdshader
new file mode 100644
index 00000000..145dab78
--- /dev/null
+++ b/client/menu/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/menu/text_loading_anim.gdshader.uid b/client/menu/text_loading_anim.gdshader.uid
new file mode 100644
index 00000000..26730c73
--- /dev/null
+++ b/client/menu/text_loading_anim.gdshader.uid
@@ -0,0 +1 @@
+uid://bmxrbbw18xq7u