Worked with doug to figure out how to use Mode 2 of the File Dialog Class

This commit is contained in:
PersonGuyGit 2022-10-16 12:52:23 -06:00
parent b8742dc922
commit 47a0a46b5b
2 changed files with 14 additions and 27 deletions

View File

@ -9,7 +9,6 @@ var rows
onready var settings = get_node("/root/GlobalSaveInstance").settingsInstance onready var settings = get_node("/root/GlobalSaveInstance").settingsInstance
onready var SaveButton = get_node("HBoxContainer/VBoxContainer/SaveButton") onready var SaveButton = get_node("HBoxContainer/VBoxContainer/SaveButton")
onready var nameVar = get_node("HBoxContainer/VBoxContainer/LabelName/LineEditName") onready var nameVar = get_node("HBoxContainer/VBoxContainer/LabelName/LineEditName")
onready var profVar = get_node("HBoxContainer/VBoxContainer/LabelProfession/LineEditProf") onready var profVar = get_node("HBoxContainer/VBoxContainer/LabelProfession/LineEditProf")
onready var strengthVar = get_node("HBoxContainer/VBoxContainer/LabelStrength/LineEditStrength") onready var strengthVar = get_node("HBoxContainer/VBoxContainer/LabelStrength/LineEditStrength")
@ -20,38 +19,29 @@ onready var weaponVar = get_node("HBoxContainer/VBoxContainer2/LabelWeapon/LineE
onready var armorVar = get_node("HBoxContainer/VBoxContainer2/LabelArmor/LineEditArmor") onready var armorVar = get_node("HBoxContainer/VBoxContainer2/LabelArmor/LineEditArmor")
onready var quoteVar = get_node("HBoxContainer/VBoxContainer2/LabelQuote/LineEditQuote") onready var quoteVar = get_node("HBoxContainer/VBoxContainer2/LabelQuote/LineEditQuote")
func writeToCSV(nameV, profV, strengthV, intelV, willpowerV, charmV, weaponV, armorV, quoteV):
var f = File.new()
f.open("res://_userFiles/CharacterOutput.csv", File.WRITE)
var ArrayStrings = [PoolStringArray()]
f.store_csv_line(["Name", nameV])
f.store_csv_line(["Profession", profV])
f.store_csv_line(["Strength", strengthV])
f.store_csv_line(["Intellegence", intelV])
f.store_csv_line(["Willpower", willpowerV])
f.store_csv_line(["Charm", charmV])
f.store_csv_line(["Weapon", weaponV])
f.store_csv_line(["Armor", armorV])
f.store_csv_line(["Quote", quoteV])
f.close()
func _process(delta): func _process(delta):
if SaveButton.pressed == true: if SaveButton.pressed == true:
$Title/FileDialog.popup() $Title/FileDialog.popup()
writeToCSV(nameVar.get_text(), profVar.get_text(),
strengthVar.get_text(), intelVar.get_text(), willpowerVar.get_text(),
charmVar.get_text(), weaponVar.get_text(), armorVar.get_text(), quoteVar.get_text())
func _ready() -> void: func _ready() -> void:
theme=load(settings.themeFile) theme=load(settings.themeFile)
#DKM TEMP: just text for now from text edit #DKM TEMP: just text for now from text edit
func _on_FileDialog_file_selected(path: String) -> void: func _on_FileDialog_file_selected(path: String) -> void:
var pc = get_node("/root/PlayerCharacter") var pc = get_node("/root/PlayerCharacter")
var newCharFile = File.new() var newCharFile = File.new()
newCharFile.open(path, 2) newCharFile.open(path, 2)
newCharFile.store_string($TextEdit.text) var f = File.new()
pc.playerCharacterSingleton.pcText = $TextEdit.text
f.store_csv_line(["Name", nameVar.get_text()])
f.store_csv_line(["Profession", profVar.get_text()])
f.store_csv_line(["Strength", strengthVar.get_text()])
f.store_csv_line(["Intellegence", intelVar.get_text()])
f.store_csv_line(["Willpower", willpowerVar.get_text()])
f.store_csv_line(["Charm", charmVar.get_text()])
f.store_csv_line(["Weapon", weaponVar.get_text()])
f.store_csv_line(["Armor", armorVar.get_text()])
f.store_csv_line(["Quote", quoteVar.get_text()])
f.close()

View File

@ -12,9 +12,6 @@ anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
theme = ExtResource( 6 ) theme = ExtResource( 6 )
script = ExtResource( 2 ) script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Background" type="Panel" parent="."] [node name="Background" type="Panel" parent="."]
anchor_right = 1.0 anchor_right = 1.0