frame-of-mind/src/logic-scenes/chat_view/chat-view.gd

20 lines
701 B
GDScript3
Raw Normal View History

class_name ChatView extends Control
2025-04-26 21:33:44 +00:00
@export var conversation : ChatConversation
@export var scroll_offset := 220
2026-03-20 21:06:48 +00:00
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")
func _ready() -> void:
2026-03-20 21:06:48 +00:00
rebuild.call_deferred()
func rebuild() -> void:
for message in conversation.messages:
2026-03-20 21:06:48 +00:00
var bubble : ChatBubble = prefab_self.instantiate() if message.is_own_message else prefab_other.instantiate()
%ChatHistory.add_child(bubble)
2026-03-20 21:06:48 +00:00
bubble.set_text.call_deferred(message.text, message.time_string)
await get_tree().process_frame
%ChatContainer.scroll_vertical = scroll_offset