aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortpart <tpart120@proton.me>2024-08-16 21:07:02 +0200
committertpart <tpart120@proton.me>2024-08-16 21:07:02 +0200
commit2c183e2e645b5fdf0324a9b1baf584c9dc06d268 (patch)
treee68dca7eea4ef25f0256dcf2aa9146de1c314188
parent04c7e6530a5afcb2b181d8870e9132cae20a3ae9 (diff)
downloadhurrycurry-2c183e2e645b5fdf0324a9b1baf584c9dc06d268.tar
hurrycurry-2c183e2e645b5fdf0324a9b1baf584c9dc06d268.tar.bz2
hurrycurry-2c183e2e645b5fdf0324a9b1baf584c9dc06d268.tar.zst
Add item bubble colours
-rw-r--r--client/menu/theme/item_bubble_progress_style.tres6
-rw-r--r--client/player/item_bubble.gd12
-rw-r--r--client/player/item_bubble.tscn9
3 files changed, 19 insertions, 8 deletions
diff --git a/client/menu/theme/item_bubble_progress_style.tres b/client/menu/theme/item_bubble_progress_style.tres
new file mode 100644
index 00000000..69543f24
--- /dev/null
+++ b/client/menu/theme/item_bubble_progress_style.tres
@@ -0,0 +1,6 @@
+[gd_resource type="StyleBoxFlat" format=3 uid="uid://brw8uogdgx2gf"]
+
+[resource]
+resource_local_to_scene = true
+bg_color = Color(0.501961, 0, 0, 1)
+corner_radius_bottom_left = 32
diff --git a/client/player/item_bubble.gd b/client/player/item_bubble.gd
index 5a013053..1b7dbaa5 100644
--- a/client/player/item_bubble.gd
+++ b/client/player/item_bubble.gd
@@ -22,15 +22,20 @@ signal submit_message
@onready var progress: ProgressBar = $SubViewport/ItemMessage/VBoxContainer/ProgressBar
var item: Item
-
var timeout_remaining := 0.
+var timeout_initial := 0.
+var progress_style = preload("res://menu/theme/item_bubble_progress_style.tres")
+
+func _init():
+ progress_style = progress_style.duplicate()
-func set_item(t: String, timeout_initial: float, timeout_remaining_: float):
+func set_item(t: String, timeout_initial_: float, timeout_remaining_: float):
visible = true
item = ItemFactory.produce(t, base)
base.add_child(item)
timeout_remaining = timeout_remaining_
+ timeout_initial = timeout_initial_
progress.max_value = timeout_initial
progress.value = timeout_remaining
@@ -44,3 +49,6 @@ func _process(delta):
item.rotation.y += delta * TAU * .05
timeout_remaining -= delta
progress.value = timeout_remaining
+ var x: float = timeout_remaining / timeout_initial
+ progress_style.bg_color = Color(min((1-x) * 2, 1), min(x * 2, 1), 0.)
+ progress.add_theme_stylebox_override("fill", progress_style)
diff --git a/client/player/item_bubble.tscn b/client/player/item_bubble.tscn
index 71359670..89cd89ad 100644
--- a/client/player/item_bubble.tscn
+++ b/client/player/item_bubble.tscn
@@ -1,6 +1,7 @@
[gd_scene load_steps=9 format=3 uid="uid://cj777mi5nok6c"]
[ext_resource type="Script" path="res://player/item_bubble.gd" id="1_84g24"]
+[ext_resource type="StyleBox" uid="uid://brw8uogdgx2gf" path="res://menu/theme/item_bubble_progress_style.tres" id="2_5qt7f"]
[sub_resource type="QuadMesh" id="QuadMesh_tlsxo"]
@@ -31,10 +32,6 @@ ambient_light_energy = 0.5
corner_radius_bottom_right = 32
corner_radius_bottom_left = 32
-[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_x1tnr"]
-bg_color = Color(0.415945, 0.888786, 0, 1)
-corner_radius_bottom_left = 32
-
[node name="ItemBubble" type="MeshInstance3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0)
visible = false
@@ -86,7 +83,7 @@ environment = SubResource("Environment_iyxrx")
custom_minimum_size = Vector2(0, 32)
layout_mode = 2
theme_override_styles/background = SubResource("StyleBoxFlat_ima0t")
-theme_override_styles/fill = SubResource("StyleBoxFlat_x1tnr")
+theme_override_styles/fill = ExtResource("2_5qt7f")
step = 0.0
-value = 82.94
+value = 100.0
show_percentage = false