From 48e52f43172f004faeb0097f0bd94b9089a56fd7 Mon Sep 17 00:00:00 2001 From: Ryan Reed Date: Fri, 28 Mar 2025 10:59:35 -0400 Subject: [PATCH] Adding autosave notification --- .../autoloads/save_game_manager.gd | 2 + .../save_game_settings_resource.tres | 2 +- assets/ui/spinner-clockwise.png | Bin 0 -> 6509 bytes assets/ui/spinner-clockwise.png.import | 34 +++++++ scenes/ui/autosave_notification.gd | 26 ++++++ scenes/ui/autosave_notification.gd.uid | 1 + scenes/ui/autosave_notification.tscn | 87 ++++++++++++++++++ scenes/ui/ui.tscn | 6 +- 8 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 assets/ui/spinner-clockwise.png create mode 100644 assets/ui/spinner-clockwise.png.import create mode 100644 scenes/ui/autosave_notification.gd create mode 100644 scenes/ui/autosave_notification.gd.uid create mode 100644 scenes/ui/autosave_notification.tscn 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 0000000000000000000000000000000000000000..83bae9c1898bf97339e8f45633bddc1aff010eb9 GIT binary patch literal 6509 zcmb7}g{tM6~--*mJa%o=!5;scZT{~s@jt^eN5*v}aL+Dq}JM}WPPg3A6el|3=F zJuTI1;v^DzF${+ex-mgJvwl?6g=olySfHTy{jgOHO3(mbxst-zKBX7Z70e)n8mtQf z#UCE>j4UrZYGXu8+~A|48fsLnb^#nbmoJBF=O=jIu4i#zc~7M9!O;3@p2_(^$SKhs z|8G3i`L^%+PQ7?Cx2~$AUp<)BbmV|$2<*ym@?Ks=DmL}I4Z}TCD6Gzgztt{01mz%v zo(ULzQt($$SYhYi_b@AtE^*&AAiFS3bCNN_lrwheD1`g`K2mdfV{FUZd+PP%>AQzQ zExe4X+>b^!iQux9xl>>HdWICk>xOIZZSGa~N}Fx0R}$YVPmFULEq$fswAM4kZVvsf z6T+m-2>RowjxMB^XOpZ$4H`r$jOVJmC2R|ONm%bjZH{ZLi8^6v$%s9b1{w+2L!I(+ zx#c`4hR5x)w^U3zGLWVjpXXkNLtU(4)nPi}Z!e`_&0vJrn%<7#&zYg5`n?Lb@%XRG z6juBn0w#Z+FRg=eR)^@&IZEf^Wo5Dq{v-arEooGub_k9RW#@G@>*h$ zCzut_{(pm9ZAfh7y;l^7g;Cee#60W83*HIEQ3vj)C*1Z{r*3r2PW%Tx z=NlyJ4P|S{WOxv!-F}zggwWo~NClr>mcKb)VM#fb@94_Qt>GX22_gQ@y&Og6)@U1A zK`FMmdZ*xm5T}+C#uH-vooCL}^oRu{zD$}-t#^uKMcd z*S>UjKR=F&W>q&+k&>KxSGC<8vE{*Iue_uWOWWUjdimFm&bkIw?i;@lJ;D9078u&y zo$TgdB$>{s-_cV=OP8DCEFz|v(?{KR`k+5a)gpc}$bXDt5Q?V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2X@*7UtAskt@Ek3qOeR~}MVH)C7QXa?#- zFAWx_Df3o4WgCeQQ^L=iVO)0I;WX9vj z+!*N|U7UDV$U|%}DdvaKz!iYvS;!QthDe%YdRqT7)s@S^XC`ig1gO4Q!#)T zIjn~YXk4xuik#?SkC3r@)ORLrzNud1(YS;tLL6O0u}##R4>osho0lYJ7k-*pMsJ?* zGCbWsA=&Fb`ifna8vw-8$X;D@p9cP1gI!4diDqMPb3U2rXS9g zD`7wQ?h$C_L0y4rg*Bijy0i7|DuSXm(JGU_&Q 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