Browse Source

Initial save game UI work (WIP)

pull/15/head
Ryan Reed 1 month ago
parent
commit
d6cdf5b2eb
28 changed files with 624 additions and 42 deletions
  1. BIN
      save_load/assets/folder-open-hover.png
  2. +34
    -0
      save_load/assets/folder-open-hover.png.import
  3. BIN
      save_load/assets/folder-open-normal.png
  4. +34
    -0
      save_load/assets/folder-open-normal.png.import
  5. BIN
      save_load/assets/folder-open-pressed.png
  6. +34
    -0
      save_load/assets/folder-open-pressed.png.import
  7. BIN
      save_load/assets/save-hover.png
  8. +34
    -0
      save_load/assets/save-hover.png.import
  9. BIN
      save_load/assets/save-normal.png
  10. +34
    -0
      save_load/assets/save-normal.png.import
  11. BIN
      save_load/assets/save-pressed.png
  12. +34
    -0
      save_load/assets/save-pressed.png.import
  13. BIN
      save_load/assets/trash-hover.png
  14. +34
    -0
      save_load/assets/trash-hover.png.import
  15. BIN
      save_load/assets/trash-normal.png
  16. +34
    -0
      save_load/assets/trash-normal.png.import
  17. BIN
      save_load/assets/trash-pressed.png
  18. +34
    -0
      save_load/assets/trash-pressed.png.import
  19. +12
    -10
      save_load/autoloads/save_game_manager.gd
  20. +50
    -32
      save_load/components/save_level_data_component.gd
  21. +4
    -0
      save_load/resources/save_file_highlight_panel_theme.tres
  22. +8
    -0
      save_load/resources/save_file_panel_theme.tres
  23. +63
    -0
      save_load/ui/save_file.gd
  24. +1
    -0
      save_load/ui/save_file.gd.uid
  25. +100
    -0
      save_load/ui/save_file.tscn
  26. +29
    -0
      save_load/ui/save_files_list.gd
  27. +1
    -0
      save_load/ui/save_files_list.gd.uid
  28. +50
    -0
      save_load/ui/save_load_ui.tscn

BIN
save_load/assets/folder-open-hover.png View File

Before After
Width: 57  |  Height: 46  |  Size: 887 B

+ 34
- 0
save_load/assets/folder-open-hover.png.import View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://by4w5ll3le7g6"
path="res://.godot/imported/folder-open-hover.png-a1ef3a807e674ab8f8806dada553ab61.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://save_load/assets/folder-open-hover.png"
dest_files=["res://.godot/imported/folder-open-hover.png-a1ef3a807e674ab8f8806dada553ab61.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

BIN
save_load/assets/folder-open-normal.png View File

Before After
Width: 57  |  Height: 46  |  Size: 842 B

+ 34
- 0
save_load/assets/folder-open-normal.png.import View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cmq51cgasug81"
path="res://.godot/imported/folder-open-normal.png-f7f228a37723c0515dbd7272838372e1.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://save_load/assets/folder-open-normal.png"
dest_files=["res://.godot/imported/folder-open-normal.png-f7f228a37723c0515dbd7272838372e1.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

BIN
save_load/assets/folder-open-pressed.png View File

Before After
Width: 57  |  Height: 46  |  Size: 771 B

+ 34
- 0
save_load/assets/folder-open-pressed.png.import View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://blyryo60jydgi"
path="res://.godot/imported/folder-open-pressed.png-b69b4af3e2256bb46d3464e4d48a50c0.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://save_load/assets/folder-open-pressed.png"
dest_files=["res://.godot/imported/folder-open-pressed.png-b69b4af3e2256bb46d3464e4d48a50c0.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

BIN
save_load/assets/save-hover.png View File

Before After
Width: 48  |  Height: 48  |  Size: 869 B

+ 34
- 0
save_load/assets/save-hover.png.import View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://o3l0j53mgkan"
path="res://.godot/imported/save-hover.png-a059532ff43c1b9b7f190c464e6ac95e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://save_load/assets/save-hover.png"
dest_files=["res://.godot/imported/save-hover.png-a059532ff43c1b9b7f190c464e6ac95e.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

BIN
save_load/assets/save-normal.png View File

Before After
Width: 48  |  Height: 48  |  Size: 855 B

+ 34
- 0
save_load/assets/save-normal.png.import View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ja8bc1h5x85o"
path="res://.godot/imported/save-normal.png-126e9be66da8efc0f0eb84b8cc03c6ff.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://save_load/assets/save-normal.png"
dest_files=["res://.godot/imported/save-normal.png-126e9be66da8efc0f0eb84b8cc03c6ff.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

BIN
save_load/assets/save-pressed.png View File

Before After
Width: 48  |  Height: 48  |  Size: 773 B

+ 34
- 0
save_load/assets/save-pressed.png.import View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://crqgyft4gfilt"
path="res://.godot/imported/save-pressed.png-49f5851a0548d3847310651a4ef477c2.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://save_load/assets/save-pressed.png"
dest_files=["res://.godot/imported/save-pressed.png-49f5851a0548d3847310651a4ef477c2.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

BIN
save_load/assets/trash-hover.png View File

Before After
Width: 48  |  Height: 54  |  Size: 860 B

+ 34
- 0
save_load/assets/trash-hover.png.import View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cmrtuy0i5qc01"
path="res://.godot/imported/trash-hover.png-0c87af6ed9b10a21de0dd22a56db8a47.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://save_load/assets/trash-hover.png"
dest_files=["res://.godot/imported/trash-hover.png-0c87af6ed9b10a21de0dd22a56db8a47.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

BIN
save_load/assets/trash-normal.png View File

Before After
Width: 48  |  Height: 54  |  Size: 826 B

+ 34
- 0
save_load/assets/trash-normal.png.import View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dvp5yeoqw36yt"
path="res://.godot/imported/trash-normal.png-9a70475e0bfa21e155c8f068d078dd58.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://save_load/assets/trash-normal.png"
dest_files=["res://.godot/imported/trash-normal.png-9a70475e0bfa21e155c8f068d078dd58.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

BIN
save_load/assets/trash-pressed.png View File

Before After
Width: 48  |  Height: 54  |  Size: 768 B

+ 34
- 0
save_load/assets/trash-pressed.png.import View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://brwa8yljyrlgy"
path="res://.godot/imported/trash-pressed.png-635c7d9409ea36b0244299e895c300c2.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://save_load/assets/trash-pressed.png"
dest_files=["res://.godot/imported/trash-pressed.png-635c7d9409ea36b0244299e895c300c2.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

+ 12
- 10
save_load/autoloads/save_game_manager.gd View File

@ -9,33 +9,35 @@ extends Node
signal game_saved
signal game_loaded
signal refresh_saves_list
signal create_save_file(filename: String)
signal delete_save_file(filename: String)
signal load_save_file(filename: String)
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("quick_save"):
save_game()
quick_save()
if event.is_action_pressed("quick_load"):
load_game()
quick_load()
func save_game() -> void:
func quick_save() -> void:
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
save_level_data_component.save_game()
save_level_data_component.quick_save_game()
game_saved.emit()
func load_game() -> void:
EntityManager.reset_world.emit()
func quick_load() -> void:
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
save_level_data_component.load_game()
# TODO: Don't reset world if quicksave not found
EntityManager.reset_world.emit()
save_level_data_component.quick_load_game()
game_loaded.emit()

+ 50
- 32
save_load/components/save_level_data_component.gd View File

@ -10,21 +10,61 @@ extends Node
## * Linux: ~/.local/share/godot/app_userdata/[project_name][br]
@export var save_game_data_path: String = "user://game_data/"
@export var save_file_name: String = "save_%s_game_data.tres"
@export var quicksave_file_name: String = "quicksave_%s_game_data.tres"
var level_scene_name: String
var game_data_resource: SaveGameDataResource
var level_save_file_name: String
var save_game_file_path: String
#var level_save_file_name: String
#var save_game_file_path: String
func _ready() -> void:
add_to_group("save_level_data_component")
level_scene_name = get_parent().name
level_save_file_name = save_file_name % level_scene_name
save_game_file_path = save_game_data_path + level_save_file_name
func list_saves() -> Array[SaveFileDetailsResource]: # TODO: Update hints
var save_files: Array[SaveFileDetailsResource] = []
if !DirAccess.dir_exists_absolute(save_game_data_path):
return save_files
for filename: String in ResourceLoader.list_directory(save_game_data_path):
if !filename.begins_with("save_"): continue
if !filename.ends_with(".tres"): continue # Screenshots, etc
var _save_path: String = save_game_data_path + filename
var _save_icon: String = filename.replace(".tres", ".png")
var _save_resource: SaveFileDetailsResource = SaveFileDetailsResource.new()
var _loaded_file: FileAccess = FileAccess.open(_save_path, FileAccess.READ)
_save_resource.filename = filename
_save_resource.date_created = Time.get_datetime_string_from_unix_time(FileAccess.get_modified_time(_save_path))
_save_resource.filesize = _loaded_file.get_length()
if FileAccess.file_exists(save_game_data_path + _save_icon):
_save_resource.save_icon = _save_icon
save_files.append(_save_resource)
return save_files
func load_game() -> void:
_load_game_resource(save_file_name % level_scene_name)
func quick_load_game() -> void:
# TODO: Change this to a dynamic quick save file
# This might be left as 01 (01 always the last quicksave)
_load_game_resource(quicksave_file_name % "01")
func quick_save_game() -> void:
# TODO: Change this to a dynamic quick save file
_save_game_as_resource(quicksave_file_name % "01")
func save_game() -> void:
_save_game_as_resource(save_file_name % level_scene_name)
func save_node_data() -> void:
var nodes: Array = get_tree().get_nodes_in_group("save_data_component")
@ -38,17 +78,21 @@ func save_node_data() -> void:
var save_final_resource: Node3DDataResource = save_data_resource.duplicate()
game_data_resource.save_data_nodes.append(save_final_resource)
func save_game() -> void:
func _save_game_as_resource(resource_filename: String) -> void:
if !DirAccess.dir_exists_absolute(save_game_data_path):
DirAccess.make_dir_absolute(save_game_data_path)
var save_game_file_path: String = save_game_data_path + resource_filename
save_node_data()
var result: int = ResourceSaver.save(game_data_resource, save_game_file_path)
if result != OK:
printerr("Failed to save game: ", result)
func load_game() -> void:
func _load_game_resource(resource_filename: String) -> void:
var save_game_file_path: String = save_game_data_path + resource_filename
if !FileAccess.file_exists(save_game_file_path):
printerr("Failed to load save. File does not exist: ", save_game_file_path)
return
@ -62,29 +106,3 @@ func load_game() -> void:
for resource: Resource in game_data_resource.save_data_nodes:
if resource is Node3DDataResource:
(resource as Node3DDataResource)._load_data(root_node)
func list_saves() -> Array[SaveFileDetailsResource]: # TODO: Update hints
var save_files: Array[SaveFileDetailsResource] = []
if !DirAccess.dir_exists_absolute(save_game_data_path):
return save_files
for filename: String in ResourceLoader.list_directory(save_game_data_path):
if !filename.begins_with("save_"): continue
if !filename.ends_with(".tres"): continue # Screenshots, etc
var _save_path: String = save_game_data_path + filename
var _save_icon: String = filename.replace(".tres", ".png")
var _save_resource: SaveFileDetailsResource = SaveFileDetailsResource.new()
var _loaded_file: FileAccess = FileAccess.open(_save_path, FileAccess.READ)
_save_resource.filename = filename
_save_resource.date_created = Time.get_datetime_string_from_unix_time(FileAccess.get_modified_time(_save_path))
_save_resource.filesize = _loaded_file.get_length()
if FileAccess.file_exists(save_game_data_path + _save_icon):
_save_resource.save_icon = _save_icon
save_files.append(_save_resource)
return save_files

+ 4
- 0
save_load/resources/save_file_highlight_panel_theme.tres View File

@ -0,0 +1,4 @@
[gd_resource type="StyleBoxFlat" format=3 uid="uid://bwm315lqbbb87"]
[resource]
bg_color = Color(0.728173, 0.579132, 0.164487, 1)

+ 8
- 0
save_load/resources/save_file_panel_theme.tres View File

@ -0,0 +1,8 @@
[gd_resource type="StyleBoxFlat" format=3 uid="uid://biousyggn7iua"]
[resource]
content_margin_left = 5.0
content_margin_top = 5.0
content_margin_right = 5.0
content_margin_bottom = 5.0
bg_color = Color(0, 0.65098, 0.886275, 0)

+ 63
- 0
save_load/ui/save_file.gd View File

@ -0,0 +1,63 @@
class_name SaveFilePanel
extends Panel
@export var save_panel_highlight: StyleBoxFlat
@export var save_panel_normal: StyleBoxFlat
@export_group("Node Exports")
@export var save_name_label: Label
@export var save_date_label: Label
@export var save_icon: TextureRect
@export var save_button: TextureButton
@export var load_button: TextureButton
@export var delete_button: TextureButton
var save_file_details: SaveFileDetailsResource
func _ready() -> void:
mouse_entered.connect(_on_mouse_entered)
mouse_exited.connect(_on_mouse_exited)
delete_button.pressed.connect(_on_delete_button_pressed)
save_button.pressed.connect(_on_save_button_pressed)
load_button.pressed.connect(_on_load_button_pressed)
func initialize(_resource: SaveFileDetailsResource) -> void:
save_file_details = _resource
set_save_date()
set_save_icon()
set_save_name()
func set_save_date() -> void:
save_date_label.text = save_file_details.date_created
func set_save_icon() -> void:
save_icon.texture = load(save_file_details.save_icon)
func set_save_name() -> void:
# TODO: Remove extension from name
save_name_label.text = save_file_details.filename
func _on_delete_button_pressed() -> void:
SaveGameManager.delete_save_file.emit(save_file_details.filename)
print("DELETING: ", save_file_details.filename)
func _on_load_button_pressed() -> void:
SaveGameManager.load_save_file.emit(save_file_details.filename)
print("LOADING: ", save_file_details.filename)
func _on_save_button_pressed() -> void:
SaveGameManager.create_save_file.emit(save_file_details.filename)
print("SAVING: ", save_file_details.filename)
func _on_mouse_entered() -> void:
set("theme_override_styles/panel", save_panel_highlight)
func _on_mouse_exited() -> void:
set("theme_override_styles/panel", save_panel_normal)

+ 1
- 0
save_load/ui/save_file.gd.uid View File

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

+ 100
- 0
save_load/ui/save_file.tscn View File

@ -0,0 +1,100 @@
[gd_scene load_steps=14 format=3 uid="uid://bb7poutsn4ex2"]
[ext_resource type="Texture2D" uid="uid://dknv7amroftm8" path="res://assets/icon.svg" id="1_714lu"]
[ext_resource type="StyleBox" uid="uid://biousyggn7iua" path="res://save_load/resources/save_file_panel_theme.tres" id="1_cqw77"]
[ext_resource type="Texture2D" uid="uid://cmq51cgasug81" path="res://save_load/assets/folder-open-normal.png" id="1_k6haa"]
[ext_resource type="Script" uid="uid://dcfdyua5gwpw4" path="res://save_load/ui/save_file.gd" id="2_5g2eu"]
[ext_resource type="Texture2D" uid="uid://blyryo60jydgi" path="res://save_load/assets/folder-open-pressed.png" id="2_714lu"]
[ext_resource type="Texture2D" uid="uid://ja8bc1h5x85o" path="res://save_load/assets/save-normal.png" id="2_jgxci"]
[ext_resource type="Texture2D" uid="uid://crqgyft4gfilt" path="res://save_load/assets/save-pressed.png" id="3_cqw77"]
[ext_resource type="StyleBox" uid="uid://bwm315lqbbb87" path="res://save_load/resources/save_file_highlight_panel_theme.tres" id="3_om23c"]
[ext_resource type="Texture2D" uid="uid://by4w5ll3le7g6" path="res://save_load/assets/folder-open-hover.png" id="3_ubfnn"]
[ext_resource type="Texture2D" uid="uid://o3l0j53mgkan" path="res://save_load/assets/save-hover.png" id="4_5g2eu"]
[ext_resource type="Texture2D" uid="uid://dvp5yeoqw36yt" path="res://save_load/assets/trash-normal.png" id="4_c2bnc"]
[ext_resource type="Texture2D" uid="uid://brwa8yljyrlgy" path="res://save_load/assets/trash-pressed.png" id="5_jgxci"]
[ext_resource type="Texture2D" uid="uid://cmrtuy0i5qc01" path="res://save_load/assets/trash-hover.png" id="6_cqw77"]
[node name="SaveFilePanel" type="Panel" node_paths=PackedStringArray("save_name_label", "save_date_label", "save_icon", "save_button", "load_button", "delete_button")]
custom_minimum_size = Vector2(420, 60)
offset_right = 420.0
offset_bottom = 60.0
theme_override_styles/panel = ExtResource("1_cqw77")
script = ExtResource("2_5g2eu")
save_panel_highlight = ExtResource("3_om23c")
save_panel_normal = ExtResource("1_cqw77")
save_name_label = NodePath("HBoxContainer/NameDate/SaveName")
save_date_label = NodePath("HBoxContainer/NameDate/SaveDate")
save_icon = NodePath("HBoxContainer/SaveFileIcon")
save_button = NodePath("HBoxContainer/Actions/SaveButton")
load_button = NodePath("HBoxContainer/Actions/LoadButton")
delete_button = NodePath("HBoxContainer/Actions/DeleteButton")
[node name="HBoxContainer" type="HBoxContainer" parent="."]
custom_minimum_size = Vector2(400, 0)
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -200.0
offset_top = -20.5
offset_right = 200.0
offset_bottom = 20.5
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 0
[node name="SaveFileIcon" type="TextureRect" parent="HBoxContainer"]
layout_mode = 2
texture = ExtResource("1_714lu")
expand_mode = 3
[node name="NameDate" type="VBoxContainer" parent="HBoxContainer"]
layout_mode = 2
size_flags_vertical = 8
[node name="SaveName" type="Label" parent="HBoxContainer/NameDate"]
layout_mode = 2
text = "Save name #1"
[node name="SaveDate" type="Label" parent="HBoxContainer/NameDate"]
layout_mode = 2
theme_override_font_sizes/font_size = 10
text = "2025/03/20 13:43:12"
[node name="Actions" type="HBoxContainer" parent="HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 10
[node name="SaveButton" type="TextureButton" parent="HBoxContainer/Actions"]
clip_contents = true
custom_minimum_size = Vector2(32, 32)
layout_mode = 2
tooltip_text = "Load Save"
texture_normal = ExtResource("2_jgxci")
texture_pressed = ExtResource("3_cqw77")
texture_hover = ExtResource("4_5g2eu")
ignore_texture_size = true
stretch_mode = 5
[node name="LoadButton" type="TextureButton" parent="HBoxContainer/Actions"]
clip_contents = true
custom_minimum_size = Vector2(32, 32)
layout_mode = 2
tooltip_text = "Load Save"
texture_normal = ExtResource("1_k6haa")
texture_pressed = ExtResource("2_714lu")
texture_hover = ExtResource("3_ubfnn")
ignore_texture_size = true
stretch_mode = 5
[node name="DeleteButton" type="TextureButton" parent="HBoxContainer/Actions"]
custom_minimum_size = Vector2(32, 32)
layout_mode = 2
tooltip_text = "Delete Save"
texture_normal = ExtResource("4_c2bnc")
texture_pressed = ExtResource("5_jgxci")
texture_hover = ExtResource("6_cqw77")
ignore_texture_size = true
stretch_mode = 5

+ 29
- 0
save_load/ui/save_files_list.gd View File

@ -0,0 +1,29 @@
extends VBoxContainer
@export var save_file_scene: PackedScene
func _ready() -> void:
SaveGameManager.refresh_saves_list.connect(_on_refresh_saves_list)
refresh_saves_list()
## Clear the SaveFilesList node of all saves and load most recent saves
func refresh_saves_list() -> void:
_clear_save_files_list()
var save_level_data_component: SaveLevelDataComponent = get_tree().get_first_node_in_group("save_level_data_component")
var save_files: Array[SaveFileDetailsResource] = save_level_data_component.list_saves()
for save_resource: SaveFileDetailsResource in save_files:
var _save_file: SaveFilePanel = save_file_scene.instantiate()
_save_file.initialize(save_resource)
add_child(_save_file)
func _clear_save_files_list() -> void:
for _panel: SaveFilePanel in get_children():
_panel.queue_free()
func _on_refresh_saves_list() -> void:
refresh_saves_list()

+ 1
- 0
save_load/ui/save_files_list.gd.uid View File

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

+ 50
- 0
save_load/ui/save_load_ui.tscn View File

@ -0,0 +1,50 @@
[gd_scene load_steps=3 format=3 uid="uid://dauchkhmnyk7n"]
[ext_resource type="Script" uid="uid://cqabj86bq8whn" path="res://save_load/ui/save_files_list.gd" id="1_t4pkj"]
[ext_resource type="PackedScene" uid="uid://bb7poutsn4ex2" path="res://save_load/ui/save_file.tscn" id="1_tqtxm"]
[node name="SaveLoadUI" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 6
size_flags_vertical = 4
[node name="Panel" type="Panel" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="MarginContainer" type="MarginContainer" parent="Panel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 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="Panel/MarginContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="Panel/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 40
text = "Load Save"
horizontal_alignment = 1
[node name="SaveFilesList" type="VBoxContainer" parent="Panel/MarginContainer/VBoxContainer"]
clip_contents = true
layout_mode = 2
size_flags_horizontal = 4
script = ExtResource("1_t4pkj")
save_file_scene = ExtResource("1_tqtxm")

Loading…
Cancel
Save