diff --git a/Phase2/Godot_GameCode/_MVP_Game_Demo/Luke/bcirpg_game_mvp_2024_0204A/Screens/Character_Add.gd b/Phase2/Godot_GameCode/_MVP_Game_Demo/Luke/bcirpg_game_mvp_2024_0204A/Screens/Character_Add.gd index da95615..6802acf 100644 --- a/Phase2/Godot_GameCode/_MVP_Game_Demo/Luke/bcirpg_game_mvp_2024_0204A/Screens/Character_Add.gd +++ b/Phase2/Godot_GameCode/_MVP_Game_Demo/Luke/bcirpg_game_mvp_2024_0204A/Screens/Character_Add.gd @@ -38,6 +38,7 @@ func _prep_PlayerCharacter_Template(): pSingleton.strength = Strength.text pSingleton.intellect = Intellect.text pSingleton.willpower = Willpower.text + pSingleton.weapon = Weapon.text pSingleton.charm = Charm.text pSingleton.armor = Armor.text pSingleton.quote = Quote.text @@ -74,8 +75,7 @@ func _on_But_SaveChar_pressed(): var input_data = [ ["Name", "Profession", "Strength", "Intellect", "Willpower", "Charm", "Weapon", "Armor", "Quote"], - [pSingleton.name, pSingleton.profession, pSingleton.strength, pSingleton.intellect, - pSingleton.willpower, pSingleton.charm, pSingleton.weapon, pSingleton.armor, pSingleton.quote], + [pSingleton.name, pSingleton.profession, pSingleton.strength, pSingleton.intellect, pSingleton.willpower, pSingleton.charm, pSingleton.weapon, pSingleton.armor, pSingleton.quote], ] save_data_to_csv(input_data, file_path) diff --git a/Phase2/Godot_GameCode/_MVP_Game_Demo/Luke/bcirpg_game_mvp_2024_0204A/Screens/Character_Load.gd b/Phase2/Godot_GameCode/_MVP_Game_Demo/Luke/bcirpg_game_mvp_2024_0204A/Screens/Character_Load.gd index ad6681d..47c5a24 100644 --- a/Phase2/Godot_GameCode/_MVP_Game_Demo/Luke/bcirpg_game_mvp_2024_0204A/Screens/Character_Load.gd +++ b/Phase2/Godot_GameCode/_MVP_Game_Demo/Luke/bcirpg_game_mvp_2024_0204A/Screens/Character_Load.gd @@ -4,6 +4,7 @@ extends Control onready var settings = get_node("/root/GlobalSaveInstance").settingsInstance +onready var pSingleton = get_node("/root/PlayerCharacter").pc func _ready() -> void: theme=load(settings.themeFile) @@ -14,11 +15,63 @@ func _on_But_loadCharacter_pressed() -> void: $LoadCharacter_FileDialog.popup() +func _prep_PlayerCharacter_Template(loadedCSVData): + + print(loadedCSVData) + + pSingleton.name = loadedCSVData[0] + pSingleton.profession = loadedCSVData[1] + pSingleton.strength = loadedCSVData[2] + pSingleton.intellect = loadedCSVData[3] + pSingleton.willpower = loadedCSVData[4] + pSingleton.charm = loadedCSVData[5] + pSingleton.armor = loadedCSVData[6] + pSingleton.quote = loadedCSVData[7] + + print("P Singleton") + print(pSingleton) + + +func load_csv_data(path): + var file = File.new() + var error = file.open(path, File.READ) # Open the file for reading + + if error != OK: + print("Error opening CSV file:", error) + return + + var data = [] + while !file.eof_reached(): + var line = file.get_csv_line() + data.append(line) + + file.close() + return data + + #DKM TEMP: we need to load the character item, not display to field func _on_LoadCharacter_FileDialog_file_selected(path: String) -> void: print(path) var charFile = File.new() charFile.open(path, 1) var pc = get_node("/root/PlayerCharacter") - pc.playerCharacterSingleton.pcText = charFile.get_as_text() - $TextEdit.text = pc.playerCharacterSingleton.pcText + + var csv_data = load_csv_data(path) + print(csv_data) + _prep_PlayerCharacter_Template(csv_data[1]) + + + +# pc.playerCharacterSingleton.pcText = charFile.get_as_text() +# $TextEdit.text = pc.playerCharacterSingleton.pcText + + + + +#func _ready(): +# # Replace "your_file.csv" with the actual path to your CSV file +# var csv_data = load_csv_data("res://your_file.csv") +# # Process the loaded data (data is a 2D array) +# # You can access data like this: +# # for row in csv_data: +# # print(row[0]) # Access first element in each row diff --git a/Phase2/Godot_GameCode/_MVP_Game_Demo/Luke/bcirpg_game_mvp_2024_0204A/Screens/Character_Load.tscn b/Phase2/Godot_GameCode/_MVP_Game_Demo/Luke/bcirpg_game_mvp_2024_0204A/Screens/Character_Load.tscn index 5550459..da9738a 100644 --- a/Phase2/Godot_GameCode/_MVP_Game_Demo/Luke/bcirpg_game_mvp_2024_0204A/Screens/Character_Load.tscn +++ b/Phase2/Godot_GameCode/_MVP_Game_Demo/Luke/bcirpg_game_mvp_2024_0204A/Screens/Character_Load.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=2] -[ext_resource path="res://userInterface/Title.tscn" type="PackedScene" id=1] -[ext_resource path="res://userInterface/But_ChangeScene.tscn" type="PackedScene" id=2] +[ext_resource path="res://UserInterface/Title.tscn" type="PackedScene" id=1] +[ext_resource path="res://UserInterface/But_ChangeScene.tscn" type="PackedScene" id=2] [ext_resource path="res://Screens/Character_Load.gd" type="Script" id=3] [node name="Control" type="Control"]