make debug save only exist in debug and not count for continue button
This commit is contained in:
parent
bfbc0dfd2b
commit
74fd1ec4f2
2 changed files with 10 additions and 6 deletions
|
@ -79,8 +79,11 @@ class SaveFile:
|
||||||
var play_time: float = 0.0
|
var play_time: float = 0.0
|
||||||
# dictionary of levels' save data
|
# dictionary of levels' save data
|
||||||
var levels: Dictionary
|
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
|
file_path = path
|
||||||
# initialize level save data dictionary
|
# initialize level save data dictionary
|
||||||
levels = {}
|
levels = {}
|
||||||
|
@ -89,6 +92,8 @@ class SaveFile:
|
||||||
|
|
||||||
# return total number of shards
|
# return total number of shards
|
||||||
func get_total_shards() -> int:
|
func get_total_shards() -> int:
|
||||||
|
if debug:
|
||||||
|
return 999
|
||||||
var total = 0
|
var total = 0
|
||||||
for level in levels.values():
|
for level in levels.values():
|
||||||
total += level.shards_collected.count(true)
|
total += level.shards_collected.count(true)
|
||||||
|
@ -143,16 +148,16 @@ class SaveFile:
|
||||||
level.save_to_file(file)
|
level.save_to_file(file)
|
||||||
file.save(file_path)
|
file.save(file_path)
|
||||||
|
|
||||||
|
|
||||||
## currently used save file
|
## currently used save file
|
||||||
var current_file: SaveFile = null
|
var current_file: SaveFile = null
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
# TODO: make load last played file
|
|
||||||
current_file = load_file("user://file%d.pr" % Options.last_file)
|
current_file = load_file("user://file%d.pr" % Options.last_file)
|
||||||
if current_file:
|
if current_file:
|
||||||
Game.difficulty = current_file.difficulty
|
Game.difficulty = current_file.difficulty
|
||||||
else:
|
elif OS.is_debug_build():
|
||||||
current_file = SaveFile.new("user://testing.pr")
|
current_file = SaveFile.new("user://debug_save.pr", true)
|
||||||
|
|
||||||
## shortcut for loading a save file from specific path
|
## shortcut for loading a save file from specific path
|
||||||
func load_file(path: String) -> SaveFile:
|
func load_file(path: String) -> SaveFile:
|
||||||
|
|
|
@ -6,8 +6,7 @@ func _ready():
|
||||||
Fade.fade_in(Options.transition_speed_secs)
|
Fade.fade_in(Options.transition_speed_secs)
|
||||||
#Grey out continue if no save files
|
#Grey out continue if no save files
|
||||||
yield(get_tree(),"idle_frame")
|
yield(get_tree(),"idle_frame")
|
||||||
print(Save.current_file)
|
if Save.current_file and not Save.current_file.debug:
|
||||||
if Save.current_file:
|
|
||||||
$Panel/Continue.grab_focus()
|
$Panel/Continue.grab_focus()
|
||||||
else:
|
else:
|
||||||
$Panel/Body/GreyedContinue.visible = true
|
$Panel/Body/GreyedContinue.visible = true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue