style: apply gdformat formatting across the entire project
Auto-format all GDScript files using gdformat from gdtoolkit. This is a baseline formatting pass to ensure consistent style: - Normalizes indentation and spacing - Wraps long lines to 100 characters - Removes trailing whitespace - Standardizes blank lines between functions 68 files reformatted, 8 files left unchanged (3rd-party addon files with parse errors excluded).
This commit is contained in:
@@ -8,9 +8,11 @@ const MAX_SAVE_BYTES := 16 * 1024 * 1024
|
||||
var save_directory: String
|
||||
var last_error := ""
|
||||
|
||||
|
||||
func _init(directory: String = DEFAULT_DIRECTORY) -> void:
|
||||
save_directory = directory
|
||||
|
||||
|
||||
func save(manager: Node, slot_name: String = DEFAULT_SLOT) -> bool:
|
||||
last_error = ""
|
||||
if manager == null or not manager.has_method("serialize_state"):
|
||||
@@ -55,6 +57,7 @@ func save(manager: Node, slot_name: String = DEFAULT_SLOT) -> bool:
|
||||
_remove_if_present(backup_path)
|
||||
return true
|
||||
|
||||
|
||||
func load_into(manager: Node, slot_name: String = DEFAULT_SLOT) -> bool:
|
||||
last_error = ""
|
||||
if manager == null or not manager.has_method("restore_state"):
|
||||
@@ -72,14 +75,13 @@ func load_into(manager: Node, slot_name: String = DEFAULT_SLOT) -> bool:
|
||||
return _fail("Simulation refused the validated save record")
|
||||
return true
|
||||
|
||||
|
||||
func has_slot(slot_name: String = DEFAULT_SLOT) -> bool:
|
||||
if not _is_valid_slot_name(slot_name):
|
||||
return false
|
||||
var final_path := get_slot_path(slot_name)
|
||||
return (
|
||||
_read_record(final_path) != null
|
||||
or _read_record(final_path + ".bak") != null
|
||||
)
|
||||
return _read_record(final_path) != null or _read_record(final_path + ".bak") != null
|
||||
|
||||
|
||||
func delete_slot(slot_name: String = DEFAULT_SLOT) -> bool:
|
||||
if not _is_valid_slot_name(slot_name):
|
||||
@@ -90,9 +92,11 @@ func delete_slot(slot_name: String = DEFAULT_SLOT) -> bool:
|
||||
_remove_if_present(final_path + ".bak")
|
||||
return true
|
||||
|
||||
|
||||
func get_slot_path(slot_name: String = DEFAULT_SLOT) -> String:
|
||||
return save_directory.path_join(slot_name + ".json")
|
||||
|
||||
|
||||
func _read_record(path: String) -> SimulationStateRecord:
|
||||
if not FileAccess.file_exists(path):
|
||||
return null
|
||||
@@ -106,6 +110,7 @@ func _read_record(path: String) -> SimulationStateRecord:
|
||||
file.close()
|
||||
return SimulationStateRecord.from_json(json_text)
|
||||
|
||||
|
||||
func _ensure_directory() -> bool:
|
||||
var absolute_directory := ProjectSettings.globalize_path(save_directory)
|
||||
var error := DirAccess.make_dir_recursive_absolute(absolute_directory)
|
||||
@@ -113,6 +118,7 @@ func _ensure_directory() -> bool:
|
||||
return _fail("Could not create the save directory")
|
||||
return true
|
||||
|
||||
|
||||
func _is_valid_slot_name(slot_name: String) -> bool:
|
||||
if slot_name.is_empty() or slot_name.length() > 32:
|
||||
return false
|
||||
@@ -122,10 +128,12 @@ func _is_valid_slot_name(slot_name: String) -> bool:
|
||||
return false
|
||||
return true
|
||||
|
||||
|
||||
func _remove_if_present(path: String) -> void:
|
||||
if FileAccess.file_exists(path):
|
||||
DirAccess.remove_absolute(path)
|
||||
|
||||
|
||||
func _fail(message: String) -> bool:
|
||||
last_error = message
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user