extends Control var newest_version var newest_version_data var newest_local_version = Versions.get_versions().max() var os_name var suffix func _process(delta): if newest_version != null: newest_local_version = Versions.get_versions().max() if newest_local_version: if newest_version > newest_local_version: $Panel/Play_button.text = "Update" else: $Panel/Play_button.text = "Play" func _ready(): if OS.get_name() == "X11": os_name = "linux" elif OS.get_name() == "Windows": os_name = "windows" var versions_request = HTTPRequest.new() add_child(versions_request) versions_request.connect("request_completed", self, "_versions_request_completed") var error = versions_request.request("https://code.retroedge.tech/api/v1/repos/UltraFlare/UltraFlare/releases?draft=false&pre-release=true&limit=1") func _versions_request_completed(result, response_code, headers, body): var data = JSON.parse(body.get_string_from_ascii()).result newest_version = data[0].tag_name newest_version_data = data[0] func _download_request_completed(result, response_code, headers, body): #if OS.get_name() == "X11": var os_name = "linux" #elif OS.get_name() == "Windows": # var os_name = "windows" if os_name == "windows": var suffix = ".exe" else: var suffix = "" print("Download complete") var dl_file = File.new() dl_file.open(OS.get_config_dir()+"/UltraFlare/versions/"+newest_version+"/UltraFlare-"+os_name+"-x86_64", 7) dl_file.store_buffer(body) dl_file.close() func _on_Play_button_pressed(): print(Versions.get_versions()) if newest_version: var suffix = "" if os_name == "windows": suffix = ".exe" if newest_version > newest_local_version: var download = HTTPRequest.new() add_child(download) download.connect("request_completed", self, "_download_request_completed") var url for asset in newest_version_data.assets: if asset.name == "UltraFlare-"+os_name+"-x86_64": url = asset.browser_download_url var error = download.request(url) else: var exit_code = OS.execute(OS.get_config_dir()+"/UltraFlare/versions/"+newest_local_version+"/UltraFlare-"+os_name+"-x86_64"+suffix, [], false) if exit_code != -1: get_tree().quit() else: print("Running UltraFlare failed with code: "+exit_code)