Added icons, a lot of refactoring and optimising

This commit is contained in:
2024-06-12 22:18:19 +02:00
parent f0b57981bc
commit 2f12c1e25c
30 changed files with 614 additions and 692 deletions

View File

@@ -33,7 +33,7 @@ func close():
func search():
print(search_bar.text)
delete_children(search_list)
Settings.delete_children(search_list)
for game in games:
if is_match(search_bar.text, game):
var label := Label.new()
@@ -60,31 +60,11 @@ func compile_regex(search_term: String) -> RegEx:
print(regText)
regex.compile(regText)
return regex
func delete_children(node):
for n in node.get_children():
node.remove_child(n)
n.queue_free()
func get_list_of_games() -> void:
var http_request = HTTPRequest.new()
add_child(http_request)
http_request.request_completed.connect(self._http_request_completed)
# Perform a GET request. The URL below returns JSON as of writing.
var error = http_request.request(Settings.default_path + "/music/all/order")
if error != OK:
push_error("An error occurred in the HTTP request.")
# Called when the HTTP request is completed.
func _http_request_completed(_result, _response_code, _headers, body):
var json = JSON.new()
var error = json.parse(body.get_string_from_utf8())
if error == OK:
var data_received = json.get_data()
if typeof(data_received) == TYPE_ARRAY:
games.append_array(data_received)
var handle_games = func(array):
if typeof(array) == TYPE_ARRAY:
games.append_array(array)
for game in games:
var label := Label.new()
label.text = game
@@ -92,6 +72,7 @@ func _http_request_completed(_result, _response_code, _headers, body):
search_list.add_child(label)
else:
print("Unexpected data")
Settings.make_request2("/music/all/order", handle_games, true)
func clear():
search_bar.text = ""