Add global/lobby auto-join and match chat lifecycle
This commit is contained in:
@@ -52,6 +52,7 @@ var _content_nodes : Array[Control] = [] # one entry per Tab enum value
|
||||
|
||||
var _input_bar : HBoxContainer = null
|
||||
var _message_input : LineEdit = null
|
||||
var _send_button : Button = null
|
||||
|
||||
# Per-tab content refs
|
||||
var _friends_list : VBoxContainer = null
|
||||
@@ -214,22 +215,35 @@ func _make_input_bar() -> Control:
|
||||
margin.add_child(inner)
|
||||
|
||||
_message_input = LineEdit.new()
|
||||
_message_input.placeholder_text = "Type a message…"
|
||||
_message_input.placeholder_text = "Type a message..."
|
||||
_message_input.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
_message_input.add_theme_font_size_override("font_size", 13)
|
||||
_message_input.max_length = 500
|
||||
_message_input.text_submitted.connect(_on_send)
|
||||
_message_input.text_submitted.connect(func(_text: String) -> void:
|
||||
_send_current_input())
|
||||
inner.add_child(_message_input)
|
||||
|
||||
var send_btn := Button.new()
|
||||
send_btn.text = "Send"
|
||||
send_btn.custom_minimum_size = Vector2(52, 0)
|
||||
send_btn.add_theme_font_size_override("font_size", 12)
|
||||
send_btn.pressed.connect(func() -> void: _on_send(_message_input.text))
|
||||
inner.add_child(send_btn)
|
||||
_send_button = Button.new()
|
||||
_send_button.text = "Send"
|
||||
_send_button.custom_minimum_size = Vector2(52, 0)
|
||||
_send_button.add_theme_font_size_override("font_size", 12)
|
||||
_send_button.pressed.connect(_send_current_input)
|
||||
inner.add_child(_send_button)
|
||||
|
||||
return _input_bar
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if not _panel.visible or not _input_bar.visible:
|
||||
return
|
||||
if not is_instance_valid(_message_input) or not _message_input.has_focus():
|
||||
return
|
||||
if event is InputEventKey:
|
||||
var key := event as InputEventKey
|
||||
if key.pressed and not key.echo \
|
||||
and (key.keycode == KEY_ENTER or key.keycode == KEY_KP_ENTER):
|
||||
_send_current_input()
|
||||
get_viewport().set_input_as_handled()
|
||||
# ── Tab builders ──────────────────────────────────────────────────────────────
|
||||
|
||||
func _build_tab_content(tab: Tab) -> Control:
|
||||
@@ -944,6 +958,11 @@ func _prompt_nickname(account_id: String, display_name: String) -> void:
|
||||
|
||||
# ── Send ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
func _send_current_input() -> void:
|
||||
if not is_instance_valid(_message_input):
|
||||
return
|
||||
_on_send(_message_input.text)
|
||||
|
||||
func _on_send(text: String) -> void:
|
||||
var trimmed := text.strip_edges()
|
||||
if trimmed.is_empty() or _active_channel.is_empty():
|
||||
@@ -1060,3 +1079,5 @@ func _make_section_label(text: String) -> Control:
|
||||
lbl.add_theme_font_size_override("font_size", 10)
|
||||
m.add_child(lbl)
|
||||
return m
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user