make debug save only exist in debug and not count for continue button

This commit is contained in:
Haze Weathers 2024-02-27 19:39:49 -05:00
parent bfbc0dfd2b
commit 74fd1ec4f2
2 changed files with 10 additions and 6 deletions

View file

@ -79,8 +79,11 @@ class SaveFile:
var play_time: float = 0.0
# dictionary of levels' save data
var levels: Dictionary
# whether is debug save
var debug: bool = false
func _init(path: String) -> void:
func _init(path: String, debug_save: bool = false) -> void:
debug = debug_save
file_path = path
# initialize level save data dictionary
levels = {}
@ -89,6 +92,8 @@ class SaveFile:
# return total number of shards
func get_total_shards() -> int:
if debug:
return 999
var total = 0
for level in levels.values():
total += level.shards_collected.count(true)
@ -143,16 +148,16 @@ class SaveFile:
level.save_to_file(file)
file.save(file_path)
## currently used save file
var current_file: SaveFile = null
func _ready() -> void:
# TODO: make load last played file
current_file = load_file("user://file%d.pr" % Options.last_file)
if current_file:
Game.difficulty = current_file.difficulty
else:
current_file = SaveFile.new("user://testing.pr")
elif OS.is_debug_build():
current_file = SaveFile.new("user://debug_save.pr", true)
## shortcut for loading a save file from specific path
func load_file(path: String) -> SaveFile: