From 2c343ef770e6576c09910917c7b8b5d88a3b416e Mon Sep 17 00:00:00 2001 From: SuhwanKim Date: Sun, 10 Mar 2024 11:57:38 -0700 Subject: [PATCH] Change character data save method Change character data save function to save into csv files --- Phase2/Godot_Toolset/Main/project.godot | 4 ++++ .../character_creation_wizard.gd | 18 +++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Phase2/Godot_Toolset/Main/project.godot b/Phase2/Godot_Toolset/Main/project.godot index 6f2a138..c52ec4d 100644 --- a/Phase2/Godot_Toolset/Main/project.godot +++ b/Phase2/Godot_Toolset/Main/project.godot @@ -14,6 +14,10 @@ config/name="bcirpg_toolset" run/main_scene="res://screens/wizards/character_creation/character_creation_wizard.tscn" config/icon="res://icon.png" +[autoload] + +SpecialAbility="*res://middleware/specialabliities/SpecialAbility.gd" + [global] filters=false diff --git a/Phase2/Godot_Toolset/Main/screens/wizards/character_creation/character_creation_wizard.gd b/Phase2/Godot_Toolset/Main/screens/wizards/character_creation/character_creation_wizard.gd index c3b233e..46d4ab8 100644 --- a/Phase2/Godot_Toolset/Main/screens/wizards/character_creation/character_creation_wizard.gd +++ b/Phase2/Godot_Toolset/Main/screens/wizards/character_creation/character_creation_wizard.gd @@ -100,26 +100,26 @@ func _ready(): pass # Replace with function body. -var file_path = "user://data.xml" # Use 'user://' to save in the user data directory +var file_path = "user://characterData.csv" # Use 'user://' to save in the user data directory -func save_data_to_xml(data: Array, header: Array, path: String) -> void: +func save_data_to_csv(data: Array, header: Array, path: String) -> void: var file = File.new() - if file.open("user://data.xml", File.WRITE) == OK: - var xml = "\n" + if file.open(file_path, File.WRITE) == OK: + var csv = "" var index = 0 for line_edit in data: var line_edit_text = line_edit.text - xml += header[index] + ": " + line_edit_text + "\n" + csv += header[index] + ": " + line_edit_text + "\n" index += 1 - xml += "" + - file.store_line(xml) + file.store_line(csv) file.close() - print("Data saved to XML file: ", path) + print("Data saved to csv file: ", path) else: print("Error opening file for writing: ", path) #save_user_data() @@ -162,7 +162,7 @@ func create_header() -> Array: return headerData func _on_Button_pressed(): - save_data_to_xml(create_array_to_save(), create_header(), file_path) + save_data_to_csv(create_array_to_save(), create_header(), file_path) func _on_Button_tree_entered():