Autoupdate status
This commit is contained in:
parent
a3ad473b39
commit
3a4e0f30bf
3 changed files with 25 additions and 3 deletions
|
|
@ -138,7 +138,7 @@ layout_mode = 2
|
||||||
[node name="LabelContainer" type="Control" parent="."]
|
[node name="LabelContainer" type="Control" parent="."]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="LabelContainer"]
|
[node name="Label" type="RichTextLabel" parent="LabelContainer"]
|
||||||
top_level = true
|
top_level = true
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 3
|
anchors_preset = 3
|
||||||
|
|
@ -150,6 +150,12 @@ offset_left = -1.0
|
||||||
offset_top = -23.0
|
offset_top = -23.0
|
||||||
grow_horizontal = 0
|
grow_horizontal = 0
|
||||||
grow_vertical = 0
|
grow_vertical = 0
|
||||||
|
bbcode_enabled = true
|
||||||
|
fit_content = true
|
||||||
|
scroll_active = false
|
||||||
|
autowrap_mode = 0
|
||||||
|
horizontal_alignment = 2
|
||||||
|
vertical_alignment = 2
|
||||||
script = ExtResource("3_qy2xc")
|
script = ExtResource("3_qy2xc")
|
||||||
|
|
||||||
[connection signal="text_changed" from="MainMenu/VBoxContainer/NicknameEdit" to="." method="_on_nickname_edit_text_changed"]
|
[connection signal="text_changed" from="MainMenu/VBoxContainer/NicknameEdit" to="." method="_on_nickname_edit_text_changed"]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,11 @@
|
||||||
extends Label
|
extends RichTextLabel
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
text = "Текущая версия игры: " + preload("res://version.tres").version
|
AutoUpdate.update_version_text.connect(update_version)
|
||||||
|
update_version("")
|
||||||
|
|
||||||
|
|
||||||
|
func update_version(version: StringName):
|
||||||
|
text = "Текущая версия игры: " + preload("res://version.tres").version + "\n" + version
|
||||||
|
print(text)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ var popup_scene: PackedScene = preload("uid://5goo8fyxkv33")
|
||||||
var new_version_avaiable: bool
|
var new_version_avaiable: bool
|
||||||
var popup: ConfirmationDialog
|
var popup: ConfirmationDialog
|
||||||
|
|
||||||
|
signal update_version_text(to: StringName)
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
request_completed.connect(on_request_completed)
|
request_completed.connect(on_request_completed)
|
||||||
popup = popup_scene.instantiate()
|
popup = popup_scene.instantiate()
|
||||||
|
|
@ -18,16 +20,22 @@ func _ready() -> void:
|
||||||
patch_request.download_file = exec_dir + "chelimbalo.pck"
|
patch_request.download_file = exec_dir + "chelimbalo.pck"
|
||||||
patch_request.request_completed.connect(patch_downloaded)
|
patch_request.request_completed.connect(patch_downloaded)
|
||||||
|
|
||||||
|
update_version_text.emit("Подгружаем данные с сервера...")
|
||||||
|
|
||||||
request("https://2ndbeam.ru/durenije/chelimbalo/release/deploy_data")
|
request("https://2ndbeam.ru/durenije/chelimbalo/release/deploy_data")
|
||||||
|
|
||||||
func on_request_completed(result: int, _response_code: int, _headers: PackedStringArray, body: PackedByteArray):
|
func on_request_completed(result: int, _response_code: int, _headers: PackedStringArray, body: PackedByteArray):
|
||||||
if result != OK:
|
if result != OK:
|
||||||
|
update_version_text.emit("[color=red]Ошибка загрузки данных:" + str(result) +"[/color]")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
var ver_hash = body.get_string_from_ascii().split("\n")[1]
|
var ver_hash = body.get_string_from_ascii().split("\n")[1]
|
||||||
if ver_hash != load("res://version.tres").version:
|
if ver_hash != load("res://version.tres").version:
|
||||||
|
update_version_text.emit("Доступна новая версия!")
|
||||||
popup.popup_centered()
|
popup.popup_centered()
|
||||||
|
else:
|
||||||
|
update_version_text.emit("[color=green]У вас самая актуальная версия игры![/color]")
|
||||||
|
|
||||||
func download_button_pressed() -> void:
|
func download_button_pressed() -> void:
|
||||||
popup.get_node("HTTPRequest").request("https://2ndbeam.ru/durenije/chelimbalo/release/chelimbalo.pck")
|
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:
|
func patch_downloaded(result: int, _response_code: int, _headers: PackedStringArray, _body: PackedByteArray) -> void:
|
||||||
if result == OK:
|
if result == OK:
|
||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
|
else:
|
||||||
|
update_version_text.emit("[color=red]Ошибка загрузки новой версии:" + str(result) +"[/color]")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue