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.

47 lines
1.2 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("http://localhost:8080/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. if server.version == util.version:
  19. completed()
  20. else:
  21. is_update_payload = true
  22. save_to = server.save_location
  23. request(server.download_path)
  24. else:
  25. var file = File.new()
  26. file.open(save_to, File.WRITE)
  27. file.store_buffer(body)
  28. file.close()
  29. restart()
  30. func _process(delta):
  31. time += delta
  32. var fake_progress = 1 - (0.8 / time)
  33. get_node("../ProgressBar").value = 100*fake_progress
  34. func restart():
  35. # Pass on args to new instance, then quit
  36. var output = []
  37. OS.execute("./vanagloria", [], false, output) # Mirror just runs godot again
  38. get_tree().quit()
  39. func completed():
  40. get_tree().change_scene("res://scenes/lobby.tscn")