mirror of
https://github.com/RPG-Research/bcirpg.git
synced 2024-04-16 14:23:01 +00:00
Created a way for the player data from AddCharacter.gd to be stored in the PlayerCharacterTemplate object and the Player Character Singleton.
This commit is contained in:
parent
de608e7c33
commit
30ef1cac67
@ -9,3 +9,6 @@
|
||||
4: Then save the singleton data to a CSV
|
||||
|
||||
5: Figure out the issues with CSV like doug mentioned.
|
||||
|
||||
|
||||
Completed: 3
|
||||
|
@ -7,23 +7,54 @@ extends Control
|
||||
onready var settings = get_node("/root/GlobalSaveInstance").settingsInstance
|
||||
onready var pSingleton = get_node("/root/PlayerCharacter").pc
|
||||
|
||||
onready var Name = get_node("Title/VBoxContainer/LabelName/LE_Name")
|
||||
|
||||
onready var Profession = get_node("Title/VBoxContainer/LabelProfession/LE_Pro")
|
||||
|
||||
onready var Strength = get_node("Title/VBoxContainer/LabelStrength/LE_Str")
|
||||
|
||||
onready var Intellect = get_node("Title/VBoxContainer/LabelIntellect/LE_Intl")
|
||||
|
||||
onready var Willpower = get_node("Title/VBoxContainer/LabelWillpower/LE_Will")
|
||||
|
||||
onready var Charm = get_node("Title/VBoxContainer/LabelCharm/LE_Charm")
|
||||
|
||||
onready var Weapon = get_node("Title/VBoxContainer/LabelWeapon/LE_Weapon")
|
||||
|
||||
onready var Armor = get_node("Title/VBoxContainer/LabelArmor/LE_Armor")
|
||||
|
||||
onready var Quote = get_node("Title/VBoxContainer/LabelQuote/LE_Quote")
|
||||
|
||||
func _ready() -> void:
|
||||
theme=load(settings.themeFile)
|
||||
$Title/But_SaveChar.grab_focus()
|
||||
|
||||
func _prep_PlayerCharacter_Template():
|
||||
# This function prepares the data for the player character in two ways.
|
||||
# Way 1: By loading all of this data into the singleton for easy reads during gameplay
|
||||
# Way 2: To prepare the data to be pulled from the singleton, when writing a file.
|
||||
pSingleton.name = Name.text
|
||||
pSingleton.profession = Profession.text
|
||||
pSingleton.strength = Strength.text
|
||||
pSingleton.intellect = Intellect.text
|
||||
pSingleton.willpower = Willpower.text
|
||||
pSingleton.charm = Charm.text
|
||||
pSingleton.armor = Armor.text
|
||||
pSingleton.quote = Quote.text
|
||||
|
||||
func _on_But_SaveChar_pressed() -> void:
|
||||
_prep_PlayerCharacter_Template()
|
||||
$Title/FileDialog.popup()
|
||||
|
||||
#DKM TEMP: this code was inherited and it needs pretty substantial
|
||||
# overhaul for use in the module, depending on toolset use.
|
||||
# For now all the labels are individual lineEdits we need to grab.
|
||||
func _on_FileDialog_file_selected(path: String) -> void:
|
||||
# This function runs when you hit the button to save your file, after you selected the name and location
|
||||
# TODO: Create the CSV File, Populate the CSV File, workout where it saves to.
|
||||
|
||||
var pc = get_node("/root/PlayerCharacter")
|
||||
var newCharFile = File.new()
|
||||
newCharFile.open(path, 2)
|
||||
|
||||
#DKM TEMP: getting something to work with as text
|
||||
var newCharStr = $Title/VBoxContainer/LabelName/LE_Name.text
|
||||
newCharFile.store_string(newCharStr)
|
||||
pSingleton.pcText = "Name: " + newCharStr
|
||||
print("PC text: " + pSingleton.pcText )
|
||||
|
||||
|
@ -88,7 +88,7 @@ margin_bottom = 66.0
|
||||
text = "PROFESSION
|
||||
"
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="Title/VBoxContainer/LabelProfession"]
|
||||
[node name="LE_Pro" type="LineEdit" parent="Title/VBoxContainer/LabelProfession"]
|
||||
margin_top = 15.0
|
||||
margin_right = 58.0
|
||||
margin_bottom = 24.0
|
||||
@ -100,10 +100,10 @@ margin_bottom = 101.0
|
||||
text = "STRENGTH
|
||||
"
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="Title/VBoxContainer/LabelStrength"]
|
||||
[node name="LE_Str" type="LineEdit" parent="Title/VBoxContainer/LabelStrength"]
|
||||
margin_top = 15.0
|
||||
margin_right = 58.0
|
||||
margin_bottom = 24.0
|
||||
margin_bottom = 39.0
|
||||
|
||||
[node name="LabelIntellect" type="Label" parent="Title/VBoxContainer"]
|
||||
margin_top = 105.0
|
||||
@ -112,7 +112,7 @@ margin_bottom = 136.0
|
||||
text = "INTELLECT
|
||||
"
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="Title/VBoxContainer/LabelIntellect"]
|
||||
[node name="LE_Intl" type="LineEdit" parent="Title/VBoxContainer/LabelIntellect"]
|
||||
margin_top = 15.0
|
||||
margin_right = 58.0
|
||||
margin_bottom = 24.0
|
||||
@ -124,7 +124,7 @@ margin_bottom = 171.0
|
||||
text = "WILLPOWER
|
||||
"
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="Title/VBoxContainer/LabelWillpower"]
|
||||
[node name="LE_Will" type="LineEdit" parent="Title/VBoxContainer/LabelWillpower"]
|
||||
margin_top = 15.0
|
||||
margin_right = 58.0
|
||||
margin_bottom = 24.0
|
||||
@ -135,7 +135,7 @@ margin_right = 81.0
|
||||
margin_bottom = 189.0
|
||||
text = "CHARM"
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="Title/VBoxContainer/LabelCharm"]
|
||||
[node name="LE_Charm" type="LineEdit" parent="Title/VBoxContainer/LabelCharm"]
|
||||
margin_top = 15.0
|
||||
margin_right = 58.0
|
||||
margin_bottom = 24.0
|
||||
@ -147,7 +147,7 @@ margin_bottom = 224.0
|
||||
text = "WEAPON
|
||||
"
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="Title/VBoxContainer/LabelWeapon"]
|
||||
[node name="LE_Weapon" type="LineEdit" parent="Title/VBoxContainer/LabelWeapon"]
|
||||
margin_top = 15.0
|
||||
margin_right = 58.0
|
||||
margin_bottom = 24.0
|
||||
@ -158,7 +158,7 @@ margin_right = 81.0
|
||||
margin_bottom = 242.0
|
||||
text = "ARMOR"
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="Title/VBoxContainer/LabelArmor"]
|
||||
[node name="LE_Armor" type="LineEdit" parent="Title/VBoxContainer/LabelArmor"]
|
||||
margin_top = 15.0
|
||||
margin_right = 58.0
|
||||
margin_bottom = 24.0
|
||||
@ -169,7 +169,7 @@ margin_right = 81.0
|
||||
margin_bottom = 260.0
|
||||
text = "QUOTE"
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="Title/VBoxContainer/LabelQuote"]
|
||||
[node name="LE_Quote" type="LineEdit" parent="Title/VBoxContainer/LabelQuote"]
|
||||
margin_top = 15.0
|
||||
margin_right = 58.0
|
||||
margin_bottom = 24.0
|
||||
|
@ -1,6 +1,8 @@
|
||||
#PLAYER CHARACTER:
|
||||
# Unique handler script for root PC singleton. May be adapted for
|
||||
# player loading and saving functionality
|
||||
# player loading and saving functionality.
|
||||
|
||||
# Values are pulled from PlayerCharacterTemplate.gd
|
||||
|
||||
extends Node
|
||||
|
||||
|
@ -6,3 +6,21 @@ extends Resource
|
||||
class_name playerCharacterTemplate
|
||||
|
||||
var pcText = ""
|
||||
|
||||
var name = ""
|
||||
|
||||
var profession = ""
|
||||
|
||||
var strength = ""
|
||||
|
||||
var intellect = ""
|
||||
|
||||
var willpower = ""
|
||||
|
||||
var charm = ""
|
||||
|
||||
var weapon = ""
|
||||
|
||||
var armor = ""
|
||||
|
||||
var quote = ""
|
||||
|
Loading…
Reference in New Issue
Block a user