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.

48 lines
1.3 KiB

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