Import Player and Settings Updates

Additional updates as follows: mods to dark and light themes for text edits, modification to import for CSV parsing and saving to the player singleton text file, adds an alert popup for import in cases where no character has been loaded (won't allow start game), replaces the select character within game to use this import character option, also adds testing files directory overall to Github
This commit is contained in:
MacDugRPG 2022-08-29 18:00:57 -04:00
parent baa4ee34d4
commit 935da98638
11 changed files with 176 additions and 76 deletions

View File

@ -0,0 +1,23 @@
[player_preferences]
player_name="Tester the Bold!"
risk_threshold=2.0
[visual_controls]
font_size=3.0
brightness=5.0
[general_settings]
volume=0.0
closed_captions=false
dev_console=true
[virtual_keyboard]
keyboard_layout=2
[theme]
theme_selection=0

View File

@ -0,0 +1,3 @@
Files for testing only. On deployment, these should be put at the appropriate user:// location for your operating system. For windows this is:
C:\Users\{username}\AppData\Roaming\Godot\app_userdata\BCIRPGR_mergedDemo

View File

@ -0,0 +1,9 @@
Name,Thickly Goes
Profession,Brawler
Strength,Excessive
Intellect,Diminished
Willpower,Variable
Charm,Lacking
Weapon,Meaty Fists
Armor,Leather Jacket and Chaps
A Quote,You talkin to me?!
1 Name Thickly Goes
2 Profession Brawler
3 Strength Excessive
4 Intellect Diminished
5 Willpower Variable
6 Charm Lacking
7 Weapon Meaty Fists
8 Armor Leather Jacket and Chaps
9 A Quote You talkin to me?!

View File

@ -92,9 +92,9 @@ TextEdit/colors/completion_scroll_color = Color( 1, 1, 1, 1 )
TextEdit/colors/completion_selected_color = Color( 0.26, 0.26, 0.27, 1 ) TextEdit/colors/completion_selected_color = Color( 0.26, 0.26, 0.27, 1 )
TextEdit/colors/current_line_color = Color( 0.25, 0.25, 0.26, 0.8 ) TextEdit/colors/current_line_color = Color( 0.25, 0.25, 0.26, 0.8 )
TextEdit/colors/executing_line_color = Color( 0.2, 0.8, 0.2, 0.4 ) TextEdit/colors/executing_line_color = Color( 0.2, 0.8, 0.2, 0.4 )
TextEdit/colors/font_color = Color( 0.00392157, 0.00392157, 0.00392157, 1 ) TextEdit/colors/font_color = Color( 1, 1, 1, 1 )
TextEdit/colors/font_color_readonly = Color( 0.933333, 0.933333, 0.933333, 0.501961 ) TextEdit/colors/font_color_readonly = Color( 0.933333, 0.933333, 0.933333, 0.501961 )
TextEdit/colors/font_color_selected = Color( 0, 0, 0, 1 ) TextEdit/colors/font_color_selected = Color( 1, 1, 1, 1 )
TextEdit/colors/function_color = Color( 0.4, 0.64, 0.81, 1 ) TextEdit/colors/function_color = Color( 0.4, 0.64, 0.81, 1 )
TextEdit/colors/line_number_color = Color( 0.67, 0.67, 0.67, 0.4 ) TextEdit/colors/line_number_color = Color( 0.67, 0.67, 0.67, 0.4 )
TextEdit/colors/mark_color = Color( 1, 0.4, 0.4, 0.4 ) TextEdit/colors/mark_color = Color( 1, 0.4, 0.4, 0.4 )
@ -113,8 +113,8 @@ TextEdit/icons/fold = null
TextEdit/icons/folded = null TextEdit/icons/folded = null
TextEdit/icons/space = null TextEdit/icons/space = null
TextEdit/icons/tab = null TextEdit/icons/tab = null
TextEdit/styles/completion = null TextEdit/styles/completion = ExtResource( 1 )
TextEdit/styles/focus = null TextEdit/styles/focus = ExtResource( 1 )
TextEdit/styles/normal = ExtResource( 1 ) TextEdit/styles/normal = ExtResource( 1 )
TextEdit/styles/read_only = ExtResource( 1 ) TextEdit/styles/read_only = ExtResource( 1 )
VBoxContainer/constants/separation = 4 VBoxContainer/constants/separation = 4

View File

@ -18,7 +18,7 @@ onready var locale_manager = $LocaleManager
onready var option_one = $Background/MarginContainer/Rows/InputArea/VBoxContainer/option1 onready var option_one = $Background/MarginContainer/Rows/InputArea/VBoxContainer/option1
onready var option_two= $Background/MarginContainer/Rows/InputArea/VBoxContainer/option2 onready var option_two= $Background/MarginContainer/Rows/InputArea/VBoxContainer/option2
onready var option_three = $Background/MarginContainer/Rows/InputArea/VBoxContainer/option3 onready var option_three = $Background/MarginContainer/Rows/InputArea/VBoxContainer/option3
onready var pc = get_node("/root/PlayerCharacter") onready var pSingleton = get_node("/root/PlayerCharacter")
onready var charSheet = $Con_charSheet/MarginContainer/VBoxContainer/CharacterSheet onready var charSheet = $Con_charSheet/MarginContainer/VBoxContainer/CharacterSheet
@ -35,7 +35,7 @@ func _ready() -> void:
option_three.show() option_three.show()
#Load character sheet: #Load character sheet:
charSheet.text = pc.playerCharacterSingleton.pcText charSheet.text = pSingleton.pc.pcText
var opening_text = "The game has begun! You can select from the available options below. " var opening_text = "The game has begun! You can select from the available options below. "
#create_response("The game has begun! You can select from the available options below.") #create_response("The game has begun! You can select from the available options below.")

View File

@ -4,8 +4,8 @@
extends Node extends Node
var playerCharacterSingleton var pc
func _ready() -> void: func _ready() -> void:
playerCharacterSingleton = playerCharacterTemplate.new() pc = playerCharacterTemplate.new()

View File

@ -4,6 +4,7 @@
extends Control extends Control
onready var settings = get_node("/root/GlobalSaveInstance").settingsInstance onready var settings = get_node("/root/GlobalSaveInstance").settingsInstance
onready var pSingleton = get_node("/root/PlayerCharacter").pc
var charFilePath var charFilePath
var a var a
@ -13,30 +14,35 @@ func _ready() -> void:
theme=load(settings.themeFile) theme=load(settings.themeFile)
func _on_Button_pressed(): func _on_Button_pressed():
$VBoxContainer2/VBoxContainer/FileDialog.popup() $FileDialog.popup()
#this is going to take information from the file the player chose and put the individul parts into textboxes so it can be edited and then saved #this is going to take information from the file the player chose and put the individul parts into textboxes so it can be edited and then saved
func _on_FileDialog_file_selected(path): func _on_FileDialog_file_selected(path):
var file = File.new() var file = File.new()
#read the text in the file, save it in the variable a #read the text in the file, save it in the variable a
file.open(path, File.READ) file.open(path, File.READ)
# a = int(file.get_line())
a = file.get_as_text()
#split by the spaces so the individual pieces can be separated into textboxes #split by the spaces so the individual pieces can be separated into textboxes
var b = a.split(";") while file.eof_reached() == false:
# for i in b.size(): var csvStrArray = file.get_csv_line()
var i = 0 var i = 0
while i < b.size(): var isLabel = true
var c = b[i] while i < csvStrArray.size():
var d = c.split(":") var csvStr = csvStrArray[i]
#make a new textbox for each piece of information if(isLabel):
var textLine = Label.new() #make a new textbox for each piece of information
$VBoxContainer2/VBoxContainer.add_child(textLine) var textLine = Label.new()
var lineLabel = d[0] $ScrollContainer/VBoxContainer.add_child(textLine)
textLine.text = lineLabel textLine.text = csvStr.to_upper()
var textBox = LineEdit.new() isLabel = false
$VBoxContainer2/VBoxContainer.add_child(textBox) #DKM TEMP: save this unformatted to the singleton text string
if(d.size() > 1): pSingleton.pcText += csvStr.to_upper() + ": "
textBox.text = d[1] else:
i += 1 isLabel = true
var textBox = LineEdit.new()
$ScrollContainer/VBoxContainer.add_child(textBox)
textBox.text = csvStr
#DKM TEMP: save this unformatted to the singleton text string
pSingleton.pcText += csvStr + "\n"
i += 1
file.close() file.close()

View File

@ -1,8 +1,9 @@
[gd_scene load_steps=4 format=2] [gd_scene load_steps=5 format=2]
[ext_resource path="res://UserInterface/Title.tscn" type="PackedScene" id=1] [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/But_ChangeScene.tscn" type="PackedScene" id=2]
[ext_resource path="res://screens/ImportCharacter.gd" type="Script" id=3] [ext_resource path="res://screens/ImportCharacter.gd" type="Script" id=3]
[ext_resource path="res://userInterface/But_PlayButton.gd" type="Script" id=4]
[node name="Control" type="Control"] [node name="Control" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
@ -12,6 +13,15 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="PopupDialog" type="PopupDialog" parent="."]
anchor_top = 0.5
anchor_bottom = 0.5
[node name="WarnText" type="Label" parent="PopupDialog"]
margin_right = 40.0
margin_bottom = 14.0
text = "Example"
[node name="Background" type="Panel" parent="."] [node name="Background" type="Panel" parent="."]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
@ -19,6 +29,20 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="FileDialog" type="FileDialog" parent="."]
margin_left = 113.0
margin_top = 24.0
margin_right = 886.0
margin_bottom = 480.0
window_title = "Open a File"
mode = 0
access = 1
current_dir = "user://characterFiles"
current_path = "user://characterFiles/"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Title" parent="." instance=ExtResource( 1 )] [node name="Title" parent="." instance=ExtResource( 1 )]
margin_left = -164.0 margin_left = -164.0
margin_top = 0.0 margin_top = 0.0
@ -26,70 +50,77 @@ margin_right = 164.0
margin_bottom = 14.0 margin_bottom = 14.0
text = "Import Character" text = "Import Character"
[node name="But_ChangeScene" parent="." instance=ExtResource( 2 )] [node name="But_Play" parent="." instance=ExtResource( 2 )]
margin_right = 92.0 margin_left = 1.0
margin_bottom = 37.0 margin_top = 34.0
margin_right = 152.0
margin_bottom = 71.0
text = "Start Game"
script = ExtResource( 4 )
next_scene_path = "res://gamePlay/Game.tscn"
[node name="But_Cancel" parent="." instance=ExtResource( 2 )]
margin_left = 1.0
margin_top = 78.0
margin_right = 152.0
margin_bottom = 115.0
text = "Back" text = "Back"
next_scene_path = "res://Screens/MenuScreen.tscn" next_scene_path = "res://Screens/MenuScreen.tscn"
[node name="VBoxContainer2" type="VBoxContainer" parent="."] [node name="VBoxContainer2" type="VBoxContainer" parent="."]
anchor_left = 0.5 anchor_left = 0.0634766
anchor_top = 0.5 anchor_top = 0.0583333
anchor_right = 0.5 anchor_right = 0.103516
anchor_bottom = 0.5 anchor_bottom = 0.0583333
margin_left = -164.0 margin_left = 107.0
margin_top = -167.0 margin_right = 435.0
margin_right = 164.0
margin_bottom = 167.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer2"]
margin_right = 328.0
margin_bottom = 44.0 margin_bottom = 44.0
alignment = 1
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": true
} }
[node name="But_OpenFile" type="Button" parent="VBoxContainer2/VBoxContainer"] [node name="But_OpenFile" type="Button" parent="VBoxContainer2"]
margin_right = 328.0 margin_right = 369.0
margin_bottom = 20.0 margin_bottom = 20.0
text = "Open Character File" text = "Open Character File"
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="FileDialog" type="FileDialog" parent="VBoxContainer2/VBoxContainer"] [node name="Save_Button" type="Button" parent="VBoxContainer2"]
margin_top = 24.0 margin_top = 24.0
margin_right = 800.0 margin_right = 369.0
margin_bottom = 374.0 margin_bottom = 44.0
window_title = "Open a File" text = "Save"
mode = 0
access = 1 [node name="ScrollContainer" type="ScrollContainer" parent="."]
current_dir = "user://characterFiles" anchor_left = 0.5
current_path = "user://characterFiles/" anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -336.0
margin_top = -173.0
margin_right = 432.0
margin_bottom = 286.0
follow_focus = true
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="NameLabel" type="Label" parent="VBoxContainer2/VBoxContainer"] [node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer"]
__meta__ = {
"_edit_use_anchors_": false
}
[node name="NameLabel" type="Label" parent="ScrollContainer/VBoxContainer"]
visible = false visible = false
margin_top = 24.0 margin_bottom = 14.0
margin_right = 1024.0
margin_bottom = 38.0
[node name="LineEdit" type="LineEdit" parent="VBoxContainer2/VBoxContainer"] [node name="LineEdit" type="LineEdit" parent="ScrollContainer/VBoxContainer"]
visible = false visible = false
margin_top = 24.0 margin_right = 58.0
margin_right = 1024.0 margin_bottom = 24.0
margin_bottom = 48.0
[node name="Save_Button" type="Button" parent="VBoxContainer2/VBoxContainer"] [connection signal="file_selected" from="FileDialog" to="." method="_on_FileDialog_file_selected"]
margin_top = 24.0 [connection signal="pressed" from="VBoxContainer2/But_OpenFile" to="." method="_on_Button_pressed"]
margin_right = 328.0
margin_bottom = 44.0
text = "Save"
[connection signal="pressed" from="VBoxContainer2/VBoxContainer/But_OpenFile" to="." method="_on_Button_pressed"]
[connection signal="file_selected" from="VBoxContainer2/VBoxContainer/FileDialog" to="." method="_on_FileDialog_file_selected"]

View File

@ -37,8 +37,8 @@ __meta__ = {
[node name="But_ChoosePlayer" parent="VBoxContainer" instance=ExtResource( 1 )] [node name="But_ChoosePlayer" parent="VBoxContainer" instance=ExtResource( 1 )]
margin_right = 238.0 margin_right = 238.0
margin_bottom = 98.0 margin_bottom = 98.0
text = "Select Character" text = "Import Character"
next_scene_path = "res://screens/Character_Load.tscn" next_scene_path = "res://screens/ImportCharacter.tscn"
[node name="But_AddChar" parent="VBoxContainer" instance=ExtResource( 1 )] [node name="But_AddChar" parent="VBoxContainer" instance=ExtResource( 1 )]
margin_top = 102.0 margin_top = 102.0

View File

@ -7,12 +7,12 @@ extends Button
#Creates param usable in the UI; and the params next to export make it string and file browser #Creates param usable in the UI; and the params next to export make it string and file browser
export(String, FILE) var next_scene_path: = "" export(String, FILE) var next_scene_path: = ""
var tempToggle = 0
func _on_But_NewGame_button_up(): func _on_But_NewGame_button_up():
get_tree().change_scene(next_scene_path) get_tree().change_scene(next_scene_path)
func _get_configuration_warning() -> String: func _get_configuration_warning() -> String:
return "next_scene_path must be set for this button to work" if next_scene_path == "" else "" return "next_scene_path must be set for this button to work" if next_scene_path == "" else ""

View File

@ -0,0 +1,28 @@
#BUT_CHANGESCENE:
# Generic template script allowing GUI linking of scenes by button press.
tool
extends Button
#Creates param usable in the UI; and the params next to export make it string and file browser
export(String, FILE) var next_scene_path: = ""
onready var pSingleton = get_node("/root/PlayerCharacter").pc
var tempToggle = 0
func _on_But_NewGame_button_up():
if(pSingleton.pcText.length() < 1):
#print("GOT IT! Popup msg: " + $PopupDialog/WarnText.text)
var alertPopup = get_node("../PopupDialog")
var alertPopupText = get_node("../PopupDialog/WarnText")
alertPopupText.text = "No player was loaded! Please load a character to begin game."
alertPopup.popup_centered()
return
else:
get_tree().change_scene(next_scene_path)
func _get_configuration_warning() -> String:
return "next_scene_path must be set for this button to work" if next_scene_path == "" else ""