2026-03-08 13:26:01 -05:00
|
|
|
extends PanelContainer
|
|
|
|
|
|
|
|
|
|
signal user_selected(chatter: Chatter)
|
|
|
|
|
|
|
|
|
|
const USER_ENTRY = preload("res://UI/Controls/user_entry.tscn")
|
|
|
|
|
var entries_list: Array[UserEntry] = []
|
|
|
|
|
|
|
|
|
|
var filtering_live: bool = false:
|
|
|
|
|
set(value):
|
|
|
|
|
filtering_live = value
|
|
|
|
|
if value:
|
2026-03-08 16:26:06 -05:00
|
|
|
filter_list()
|
2026-03-08 13:26:01 -05:00
|
|
|
else:
|
|
|
|
|
reset_filter()
|
|
|
|
|
|
2026-03-08 16:26:06 -05:00
|
|
|
var _filter_name: String = ""
|
|
|
|
|
|
2026-03-08 13:26:01 -05:00
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
|
func _ready() -> void:
|
2026-03-08 16:26:06 -05:00
|
|
|
%Filter.text_changed.connect(_update_filter_name)
|
2026-03-08 13:26:01 -05:00
|
|
|
%FilterLive.pressed.connect(func(): filtering_live = !filtering_live)
|
2026-03-08 19:28:07 -05:00
|
|
|
%Refresh.pressed.connect(func():
|
|
|
|
|
clear_list()
|
|
|
|
|
populate_list()
|
|
|
|
|
Globals.refresh_live_streamer()
|
|
|
|
|
filter_list()
|
|
|
|
|
)
|
|
|
|
|
Globals.live_streamers_updated.connect(filter_list)
|
2026-03-08 13:26:01 -05:00
|
|
|
|
2026-03-08 16:26:06 -05:00
|
|
|
func _update_filter_name(txt: String) -> void:
|
|
|
|
|
_filter_name = txt.to_lower()
|
|
|
|
|
filter_list()
|
2026-03-08 13:26:01 -05:00
|
|
|
|
|
|
|
|
func clear_list() -> void:
|
|
|
|
|
for node in %UserList.get_children():
|
|
|
|
|
node.queue_free()
|
|
|
|
|
|
|
|
|
|
func update_list() -> void:
|
|
|
|
|
for chatter: Chatter in Globals.context.chatters.all():
|
|
|
|
|
if entries_list.any(func(x: UserEntry): return x.chatter.id == chatter.id):
|
|
|
|
|
continue
|
|
|
|
|
var inst := USER_ENTRY.instantiate()
|
|
|
|
|
inst.chatter = chatter
|
|
|
|
|
entries_list.append(inst)
|
|
|
|
|
inst.tree_exiting.connect(entries_list.erase.bind(inst))
|
|
|
|
|
inst.user_selected.connect(user_selected.emit)
|
|
|
|
|
%UserList.add_child(inst)
|
|
|
|
|
entries_list.sort_custom(func(x: UserEntry, y: UserEntry): return x.chatter.id < y.chatter.id)
|
|
|
|
|
var i = 0
|
|
|
|
|
for entry: UserEntry in entries_list:
|
|
|
|
|
%UserList.move_child(entry,i)
|
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
|
|
func populate_list() -> void:
|
|
|
|
|
for chatter: Chatter in Globals.context.chatters.all():
|
|
|
|
|
var inst := USER_ENTRY.instantiate()
|
|
|
|
|
inst.chatter = chatter
|
|
|
|
|
entries_list.append(inst)
|
|
|
|
|
inst.tree_exiting.connect(entries_list.erase.bind(inst))
|
|
|
|
|
inst.user_selected.connect(user_selected.emit)
|
|
|
|
|
%UserList.add_child(inst)
|
|
|
|
|
|
|
|
|
|
func reset_filter() -> void:
|
|
|
|
|
for entry: UserEntry in %UserList.get_children():
|
|
|
|
|
entry.visible = true
|
|
|
|
|
|
2026-03-08 16:26:06 -05:00
|
|
|
func filter_list() -> void:
|
2026-03-08 13:26:01 -05:00
|
|
|
reset_filter()
|
|
|
|
|
for entry: UserEntry in %UserList.get_children():
|
2026-03-08 16:26:06 -05:00
|
|
|
if filtering_live:
|
|
|
|
|
entry.visible = entry.chatter.twitch_id in Globals.live_streamers.keys()
|
|
|
|
|
if _filter_name != "" and entry.visible:
|
|
|
|
|
entry.visible = entry.chatter.user.display_name.to_lower().contains(_filter_name)
|