finalcode
finalcode
# Cache variables
#static var cache_path: String = ""
static var button_reference: Button
if parse_result == OK:
var json_data: Array = json_parser.data.get("data", {}).get("category",
[])
print(json_data.size())
populate_grid(json_data)
else:
print("JSON parsing error: %s" % json_parser.error_string)
else:
print("Request failed. Result: %d, Response code: %d" % [result,
response_code])
if file_exists(cache_path):
button.icon = load_cached_image(cache_path,"")
grid_container.add_child(button)
else:
download_image(full_image_url, cache_path, category_id)
image_request.request_completed.connect(_on_image_downloaded.bind(image_request))
image_request.request(url)
if body.size() == 0:
print("Error: Received an empty image body.")
return
# Cleanup
image_request.queue_free()
request_metadata.erase(image_request) # Remove the metadata after
processing the request
if load_result != OK:
print("Failed to load image:", path)
return null