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: filter_live_users() else: reset_filter() # Called when the node enters the scene tree for the first time. func _ready() -> void: %FilterLive.pressed.connect(func(): filtering_live = !filtering_live) 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 func filter_live_users() -> void: reset_filter() for entry: UserEntry in %UserList.get_children(): entry.visible = entry.chatter.twitch_id in Globals.live_streamers.keys()