diff --git a/addons/save_load_system/autoloads/save_game_manager.gd b/addons/save_load_system/autoloads/save_game_manager.gd index 062cbf3..51374e8 100644 --- a/addons/save_load_system/autoloads/save_game_manager.gd +++ b/addons/save_load_system/autoloads/save_game_manager.gd @@ -105,6 +105,7 @@ func list_saves(include_quick_saves: bool = true, include_autosaves: bool = true func _create_autosave() -> void: if not _load_save_settings(): return + _autosave_timer.stop() autosave_start.emit() _rotate_autosaves() @@ -113,6 +114,7 @@ func _create_autosave() -> void: _save_game_as_resource("Auto Save", autosave_filename) autosave_complete.emit() + _autosave_timer.start(_save_game_settings.autosave_duration) ## Sort the save files list by date created, descending func _custom_save_file_sort(a: SaveFileDetailsResource, b: SaveFileDetailsResource) -> bool: diff --git a/addons/save_load_system/resources/save_game_settings_resource.tres b/addons/save_load_system/resources/save_game_settings_resource.tres index 774be9c..7532c75 100644 --- a/addons/save_load_system/resources/save_game_settings_resource.tres +++ b/addons/save_load_system/resources/save_game_settings_resource.tres @@ -6,8 +6,8 @@ [resource] script = ExtResource("1_o1tpj") save_game_data_path = "user://game_data/" -max_auto_saves = 5 autosave_duration = 60 +max_autosaves = 5 save_file_name_prepend = "save_" quicksave_file_name_prepend = "quicksave_" autosave_file_name_prepend = "autosave_" diff --git a/assets/ui/spinner-clockwise.png b/assets/ui/spinner-clockwise.png new file mode 100644 index 0000000..83bae9c Binary files /dev/null and b/assets/ui/spinner-clockwise.png differ diff --git a/assets/ui/spinner-clockwise.png.import b/assets/ui/spinner-clockwise.png.import new file mode 100644 index 0000000..6cd9791 --- /dev/null +++ b/assets/ui/spinner-clockwise.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bsfqsslfq53dn" +path="res://.godot/imported/spinner-clockwise.png-bbb06e749ee5040cd72cec4de0d564b2.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ui/spinner-clockwise.png" +dest_files=["res://.godot/imported/spinner-clockwise.png-bbb06e749ee5040cd72cec4de0d564b2.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/scenes/ui/autosave_notification.gd b/scenes/ui/autosave_notification.gd new file mode 100644 index 0000000..f94d28f --- /dev/null +++ b/scenes/ui/autosave_notification.gd @@ -0,0 +1,26 @@ +class_name AutosaveNotification +extends MarginContainer + + +@export var animation_player: AnimationPlayer + + +func _ready() -> void: + SaveGameManager.autosave_start.connect(_on_autosave_start) + SaveGameManager.autosave_complete.connect(_on_autosave_complete) + visible = false + +func _on_autosave_start() -> void: + animation_player.play("spin") + visible = true + +func _on_autosave_complete() -> void: + # This is for testing. Saving seems to be fast making the autosave disappear immediately. + # It's not clear the cause. + # Additionally, the displaying of UI element is inconsistent. Sometimes I need to print(visible) to force it to show up, although I have no idea why that works + # TODO: Figure out what the hell is going on here + print(visible) + await get_tree().create_timer(3).timeout + + animation_player.stop() + visible = false diff --git a/scenes/ui/autosave_notification.gd.uid b/scenes/ui/autosave_notification.gd.uid new file mode 100644 index 0000000..f491611 --- /dev/null +++ b/scenes/ui/autosave_notification.gd.uid @@ -0,0 +1 @@ +uid://db0pkuhbcmfkb diff --git a/scenes/ui/autosave_notification.tscn b/scenes/ui/autosave_notification.tscn new file mode 100644 index 0000000..b8b3f3a --- /dev/null +++ b/scenes/ui/autosave_notification.tscn @@ -0,0 +1,87 @@ +[gd_scene load_steps=6 format=3 uid="uid://rfknvv8b0d4i"] + +[ext_resource type="Texture2D" uid="uid://bsfqsslfq53dn" path="res://assets/ui/spinner-clockwise.png" id="1_2tr78"] +[ext_resource type="Script" uid="uid://db0pkuhbcmfkb" path="res://scenes/ui/autosave_notification.gd" id="1_rdcu1"] + +[sub_resource type="Animation" id="Animation_y220t"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Icon/TextureRect:rotation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [0.0] +} + +[sub_resource type="Animation" id="Animation_uegxj"] +resource_name = "spin" +loop_mode = 1 +step = 0.1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Icon/TextureRect:rotation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 1), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [0.0, 6.28319] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_4kltc"] +_data = { +&"RESET": SubResource("Animation_y220t"), +&"spin": SubResource("Animation_uegxj") +} + +[node name="AutosaveNotification" type="MarginContainer" node_paths=PackedStringArray("animation_player")] +process_mode = 3 +z_index = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -164.0 +offset_bottom = 60.0 +grow_horizontal = 0 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 10 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 10 +script = ExtResource("1_rdcu1") +animation_player = NodePath("AnimationPlayer") + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +layout_mode = 2 + +[node name="Icon" type="Control" parent="HBoxContainer"] +custom_minimum_size = Vector2(40, 40) +layout_mode = 2 + +[node name="TextureRect" type="TextureRect" parent="HBoxContainer/Icon"] +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 +pivot_offset = Vector2(20, 20) +texture = ExtResource("1_2tr78") +expand_mode = 3 + +[node name="Label" type="Label" parent="HBoxContainer"] +layout_mode = 2 +theme_override_colors/font_color = Color(0.944248, 0.414786, 0.141556, 1) +theme_override_colors/font_outline_color = Color(1, 1, 1, 1) +text = "Autosaving..." +vertical_alignment = 1 + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +root_node = NodePath("../HBoxContainer") +libraries = { +&"": SubResource("AnimationLibrary_4kltc") +} +autoplay = "spin" diff --git a/scenes/ui/ui.tscn b/scenes/ui/ui.tscn index 2b77c1f..3db600e 100644 --- a/scenes/ui/ui.tscn +++ b/scenes/ui/ui.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=7 format=3 uid="uid://c7fj7wla8bd70"] +[gd_scene load_steps=8 format=3 uid="uid://c7fj7wla8bd70"] [ext_resource type="Script" uid="uid://bslimr2y4lnvq" path="res://scenes/ui/ui.gd" id="1_aac20"] [ext_resource type="PackedScene" uid="uid://dvogu3djluqsn" path="res://scenes/ui/waila.tscn" id="1_u7n8c"] [ext_resource type="PackedScene" uid="uid://cbiygbgpfk220" path="res://scenes/ui/quick_slots.tscn" id="4_g5kmx"] [ext_resource type="PackedScene" uid="uid://bopvfwcgnnawg" path="res://scenes/ui/menus/pause_menu.tscn" id="6_7vp6q"] [ext_resource type="PackedScene" uid="uid://4bdgwwx27m71" path="res://scenes/ui/menus/settings_menu.tscn" id="7_7vp6q"] +[ext_resource type="PackedScene" uid="uid://rfknvv8b0d4i" path="res://scenes/ui/autosave_notification.tscn" id="7_jcn1r"] [ext_resource type="PackedScene" uid="uid://dauchkhmnyk7n" path="res://scenes/ui/menus/saves_manager/save_load_ui.tscn" id="8_jcn1r"] [node name="UI" type="CanvasLayer"] @@ -41,3 +42,6 @@ visible = false [node name="SaveLoadUI" parent="." node_paths=PackedStringArray("ui_node") instance=ExtResource("8_jcn1r")] visible = false ui_node = NodePath("..") + +[node name="AutosaveNotification" parent="." instance=ExtResource("7_jcn1r")] +visible = false