Autoupdate status
This commit is contained in:
parent
a3ad473b39
commit
3a4e0f30bf
3 changed files with 25 additions and 3 deletions
|
|
@ -5,6 +5,8 @@ var popup_scene: PackedScene = preload("uid://5goo8fyxkv33")
|
|||
var new_version_avaiable: bool
|
||||
var popup: ConfirmationDialog
|
||||
|
||||
signal update_version_text(to: StringName)
|
||||
|
||||
func _ready() -> void:
|
||||
request_completed.connect(on_request_completed)
|
||||
popup = popup_scene.instantiate()
|
||||
|
|
@ -18,16 +20,22 @@ func _ready() -> void:
|
|||
patch_request.download_file = exec_dir + "chelimbalo.pck"
|
||||
patch_request.request_completed.connect(patch_downloaded)
|
||||
|
||||
update_version_text.emit("Подгружаем данные с сервера...")
|
||||
|
||||
request("https://2ndbeam.ru/durenije/chelimbalo/release/deploy_data")
|
||||
|
||||
func on_request_completed(result: int, _response_code: int, _headers: PackedStringArray, body: PackedByteArray):
|
||||
if result != OK:
|
||||
update_version_text.emit("[color=red]Ошибка загрузки данных:" + str(result) +"[/color]")
|
||||
return
|
||||
|
||||
|
||||
var ver_hash = body.get_string_from_ascii().split("\n")[1]
|
||||
if ver_hash != load("res://version.tres").version:
|
||||
update_version_text.emit("Доступна новая версия!")
|
||||
popup.popup_centered()
|
||||
else:
|
||||
update_version_text.emit("[color=green]У вас самая актуальная версия игры![/color]")
|
||||
|
||||
func download_button_pressed() -> void:
|
||||
popup.get_node("HTTPRequest").request("https://2ndbeam.ru/durenije/chelimbalo/release/chelimbalo.pck")
|
||||
|
|
@ -35,3 +43,5 @@ func download_button_pressed() -> void:
|
|||
func patch_downloaded(result: int, _response_code: int, _headers: PackedStringArray, _body: PackedByteArray) -> void:
|
||||
if result == OK:
|
||||
get_tree().quit()
|
||||
else:
|
||||
update_version_text.emit("[color=red]Ошибка загрузки новой версии:" + str(result) +"[/color]")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue