Character Selection Added

Adds character selection to the new game -- with create and load options with file dialog working. Right now this loads and saves text files -- does not update a persistent character object/singleton for example.

Note: this also requires a characterFiles folder in the user:// directory. Example character added to the _toArchive folder for now.
This commit is contained in:
MacDugRPG 2022-04-10 15:22:25 -04:00
parent 17d90b130f
commit 60b8f7821b
11 changed files with 287 additions and 17 deletions

View File

@ -0,0 +1,14 @@
Name: Bruno
Class: Seer
Level: 22
S: 9
I: 11
W: 16
D: 14
C: 10
Chr: 8
HP: 31
Description: slight, anxious seer who hides from view whenever possible, due to the negative ramifications of his prophetic abilities.

View File

@ -24,8 +24,8 @@ onready var option_three = $Background/MarginContainer/Rows/InputArea/VBoxContai
onready var module_map = "user://temp_map.save"
func _ready() -> void:
load_module()
#DKM TEMP: for testing only -- this will be set in settings
save_module()
theme=load("res://assets/ui_controlNode_dark_theme.tres")
history_pager.hide()
history_rows.hide()
@ -84,16 +84,13 @@ func _on_option3_button_down() -> void:
var option3 = get_node("Background/MarginContainer/Rows/InputArea/VBoxContainer/option3")
handleUserInput(option3.get_text())
# DKM TEMP: Load module map needs to:
# 1. Add the needed Locale.tsns to the Locale Manager
# 2. Populate their names
# 3. Populate their descriptions
# 4. Populate their options
# 5. Link them directionally
#This will all be part of loading a set game -- built in the toolset. Also
# will need to have dialogues, combats, etc.
func load_module():
var file = File.net()
if file.file_exists(module_map):
file.open(module_map, File.READ)
file.close()
#func load_module():
# var scene = load("user://save_01.tscn")
# get_tree().change_scene_to(scene)
#DKM TEMP: saves the entire scene in one packed scene file
func save_module():
var scene = PackedScene.new()
scene.pack(self)
ResourceSaver.save("user://game_01.tscn", scene)

View File

@ -7,6 +7,7 @@ extends Node
#DKM TEMP: must load from toolset
func _ready() -> void:
#load_module()
$Loc_Boat.connect_exit("east", $Loc_Shore)
$Loc_Shore.connect_exit("north", $Loc_WoodsA1)
$Loc_WoodsA1.connect_exit("north", $Loc_WoodsA2)

View File

@ -0,0 +1,19 @@
#CHARACTER_ADD:
# Script for adding a new character and both saving it to file and loading
# it into the character object
extends Control
func _ready() -> void:
$Title/But_SaveChar.grab_focus()
func _on_But_SaveChar_pressed() -> void:
$Title/FileDialog.popup()
#DKM TEMP: just text for now from text edit
func _on_FileDialog_file_selected(path: String) -> void:
var newCharFile = File.new()
newCharFile.open(path, 2)
newCharFile.store_string($TextEdit.text)

View File

@ -0,0 +1,64 @@
[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://screens/Character_Add.gd" type="Script" id=3]
[node name="Control" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TextEdit" type="TextEdit" parent="."]
margin_left = 215.0
margin_top = 23.0
margin_right = 997.0
margin_bottom = 447.0
[node name="Title" parent="." instance=ExtResource( 1 )]
anchor_left = 0.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 0.0
margin_top = 0.0
margin_right = 0.0
margin_bottom = 0.0
text = "Create Character (temp)"
[node name="But_SaveChar" type="Button" parent="Title"]
margin_right = 12.0
margin_bottom = 20.0
text = "Save Character"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="But_ChangeScene" parent="Title" instance=ExtResource( 2 )]
margin_left = -1.0
margin_top = 48.0
margin_right = 142.0
margin_bottom = 72.0
text = "Temp: Main Menu"
next_scene_path = "res://Screens/MenuScreen.tscn"
[node name="But_StartNewGame" parent="Title" instance=ExtResource( 2 )]
margin_top = 98.0
margin_right = 159.0
margin_bottom = 122.0
text = "Temp: Start New Game"
next_scene_path = "res://gamePlay/Game.tscn"
[node name="FileDialog" type="FileDialog" parent="Title"]
margin_left = 164.0
margin_top = 35.0
margin_right = 741.0
margin_bottom = 426.0
access = 1
current_dir = "user://characterFiles"
current_path = "user://characterFiles/"
[connection signal="pressed" from="Title/But_SaveChar" to="." method="_on_But_SaveChar_pressed"]
[connection signal="file_selected" from="Title/FileDialog" to="." method="_on_FileDialog_file_selected"]

View File

@ -0,0 +1,20 @@
#CHARACTER_LOAD:
# Script for loading a character file into the character object from file
extends Control
func _ready() -> void:
$Title/But_loadCharacter.grab_focus()
func _on_But_loadCharacter_pressed() -> void:
$LoadCharacter_FileDialog.popup()
#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)
$TextEdit.text = charFile.get_as_text()

View File

@ -0,0 +1,75 @@
[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://screens/Character_Load.gd" type="Script" id=3]
[node name="Control" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TextEdit" type="TextEdit" parent="."]
margin_left = 189.0
margin_top = 18.0
margin_right = 989.0
margin_bottom = 461.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Title" parent="." instance=ExtResource( 1 )]
anchor_left = 0.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 0.0
margin_top = 0.0
margin_right = 0.0
margin_bottom = 0.0
text = "Load Character (temp)"
[node name="But_loadCharacter" type="Button" parent="Title"]
margin_left = 22.0
margin_top = 34.0
margin_right = 155.0
margin_bottom = 54.0
text = "Load Character File"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="But_ChangeScene" parent="Title" instance=ExtResource( 2 )]
margin_left = 25.0
margin_top = 111.0
margin_right = 168.0
margin_bottom = 135.0
text = "Temp: Main Menu "
next_scene_path = "res://Screens/MenuScreen.tscn"
[node name="But_StartNewGame" parent="Title" instance=ExtResource( 2 )]
margin_left = 22.0
margin_top = 71.0
margin_right = 181.0
margin_bottom = 95.0
text = "Temp: Start New Game"
next_scene_path = "res://gamePlay/Game.tscn"
[node name="LoadCharacter_FileDialog" type="FileDialog" parent="."]
margin_left = 193.0
margin_top = 33.0
margin_right = 862.0
margin_bottom = 409.0
window_title = "Open a File"
mode = 0
access = 1
current_dir = "user://characterFiles"
current_path = "user://characterFiles/"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="Title/But_loadCharacter" to="." method="_on_But_loadCharacter_pressed"]
[connection signal="file_selected" from="LoadCharacter_FileDialog" to="." method="_on_LoadCharacter_FileDialog_file_selected"]

View File

@ -6,6 +6,6 @@ extends Control
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
#DKM TEMP: for testing only -- this will be set in settings
#DKM TEMP: for testing only -- this will be set for all scenes in settings
theme=load("res://assets/ui_controlNode_dark_theme.tres")
$VBoxContainer/But_NewGame.grab_focus()

View File

@ -45,7 +45,7 @@ __meta__ = {
[node name="But_NewGame" parent="VBoxContainer" instance=ExtResource( 1 )]
margin_right = 238.0
margin_bottom = 49.0
next_scene_path = "res://gamePlay/Game.tscn"
next_scene_path = "res://screens/PlayerSelection.tscn"
[node name="But_LoadGame" parent="VBoxContainer" instance=ExtResource( 1 )]
margin_top = 53.0
@ -66,7 +66,7 @@ margin_top = 160.0
margin_right = 238.0
margin_bottom = 210.0
text = "Add Character"
next_scene_path = "res://Screens/AddCharacter_temp.tscn"
next_scene_path = "res://Screens/Character_Add.tscn"
[node name="But_Settings" parent="VBoxContainer" instance=ExtResource( 1 )]
margin_top = 214.0

View File

@ -0,0 +1,11 @@
#PLAYERSELECTION:
# Script purely to grab focus for tabbing control
extends Control
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
#DKM TEMP: for testing only -- this will be set in settings
theme=load("res://assets/ui_controlNode_dark_theme.tres")
$VBoxContainer/But_ChoosePlayer.grab_focus()

View File

@ -0,0 +1,69 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://UserInterface/But_ChangeScene.tscn" type="PackedScene" id=1]
[ext_resource path="res://screens/PlayerSelection.gd" type="Script" id=2]
[ext_resource path="res://assets/ui_controlNode_dark_theme.tres" type="Theme" id=6]
[node name="PlayerSelection" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
theme = ExtResource( 6 )
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Background" type="Panel" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -119.0
margin_top = -152.0
margin_right = 119.0
margin_bottom = 152.0
rect_scale = Vector2( 1.04675, 1.07389 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="But_ChoosePlayer" parent="VBoxContainer" instance=ExtResource( 1 )]
margin_right = 238.0
margin_bottom = 98.0
text = "Select Character"
next_scene_path = "res://screens/Character_Load.tscn"
[node name="But_AddChar" parent="VBoxContainer" instance=ExtResource( 1 )]
margin_top = 102.0
margin_right = 238.0
margin_bottom = 201.0
text = "Create Character"
next_scene_path = "res://Screens/Character_Add.tscn"
[node name="But_MainMenu" parent="VBoxContainer" instance=ExtResource( 1 )]
margin_top = 205.0
margin_right = 238.0
margin_bottom = 304.0
text = "Main Menu"
next_scene_path = "res://Screens/MenuScreen.tscn"
[node name="Version" type="Label" parent="."]
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -177.0
margin_top = -44.0
margin_right = -5.0
margin_bottom = -6.0
text = "Version: 0.0.0"
__meta__ = {
"_edit_use_anchors_": false
}