From abfed1358bb04e09117caee91b48925a6c84fa11 Mon Sep 17 00:00:00 2001 From: tpart Date: Fri, 16 Aug 2024 15:04:52 +0200 Subject: Fix: Player node name can not be empty --- client/player/player.gd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'client/player') diff --git a/client/player/player.gd b/client/player/player.gd index 254ec020..117ee76c 100644 --- a/client/player/player.gd +++ b/client/player/player.gd @@ -54,7 +54,8 @@ func _init(_id: int, new_name: String, pos: Vector2, new_character_idx: int, new movement_base.add_child(character) position_ = pos position_anim = pos - name = new_name + if new_name != "": + name = new_name game = new_game username = new_name -- cgit v1.2.3-70-g09d2 From 04c7e6530a5afcb2b181d8870e9132cae20a3ae9 Mon Sep 17 00:00:00 2001 From: tpart Date: Fri, 16 Aug 2024 15:28:44 +0200 Subject: Add item progress bars (#44) --- client/player/item_bubble.gd | 15 ++++++++++--- client/player/item_bubble.tscn | 48 +++++++++++++++++++++++++++++------------- client/player/player.gd | 4 ++-- 3 files changed, 47 insertions(+), 20 deletions(-) (limited to 'client/player') diff --git a/client/player/item_bubble.gd b/client/player/item_bubble.gd index b5dd7352..5a013053 100644 --- a/client/player/item_bubble.gd +++ b/client/player/item_bubble.gd @@ -18,14 +18,21 @@ extends MeshInstance3D signal submit_message -@onready var base: Node3D = $SubViewport/ItemMessage/SubViewportContainer/SubViewport/ItemBase +@onready var base: Node3D = $SubViewport/ItemMessage/VBoxContainer/SubViewportContainer/SubViewport/ItemBase +@onready var progress: ProgressBar = $SubViewport/ItemMessage/VBoxContainer/ProgressBar var item: Item -func set_item(t: String): +var timeout_remaining := 0. + +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_ + progress.max_value = timeout_initial + progress.value = timeout_remaining func remove_item(): visible = false @@ -33,5 +40,7 @@ func remove_item(): item.queue_free() func _process(delta): - if item != null: + if visible: item.rotation.y += delta * TAU * .05 + timeout_remaining -= delta + progress.value = timeout_remaining diff --git a/client/player/item_bubble.tscn b/client/player/item_bubble.tscn index c6365591..71359670 100644 --- a/client/player/item_bubble.tscn +++ b/client/player/item_bubble.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=7 format=3 uid="uid://cj777mi5nok6c"] +[gd_scene load_steps=9 format=3 uid="uid://cj777mi5nok6c"] [ext_resource type="Script" path="res://player/item_bubble.gd" id="1_84g24"] @@ -27,6 +27,14 @@ ambient_light_source = 2 ambient_light_color = Color(1, 1, 1, 1) ambient_light_energy = 0.5 +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ima0t"] +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 @@ -39,36 +47,46 @@ disable_3d = true transparent_bg = true size = Vector2i(256, 256) -[node name="ItemMessage" type="Panel" parent="SubViewport"] +[node name="ItemMessage" type="PanelContainer" parent="SubViewport"] offset_right = 256.0 offset_bottom = 256.0 +size_flags_vertical = 3 auto_translate = false theme_override_styles/panel = SubResource("StyleBoxFlat_dpele") -[node name="SubViewportContainer" type="SubViewportContainer" parent="SubViewport/ItemMessage"] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 +[node name="VBoxContainer" type="VBoxContainer" parent="SubViewport/ItemMessage"] +layout_mode = 2 +theme_override_constants/separation = 0 + +[node name="SubViewportContainer" type="SubViewportContainer" parent="SubViewport/ItemMessage/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 -[node name="SubViewport" type="SubViewport" parent="SubViewport/ItemMessage/SubViewportContainer"] +[node name="SubViewport" type="SubViewport" parent="SubViewport/ItemMessage/VBoxContainer/SubViewportContainer"] own_world_3d = true transparent_bg = true handle_input_locally = false -size = Vector2i(256, 256) +size = Vector2i(256, 224) render_target_update_mode = 4 -[node name="Camera3D" type="Camera3D" parent="SubViewport/ItemMessage/SubViewportContainer/SubViewport"] +[node name="Camera3D" type="Camera3D" parent="SubViewport/ItemMessage/VBoxContainer/SubViewportContainer/SubViewport"] transform = Transform3D(1, 0, 0, 0, 0.939693, 0.34202, 0, -0.34202, 0.939693, 0, 0.5, 1) projection = 1 size = 0.6 -[node name="ItemBase" type="Node3D" parent="SubViewport/ItemMessage/SubViewportContainer/SubViewport"] +[node name="ItemBase" type="Node3D" parent="SubViewport/ItemMessage/VBoxContainer/SubViewportContainer/SubViewport"] -[node name="DirectionalLight3D" type="DirectionalLight3D" parent="SubViewport/ItemMessage/SubViewportContainer/SubViewport"] +[node name="DirectionalLight3D" type="DirectionalLight3D" parent="SubViewport/ItemMessage/VBoxContainer/SubViewportContainer/SubViewport"] transform = Transform3D(1, 0, 0, 0, 0.173648, 0.984808, 0, -0.984808, 0.173648, 0, 0, 0) -[node name="WorldEnvironment" type="WorldEnvironment" parent="SubViewport/ItemMessage/SubViewportContainer/SubViewport"] +[node name="WorldEnvironment" type="WorldEnvironment" parent="SubViewport/ItemMessage/VBoxContainer/SubViewportContainer/SubViewport"] environment = SubResource("Environment_iyxrx") + +[node name="ProgressBar" type="ProgressBar" parent="SubViewport/ItemMessage/VBoxContainer"] +custom_minimum_size = Vector2(0, 32) +layout_mode = 2 +theme_override_styles/background = SubResource("StyleBoxFlat_ima0t") +theme_override_styles/fill = SubResource("StyleBoxFlat_x1tnr") +step = 0.0 +value = 82.94 +show_percentage = false diff --git a/client/player/player.gd b/client/player/player.gd index 117ee76c..43d7dd7f 100644 --- a/client/player/player.gd +++ b/client/player/player.gd @@ -151,8 +151,8 @@ func clear_message(): chat_bubble.remove_text() effect.clear_effect() -func item_message(item_name: String, _timeout_initial: float, timeout_remaining: float): - item_bubble.set_item(item_name) +func item_message(item_name: String, timeout_initial: float, timeout_remaining: float): + item_bubble.set_item(item_name, timeout_initial, timeout_remaining) clear_timer.start(timeout_remaining) func text_message(m: String, _timeout_initial: float, timeout_remaining: float): -- cgit v1.2.3-70-g09d2 From 2c183e2e645b5fdf0324a9b1baf584c9dc06d268 Mon Sep 17 00:00:00 2001 From: tpart Date: Fri, 16 Aug 2024 21:07:02 +0200 Subject: Add item bubble colours --- client/menu/theme/item_bubble_progress_style.tres | 6 ++++++ client/player/item_bubble.gd | 12 ++++++++++-- client/player/item_bubble.tscn | 9 +++------ 3 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 client/menu/theme/item_bubble_progress_style.tres (limited to 'client/player') 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 -- cgit v1.2.3-70-g09d2 From 5e9ad1a714352d8d24c20d62e75fbc06fc0ecc8b Mon Sep 17 00:00:00 2001 From: tpart Date: Fri, 16 Aug 2024 21:19:18 +0200 Subject: Fix round corner on bottom right of item bubble progress bar --- client/player/item_bubble.gd | 1 + 1 file changed, 1 insertion(+) (limited to 'client/player') diff --git a/client/player/item_bubble.gd b/client/player/item_bubble.gd index 1b7dbaa5..927a5299 100644 --- a/client/player/item_bubble.gd +++ b/client/player/item_bubble.gd @@ -51,4 +51,5 @@ func _process(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_style.corner_radius_bottom_right = max(32.-(1.-x)*320, 0) progress.add_theme_stylebox_override("fill", progress_style) -- cgit v1.2.3-70-g09d2 From de807e8cd2186286e235808ec1fc1f753e7748f4 Mon Sep 17 00:00:00 2001 From: tpart Date: Sat, 17 Aug 2024 15:50:45 +0200 Subject: Don't create bubble if timeout remaining is 0 --- client/player/item_bubble.gd | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'client/player') diff --git a/client/player/item_bubble.gd b/client/player/item_bubble.gd index 927a5299..626fb7b6 100644 --- a/client/player/item_bubble.gd +++ b/client/player/item_bubble.gd @@ -30,6 +30,10 @@ func _init(): progress_style = progress_style.duplicate() func set_item(t: String, timeout_initial_: float, timeout_remaining_: float): + if timeout_remaining_ == 0.: + remove_item() + return + visible = true item = ItemFactory.produce(t, base) base.add_child(item) -- cgit v1.2.3-70-g09d2