auto updater implemented main
authorEduardo <[email protected]>
Wed, 26 Feb 2025 21:29:30 +0000 (22:29 +0100)
committerEduardo <[email protected]>
Wed, 26 Feb 2025 21:29:30 +0000 (22:29 +0100)
22 files changed:
assets/sound/tap-b.ogg [new file with mode: 0644]
assets/sound/tap-b.ogg.import [new file with mode: 0644]
assets/ui/button_rectangle_depth_gradient.png [new file with mode: 0644]
assets/ui/button_rectangle_depth_gradient.png.import [new file with mode: 0644]
export_presets.cfg [new file with mode: 0644]
project.godot
scenes/level/main_level.tscn
scenes/level/update_manager.tscn [new file with mode: 0644]
scripts/constants.gd [deleted file]
scripts/constants.gd.uid [deleted file]
scripts/events.gd [deleted file]
scripts/events.gd.uid [deleted file]
scripts/globals.gd [deleted file]
scripts/globals.gd.uid [deleted file]
scripts/singletons/constants.gd [new file with mode: 0644]
scripts/singletons/constants.gd.uid [new file with mode: 0644]
scripts/singletons/events.gd [new file with mode: 0644]
scripts/singletons/events.gd.uid [new file with mode: 0644]
scripts/singletons/globals.gd [new file with mode: 0644]
scripts/singletons/globals.gd.uid [new file with mode: 0644]
scripts/update_manager.gd [new file with mode: 0644]
scripts/update_manager.gd.uid [new file with mode: 0644]

diff --git a/assets/sound/tap-b.ogg b/assets/sound/tap-b.ogg
new file mode 100644 (file)
index 0000000..95fcebf
Binary files /dev/null and b/assets/sound/tap-b.ogg differ
diff --git a/assets/sound/tap-b.ogg.import b/assets/sound/tap-b.ogg.import
new file mode 100644 (file)
index 0000000..ca16b63
--- /dev/null
@@ -0,0 +1,19 @@
+[remap]
+
+importer="oggvorbisstr"
+type="AudioStreamOggVorbis"
+uid="uid://bjb6528624u5o"
+path="res://.godot/imported/tap-b.ogg-5741e618d14ee105ad8661791ce788ae.oggvorbisstr"
+
+[deps]
+
+source_file="res://assets/sound/tap-b.ogg"
+dest_files=["res://.godot/imported/tap-b.ogg-5741e618d14ee105ad8661791ce788ae.oggvorbisstr"]
+
+[params]
+
+loop=false
+loop_offset=0
+bpm=0
+beat_count=0
+bar_beats=4
diff --git a/assets/ui/button_rectangle_depth_gradient.png b/assets/ui/button_rectangle_depth_gradient.png
new file mode 100644 (file)
index 0000000..336c4c4
Binary files /dev/null and b/assets/ui/button_rectangle_depth_gradient.png differ
diff --git a/assets/ui/button_rectangle_depth_gradient.png.import b/assets/ui/button_rectangle_depth_gradient.png.import
new file mode 100644 (file)
index 0000000..0fe9e41
--- /dev/null
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://bmrk6f0v61fpc"
+path="res://.godot/imported/button_rectangle_depth_gradient.png-447d14b21c42f62d0e1f0d8f6455b0ac.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://assets/ui/button_rectangle_depth_gradient.png"
+dest_files=["res://.godot/imported/button_rectangle_depth_gradient.png-447d14b21c42f62d0e1f0d8f6455b0ac.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
diff --git a/export_presets.cfg b/export_presets.cfg
new file mode 100644 (file)
index 0000000..9dbb40c
--- /dev/null
@@ -0,0 +1,108 @@
+[preset.0]
+
+name="Windows Desktop"
+platform="Windows Desktop"
+runnable=true
+advanced_options=false
+dedicated_server=false
+custom_features=""
+export_filter="all_resources"
+include_filter=""
+exclude_filter=""
+export_path="exports/RPG template.exe"
+patches=PackedStringArray()
+encryption_include_filters=""
+encryption_exclude_filters=""
+seed=0
+encrypt_pck=false
+encrypt_directory=false
+script_export_mode=2
+
+[preset.0.options]
+
+custom_template/debug=""
+custom_template/release=""
+debug/export_console_wrapper=0
+binary_format/embed_pck=false
+texture_format/s3tc_bptc=true
+texture_format/etc2_astc=false
+binary_format/architecture="x86_64"
+codesign/enable=false
+codesign/timestamp=true
+codesign/timestamp_server_url=""
+codesign/digest_algorithm=1
+codesign/description=""
+codesign/custom_options=PackedStringArray()
+application/modify_resources=true
+application/icon=""
+application/console_wrapper_icon=""
+application/icon_interpolation=4
+application/file_version=""
+application/product_version=""
+application/company_name="Back Pain Games"
+application/product_name="RPG Template"
+application/file_description=""
+application/copyright=""
+application/trademarks=""
+application/export_angle=0
+application/export_d3d12=0
+application/d3d12_agility_sdk_multiarch=true
+ssh_remote_deploy/enabled=false
+ssh_remote_deploy/host="user@host_ip"
+ssh_remote_deploy/port="22"
+ssh_remote_deploy/extra_args_ssh=""
+ssh_remote_deploy/extra_args_scp=""
+ssh_remote_deploy/run_script="Expand-Archive -LiteralPath '{temp_dir}\\{archive_name}' -DestinationPath '{temp_dir}'
+$action = New-ScheduledTaskAction -Execute '{temp_dir}\\{exe_name}' -Argument '{cmd_args}'
+$trigger = New-ScheduledTaskTrigger -Once -At 00:00
+$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
+$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings
+Register-ScheduledTask godot_remote_debug -InputObject $task -Force:$true
+Start-ScheduledTask -TaskName godot_remote_debug
+while (Get-ScheduledTask -TaskName godot_remote_debug | ? State -eq running) { Start-Sleep -Milliseconds 100 }
+Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue"
+ssh_remote_deploy/cleanup_script="Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue
+Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue
+Remove-Item -Recurse -Force '{temp_dir}'"
+
+[preset.1]
+
+name="Linux"
+platform="Linux"
+runnable=true
+advanced_options=false
+dedicated_server=false
+custom_features=""
+export_filter="all_resources"
+include_filter=""
+exclude_filter=""
+export_path="exports/RPG template.x86_64"
+patches=PackedStringArray()
+encryption_include_filters=""
+encryption_exclude_filters=""
+seed=0
+encrypt_pck=false
+encrypt_directory=false
+script_export_mode=2
+
+[preset.1.options]
+
+custom_template/debug=""
+custom_template/release=""
+debug/export_console_wrapper=0
+binary_format/embed_pck=false
+texture_format/s3tc_bptc=true
+texture_format/etc2_astc=false
+binary_format/architecture="x86_64"
+ssh_remote_deploy/enabled=false
+ssh_remote_deploy/host="user@host_ip"
+ssh_remote_deploy/port="22"
+ssh_remote_deploy/extra_args_ssh=""
+ssh_remote_deploy/extra_args_scp=""
+ssh_remote_deploy/run_script="#!/usr/bin/env bash
+export DISPLAY=:0
+unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
+\"{temp_dir}/{exe_name}\" {cmd_args}"
+ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
+kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")
+rm -rf \"{temp_dir}\""
index 3e410630b18e60384e0d0e2bea9896ea4307a53f..64ee3fca885a5fda0bcd8ea8f7ae2ae8d88dd7f9 100644 (file)
@@ -17,12 +17,12 @@ config/icon="res://icon.svg"
 
 [autoload]
 
-Constants="*res://scripts/constants.gd"
+Constants="*res://scripts/singletons/constants.gd"
 SaveSystem="*res://addons/save_system/save_system.gd"
 PhantomCameraManager="*res://addons/phantom_camera/scripts/managers/phantom_camera_manager.gd"
 SceneManager="*res://addons/scene_manager/SceneManager.tscn"
-Events="*res://scripts/events.gd"
-Globals="*res://scripts/globals.gd"
+Events="*res://scripts/singletons/events.gd"
+Globals="*res://scripts/singletons/globals.gd"
 
 [editor_plugins]
 
index 8cdd3477f01a330ca602654fb5e705f1eb2c2c28..054c346e7058109b6716f2b961db72047341d976 100644 (file)
@@ -1,10 +1,11 @@
-[gd_scene load_steps=9 format=4 uid="uid://ds1fjw3marbia"]
+[gd_scene load_steps=10 format=4 uid="uid://ds1fjw3marbia"]
 
 [ext_resource type="Script" uid="uid://2k5farej1c8m" path="res://scripts/main_level.gd" id="1_rqc32"]
 [ext_resource type="Texture2D" uid="uid://bj3fteudhyal6" path="res://assets/textures/Overworld.png" id="2_hr3vg"]
 [ext_resource type="PackedScene" uid="uid://da1uex028xkv1" path="res://scenes/elements/door_scene_manager.tscn" id="3_5ranr"]
 [ext_resource type="PackedScene" uid="uid://k76535tjepm3" path="res://scenes/elements/player.tscn" id="4_y0qys"]
 [ext_resource type="PackedScene" uid="uid://d11oo2pxcah1g" path="res://scenes/menu/pause_menu.tscn" id="5_06oyi"]
+[ext_resource type="PackedScene" uid="uid://dyuc24hn5lmiv" path="res://scenes/level/update_manager.tscn" id="5_sd876"]
 [ext_resource type="PackedScene" uid="uid://cjvtoi20cy8wi" path="res://scenes/menu/inventory.tscn" id="6_cymwe"]
 
 [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_n0o3p"]
@@ -1662,6 +1663,8 @@ motion_mode = 1
 z_index = 4096
 zoom = Vector2(2, 2)
 
+[node name="UpdateManager" parent="Player/Camera2D" instance=ExtResource("5_sd876")]
+
 [node name="PauseMenu" parent="Player/Camera2D" instance=ExtResource("5_06oyi")]
 offset_left = -288.0
 offset_top = -162.0
diff --git a/scenes/level/update_manager.tscn b/scenes/level/update_manager.tscn
new file mode 100644 (file)
index 0000000..31d1eeb
--- /dev/null
@@ -0,0 +1,169 @@
+[gd_scene load_steps=6 format=3 uid="uid://dyuc24hn5lmiv"]
+
+[ext_resource type="Script" uid="uid://cnrbihl340sml" path="res://scripts/update_manager.gd" id="1_0uu6u"]
+[ext_resource type="Texture2D" uid="uid://b3depm3avmfan" path="res://assets/ui/button_square_line.png" id="1_616ou"]
+[ext_resource type="Theme" uid="uid://c6osikflt1uy1" path="res://assets/resources/ui_theme.tres" id="2_616ou"]
+
+[sub_resource type="LabelSettings" id="LabelSettings_0uu6u"]
+font_size = 32
+font_color = Color(0, 0, 0, 1)
+
+[sub_resource type="LabelSettings" id="LabelSettings_y178i"]
+font_color = Color(0.241156, 0.241156, 0.241156, 1)
+
+[node name="UpdateManager" type="Control"]
+layout_mode = 3
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+script = ExtResource("1_0uu6u")
+
+[node name="UpdateHTTPRequest" type="HTTPRequest" parent="."]
+
+[node name="UpdateDialog" type="CenterContainer" parent="."]
+visible = false
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+
+[node name="PanelContainer" type="PanelContainer" parent="UpdateDialog"]
+layout_mode = 2
+
+[node name="NinePatchRect" type="NinePatchRect" parent="UpdateDialog/PanelContainer"]
+modulate = Color(0.831373, 0.843137, 0.905882, 1)
+custom_minimum_size = Vector2(100, 100)
+layout_mode = 2
+texture = ExtResource("1_616ou")
+patch_margin_left = 16
+patch_margin_top = 16
+patch_margin_right = 16
+patch_margin_bottom = 16
+
+[node name="MarginContainer" type="MarginContainer" parent="UpdateDialog/PanelContainer"]
+layout_mode = 2
+theme_override_constants/margin_left = 20
+theme_override_constants/margin_top = 20
+theme_override_constants/margin_right = 20
+theme_override_constants/margin_bottom = 20
+
+[node name="VBoxContainer" type="VBoxContainer" parent="UpdateDialog/PanelContainer/MarginContainer"]
+clip_contents = true
+layout_mode = 2
+
+[node name="TitleLabel" type="Label" parent="UpdateDialog/PanelContainer/MarginContainer/VBoxContainer"]
+layout_mode = 2
+text = "Nueva versión disponible!"
+label_settings = SubResource("LabelSettings_0uu6u")
+horizontal_alignment = 1
+
+[node name="MarginContainer" type="MarginContainer" parent="UpdateDialog/PanelContainer/MarginContainer/VBoxContainer"]
+layout_mode = 2
+theme_override_constants/margin_top = 20
+theme_override_constants/margin_bottom = 20
+
+[node name="ContentLabel" type="Label" parent="UpdateDialog/PanelContainer/MarginContainer/VBoxContainer/MarginContainer"]
+custom_minimum_size = Vector2(0, 10)
+layout_mode = 2
+text = "La nueva versión se descargará y se reiniciará el juego, asegurate de tener la partida guardada!"
+label_settings = SubResource("LabelSettings_y178i")
+horizontal_alignment = 1
+autowrap_mode = 3
+
+[node name="HBoxContainer" type="HBoxContainer" parent="UpdateDialog/PanelContainer/MarginContainer/VBoxContainer"]
+layout_mode = 2
+size_flags_vertical = 3
+alignment = 1
+
+[node name="MarginContainer2" type="MarginContainer" parent="UpdateDialog/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer"]
+layout_mode = 2
+theme_override_constants/margin_left = 10
+theme_override_constants/margin_top = 10
+theme_override_constants/margin_right = 20
+theme_override_constants/margin_bottom = 10
+
+[node name="DownloadButton" type="Button" parent="UpdateDialog/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/MarginContainer2"]
+modulate = Color(0.901197, 0.823165, 0.861526, 1)
+custom_minimum_size = Vector2(150, 0)
+layout_mode = 2
+theme = ExtResource("2_616ou")
+text = "Download
+"
+
+[node name="MarginContainer3" type="MarginContainer" parent="UpdateDialog/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer"]
+layout_mode = 2
+theme_override_constants/margin_left = 20
+theme_override_constants/margin_top = 10
+theme_override_constants/margin_right = 10
+theme_override_constants/margin_bottom = 10
+
+[node name="IgnoreButton" type="Button" parent="UpdateDialog/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/MarginContainer3"]
+modulate = Color(0.901197, 0.823165, 0.861526, 1)
+custom_minimum_size = Vector2(150, 0)
+layout_mode = 2
+theme = ExtResource("2_616ou")
+text = "Ignore"
+
+[node name="DownloadDialog" type="CenterContainer" parent="."]
+visible = false
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+
+[node name="PanelContainer" type="PanelContainer" parent="DownloadDialog"]
+layout_mode = 2
+
+[node name="NinePatchRect" type="NinePatchRect" parent="DownloadDialog/PanelContainer"]
+modulate = Color(0.831373, 0.843137, 0.905882, 1)
+custom_minimum_size = Vector2(100, 100)
+layout_mode = 2
+texture = ExtResource("1_616ou")
+patch_margin_left = 16
+patch_margin_top = 16
+patch_margin_right = 16
+patch_margin_bottom = 16
+
+[node name="MarginContainer" type="MarginContainer" parent="DownloadDialog/PanelContainer"]
+layout_mode = 2
+theme_override_constants/margin_left = 20
+theme_override_constants/margin_top = 20
+theme_override_constants/margin_right = 20
+theme_override_constants/margin_bottom = 20
+
+[node name="VBoxContainer" type="VBoxContainer" parent="DownloadDialog/PanelContainer/MarginContainer"]
+clip_contents = true
+layout_mode = 2
+
+[node name="MarginContainer2" type="MarginContainer" parent="DownloadDialog/PanelContainer/MarginContainer/VBoxContainer"]
+layout_mode = 2
+theme_override_constants/margin_left = 50
+theme_override_constants/margin_right = 50
+
+[node name="TitleLabel" type="Label" parent="DownloadDialog/PanelContainer/MarginContainer/VBoxContainer/MarginContainer2"]
+layout_mode = 2
+text = "Descargando..."
+label_settings = SubResource("LabelSettings_0uu6u")
+horizontal_alignment = 1
+
+[node name="MarginContainer" type="MarginContainer" parent="DownloadDialog/PanelContainer/MarginContainer/VBoxContainer"]
+layout_mode = 2
+theme_override_constants/margin_top = 20
+theme_override_constants/margin_bottom = 20
+
+[node name="ContentLabel" type="Label" parent="DownloadDialog/PanelContainer/MarginContainer/VBoxContainer/MarginContainer"]
+custom_minimum_size = Vector2(0, 10)
+layout_mode = 2
+text = "El juego se reiniciará al finalizar, por favor, espere."
+label_settings = SubResource("LabelSettings_y178i")
+horizontal_alignment = 1
+autowrap_mode = 3
+
+[connection signal="pressed" from="UpdateDialog/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/MarginContainer2/DownloadButton" to="." method="_on_download_button_pressed"]
+[connection signal="pressed" from="UpdateDialog/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/MarginContainer3/IgnoreButton" to="." method="_on_ignore_button_pressed"]
diff --git a/scripts/constants.gd b/scripts/constants.gd
deleted file mode 100644 (file)
index de443bc..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-extends Node
-
-
-enum LEVELS_NAMES {
-       main_level,
-       house_template,
-       save_menu,
-}
-
-const LEVELS_PATHS: Array[String] = [
-       "res://scenes/level/main_level.tscn",
-       "res://scenes/level/house_template.tscn",
-       "res://scenes/interfaces/save_menu.tscn",
-]
diff --git a/scripts/constants.gd.uid b/scripts/constants.gd.uid
deleted file mode 100644 (file)
index 36a32f6..0000000
+++ /dev/null
@@ -1 +0,0 @@
-uid://0wnia2p8acl5
diff --git a/scripts/events.gd b/scripts/events.gd
deleted file mode 100644 (file)
index 3cd09ee..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-extends Node
-
-signal request_update_player_position
-signal game_paused(paused: bool)
-signal inventory_open(open: bool)
diff --git a/scripts/events.gd.uid b/scripts/events.gd.uid
deleted file mode 100644 (file)
index 680aa6c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-uid://rcf2owkufplh
diff --git a/scripts/globals.gd b/scripts/globals.gd
deleted file mode 100644 (file)
index 40573bc..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-extends Node
-
-
-#region player position per level
-
-
-class _PlayerPositionAt:
-       var scene: int
-       var position: Vector2
-       
-       func _init(new_scene: Constants.LEVELS_NAMES, new_position: Vector2):
-               scene = new_scene
-               position = new_position
-
-
-var player_positions: Array[_PlayerPositionAt]
-var last_scene_updated: Constants.LEVELS_NAMES
-
-
-func update_player_position(scene: Constants.LEVELS_NAMES, new_position: Vector2):
-       last_scene_updated = scene
-       
-       for p_pos in player_positions:
-               if p_pos.scene == scene:
-                       p_pos.position = new_position
-                       return
-       
-       player_positions.append(_PlayerPositionAt.new(scene, new_position))
-
-
-func get_last_player_position_in_scene(scene: Constants.LEVELS_NAMES) -> Vector2:
-       for p_pos in player_positions:
-               if p_pos.scene == scene:
-                       return p_pos.position
-       
-       return Vector2()
-
-
-func get_last_scene_updated() -> Constants.LEVELS_NAMES:
-       return last_scene_updated
-
-
-#endregion
-
-#region current scene
-
-
-var current_scene: Constants.LEVELS_NAMES
-
-
-func set_current_scene(scene: Constants.LEVELS_NAMES):
-       current_scene = scene
-
-
-func get_current_scene() -> Constants.LEVELS_NAMES:
-       return current_scene
-
-
-#endregion
-
-#region utils
-
-
-func get_scene_path(scene_name: Constants.LEVELS_NAMES) -> String:
-       return Constants.LEVELS_PATHS[scene_name]
-
-
-#endregion
diff --git a/scripts/globals.gd.uid b/scripts/globals.gd.uid
deleted file mode 100644 (file)
index 2c81bed..0000000
+++ /dev/null
@@ -1 +0,0 @@
-uid://d2ubolfbi143e
diff --git a/scripts/singletons/constants.gd b/scripts/singletons/constants.gd
new file mode 100644 (file)
index 0000000..aa2abb9
--- /dev/null
@@ -0,0 +1,19 @@
+extends Node
+
+const VERSION = "0.0.1"
+
+enum LEVELS_NAMES {
+       main_level,
+       house_template,
+       save_menu,
+}
+
+const LEVELS_PATHS: Array[String] = [
+       "res://scenes/level/main_level.tscn",
+       "res://scenes/level/house_template.tscn",
+       "res://scenes/interfaces/save_menu.tscn",
+]
+
+const VERSION_CHECK_ENDPOINT = "https://betelgeuse.edufdez.es/rpg_test/version"
+const VERSION_PCK_DOWNLOAD_ENDPOINT = "https://betelgeuse.edufdez.es/rpg_test/RPG%20template.pck"
+const PCK_PATH_NAME = "res://RPG template.pck"
diff --git a/scripts/singletons/constants.gd.uid b/scripts/singletons/constants.gd.uid
new file mode 100644 (file)
index 0000000..36a32f6
--- /dev/null
@@ -0,0 +1 @@
+uid://0wnia2p8acl5
diff --git a/scripts/singletons/events.gd b/scripts/singletons/events.gd
new file mode 100644 (file)
index 0000000..73b591b
--- /dev/null
@@ -0,0 +1,8 @@
+extends Node
+
+@warning_ignore_start("unused_signal")
+
+signal request_update_player_position
+signal game_paused(paused: bool)
+signal inventory_open(open: bool)
+signal update_available(update: bool)
diff --git a/scripts/singletons/events.gd.uid b/scripts/singletons/events.gd.uid
new file mode 100644 (file)
index 0000000..680aa6c
--- /dev/null
@@ -0,0 +1 @@
+uid://rcf2owkufplh
diff --git a/scripts/singletons/globals.gd b/scripts/singletons/globals.gd
new file mode 100644 (file)
index 0000000..40573bc
--- /dev/null
@@ -0,0 +1,68 @@
+extends Node
+
+
+#region player position per level
+
+
+class _PlayerPositionAt:
+       var scene: int
+       var position: Vector2
+       
+       func _init(new_scene: Constants.LEVELS_NAMES, new_position: Vector2):
+               scene = new_scene
+               position = new_position
+
+
+var player_positions: Array[_PlayerPositionAt]
+var last_scene_updated: Constants.LEVELS_NAMES
+
+
+func update_player_position(scene: Constants.LEVELS_NAMES, new_position: Vector2):
+       last_scene_updated = scene
+       
+       for p_pos in player_positions:
+               if p_pos.scene == scene:
+                       p_pos.position = new_position
+                       return
+       
+       player_positions.append(_PlayerPositionAt.new(scene, new_position))
+
+
+func get_last_player_position_in_scene(scene: Constants.LEVELS_NAMES) -> Vector2:
+       for p_pos in player_positions:
+               if p_pos.scene == scene:
+                       return p_pos.position
+       
+       return Vector2()
+
+
+func get_last_scene_updated() -> Constants.LEVELS_NAMES:
+       return last_scene_updated
+
+
+#endregion
+
+#region current scene
+
+
+var current_scene: Constants.LEVELS_NAMES
+
+
+func set_current_scene(scene: Constants.LEVELS_NAMES):
+       current_scene = scene
+
+
+func get_current_scene() -> Constants.LEVELS_NAMES:
+       return current_scene
+
+
+#endregion
+
+#region utils
+
+
+func get_scene_path(scene_name: Constants.LEVELS_NAMES) -> String:
+       return Constants.LEVELS_PATHS[scene_name]
+
+
+#endregion
diff --git a/scripts/singletons/globals.gd.uid b/scripts/singletons/globals.gd.uid
new file mode 100644 (file)
index 0000000..2c81bed
--- /dev/null
@@ -0,0 +1 @@
+uid://d2ubolfbi143e
diff --git a/scripts/update_manager.gd b/scripts/update_manager.gd
new file mode 100644 (file)
index 0000000..5114132
--- /dev/null
@@ -0,0 +1,73 @@
+extends Control
+
+
+var is_update_available: bool = false
+
+@onready var update_dialog = $UpdateDialog
+@onready var download_dialog = $DownloadDialog
+
+@onready var update_http_request = $UpdateHTTPRequest
+
+
+func _ready():
+       Events.update_available.connect(_on_update_available)
+       update_http_request.request_completed.connect(_on_request_completed)
+       update_http_request.request(Constants.VERSION_CHECK_ENDPOINT)
+
+
+func _on_request_completed(_result: int, response_code: int, _headers: PackedStringArray, body: PackedByteArray):
+       if response_code == 200:
+               print("Current version: ", Constants.VERSION)
+               print("Online version: ", body.get_string_from_utf8())
+               
+               if Constants.VERSION != body.get_string_from_utf8().strip_edges():
+                       Events.update_available.emit(true)
+                       is_update_available = true
+               else:
+                       Events.update_available.emit(false)
+                       self.queue_free()
+       else:
+               push_error( "Error Checking Version\n","Response code: ", response_code, "\n", body.get_string_from_utf8().strip_edges())
+               self.queue_free()
+
+
+func _on_update_available(update: bool):
+       if not update:
+               return
+       
+       update_dialog.show()
+
+
+func _on_ignore_button_pressed():
+       update_dialog.hide()
+
+
+func _on_download_button_pressed():
+       update_dialog.hide()
+       download_dialog.show()
+       
+       var httpDownloader = HTTPRequest.new()
+       add_child(httpDownloader)
+       httpDownloader.request_completed.connect(_on_download_request_completed)
+       httpDownloader.download_file = Constants.PCK_PATH_NAME
+       httpDownloader.request(Constants.VERSION_PCK_DOWNLOAD_ENDPOINT)
+
+
+func _on_download_request_completed(_result: int, response_code: int, _headers: PackedStringArray, body: PackedByteArray):
+       if response_code == 200:
+               var success = ProjectSettings.load_resource_pack(Constants.PCK_PATH_NAME)
+               if success:
+                       print("update ok\nrestarting...")
+                       var thread = Thread.new()
+                       thread.start(_launch_game.bind())
+                       await get_tree().create_timer(1).timeout
+                       get_tree().quit()
+       else:
+               push_error( "Error Downloading PCK\n","Response code: ", response_code, "\n", body.get_string_from_utf8().strip_edges())
+               remove_child($httpDownloader)
+               download_dialog.hide()
+               self.queue_free()
+
+func _launch_game():
+       var executable_path = OS.get_executable_path()
+       OS.execute(executable_path, [])
diff --git a/scripts/update_manager.gd.uid b/scripts/update_manager.gd.uid
new file mode 100644 (file)
index 0000000..83ac74b
--- /dev/null
@@ -0,0 +1 @@
+uid://cnrbihl340sml