feat(chat): 优化聊天UI布局和WebSocket连接

- 更新 WebSocket URL 以支持 Socket.IO 握手参数 (EIO=4)
- 重构聊天面板布局,使用绝对定位和百分比锚点
- 优化输入框样式,添加装饰元素
- 修复输入框焦点释放的事件冲突问题
- 将 ChatUI 集成到主场景中
- 改进主场景容器布局设置
This commit is contained in:
WhaleTown Developer
2026-01-08 23:59:21 +08:00
parent 9c2e3bf15a
commit 25a21f92be
9 changed files with 102 additions and 59 deletions

View File

@@ -1,6 +1,6 @@
[gd_scene load_steps=3 format=3 uid="uid://cjabtnqbdd2ey"]
[gd_scene load_steps=4 format=3 uid="uid://cjabtnqbdd2ey"]
[ext_resource type="Script" path="res://scenes/MainScene.gd" id="1_script"]
[ext_resource type="Script" uid="uid://ghehm4srs0ho" path="res://scenes/MainScene.gd" id="1_script"]
[ext_resource type="PackedScene" uid="uid://by7m8snb4xllf" path="res://scenes/ui/AuthScene.tscn" id="2_main"]
[ext_resource type="PackedScene" uid="uid://bv7k2nan4xj8q" path="res://scenes/ui/ChatUI.tscn" id="3_chat_ui"]
@@ -9,6 +9,8 @@ layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_script")
[node name="AuthScene" parent="." instance=ExtResource("2_main")]
@@ -20,12 +22,15 @@ layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="TopBar" type="Panel" parent="MainGameUI"]
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_bottom = 60.0
grow_horizontal = 2
[node name="HBoxContainer" type="HBoxContainer" parent="MainGameUI/TopBar"]
layout_mode = 1
@@ -36,6 +41,8 @@ offset_left = 20.0
offset_top = 10.0
offset_right = -20.0
offset_bottom = -10.0
grow_horizontal = 2
grow_vertical = 2
[node name="UserLabel" type="Label" parent="MainGameUI/TopBar/HBoxContainer"]
layout_mode = 2
@@ -53,19 +60,23 @@ anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = 60.0
grow_horizontal = 2
grow_vertical = 2
[node name="CenterContainer" type="CenterContainer" parent="MainGameUI/MainContent"]
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="MainGameUI/MainContent/CenterContainer"]
layout_mode = 2
[node name="StatusPanel" type="Panel" parent="MainGameUI/MainContent/CenterContainer/VBoxContainer"]
layout_mode = 2
custom_minimum_size = Vector2(400, 150)
layout_mode = 2
[node name="StatusContainer" type="MarginContainer" parent="MainGameUI/MainContent/CenterContainer/VBoxContainer/StatusPanel"]
layout_mode = 1
@@ -76,6 +87,8 @@ offset_left = 20.0
offset_top = 20.0
offset_right = -20.0
offset_bottom = -20.0
grow_horizontal = 2
grow_vertical = 2
[node name="StatusGrid" type="GridContainer" parent="MainGameUI/MainContent/CenterContainer/VBoxContainer/StatusPanel/StatusContainer"]
layout_mode = 2
@@ -102,21 +115,24 @@ layout_mode = 2
columns = 2
[node name="ExploreButton" type="Button" parent="MainGameUI/MainContent/CenterContainer/VBoxContainer/GameMenuGrid"]
layout_mode = 2
custom_minimum_size = Vector2(150, 50)
layout_mode = 2
text = "🗺️ 探索小镇"
[node name="InventoryButton" type="Button" parent="MainGameUI/MainContent/CenterContainer/VBoxContainer/GameMenuGrid"]
layout_mode = 2
custom_minimum_size = Vector2(150, 50)
layout_mode = 2
text = "🎒 背包"
[node name="ShopButton" type="Button" parent="MainGameUI/MainContent/CenterContainer/VBoxContainer/GameMenuGrid"]
layout_mode = 2
custom_minimum_size = Vector2(150, 50)
layout_mode = 2
text = "🏪 商店"
[node name="FriendsButton" type="Button" parent="MainGameUI/MainContent/CenterContainer/VBoxContainer/GameMenuGrid"]
layout_mode = 2
custom_minimum_size = Vector2(150, 50)
text = "👥 好友"
layout_mode = 2
text = "👥 好友"
[node name="ChatUI" parent="MainGameUI" instance=ExtResource("3_chat_ui")]
layout_mode = 1