feat: signal-inspired layout and chat now loads messages from root resource

This commit is contained in:
tiger tiger tiger 2026-03-21 13:54:42 +01:00
parent 9d0272f68c
commit 39fe28f5ed
14 changed files with 258 additions and 94 deletions

BIN
src/logic-scenes/chat_view/avatar-other-large.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dw5d2ffpq8w3r"
path="res://.godot/imported/avatar-other-large.png-13bb73d673b58a9200359552f01269ba.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://logic-scenes/chat_view/avatar-other-large.png"
dest_files=["res://.godot/imported/avatar-other-large.png-13bb73d673b58a9200359552f01269ba.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@ -0,0 +1,2 @@
class_name ChatConversation extends Resource
@export var messages: Array[ChatMessage]

View File

@ -0,0 +1 @@
uid://c8hqd1leg4dfy

View File

@ -1,17 +1,19 @@
class_name ChatView extends ScrollContainer
class_name ChatView extends Control
@export var messages: Array[ChatMessage]
@export var conversation : ChatConversation
@export var scroll_offset := 220
var prefab_other: PackedScene = preload("res://logic-scenes/chat_view/message_other.tscn")
var prefab_self: PackedScene = preload("res://logic-scenes/chat_view/message_self.tscn")
var v_box: VBoxContainer
func _ready() -> void:
rebuild.call_deferred()
func rebuild():
for message in messages:
func rebuild() -> void:
for message in conversation.messages:
var bubble : ChatBubble = prefab_self.instantiate() if message.is_own_message else prefab_other.instantiate()
$VBoxContainer.add_child(bubble)
%ChatHistory.add_child(bubble)
bubble.set_text.call_deferred(message.text, message.time_string)
await get_tree().process_frame
%ChatContainer.scroll_vertical = scroll_offset

View File

@ -1,142 +1,182 @@
[gd_scene format=3 uid="uid://dgb7x8na0ek57"]
[ext_resource type="Theme" uid="uid://bhw3jbbrt3m1k" path="res://logic-scenes/chat_view/theme-smartphone.tres" id="1_6hmi7"]
[ext_resource type="Texture2D" uid="uid://b3guc2v1fj04p" path="res://logic-scenes/chat_view/phone-background.png" id="1_vvup7"]
[ext_resource type="LabelSettings" uid="uid://dy1l6fcsy54od" path="res://logic-scenes/chat_view/labe-top-bar.tres" id="2_xckgu"]
[ext_resource type="Resource" uid="uid://cc6q101fbtq0" path="res://logic-scenes/chat_view/conversation-brother.tres" id="3_5qtt2"]
[ext_resource type="Texture2D" uid="uid://dhecdhucnu7sq" path="res://logic-scenes/chat_view/phone-notifications.png" id="3_myhe7"]
[ext_resource type="StyleBox" uid="uid://coqfwa80t22m0" path="res://logic-scenes/chat_view/style-chat-system-shade.tres" id="3_qbcw0"]
[ext_resource type="Script" uid="uid://db7t2kqbsskoq" path="res://logic-scenes/chat_view/chat-view.gd" id="4_myhe7"]
[ext_resource type="Texture2D" uid="uid://cv58eu35ra1ku" path="res://logic-scenes/chat_view/phone-dot.png" id="4_vvup7"]
[ext_resource type="Texture2D" uid="uid://bng2qbusdg7dj" path="res://logic-scenes/chat_view/phone-signal.png" id="4_xckgu"]
[ext_resource type="Script" uid="uid://be16bo6mf4kqu" path="res://logic-scenes/chat_view/chat-message.gd" id="5_xckgu"]
[ext_resource type="Texture2D" uid="uid://dw5d2ffpq8w3r" path="res://logic-scenes/chat_view/avatar-other-large.png" id="5_5qtt2"]
[ext_resource type="LabelSettings" uid="uid://mh8uu4rlqmv5" path="res://logic-scenes/chat_view/label-timestamp.tres" id="5_qgt32"]
[ext_resource type="PackedScene" uid="uid://dc58hnxdn0l2o" path="res://logic-scenes/chat_view/message_other.tscn" id="8_wih1b"]
[ext_resource type="PackedScene" uid="uid://cjodbrwc01gwi" path="res://logic-scenes/chat_view/message_self.tscn" id="13_qw8qg"]
[sub_resource type="Resource" id="Resource_iwd5k"]
script = ExtResource("5_xckgu")
text = "Sorry"
time_string = "This is smol."
metadata/_custom_type_script = "uid://be16bo6mf4kqu"
[sub_resource type="Gradient" id="Gradient_qgt32"]
colors = PackedColorArray(0, 0, 0, 0.5019608, 1, 1, 1, 0)
[sub_resource type="Resource" id="Resource_1hd2w"]
script = ExtResource("5_xckgu")
text = "I never knew what to say. Can I write instead? "
time_string = "8:12 PM"
metadata/_custom_type_script = "uid://be16bo6mf4kqu"
[sub_resource type="GradientTexture2D" id="GradientTexture2D_5qtt2"]
gradient = SubResource("Gradient_qgt32")
fill_from = Vector2(0, 0.5)
fill_to = Vector2(0, 1)
[sub_resource type="Resource" id="Resource_w8y7q"]
script = ExtResource("5_xckgu")
text = "🙄"
time_string = "7:59 PM"
is_own_message = true
metadata/_custom_type_script = "uid://be16bo6mf4kqu"
[node name="PhoneScreen" type="TextureRect" unique_id=422469732]
custom_minimum_size = Vector2(400, 640)
anchors_preset = -1
anchor_right = 0.41666666
anchor_bottom = 1.1851852
size_flags_horizontal = 0
size_flags_vertical = 0
texture = ExtResource("1_vvup7")
script = ExtResource("4_myhe7")
conversation = ExtResource("3_5qtt2")
metadata/_edit_use_anchors_ = true
[node name="PhoneScreen" type="ColorRect" unique_id=1416718783]
custom_minimum_size = Vector2(800, 1280)
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -1920.0
offset_right = -1048.0
offset_bottom = 1424.0
grow_horizontal = 0
color = Color(0, 0, 0, 1)
[node name="AppLayout" type="VBoxContainer" parent="." unique_id=1207866359]
[node name="ForegroundApp" type="MarginContainer" parent="." unique_id=1253480453]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 0
[node name="AppLayout" type="VBoxContainer" parent="ForegroundApp" unique_id=1207866359]
layout_mode = 2
theme = ExtResource("1_6hmi7")
[node name="TopBar" type="HBoxContainer" parent="AppLayout" unique_id=715115340]
[node name="ChatContainer" type="ScrollContainer" parent="ForegroundApp/AppLayout" unique_id=124411261]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
horizontal_scroll_mode = 0
vertical_scroll_mode = 2
[node name="ChatHistory" type="VBoxContainer" parent="ForegroundApp/AppLayout/ChatContainer" unique_id=1303301180]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
[node name="ChatHeader" type="TextureRect" parent="ForegroundApp/AppLayout/ChatContainer/ChatHistory" unique_id=706531178]
custom_minimum_size = Vector2(0, 320)
layout_mode = 2
texture = SubResource("GradientTexture2D_5qtt2")
[node name="VBoxContainer" type="VBoxContainer" parent="ForegroundApp/AppLayout/ChatContainer/ChatHistory/ChatHeader" unique_id=2070178907]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Spacer" type="Control" parent="ForegroundApp/AppLayout/ChatContainer/ChatHistory/ChatHeader/VBoxContainer" unique_id=52070824]
custom_minimum_size = Vector2(0, 64)
layout_mode = 2
[node name="ContactAvatar" type="TextureRect" parent="ForegroundApp/AppLayout/ChatContainer/ChatHistory/ChatHeader/VBoxContainer" unique_id=1516679922]
layout_mode = 2
texture = ExtResource("5_5qtt2")
stretch_mode = 3
[node name="ContactText" type="Label" parent="ForegroundApp/AppLayout/ChatContainer/ChatHistory/ChatHeader/VBoxContainer" unique_id=21415362]
layout_mode = 2
text = "<Name> <Given Name>
+49 123456789
Member of 👯Geschwister"
label_settings = ExtResource("5_qgt32")
horizontal_alignment = 1
vertical_alignment = 2
[node name="BoundaryText" type="Label" parent="ForegroundApp/AppLayout/ChatContainer/ChatHistory/ChatHeader/VBoxContainer" unique_id=1935901886]
layout_mode = 2
text = "This is the beginning of your chat history with <Name> on this device.
"
label_settings = ExtResource("5_qgt32")
horizontal_alignment = 1
vertical_alignment = 2
[node name="Message-Other" parent="ForegroundApp/AppLayout/ChatContainer/ChatHistory" unique_id=102479796 instance=ExtResource("8_wih1b")]
layout_mode = 2
script = null
[node name="Message-Self" parent="ForegroundApp/AppLayout/ChatContainer/ChatHistory" unique_id=806983375 instance=ExtResource("13_qw8qg")]
layout_mode = 2
script = null
[node name="TopBarShade" type="PanelContainer" parent="." unique_id=18123572]
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_bottom = 32.0
grow_horizontal = 2
size_flags_vertical = 0
theme_override_styles/panel = ExtResource("3_qbcw0")
[node name="TopBar" type="HBoxContainer" parent="TopBarShade" unique_id=715115340]
layout_mode = 2
alignment = 1
[node name="Time" type="Label" parent="AppLayout/TopBar" unique_id=538973152]
[node name="Time" type="Label" parent="TopBarShade/TopBar" unique_id=538973152]
layout_mode = 2
text = "08:12 PM"
label_settings = ExtResource("2_xckgu")
horizontal_alignment = 1
vertical_alignment = 1
[node name="Notifcations" type="TextureRect" parent="AppLayout/TopBar" unique_id=164400921]
[node name="Notifcations" type="TextureRect" parent="TopBarShade/TopBar" unique_id=164400921]
layout_mode = 2
texture = ExtResource("3_myhe7")
[node name="Dot1" type="TextureRect" parent="AppLayout/TopBar" unique_id=1306078406]
[node name="Dot1" type="TextureRect" parent="TopBarShade/TopBar" unique_id=1306078406]
layout_mode = 2
texture = ExtResource("4_vvup7")
[node name="Dot2" type="TextureRect" parent="AppLayout/TopBar" unique_id=256206201]
[node name="Dot2" type="TextureRect" parent="TopBarShade/TopBar" unique_id=256206201]
layout_mode = 2
texture = ExtResource("4_vvup7")
[node name="Control2" type="Control" parent="AppLayout/TopBar" unique_id=209916177]
[node name="Control2" type="Control" parent="TopBarShade/TopBar" unique_id=209916177]
layout_mode = 2
size_flags_horizontal = 3
[node name="SignalStrength" type="TextureRect" parent="AppLayout/TopBar" unique_id=416104296]
[node name="SignalStrength" type="TextureRect" parent="TopBarShade/TopBar" unique_id=416104296]
layout_mode = 2
texture = ExtResource("4_xckgu")
[node name="Carrier" type="Label" parent="AppLayout/TopBar" unique_id=61022698]
[node name="Carrier" type="Label" parent="TopBarShade/TopBar" unique_id=61022698]
layout_mode = 2
text = "HRT-Mobile"
label_settings = ExtResource("2_xckgu")
horizontal_alignment = 1
vertical_alignment = 1
[node name="AppBar" type="HBoxContainer" parent="AppLayout" unique_id=981636098]
[node name="NavBarShade" type="PanelContainer" parent="." unique_id=555699836]
layout_mode = 1
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -32.0
grow_horizontal = 2
grow_vertical = 0
size_flags_vertical = 0
theme_override_styles/panel = ExtResource("3_qbcw0")
[node name="NavBar" type="HBoxContainer" parent="NavBarShade" unique_id=2104485739]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 8
alignment = 1
[node name="ContactName" type="Label" parent="AppLayout/AppBar" unique_id=1110888559]
layout_mode = 2
text = "Contact Name"
label_settings = ExtResource("2_xckgu")
horizontal_alignment = 1
vertical_alignment = 1
[node name="ChatName" type="Label" parent="AppLayout/AppBar" unique_id=215068956]
layout_mode = 2
text = "(Nick)"
label_settings = ExtResource("2_xckgu")
horizontal_alignment = 1
vertical_alignment = 1
[node name="ChatContainer" type="ScrollContainer" parent="AppLayout" unique_id=124411261]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
horizontal_scroll_mode = 0
vertical_scroll_mode = 2
script = ExtResource("4_myhe7")
messages = Array[ExtResource("5_xckgu")]([SubResource("Resource_iwd5k"), SubResource("Resource_1hd2w"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q")])
[node name="VBoxContainer" type="VBoxContainer" parent="AppLayout/ChatContainer" unique_id=1303301180]
layout_mode = 2
size_flags_horizontal = 3
[node name="Message-Other" parent="AppLayout/ChatContainer/VBoxContainer" unique_id=102479796 instance=ExtResource("8_wih1b")]
layout_mode = 2
script = null
[node name="Message-Self" parent="AppLayout/ChatContainer/VBoxContainer" unique_id=806983375 instance=ExtResource("13_qw8qg")]
layout_mode = 2
script = null
[node name="PanelContainer" type="PanelContainer" parent="AppLayout" unique_id=1252298765]
layout_mode = 2
[node name="NavBar" type="HBoxContainer" parent="AppLayout" unique_id=1214154460]
layout_mode = 2
alignment = 1
[node name="Dot1" type="TextureRect" parent="AppLayout/NavBar" unique_id=721203980]
[node name="Dot1" type="TextureRect" parent="NavBarShade/NavBar" unique_id=839179932]
layout_mode = 2
texture = ExtResource("4_vvup7")
[node name="Dot2" type="TextureRect" parent="AppLayout/NavBar" unique_id=1265715350]
[node name="Dot2" type="TextureRect" parent="NavBarShade/NavBar" unique_id=993692065]
layout_mode = 2
texture = ExtResource("4_vvup7")

View File

@ -0,0 +1,28 @@
[gd_resource type="Resource" script_class="ChatConversation" format=3 uid="uid://cc6q101fbtq0"]
[ext_resource type="Script" uid="uid://be16bo6mf4kqu" path="res://logic-scenes/chat_view/chat-message.gd" id="1_lpye3"]
[ext_resource type="Script" uid="uid://c8hqd1leg4dfy" path="res://logic-scenes/chat_view/chat-conversation.gd" id="2_kg6cg"]
[sub_resource type="Resource" id="Resource_iwd5k"]
script = ExtResource("1_lpye3")
text = "Sorry"
time_string = "This is smol."
metadata/_custom_type_script = "uid://be16bo6mf4kqu"
[sub_resource type="Resource" id="Resource_1hd2w"]
script = ExtResource("1_lpye3")
text = "I never knew what to say. Can I write instead? "
time_string = "8:12 PM"
metadata/_custom_type_script = "uid://be16bo6mf4kqu"
[sub_resource type="Resource" id="Resource_w8y7q"]
script = ExtResource("1_lpye3")
text = "🙄"
time_string = "7:59 PM"
is_own_message = true
metadata/_custom_type_script = "uid://be16bo6mf4kqu"
[resource]
script = ExtResource("2_kg6cg")
messages = Array[ExtResource("1_lpye3")]([SubResource("Resource_iwd5k"), SubResource("Resource_1hd2w"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q")])
metadata/_custom_type_script = "uid://c8hqd1leg4dfy"

View File

@ -5,3 +5,4 @@
[resource]
font = ExtResource("1_tvq1w")
font_size = 18
shadow_size = 0

View File

@ -1,8 +1,8 @@
[gd_resource type="LabelSettings" format=3 uid="uid://mh8uu4rlqmv5"]
[ext_resource type="FontFile" uid="uid://b0i5ipn75noh6" path="res://import/fonts/Ubuntu-R.ttf" id="1_f4p0e"]
[ext_resource type="FontFile" uid="uid://bdkb43smt08c0" path="res://import/fonts/Ubuntu-B.ttf" id="1_f4p0e"]
[resource]
font = ExtResource("1_f4p0e")
font_size = 12
font_color = Color(0.5673677, 0.56736773, 0.56736773, 1)
font_color = Color(0, 0, 0, 0.8627451)
shadow_size = 0

BIN
src/logic-scenes/chat_view/phone-background.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b3guc2v1fj04p"
path="res://.godot/imported/phone-background.png-a0d3235eeec56f234efbacce8d08f024.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://logic-scenes/chat_view/phone-background.png"
dest_files=["res://.godot/imported/phone-background.png-a0d3235eeec56f234efbacce8d08f024.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@ -1,7 +1,7 @@
[gd_resource type="StyleBoxFlat" format=3 uid="uid://dd4xc216ul21m"]
[resource]
bg_color = Color(2.2140146e-06, 0.55150306, 0.515221, 1)
bg_color = Color(0.21568628, 0.49019608, 0.7607843, 1)
border_width_left = 3
border_width_top = 3
border_width_right = 3

View File

@ -1,7 +1,7 @@
[gd_resource type="StyleBoxFlat" format=3 uid="uid://dj1fuvcy0sw7k"]
[resource]
bg_color = Color(0.21546715, 0.48896384, 0.7619432, 1)
bg_color = Color(0, 0.5529412, 0.5137255, 1)
border_width_left = 3
border_width_top = 3
border_width_right = 3

View File

@ -0,0 +1,4 @@
[gd_resource type="StyleBoxFlat" format=3 uid="uid://coqfwa80t22m0"]
[resource]
bg_color = Color(0, 0, 0, 0.627451)