A team game with an emphasis on movement (with no shooting), inspired by Overwatch and Zineth
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.6 KiB

  1. extends HTTPRequest
  2. var is_update_payload = false
  3. var save_to
  4. var time = 0
  5. export var domain = "http://ipv4.cosinegaming.com"
  6. func _ready():
  7. connect("request_completed", self, "_request_completed")
  8. # Check if we need an update
  9. request(domain + "/static/vanagloria/version.json", [], false)
  10. set_process(true)
  11. func _request_completed(result, response_code, headers, body):
  12. if result != RESULT_SUCCESS:
  13. print("ERROR: COULD NOT UPDATE. RESULT #" + str(result))
  14. completed()
  15. return
  16. if not is_update_payload:
  17. # Just checking if we need an update
  18. var server = JSON.parse(body.get_string_from_utf8()).result
  19. # 0.0.0 -> Update-shell application, needs more resources
  20. if server.version == util.version and util.version != "0.0.0":
  21. print("Game up-to-date! Launching")
  22. completed()
  23. else:
  24. is_update_payload = true
  25. save_to = server.save_location
  26. use_threads = true
  27. print("Need to update! Downloading " + server.download_path)
  28. request(domain + server.download_path)
  29. else:
  30. print("Update recieved. Saving to " + save_to)
  31. var file = File.new()
  32. file.open(save_to, File.WRITE)
  33. file.store_buffer(body)
  34. file.close()
  35. restart()
  36. func _process(delta):
  37. time += delta
  38. var fake_progress = 1 - (0.8 / time)
  39. # var progress = get_downloaded_bytes() / get_body_size()
  40. var progress = fake_progress
  41. get_node("../ProgressBar").value = 100*progress
  42. func restart():
  43. # Pass on args to new instance, then quit
  44. var output = []
  45. OS.execute("./vanagloria", [], false, output) # Mirror just runs godot again
  46. get_tree().quit()
  47. func completed():
  48. get_tree().change_scene("res://scenes/menu.tscn")