Improved UI event system
This commit is contained in:
7
client/ui/chat/Chat.gd
Normal file
7
client/ui/chat/Chat.gd
Normal file
@ -0,0 +1,7 @@
|
||||
class_name Chat
|
||||
extends VBoxContainer
|
||||
|
||||
signal message_submitted(message: String)
|
||||
|
||||
func add_message(message: String):
|
||||
%Messages.append_text(message + "\n")
|
26
client/ui/chat/Chat.tscn
Normal file
26
client/ui/chat/Chat.tscn
Normal file
@ -0,0 +1,26 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dvfy6k5h51x7w"]
|
||||
|
||||
[ext_resource type="Script" path="res://ui/chat/Chat.gd" id="1_sxxey"]
|
||||
[ext_resource type="Script" path="res://ui/chat/ChatInput.gd" id="2_yjq4f"]
|
||||
|
||||
[node name="Chat" type="VBoxContainer"]
|
||||
custom_minimum_size = Vector2(320, 180)
|
||||
size_flags_vertical = 3
|
||||
alignment = 2
|
||||
script = ExtResource("1_sxxey")
|
||||
|
||||
[node name="Messages" type="RichTextLabel" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
focus_mode = 2
|
||||
bbcode_enabled = true
|
||||
scroll_active = false
|
||||
scroll_following = true
|
||||
context_menu_enabled = true
|
||||
selection_enabled = true
|
||||
|
||||
[node name="Input" type="LineEdit" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
script = ExtResource("2_yjq4f")
|
@ -1,7 +0,0 @@
|
||||
extends RichTextLabel
|
||||
|
||||
func _ready():
|
||||
owner.message_received.connect(on_message_received)
|
||||
|
||||
func on_message_received(bbcode: String):
|
||||
append_text(bbcode + "\n")
|
@ -23,6 +23,6 @@ func on_focus_exited():
|
||||
tween.tween_property(self, "modulate", Color(1, 1, 1, 0), 0.2)
|
||||
|
||||
func on_text_submitted(message: String):
|
||||
(owner as UI).chat_message_submitted.emit(message)
|
||||
text = ""
|
||||
release_focus()
|
||||
(owner as Chat).message_submitted.emit(message)
|
||||
|
Reference in New Issue
Block a user