Skip to content

Commit

Permalink
Upload my section in MVP demo to make load system
Browse files Browse the repository at this point in the history
Made a default load system button and stuff by our game style. and next week, I'll try to connect the directory system and load character files by CSV files.
  • Loading branch information
suuuhwankim committed Apr 21, 2024
1 parent d1cbb70 commit 988382d
Show file tree
Hide file tree
Showing 126 changed files with 4,279 additions and 0 deletions.
@@ -0,0 +1 @@

@@ -0,0 +1,3 @@
source_md5="79d2b9a5284e50d91a97c2dd565f2fa4"
dest_md5="ab01d4eeab6e15a95fc10ee1b4e02967"

Binary file not shown.
@@ -0,0 +1,3 @@
source_md5="79d2b9a5284e50d91a97c2dd565f2fa4"
dest_md5="ab01d4eeab6e15a95fc10ee1b4e02967"

Binary file not shown.
@@ -0,0 +1,3 @@
source_md5="13a1e728def8fb06bd8e797fcc392604"
dest_md5="b396169339b2e8d769e9830c387050ad"

Binary file not shown.
@@ -0,0 +1,3 @@
source_md5="13a1e728def8fb06bd8e797fcc392604"
dest_md5="b396169339b2e8d769e9830c387050ad"

Binary file not shown.
@@ -0,0 +1,3 @@
source_md5="266f789a4e895911161321092c2c2429"
dest_md5="a08a6dcf169f683724bfd5cd82e23fe6"

Binary file not shown.
@@ -0,0 +1,3 @@
source_md5="266f789a4e895911161321092c2c2429"
dest_md5="a08a6dcf169f683724bfd5cd82e23fe6"

Binary file not shown.
@@ -0,0 +1,3 @@
source_md5="47313fa4c47a9963fddd764e1ec6e4a8"
dest_md5="2ded9e7f9060e2b530aab678b135fc5b"

Binary file not shown.
@@ -0,0 +1 @@
source_md5="cfb2a27b25dace2544a35a8ec7d50081"
@@ -0,0 +1,3 @@
source_md5="6c1f8727c8d1f2bf769473ce1e014294"
dest_md5="93baaa829d8920726f5c904e487be855"

@@ -0,0 +1 @@
source_md5="fe8dea03f3f241ec8c3f199dcd974cbe"
@@ -0,0 +1,8 @@
[gd_scene format=2]

[node name="Control" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
@@ -0,0 +1,43 @@
****************************
README.TXT:
****************************
Author: Doug McCord
Date: 4-Feb-2024

****************************
Intro notes:
This project updates the RPGR BCI merged demo game from August 6, 2023 for
the Modgodtoolset and associated updates. Draws game from XML, and adds
numerous missing features.

The roadmap for this file can be found in the project Github:
Phase2/Documentation



****************************
Project file structure:
Surface Layer:
Default Godot files remain at this level

_toArchive:
Directory to serve as reference-only; precursor to trash

assets:
Images, fonts, themes and styles (TRES text resource data files). Note that all fonts and styles are defined in
the following themes: ui_controlNode_light_theme.tres and ui_controlNode_dark_theme.tres. Any style changes
should be made in those theme files to assure propagation throughout.

gamePlay:
Scenes and scripts specific to the gameplay section

globalScripts:
For project-wide use, or scripts that are not either:
A. attached to a template scene, intended to go with all instances of that, or
B. unique, scene-specific scripts.

screens:
Planned to include both .tscn scene files and their associated scripts.

userInterface: (note misnomer for text-based game)
Re-useable UI elements and their scripts, such as change-scene, input-response
@@ -0,0 +1,13 @@
#BUT_HISTORYPAGER:
# Iterates the page number and calls HistoryViewer script to display
# stored page and response fro the history array
#

extends Button

onready var historyViewerScript = get_node("/root/HistoryViewer")

#DKM TEMP: this needs refactoring -- too much being calculated as needed/repeated
func _on_But_HistoryPager_button_up() -> void:
historyViewerScript.update_pager()

@@ -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:
var _changeResponse = 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 ""

@@ -0,0 +1,88 @@
#CHARACTER_ADD:
# Script for adding a new character and both saving it to file and loading
# it into the character object

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 save_data_to_csv(data: Array, file_path : String) ->void:
var file = File.new()

if file.open(file_path, File.WRITE) == OK:
for row in data:
file.store_string(format_row(row))
file.close()
print("Data saved to ", file_path)
else:
print("Failed to open ", file_path, " for writing.")


func format_row(row_data: Array) -> String:
# Convert the array of data to a comma-separated string
var formatted_row = ""
for i in range(row_data.size()):
formatted_row += str(row_data[i])
if i < row_data.size() - 1:
formatted_row += ","

formatted_row += "\n"

return formatted_row



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()
var file_path = ""

if pSingleton.name != "":
file_path = "user://" + pSingleton.name + "_data.csv"
else:
file_path = "user//character_data.csv"

var input_data = [
["Name", "Profession", "Strength", "Intellect", "Willpower", "Charm", "Weapon", "Armor", "Quote"],
[pSingleton.name, pSingleton.profession, pSingleton.strength, pSingleton.intellect, pSingleton.willpower, pSingleton.charm, pSingleton.weapon, pSingleton.armor, pSingleton.quote],
]

save_data_to_csv(input_data, file_path)


0 comments on commit 988382d

Please sign in to comment.