chat things
This commit is contained in:
parent
4bd1d6bc9c
commit
ff92434409
@ -138,8 +138,8 @@ func _submit_chat_message(text: String) -> void:
|
||||
|
||||
@rpc("authority", "call_local", "reliable", 1)
|
||||
func _add_chat_message(username: String, text: String) -> void:
|
||||
_chat_history.add_child(_make_chat_message(username, text))
|
||||
_chat_history_inactive.add_child(_make_chat_message(username, text))
|
||||
_chat_history.add_child(_make_chat_message(username, text, false))
|
||||
_chat_history_inactive.add_child(_make_chat_message(username, text, true))
|
||||
|
||||
|
||||
func _on_chat_history_scroll_changed(history: ScrollContainer) -> void:
|
||||
@ -147,11 +147,24 @@ func _on_chat_history_scroll_changed(history: ScrollContainer) -> void:
|
||||
history.scroll_vertical = int(history.get_v_scroll_bar().max_value)
|
||||
|
||||
|
||||
func _make_chat_message(username: String, text: String) -> RichTextLabel:
|
||||
func _fade_inactive_chat_message(p_label: RichTextLabel) -> void:
|
||||
var start := Time.get_ticks_msec()
|
||||
while true:
|
||||
var now := Time.get_ticks_msec()
|
||||
if now - start >= 10000: break
|
||||
p_label.add_theme_color_override("default_color", Color(0, 0, 0, 1.0 - (now - start) / 10000.0 ))
|
||||
await get_tree().process_frame
|
||||
p_label.queue_free()
|
||||
|
||||
|
||||
func _make_chat_message(username: String, text: String, inactive: bool) -> RichTextLabel:
|
||||
var label := RichTextLabel.new()
|
||||
label.bbcode_enabled = true
|
||||
label.fit_content = true
|
||||
label.append_text("[color=red]%s[/color] %s" % [username.replace("[", "[lb]"), text.replace("[", "[lb]")])
|
||||
if inactive:
|
||||
label.add_theme_color_override("default_color", Color.BLACK)
|
||||
_fade_inactive_chat_message(label)
|
||||
return label
|
||||
|
||||
|
||||
|
@ -155,7 +155,7 @@ vertical_scroll_mode = 3
|
||||
[node name="ChatHistory" type="VBoxContainer" parent="UI/ChatPanelInactive/ChatHistoryScroll"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
size_flags_vertical = 10
|
||||
|
||||
[node name="ComboTimer" type="Timer" parent="UI"]
|
||||
wait_time = 3.0
|
||||
|
Loading…
Reference in New Issue
Block a user