From 989742955ba5c4d9f98e58d4b2b4ca606d088412 Mon Sep 17 00:00:00 2001 From: Noah Date: Fri, 28 Oct 2022 12:58:19 -0500 Subject: [PATCH] De-duplicate variable definitions --- Main_menu.gd | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/Main_menu.gd b/Main_menu.gd index 8378125..69dec53 100644 --- a/Main_menu.gd +++ b/Main_menu.gd @@ -22,6 +22,12 @@ func _ready(): os_name = "linux" elif OS.get_name() == "Windows": os_name = "windows" + + if os_name == "windows": + suffix = ".exe" + else: + suffix = "" + var versions_request = HTTPRequest.new() add_child(versions_request) @@ -37,17 +43,6 @@ func _versions_request_completed(result, response_code, headers, body): print("Got versions!") 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/current/UltraFlare-"+os_name+"-x86_64", 7) dl_file.store_buffer(body) @@ -60,20 +55,14 @@ func _download_request_completed(result, response_code, headers, body): OS.execute("chmod", ["+x", OS.get_config_dir()+"/UltraFlare/current/UltraFlare-"+os_name+"-x86_64"]) func _on_Play_button_pressed(): - var suffix = "" - if os_name == "windows": - suffix = ".exe" - - print(os_name) - if not newest_local_version or newest_version > newest_local_version: var download = HTTPRequest.new() + var url + 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"+suffix: url = asset.browser_download_url