From 60b8f7821b954be595c0d2e840a94381e4a2b5a6 Mon Sep 17 00:00:00 2001 From: MacDugRPG <57243055+MacDugRPG@users.noreply.github.com> Date: Sun, 10 Apr 2022 15:22:25 -0400 Subject: [PATCH] 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. --- .../characterFiles/demoCharacter_Bruno.txt | 14 ++++ .../bcirpg_newGame_20220227A/gamePlay/Game.gd | 25 +++---- .../gamePlay/LocaleManager.gd | 1 + .../screens/Character_Add.gd | 19 +++++ .../screens/Character_Add.tscn | 64 ++++++++++++++++ .../screens/Character_Load.gd | 20 +++++ .../screens/Character_Load.tscn | 75 +++++++++++++++++++ .../screens/MenuScreen.gd | 2 +- .../screens/MenuScreen.tscn | 4 +- .../screens/PlayerSelection.gd | 11 +++ .../screens/PlayerSelection.tscn | 69 +++++++++++++++++ 11 files changed, 287 insertions(+), 17 deletions(-) create mode 100644 Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/_toArchive/characterFiles/demoCharacter_Bruno.txt create mode 100644 Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/Character_Add.gd create mode 100644 Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/Character_Add.tscn create mode 100644 Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/Character_Load.gd create mode 100644 Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/Character_Load.tscn create mode 100644 Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/PlayerSelection.gd create mode 100644 Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/PlayerSelection.tscn diff --git a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/_toArchive/characterFiles/demoCharacter_Bruno.txt b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/_toArchive/characterFiles/demoCharacter_Bruno.txt new file mode 100644 index 0000000..5bde792 --- /dev/null +++ b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/_toArchive/characterFiles/demoCharacter_Bruno.txt @@ -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. \ No newline at end of file diff --git a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/gamePlay/Game.gd b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/gamePlay/Game.gd index 182c564..490bbe7 100644 --- a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/gamePlay/Game.gd +++ b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/gamePlay/Game.gd @@ -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) diff --git a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/gamePlay/LocaleManager.gd b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/gamePlay/LocaleManager.gd index 0917933..e0ba69c 100644 --- a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/gamePlay/LocaleManager.gd +++ b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/gamePlay/LocaleManager.gd @@ -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) diff --git a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/Character_Add.gd b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/Character_Add.gd new file mode 100644 index 0000000..1c10474 --- /dev/null +++ b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/Character_Add.gd @@ -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) diff --git a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/Character_Add.tscn b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/Character_Add.tscn new file mode 100644 index 0000000..92fc993 --- /dev/null +++ b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/Character_Add.tscn @@ -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"] diff --git a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/Character_Load.gd b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/Character_Load.gd new file mode 100644 index 0000000..a859d3a --- /dev/null +++ b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/Character_Load.gd @@ -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() diff --git a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/Character_Load.tscn b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/Character_Load.tscn new file mode 100644 index 0000000..5ca364e --- /dev/null +++ b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/Character_Load.tscn @@ -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"] diff --git a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/MenuScreen.gd b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/MenuScreen.gd index 702e1b8..bfc6935 100644 --- a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/MenuScreen.gd +++ b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/MenuScreen.gd @@ -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() diff --git a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/MenuScreen.tscn b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/MenuScreen.tscn index 445d83b..8a326a7 100644 --- a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/MenuScreen.tscn +++ b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/MenuScreen.tscn @@ -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 diff --git a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/PlayerSelection.gd b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/PlayerSelection.gd new file mode 100644 index 0000000..4a92014 --- /dev/null +++ b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/PlayerSelection.gd @@ -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() diff --git a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/PlayerSelection.tscn b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/PlayerSelection.tscn new file mode 100644 index 0000000..62033d2 --- /dev/null +++ b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/PlayerSelection.tscn @@ -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 +}