extends Panel signal file_loaded() const FileCreate = preload("res://menus/file_create.tscn") export var number = 1 var file: Save.SaveFile = null onready var splatter = $DeathSplatter func _ready(): $FileNumber.text = "FILE%d" % number refresh() func select() -> void: if get_parent().kill_mode == false: # if a file exists, load and play it! if file: # set current file and difficulty Save.current_file = file Game.difficulty = file.difficulty # update last-played file for continue button Options.last_file = number Options.save_options() # let file select scene know a file has been loaded emit_signal("file_loaded") # empty file, so go to file creation screen else: # wait for fade Fade.fade_out(0.4) yield(Fade, "fade_finished") # create new file and give it to the file create screen var file_create = FileCreate.instance() file_create.file = Save.SaveFile.new("user://file%d.pr" % number) SceneManager.current_scene = file_create else: #Delete file if file: var dir = Directory.new() dir.remove(file.file_path) splatter.emitting = true Audio.play_sound(Audio.a_die,Audio.ac_die) file = null refresh() func refresh(): # check if the file exists if File.new().file_exists("user://file%d.pr" % number): # load file and fill in information file = Save.load_file("user://file%d.pr" % number) $"%Name".text = file.name $"%ShardCounter".text = "%02d" % file.get_total_shards() $"%KeyCounter".text = "%03d" % file.get_total_keys() $"%DeathCounter".text = "%04d" % file.get_total_deaths() $"%TimeCounter".text = "%02d:%02d" % [file.play_time / 3600.0, fmod(file.play_time / 60.0, 60.0)] $"%Difficulty".text = Game.DIFFICULTY_NAMES[file.difficulty] else: file = null $FileExists.visible = false $FileDoesNotExist.visible = true