Updated UserList
Refactor filter_live_users() into filter_list(). New Filter function, first filters for live users, then checks to see if _filter_name is an empty string, and the item is visible, before checking to see if display name matches te filter name variable.
This commit is contained in:
parent
991597ff21
commit
b9e0233f25
1 changed files with 12 additions and 3 deletions
|
|
@ -9,14 +9,20 @@ var filtering_live: bool = false:
|
||||||
set(value):
|
set(value):
|
||||||
filtering_live = value
|
filtering_live = value
|
||||||
if value:
|
if value:
|
||||||
filter_live_users()
|
filter_list()
|
||||||
else:
|
else:
|
||||||
reset_filter()
|
reset_filter()
|
||||||
|
|
||||||
|
var _filter_name: String = ""
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
%Filter.text_changed.connect(_update_filter_name)
|
||||||
%FilterLive.pressed.connect(func(): filtering_live = !filtering_live)
|
%FilterLive.pressed.connect(func(): filtering_live = !filtering_live)
|
||||||
|
|
||||||
|
func _update_filter_name(txt: String) -> void:
|
||||||
|
_filter_name = txt.to_lower()
|
||||||
|
filter_list()
|
||||||
|
|
||||||
func clear_list() -> void:
|
func clear_list() -> void:
|
||||||
for node in %UserList.get_children():
|
for node in %UserList.get_children():
|
||||||
|
|
@ -51,7 +57,10 @@ func reset_filter() -> void:
|
||||||
for entry: UserEntry in %UserList.get_children():
|
for entry: UserEntry in %UserList.get_children():
|
||||||
entry.visible = true
|
entry.visible = true
|
||||||
|
|
||||||
func filter_live_users() -> void:
|
func filter_list() -> void:
|
||||||
reset_filter()
|
reset_filter()
|
||||||
for entry: UserEntry in %UserList.get_children():
|
for entry: UserEntry in %UserList.get_children():
|
||||||
entry.visible = entry.chatter.twitch_id in Globals.live_streamers.keys()
|
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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue