Browse Source

Merge pull request 'Autosaves and Simplifying SaveLevelDataComponent' (#19) from autosaves into master

pull/20/head
Ryan Reed 1 month ago
parent
commit
c1ca3a98cb
16 changed files with 297 additions and 62 deletions
  1. +105
    -36
      addons/save_load_system/autoloads/save_game_manager.gd
  2. +0
    -2
      addons/save_load_system/components/save_level_data_component.gd
  3. +1
    -3
      addons/save_load_system/components/save_level_data_component.tscn
  4. +1
    -1
      addons/save_load_system/resources/save_file_details_resource.gd
  5. +1
    -0
      addons/save_load_system/resources/save_game_data_resource.gd
  6. +8
    -4
      addons/save_load_system/resources/save_game_settings_resource.gd
  7. +8
    -5
      addons/save_load_system/resources/save_game_settings_resource.tres
  8. BIN
      assets/ui/spinner-clockwise.png
  9. +34
    -0
      assets/ui/spinner-clockwise.png.import
  10. +25
    -0
      scenes/ui/autosave_notification.gd
  11. +1
    -0
      scenes/ui/autosave_notification.gd.uid
  12. +87
    -0
      scenes/ui/autosave_notification.tscn
  13. +1
    -1
      scenes/ui/menus/saves_manager/save_file.gd
  14. +8
    -8
      scenes/ui/menus/saves_manager/save_load_ui.gd
  15. +7
    -2
      scenes/ui/ui.tscn
  16. +10
    -0
      scenes/world/world.gd

+ 105
- 36
addons/save_load_system/autoloads/save_game_manager.gd View File

@ -9,7 +9,9 @@ extends Node
signal apply_complete
signal apply_save ## Apply the loaded data to the tree. Note: This should happen AFTER load_save()
signal create_auto_save
signal autosave_complete ## Autosave has completed
signal autosave_start ## Autosave has started
signal create_autosave
signal create_save(save_name: String)
signal delete_save(filename: String)
signal delete_error(error_message: String)
@ -18,16 +20,19 @@ signal load_error(error_message: String)
signal load_save(filename: String) ## Loads the save into memory. Does NOT apply the load as this allows for other actions (such as resetting the levle/world).[br]Don't forget to run `apply_save` after loading
signal save_complete
signal save_error(error_message: String)
signal start_autosave
signal stop_autosave
signal quick_save
signal quick_load
signal toggle_save_icon_generation(toggled: bool) ## Enable/Disable the generation of a screenshot during save for the save icon.
var _autosave_timer: Timer = Timer.new()
var _enable_save_icon_generation: bool = true
var _loaded_save_resource: SaveGameDataResource = SaveGameDataResource.new()
var _save_game_settings: SaveGameSettings ## Contains the save paths, filename prepends, and other save settings
var _save_icon_size: Vector2i = Vector2i(896, 504) ## If Vector2.ZERO, uses the user's resolution
var _save_level_data_component: SaveLevelDataComponent ## Contains the save paths and filenames
func _ready() -> void:
@ -37,29 +42,39 @@ func _ready() -> void:
load_save.connect(_on_load_game_save)
quick_load.connect(_on_quick_load)
quick_save.connect(_on_quick_save)
start_autosave.connect(_on_start_autosave)
stop_autosave.connect(_on_stop_autosave)
toggle_save_icon_generation.connect(_on_toggle_save_icon_generation)
_autosave_timer.name = "AutosaveTimer"
_autosave_timer.one_shot = false
_autosave_timer.timeout.connect(_on_autosave_timer_timeout)
add_child(_autosave_timer)
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("quick_save"):
_on_quick_save()
quick_save.emit()
if event.is_action_pressed("quick_load"):
_on_quick_load()
quick_load.emit()
func list_saves(include_quick_saves: bool = true, include_auto_saves: bool = true) -> Array[SaveFileDetailsResource]:
func list_saves(include_quick_saves: bool = true, include_autosaves: bool = true) -> Array[SaveFileDetailsResource]:
var save_files: Array[SaveFileDetailsResource] = []
if not _load_save_level_data_component():
if not _load_save_settings():
return save_files
var save_game_data_path: String = _save_level_data_component.settings.save_game_data_path
var save_game_data_path: String = _save_game_settings.save_game_data_path
if !DirAccess.dir_exists_absolute(save_game_data_path):
return save_files
for filename: String in ResourceLoader.list_directory(save_game_data_path):
# TODO: Rework so the settings determine the file_name using prepends
if filename.begins_with("quicksave_") and not include_quick_saves: continue
elif filename.begins_with("autosave_") and not include_auto_saves: continue
elif !filename.begins_with("save_") and !filename.begins_with("quicksave_") and !filename.begins_with("autosave_"): continue
if filename.begins_with(_save_game_settings.quicksave_file_name_prepend) and not include_quick_saves:
continue
elif filename.begins_with(_save_game_settings.autosave_file_name_prepend) and not include_autosaves:
continue
elif !filename.begins_with(_save_game_settings.save_file_name_prepend) and !filename.begins_with(_save_game_settings.quicksave_file_name_prepend) and !filename.begins_with(_save_game_settings.autosave_file_name_prepend):
continue
var _save_path: String = save_game_data_path + filename
var _save_icon: String = filename.replace(".tres", ".png")
@ -70,9 +85,9 @@ func list_saves(include_quick_saves: bool = true, include_auto_saves: bool = tru
# Should work out a better method for getting the save name (filename != save name)
var _save_file: SaveGameDataResource = ResourceLoader.load(_save_path)
_save_resource.save_name = _save_file.save_name
_save_resource.save_date = _save_file.save_date
_save_resource.filename = filename
_save_resource.date_created = Time.get_datetime_string_from_unix_time(FileAccess.get_modified_time(_save_path))
## In 4.5, this can probably be replaced with FileAccess.get_size(_save_path)
## This should reduce the need for opening the file here
@ -87,9 +102,23 @@ func list_saves(include_quick_saves: bool = true, include_auto_saves: bool = tru
return save_files
func _create_autosave() -> void:
if not _load_save_settings(): return
_autosave_timer.stop()
autosave_start.emit()
_rotate_autosaves()
var autosave_filename: String = _save_game_settings.autosave_file_name_prepend + "01.tres"
_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:
return a.date_created > b.date_created
return a.save_date > b.save_date
## Save the properties defined on the SaveDataComponents attached to various nodes (such as Block)
func _generate_save_game_resource() -> SaveGameDataResource:
@ -111,9 +140,9 @@ func _generate_save_game_resource() -> SaveGameDataResource:
func _generate_save_icon_texture(save_icon: String) -> Texture2D:
var _icon_texture: Texture2D = ImageTexture.new()
if save_icon != null and !FileAccess.file_exists(save_icon):
_icon_texture = _save_level_data_component.default_save_icon_resource
_icon_texture = _save_game_settings.default_save_icon_resource
elif save_icon == null:
_icon_texture = _save_level_data_component.default_save_icon_resource
_icon_texture = _save_game_settings.default_save_icon_resource
else:
var _icon_image: Image = Image.new()
_icon_image.load(save_icon)
@ -123,19 +152,10 @@ func _generate_save_icon_texture(save_icon: String) -> Texture2D:
return _icon_texture
## Find the SaveLevelDataComponent within the level which stores the save settings
func _load_save_level_data_component() -> bool:
_save_level_data_component = get_tree().get_first_node_in_group("save_level_data_component")
if _save_level_data_component == null:
push_error("Could not find SaveLevelDataComponent node in level")
return false
return true
func _load_game_resource(resource_filename: String) -> void:
if not _load_save_level_data_component(): return
if not _load_save_settings(): return
var save_game_file_path: String = _save_level_data_component.settings.save_game_data_path + resource_filename
var save_game_file_path: String = _save_game_settings.save_game_data_path + resource_filename
if !FileAccess.file_exists(save_game_file_path):
load_error.emit("Failed to load save. File does not exist: %s" % save_game_file_path)
return
@ -147,16 +167,54 @@ func _load_game_resource(resource_filename: String) -> void:
load_complete.emit()
## Find the SaveLevelDataComponent within the tree which stores the save settings
func _load_save_settings() -> bool:
var _save_level_data_component: SaveLevelDataComponent = get_tree().get_first_node_in_group("save_level_data_component")
if _save_level_data_component == null:
push_error("Could not find SaveLevelDataComponent node in level")
return false
_save_game_settings = _save_level_data_component.settings
return true
## Increment autosave numbers and if we've reach max number of autosaves, remove the oldest one
func _rotate_autosaves() -> void:
var saves_dir = DirAccess.open(_save_game_settings.save_game_data_path)
if saves_dir == null:
DirAccess.make_dir_absolute(_save_game_settings.save_game_data_path)
var autosaves: Array[String] = []
for filename in saves_dir.get_files():
if !filename.begins_with(_save_game_settings.autosave_file_name_prepend): continue
if !filename.ends_with(".tres"): continue
autosaves.append(filename)
if autosaves.size() == _save_game_settings.max_autosaves: # Delete oldest save
DirAccess.remove_absolute(_save_game_settings.save_game_data_path + autosaves.pop_back())
var filepath: String = _save_game_settings.save_game_data_path + _save_game_settings.autosave_file_name_prepend
for index in range(autosaves.size(), 0, -1):
var old_save_path: String = "%s%02d.tres" % [filepath, index]
var old_screenshot_path: String = "%s%02d.png" % [filepath, index]
var new_save_path: String = "%s%02d.tres" % [filepath, index + 1]
var new_screenshot_path: String = "%s%02d.png" % [filepath, index + 1]
DirAccess.copy_absolute(old_save_path, new_save_path)
if FileAccess.file_exists(old_screenshot_path):
DirAccess.copy_absolute(old_screenshot_path, new_screenshot_path)
func _save_game_as_resource(save_name, resource_filename: String) -> void:
if not _load_save_level_data_component(): return
if not _load_save_settings(): return
if !DirAccess.dir_exists_absolute(_save_level_data_component.settings.save_game_data_path):
DirAccess.make_dir_absolute(_save_level_data_component.settings.save_game_data_path)
if !DirAccess.dir_exists_absolute(_save_game_settings.save_game_data_path):
DirAccess.make_dir_absolute(_save_game_settings.save_game_data_path)
var save_game_file_path: String = _save_level_data_component.settings.save_game_data_path + resource_filename
var save_game_file_path: String = _save_game_settings.save_game_data_path + resource_filename
var _save_resource: SaveGameDataResource = _generate_save_game_resource()
_save_resource.save_name = save_name
_save_resource.save_date = Time.get_datetime_string_from_system(false, true)
var result: int = ResourceSaver.save(_save_resource, save_game_file_path)
if result != OK:
@ -191,13 +249,16 @@ func _on_apply_save() -> void:
apply_complete.emit()
func _on_autosave_timer_timeout() -> void:
_create_autosave()
## Delete both the save file and the related screenshot
func _on_delete_save(filename: String) -> void:
if filename.length() < 1:
delete_error.emit("Empty filename provided")
return
var save_file_path: String = _save_level_data_component.settings.save_game_data_path + filename
var save_file_path: String = _save_game_settings.save_game_data_path + filename
DirAccess.remove_absolute(save_file_path)
DirAccess.remove_absolute(save_file_path.replace(".tres", ".png")) # Delete icon
@ -205,24 +266,32 @@ func _on_load_game_save(resource_filename: String) -> void:
_load_game_resource(resource_filename)
func _on_quick_load() -> void:
if not _load_save_level_data_component(): return
_load_game_resource(_save_level_data_component.settings.quicksave_file_name)
if not _load_save_settings(): return
_load_game_resource(_save_game_settings.quicksave_file_name_prepend + "game_data.tres")
func _on_quick_save() -> void:
if not _load_save_level_data_component(): return
if not _load_save_settings(): return
_save_game_as_resource("Quick Save", _save_level_data_component.settings.quicksave_file_name)
_save_game_as_resource("Quick Save", _save_game_settings.quicksave_file_name_prepend + "game_data.tres")
## Save the game, with a filename of `<save_prepend><current_date>.tres
func _on_save_game_as_resource(save_name: String) -> void:
if not _load_save_level_data_component(): return
if not _load_save_settings(): return
var current_date: String = Time.get_datetime_string_from_system().replace(":", "")
var _filename: String = "save_" + current_date + ".tres"
var _filename: String = _save_game_settings.save_file_name_prepend + current_date + ".tres"
_loaded_save_resource.save_name = save_name
_save_game_as_resource(save_name, _filename)
save_complete.emit()
func _on_start_autosave() -> void:
if _save_game_settings == null:
_load_save_settings()
_autosave_timer.start(_save_game_settings.autosave_duration)
func _on_stop_autosave() -> void:
_autosave_timer.stop()
func _on_toggle_save_icon_generation(toggled: bool) -> void:
_enable_save_icon_generation = toggled

+ 0
- 2
addons/save_load_system/components/save_level_data_component.gd View File

@ -4,9 +4,7 @@ class_name SaveLevelDataComponent
extends Node
@export var default_save_icon_resource: CompressedTexture2D
@export var settings: SaveGameSettings ## The SaveGameSettings resource
@export var ui_node: CanvasLayer ## The UI to Show/Hide when taking screenshot (e.g. save icon generation)
func _ready() -> void:


+ 1
- 3
addons/save_load_system/components/save_level_data_component.tscn View File

@ -1,10 +1,8 @@
[gd_scene load_steps=4 format=3 uid="uid://c3pqilb6yh5kc"]
[gd_scene load_steps=3 format=3 uid="uid://c3pqilb6yh5kc"]
[ext_resource type="Script" uid="uid://c7x2qvyu62230" path="res://addons/save_load_system/components/save_level_data_component.gd" id="1_exguq"]
[ext_resource type="Texture2D" uid="uid://b4lam0dwtv8fq" path="res://addons/save_load_system/default_icon.svg" id="2_hd7aa"]
[ext_resource type="Resource" uid="uid://o32fooj1lxg7" path="res://addons/save_load_system/resources/save_game_settings_resource.tres" id="2_rkr1f"]
[node name="SaveLevelDataComponent" type="Node"]
script = ExtResource("1_exguq")
default_save_icon_resource = ExtResource("2_hd7aa")
settings = ExtResource("2_rkr1f")

+ 1
- 1
addons/save_load_system/resources/save_file_details_resource.gd View File

@ -6,6 +6,6 @@ extends Node
@export var save_name: String = "My Save"
@export var filename: String = ""
@export var date_created: String = ""
@export var save_date: String = ""
@export var filesize: int = 0
@export var save_icon_texture: Texture2D

+ 1
- 0
addons/save_load_system/resources/save_game_data_resource.gd View File

@ -8,3 +8,4 @@ extends Resource
@export var save_data_nodes: Array[Node3DDataResource]
@export var save_name: String
@export var save_date: String

+ 8
- 4
addons/save_load_system/resources/save_game_settings_resource.gd View File

@ -8,8 +8,12 @@ extends Resource
## * macOS: ~/Library/Application Support/Godot/app_userdata/[project_name][br]
## * Linux: ~/.local/share/godot/app_userdata/[project_name][br]
@export var save_game_data_path: String = "user://game_data/"
@export var max_auto_saves: int = 5
@export var max_autosaves: int = 5
@export var save_file_name: String = "save_game_data.tres"
@export var quicksave_file_name: String = "quicksave_game_data.tres"
@export var autosave_file_name: String = "autosave_%s_game_data.tres" ## %s is the save number (probably 01)
@export var autosave_duration: int = 60 ## How often, in seconds, should an autosave run[br]SaveGameManager will NOT autostart the autosave timer. This must be done by the world/scene.
@export var save_file_name_prepend: String = "save_"
@export var quicksave_file_name_prepend: String = "quicksave_"
@export var autosave_file_name_prepend: String = "autosave_"
@export var default_save_icon_resource: CompressedTexture2D

+ 8
- 5
addons/save_load_system/resources/save_game_settings_resource.tres View File

@ -1,12 +1,15 @@
[gd_resource type="Resource" script_class="SaveGameSettings" load_steps=2 format=3 uid="uid://o32fooj1lxg7"]
[gd_resource type="Resource" script_class="SaveGameSettings" load_steps=3 format=3 uid="uid://o32fooj1lxg7"]
[ext_resource type="Texture2D" uid="uid://b4lam0dwtv8fq" path="res://addons/save_load_system/default_icon.svg" id="1_fm0fk"]
[ext_resource type="Script" uid="uid://d0iptf06t7f47" path="res://addons/save_load_system/resources/save_game_settings_resource.gd" id="1_o1tpj"]
[resource]
script = ExtResource("1_o1tpj")
save_game_data_path = "user://game_data/"
max_auto_saves = 5
save_file_name = "save_%s_game_data.tres"
quicksave_file_name = "quicksave_game_data.tres"
autosave_file_name = "autosave_%s_game_data.tres"
autosave_duration = 60
max_autosaves = 5
save_file_name_prepend = "save_"
quicksave_file_name_prepend = "quicksave_"
autosave_file_name_prepend = "autosave_"
default_save_icon_resource = ExtResource("1_fm0fk")
metadata/_custom_type_script = "uid://d0iptf06t7f47"

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

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

@ -0,0 +1,25 @@
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. 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. It might not actually be doing anything and is just randomish.
# 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"

+ 1
- 1
scenes/ui/menus/saves_manager/save_file.gd View File

@ -36,7 +36,7 @@ func initialize(_resource: SaveFileDetailsResource) -> void:
set_save_name()
func set_save_date() -> void:
save_date_label.text = save_file_details.date_created
save_date_label.text = save_file_details.save_date
func set_save_icon() -> void:
save_icon.texture = save_file_details.save_icon_texture


+ 8
- 8
scenes/ui/menus/saves_manager/save_load_ui.gd View File

@ -12,6 +12,8 @@ signal open_save_list
@export var create_save_button: BaseButton
@export var create_save_cancel_button: BaseButton
@export var ui_node: CanvasLayer ## The UI to Show/Hide when taking screenshot (e.g. save icon generation)
func _ready() -> void:
show_save_ui_button.pressed.connect(_on_show_save_ui_button_pressed)
@ -24,15 +26,14 @@ func _ready() -> void:
func _on_create_save_button_pressed() -> void:
var save_name: String = save_name_input.text
if save_name.strip_edges() == "":
save_name = Time.get_datetime_string_from_system().replace(":", "")
save_name = Time.get_datetime_string_from_system(false, true)
var _save_level_data_component: SaveLevelDataComponent = get_tree().get_first_node_in_group("save_level_data_component")
if _save_level_data_component.ui_node != null:
_save_level_data_component.ui_node.visible = false
if ui_node != null:
ui_node.visible = false
await get_tree().create_timer(.150).timeout # A hack to allow time for UI to hide before taking screenshot
SaveGameManager.create_save.emit(save_name)
if _save_level_data_component.ui_node != null:
_save_level_data_component.ui_node.visible = true
if ui_node != null:
ui_node.visible = true
new_save_ui.hide()
SignalManager.resume_game.emit()
@ -40,6 +41,5 @@ func _on_create_save_cancel_button_pressed() -> void:
new_save_ui.hide()
func _on_show_save_ui_button_pressed() -> void:
var current_date: String = Time.get_datetime_string_from_system()
save_name_input.text = current_date.replace(":", "")
save_name_input.text = Time.get_datetime_string_from_system(false, true)
new_save_ui.show()

+ 7
- 2
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="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"]
@ -38,5 +39,9 @@ save_load_ui = NodePath("../SaveLoadUI")
[node name="SettingsMenu" parent="." instance=ExtResource("7_7vp6q")]
visible = false
[node name="SaveLoadUI" parent="." instance=ExtResource("8_jcn1r")]
[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

+ 10
- 0
scenes/world/world.gd View File

@ -16,9 +16,12 @@ func _ready() -> void:
EntityManager.reset_world.connect(clear_world)
EntityManager.spawn_player.connect(spawn_player)
SaveGameManager.load_complete.connect(_on_load_save_complete)
SignalManager.open_pause_menu.connect(_on_open_pause_menu)
SignalManager.resume_game.connect(_on_resume_game)
clear_world()
create_world()
SaveGameManager.start_autosave.emit()
## For resetting/emptying the world to allow for load_game or generating a new world
func clear_world() -> void:
@ -87,3 +90,10 @@ func _on_reset_world() -> void:
func _on_load_save_complete() -> void:
clear_world()
SaveGameManager.apply_save.emit()
SaveGameManager.start_autosave.emit()
func _on_open_pause_menu() -> void:
SaveGameManager.stop_autosave.emit()
func _on_resume_game() -> void:
SaveGameManager.start_autosave.emit()

Loading…
Cancel
Save