Browse Source

Adding autosave notification

pull/19/head
Ryan Reed 1 month ago
parent
commit
48e52f4317
8 changed files with 156 additions and 2 deletions
  1. +2
    -0
      addons/save_load_system/autoloads/save_game_manager.gd
  2. +1
    -1
      addons/save_load_system/resources/save_game_settings_resource.tres
  3. BIN
      assets/ui/spinner-clockwise.png
  4. +34
    -0
      assets/ui/spinner-clockwise.png.import
  5. +26
    -0
      scenes/ui/autosave_notification.gd
  6. +1
    -0
      scenes/ui/autosave_notification.gd.uid
  7. +87
    -0
      scenes/ui/autosave_notification.tscn
  8. +5
    -1
      scenes/ui/ui.tscn

+ 2
- 0
addons/save_load_system/autoloads/save_game_manager.gd View File

@ -105,6 +105,7 @@ func list_saves(include_quick_saves: bool = true, include_autosaves: bool = true
func _create_autosave() -> void: func _create_autosave() -> void:
if not _load_save_settings(): return if not _load_save_settings(): return
_autosave_timer.stop()
autosave_start.emit() autosave_start.emit()
_rotate_autosaves() _rotate_autosaves()
@ -113,6 +114,7 @@ func _create_autosave() -> void:
_save_game_as_resource("Auto Save", autosave_filename) _save_game_as_resource("Auto Save", autosave_filename)
autosave_complete.emit() autosave_complete.emit()
_autosave_timer.start(_save_game_settings.autosave_duration)
## Sort the save files list by date created, descending ## Sort the save files list by date created, descending
func _custom_save_file_sort(a: SaveFileDetailsResource, b: SaveFileDetailsResource) -> bool: func _custom_save_file_sort(a: SaveFileDetailsResource, b: SaveFileDetailsResource) -> bool:


+ 1
- 1
addons/save_load_system/resources/save_game_settings_resource.tres View File

@ -6,8 +6,8 @@
[resource] [resource]
script = ExtResource("1_o1tpj") script = ExtResource("1_o1tpj")
save_game_data_path = "user://game_data/" save_game_data_path = "user://game_data/"
max_auto_saves = 5
autosave_duration = 60 autosave_duration = 60
max_autosaves = 5
save_file_name_prepend = "save_" save_file_name_prepend = "save_"
quicksave_file_name_prepend = "quicksave_" quicksave_file_name_prepend = "quicksave_"
autosave_file_name_prepend = "autosave_" autosave_file_name_prepend = "autosave_"


BIN
assets/ui/spinner-clockwise.png View File

Before After
Width: 240  |  Height: 240  |  Size: 6.4 KiB

+ 34
- 0
assets/ui/spinner-clockwise.png.import View File

@ -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

+ 26
- 0
scenes/ui/autosave_notification.gd View File

@ -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

+ 1
- 0
scenes/ui/autosave_notification.gd.uid View File

@ -0,0 +1 @@
uid://db0pkuhbcmfkb

+ 87
- 0
scenes/ui/autosave_notification.tscn View File

@ -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"

+ 5
- 1
scenes/ui/ui.tscn View File

@ -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="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://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://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://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://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"] [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"] [node name="UI" type="CanvasLayer"]
@ -41,3 +42,6 @@ visible = false
[node name="SaveLoadUI" parent="." node_paths=PackedStringArray("ui_node") instance=ExtResource("8_jcn1r")] [node name="SaveLoadUI" parent="." node_paths=PackedStringArray("ui_node") instance=ExtResource("8_jcn1r")]
visible = false visible = false
ui_node = NodePath("..") ui_node = NodePath("..")
[node name="AutosaveNotification" parent="." instance=ExtResource("7_jcn1r")]
visible = false

Loading…
Cancel
Save