FAbrowser/scripts/Filter.gd
2024-07-22 11:06:25 -04:00

35 lines
828 B
GDScript

extends HFlowContainer
var grid:Container
const USER_PREFIX = "user:"
# Called when the node enters the scene tree for the first time.
func _ready():
grid = get_node("%ThumbGrid")
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if Input.is_action_just_pressed("find"):
show()
$Search.grab_focus()
elif Input.is_action_just_pressed("ui_cancel") and $Search.has_focus():
hide()
func _on_Search_text_changed(new_text:String):
var check:String
if new_text.begins_with(USER_PREFIX):
check = "user"
new_text = new_text.trim_prefix(USER_PREFIX)
else:
check = "title"
for i in grid.get_children():
if i is SubEntry:
if new_text.empty():
i.visible = true
elif new_text in i.SubData.get(check,""):
i.visible = true
else:
i.visible = false