aboutsummaryrefslogtreecommitdiff
path: root/client/player
diff options
context:
space:
mode:
Diffstat (limited to 'client/player')
-rw-r--r--client/player/chat_bubble.gd12
-rw-r--r--client/player/chat_bubble.tscn29
-rw-r--r--client/player/chat_message.tscn36
-rw-r--r--client/player/player.gd11
4 files changed, 84 insertions, 4 deletions
diff --git a/client/player/chat_bubble.gd b/client/player/chat_bubble.gd
new file mode 100644
index 00000000..6b09b69b
--- /dev/null
+++ b/client/player/chat_bubble.gd
@@ -0,0 +1,12 @@
+class_name ChatBubble
+extends MeshInstance3D
+
+@onready var label: Label = $SubViewport/ChatMessage/Label
+
+func set_text(t: String):
+ visible = true
+ label.text = t
+
+func remove_text():
+ visible = false
+ label.text = ""
diff --git a/client/player/chat_bubble.tscn b/client/player/chat_bubble.tscn
new file mode 100644
index 00000000..1a5f7dfc
--- /dev/null
+++ b/client/player/chat_bubble.tscn
@@ -0,0 +1,29 @@
+[gd_scene load_steps=6 format=3 uid="uid://cgi6vcfrnqp0i"]
+
+[ext_resource type="Script" path="res://player/chat_bubble.gd" id="1_4v1cx"]
+[ext_resource type="PackedScene" uid="uid://5rcfoyuiwuya" path="res://player/chat_message.tscn" id="2_lyyq0"]
+
+[sub_resource type="QuadMesh" id="QuadMesh_tlsxo"]
+size = Vector2(2, 0.5)
+
+[sub_resource type="ViewportTexture" id="ViewportTexture_mko8a"]
+viewport_path = NodePath("SubViewport")
+
+[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_5iy0t"]
+resource_local_to_scene = true
+transparency = 1
+albedo_texture = SubResource("ViewportTexture_mko8a")
+billboard_mode = 2
+
+[node name="ChatBubble" type="MeshInstance3D"]
+transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0)
+visible = false
+mesh = SubResource("QuadMesh_tlsxo")
+surface_material_override/0 = SubResource("StandardMaterial3D_5iy0t")
+script = ExtResource("1_4v1cx")
+
+[node name="SubViewport" type="SubViewport" parent="."]
+transparent_bg = true
+size = Vector2i(512, 128)
+
+[node name="ChatMessage" parent="SubViewport" instance=ExtResource("2_lyyq0")]
diff --git a/client/player/chat_message.tscn b/client/player/chat_message.tscn
new file mode 100644
index 00000000..1ac82368
--- /dev/null
+++ b/client/player/chat_message.tscn
@@ -0,0 +1,36 @@
+[gd_scene load_steps=4 format=3 uid="uid://5rcfoyuiwuya"]
+
+[ext_resource type="FontFile" uid="uid://5ixo6b3bd3km" path="res://menu/font-josefin-sans.woff2" id="1_3ximm"]
+
+[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dpele"]
+bg_color = Color(1, 1, 1, 1)
+corner_radius_top_left = 30
+corner_radius_top_right = 30
+corner_radius_bottom_right = 30
+corner_radius_bottom_left = 30
+
+[sub_resource type="FontVariation" id="FontVariation_ecurp"]
+base_font = ExtResource("1_3ximm")
+variation_embolden = 1.0
+
+[node name="ChatMessage" type="Panel"]
+offset_right = 512.0
+offset_bottom = 128.0
+auto_translate = false
+theme_override_styles/panel = SubResource("StyleBoxFlat_dpele")
+
+[node name="Label" type="Label" parent="."]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+auto_translate = false
+theme_override_colors/font_color = Color(0, 0, 0, 1)
+theme_override_fonts/font = SubResource("FontVariation_ecurp")
+theme_override_font_sizes/font_size = 40
+horizontal_alignment = 1
+vertical_alignment = 1
+autowrap_mode = 3
+text_overrun_behavior = 3
diff --git a/client/player/player.gd b/client/player/player.gd
index 5873c9ef..4a5cfa6a 100644
--- a/client/player/player.gd
+++ b/client/player/player.gd
@@ -2,19 +2,19 @@
# Copyright 2024 nokoe
# Copyright 2024 metamuffin
# Copyright 2024 tpart
-#
+#
# 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 Player
extends Node3D
@@ -28,6 +28,7 @@ var position_ = Vector2(0, 0)
var position_anim = Vector2(0, 0)
var character: Character = preload("res://player/character/character.tscn").instantiate()
+var bubble: ChatBubble = preload("res://player/chat_bubble.tscn").instantiate()
var hand: Item = null
var hand_base: Node3D = Node3D.new()
@@ -45,6 +46,8 @@ func _init(_id: int, new_name: String, pos: Vector2, _character: int, new_game:
hand_base.position = HAND_BASE_POSITION
add_child(hand_base)
+ add_child(bubble)
+
func update_position(new_position: Vector2, new_rotation: float):
position_ = new_position
rotation_ = new_rotation