Change 2 for cleanup

This commit is contained in:
PersonGuyGit
2023-07-09 12:28:09 -06:00
parent 707e8a5b16
commit 2c971b6e7c
1741 changed files with 0 additions and 0 deletions

View File

@ -0,0 +1,39 @@
#BUT_HISTORY:
# Unique script attached to the But_History to hide/show history versus
# current game page.
tool
extends Button
onready var game_history_array = get_node("/root/History").historyScreensSingleton.output_history_array
var is_history = false
func _on_But_History_button_up():
var history_pager_button = get_node("../../ItemList/But_History_Page")
var history_rows_node = get_node("../../GameInfo/HistoryRows")
var current_text_node = get_node("../../GameInfo/CurrentText")
var option_one = get_node("../../InputArea/VBoxContainer/option1")
var option_two = get_node("../../InputArea/VBoxContainer/option2")
var option_three = get_node("../../InputArea/VBoxContainer/option3")
if(!is_history):
if(game_history_array != null):
history_rows_node.add_child(game_history_array[0])
history_pager_button.show()
history_rows_node.show()
current_text_node.hide()
option_one.hide()
option_two.hide()
option_three.hide()
is_history = true
else:
history_pager_button.hide()
history_rows_node.hide()
current_text_node.show()
option_one.show()
option_two.show()
option_three.show()
is_history = false

View File

@ -0,0 +1,21 @@
#BUT_HISTORY_PAGE:
# Unique paging script for showing next page in the history game's history
# array.
tool
extends Button
var current_page = 0
func _on_But_History_Page_button_up():
var game_history_array = get_node("/root/History").historyScreensSingleton.output_history_array
var history_rows_node = get_node("../../GameInfo/HistoryRows")
if(current_page < game_history_array.size()-1):
current_page += 1
else:
current_page = 0
history_rows_node.remove_child(history_rows_node.get_child(0))
history_rows_node.add_child(game_history_array[current_page])

View File

@ -0,0 +1,25 @@
#But_MoreOptions:
# For these options, we leave the game object active and manually add and remove
# the scenes as needed.
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: = ""
func _on_But_MoreOptions_button_up():
var root = get_node("/root")
var gameCurrent = get_node("/root/Game")
var gameSingleton = get_node("/root/GameCurrent")
var nextScene = load(next_scene_path)
gameSingleton.gameCurrent_scene = gameCurrent
root.remove_child(gameCurrent)
nextScene = nextScene.instance()
root.add_child(nextScene)
func _get_configuration_warning() -> String:
return "next_scene_path must be set for this button to work" if next_scene_path == "" else ""

View File

@ -0,0 +1,13 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://assets/liberation_serif_30pt.tres" type="DynamicFont" id=1]
[node name="option1" type="Button"]
margin_right = 706.0
margin_bottom = 36.0
custom_fonts/font = ExtResource( 1 )
text = "Option 1"
align = 0
__meta__ = {
"_edit_use_anchors_": false
}

View File

@ -0,0 +1,222 @@
#GAME:
# Controls output space, loading descriptions and options for each locale and
# appending to the history array.
extends Control
#Source for module file:
#export(String, FILE, "*.json") var module_file_path:String
#DKM TEMP:
var module_file_path = "res://_userFiles/Module_Demo_001.json"
onready var history_source = get_node("/root/History").historyScreensSingleton
onready var settings = get_node("/root/GlobalSaveInstance").settingsInstance
#Abstract class we instance when wanted in game as child of HistoryReference
const TextOutput = preload("res://UserInterface/Response.tscn")
const InputResponse = preload("res://UserInterface/InputResponse.tscn")
const OptionOutput = preload("res://UserInterface/Option.tscn")
onready var current_text = $Background/MarginContainer/Rows/GameInfo/CurrentText
onready var options_container = $Background/MarginContainer/Rows/InputArea/ScrollContainer/OptionsContainer
onready var pSingleton = get_node("/root/PlayerCharacter")
onready var charSheet = $Con_charSheet/MarginContainer/VBoxContainer/CharacterSheet
var nodeArray
func _ready() -> void:
theme=load(settings.themeFile)
#Initialize module and display text:
load_new_module()
current_text.show()
#Load character sheet:
charSheet.text = pSingleton.pc.pcText
#Initializes the default module:
func load_new_module() -> void:
var moduleDict = load_JSON_to_dict(module_file_path)
var i = 0
var initialNode = Locale.new()
nodeArray = [initialNode]
for moduleNode in moduleDict.values():
if nodeArray.size() <= i:
var newNode = Locale.new()
nodeArray.append(newNode)
nodeArray[i].locale_name = moduleNode.get("Id")
nodeArray[i].locale_description = moduleNode.get("Text")
nodeArray[i].locale_action = moduleNode.get("Action")
var actionParameters = moduleNode.get("A_Params")
for p in actionParameters:
nodeArray[i].locale_action_params.append(p)
var nodeOptions = moduleNode.get("Option_Labels")
for option in nodeOptions:
nodeArray[i].options_array.append(option)
#print("For #" + str(i) + ": appended option of: " + str(option))
var nodeDestinations = moduleNode.get("Option_GoTos")
for dest in nodeDestinations:
nodeArray[i].destinations_array.append(dest)
#print("For #" + str(i) + ": appended go to destination of: " + str(dest))
#print("Node array name for #" + str(i) + ": " + nodeArray[i].locale_name)
i = i+1
create_response(nodeArray[0].locale_description)
clear_prior_options()
i = 0
for option in nodeArray[0].options_array:
var destArr = nodeArray[0].destinations_array
create_option(option, destArr[i])
i = i+1
options_container.get_child(0).grab_focus()
#Master method for handling user interaction:
func change_node(destinationNode: String, destinationParams: Array = []) -> void:
var target_Locale = get_node_by_name(destinationNode)
#Run provided action:
if target_Locale.locale_action == "ShowText":
action_show_text(target_Locale)
elif target_Locale.locale_action == "RollDice" && target_Locale.destinations_array.size() == 1:
action_roll_die(target_Locale)
#DKM TEMP: testing passed param handling by node to node
elif target_Locale.locale_action == "TestHandleNodeParams":
action_handle_node_params_testing(target_Locale, destinationParams)
#DKM TEMP: running an ability check test on passed node:
elif target_Locale.locale_action == "TestAbstractAbilityCheck":
action_ability_check_testing(target_Locale, destinationParams)
options_container.get_child(0).grab_focus()
####################################################
#DISPLAY METHODS:
# Handles output text and options
####################################################
func create_response(response_text: String):
var response = TextOutput.instance()
response.text = response_text
add_response_to_game(response)
#Copies the response output to add to both current game output, and the
# history array.
func add_response_to_game(response: Control):
add_response_to_history(response)
if(current_text.get_child_count() > 0):
current_text.remove_child(current_text.get_child(0))
current_text.add_child(response)
func add_response_to_history(response: Control) -> void:
var response_for_history = response.duplicate()
history_source.output_history_array.append(response_for_history)
func clear_prior_options() -> void:
for n in options_container.get_children():
options_container.remove_child(n)
n.queue_free()
func create_option(option: String, dest: String) -> void:
#print("Received request to make option for label: " + option +"; and destination: " + dest)
var optionNew = OptionOutput.instance()
optionNew.destinationLabel = dest
optionNew.text = option
add_option_to_game(optionNew)
func add_option_to_game(optionNew: Control) -> void:
options_container.add_child(optionNew)
var newOptNumber = options_container.get_child_count()
if newOptNumber-1 >= 0:
#print("New added opt is: " + str(newOptNumber-1))
options_container.get_child(newOptNumber-1).connect("option_pressed", self, "_on_option_pressed")
func _on_option_pressed(destinationSelected: String) -> void:
#print("Destination node for pressed option is: " + destinationSelected)
change_node(destinationSelected)
####################################################
#ACTION HANDLERS:
# Process actions from selected nodes
####################################################
func action_show_text(newLocale: Locale) -> void:
create_response(newLocale.locale_description)
clear_prior_options()
var i = 0
for option in newLocale.options_array:
var destArr = newLocale.destinations_array
create_option(option, destArr[i])
i = i+1
func action_roll_die(newLocale: Locale) -> void:
print("Running test action " + newLocale.locale_action + "; with parameters of: ")
var nodeParameters = []
for param in newLocale.locale_action_params:
print(param)
nodeParameters.append(param)
#DKM TEST: testing the die roller with Andrew's code; randomly assigning percentage to pass.
# Should this param be optional if you purely want to roll dice?
var dieParams = nodeParameters
DiceRoller.dieManager.clearData()
DiceRoller.dieManager.setDieManager(dieParams, 0.5)
var result = DiceRoller.dieManager.rollDice()
print("Rolled values: " + str(result[0]))
if(DiceRoller.dieManager.isPercentageRoll):
var percDie = int(result[1]*100)
print("DKM TEMP: is percentage roll and perc res is: " + str(percDie))
var perc_result = [percDie]
change_node(newLocale.destinations_array[0], perc_result)
else:
change_node(newLocale.destinations_array[0], result[0])
#TESTING ACTIONS:
#Test version of ability check -- only built our for strength and agility with this output
func action_ability_check_testing(t_Locale: Locale, d_Params: Array = []) -> void:
var check_result ="NA"
print("Testing: passed stat is :" +t_Locale.locale_action_params[0])
if(t_Locale.locale_action_params[0] in pSingleton.pc.viableCharStats):
match t_Locale.locale_action_params[0]:
"AG":
if(int(d_Params[0])<= pSingleton.pc.agility):
check_result = "PASS"
else:
check_result = "FAIL"
"ST":
if(int(d_Params[0])<= pSingleton.pc.strength):
check_result = "PASS"
else:
check_result = "FAIL"
create_response(t_Locale.locale_description + check_result + " with roll of: " + str(d_Params) + "; on ability of: " + str(pSingleton.pc.strength))
clear_prior_options()
var i = 0
for option in t_Locale.options_array:
var destArr = t_Locale.destinations_array
create_option(option, destArr[i])
i = i+1
func action_handle_node_params_testing(t_Locale: Locale, d_Params: Array = []) -> void:
create_response(t_Locale.locale_description + str(d_Params))
clear_prior_options()
var i = 0
for option in t_Locale.options_array:
var destArr = t_Locale.destinations_array
create_option(option, destArr[i])
i = i+1
####################################################
#HELPER METHODS:
####################################################
func get_node_by_name(nodeName: String) -> Locale:
for n in nodeArray:
if n.locale_name == nodeName:
return n
return nodeArray[0]
#Convert JSON file to dictionary for module import:
# DKM TEMP: JSON only for development work -- will come from alt data source
func load_JSON_to_dict(filepath:String)->Dictionary:
var file = File.new()
#assert file.file_exists(filepath)
file.open(filepath,file.READ)
var moduleDict = parse_json(file.get_as_text())
#assert moduleDict.size() > 0
return moduleDict

View File

@ -0,0 +1,195 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://gamePlay/But_Option.tscn" type="PackedScene" id=1]
[ext_resource path="res://gamePlay/Game.gd" type="Script" id=2]
[ext_resource path="res://assets/ui_controlNode_dark_theme.tres" type="Theme" id=3]
[ext_resource path="res://gamePlay/But_MoreOptions.gd" type="Script" id=9]
[node name="Game" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
theme = ExtResource( 3 )
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Background" type="PanelContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_right = -274.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MarginContainer" type="MarginContainer" parent="Background"]
margin_left = 1.0
margin_top = 1.0
margin_right = 749.0
margin_bottom = 599.0
custom_constants/margin_right = 20
custom_constants/margin_top = 10
custom_constants/margin_left = 20
custom_constants/margin_bottom = 20
[node name="Rows" type="VBoxContainer" parent="Background/MarginContainer"]
margin_left = 20.0
margin_top = 10.0
margin_right = 728.0
margin_bottom = 578.0
custom_constants/separation = 10
[node name="ItemList" type="ItemList" parent="Background/MarginContainer/Rows"]
margin_right = 708.0
margin_bottom = 40.0
rect_min_size = Vector2( 0, 40 )
[node name="But_MoreOptions" type="Button" parent="Background/MarginContainer/Rows/ItemList"]
margin_right = 197.0
margin_bottom = 36.0
text = "More Options"
script = ExtResource( 9 )
__meta__ = {
"_edit_use_anchors_": false
}
next_scene_path = "res://Screens/MoreOptions.tscn"
[node name="GameInfo" type="PanelContainer" parent="Background/MarginContainer/Rows"]
margin_top = 50.0
margin_right = 708.0
margin_bottom = 438.0
size_flags_vertical = 3
[node name="CurrentText" type="VBoxContainer" parent="Background/MarginContainer/Rows/GameInfo"]
margin_left = 1.0
margin_top = 1.0
margin_right = 707.0
margin_bottom = 387.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_constants/separation = 20
[node name="InputArea" type="PanelContainer" parent="Background/MarginContainer/Rows"]
margin_top = 448.0
margin_right = 708.0
margin_bottom = 568.0
rect_min_size = Vector2( 0, 120 )
[node name="ScrollContainer" type="ScrollContainer" parent="Background/MarginContainer/Rows/InputArea"]
margin_left = 1.0
margin_top = 1.0
margin_right = 707.0
margin_bottom = 119.0
[node name="OptionsContainer" type="VBoxContainer" parent="Background/MarginContainer/Rows/InputArea/ScrollContainer"]
margin_right = 108.0
margin_bottom = 36.0
custom_constants/separation = 5
[node name="option1" parent="Background/MarginContainer/Rows/InputArea/ScrollContainer/OptionsContainer" instance=ExtResource( 1 )]
margin_right = 108.0
[node name="Con_charSheet" type="PanelContainer" parent="."]
anchor_left = 1.0
anchor_right = 1.0
margin_left = -294.0
margin_bottom = 406.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MarginContainer" type="MarginContainer" parent="Con_charSheet"]
margin_left = 1.0
margin_top = 1.0
margin_right = 293.0
margin_bottom = 405.0
[node name="VBoxContainer" type="VBoxContainer" parent="Con_charSheet/MarginContainer"]
margin_right = 292.0
margin_bottom = 404.0
[node name="IL_cs_label" type="ItemList" parent="Con_charSheet/MarginContainer/VBoxContainer"]
margin_right = 292.0
margin_bottom = 40.0
rect_min_size = Vector2( 0, 40 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="Con_charSheet/MarginContainer/VBoxContainer/IL_cs_label"]
anchor_left = 0.5
anchor_right = 0.5
margin_left = -141.0
margin_right = 141.0
margin_bottom = 43.0
text = "Character Sheet"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="CharacterSheet" type="TextEdit" parent="Con_charSheet/MarginContainer/VBoxContainer"]
margin_top = 44.0
margin_right = 292.0
margin_bottom = 404.0
size_flags_vertical = 3
readonly = true
wrap_enabled = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Con_chatScreen" type="PanelContainer" parent="."]
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -292.0
margin_top = -196.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="Con_chatScreen"]
margin_left = 1.0
margin_top = 1.0
margin_right = 291.0
margin_bottom = 195.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="IL_cs_label" type="ItemList" parent="Con_chatScreen/VBoxContainer"]
margin_right = 290.0
margin_bottom = 40.0
rect_min_size = Vector2( 0, 40 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="Con_chatScreen/VBoxContainer/IL_cs_label"]
anchor_left = 0.5
anchor_right = 0.5
margin_left = -142.0
margin_right = 142.0
margin_bottom = 43.0
text = "Chat"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ChatScreen" type="TextEdit" parent="Con_chatScreen/VBoxContainer"]
margin_top = 44.0
margin_right = 290.0
margin_bottom = 194.0
size_flags_vertical = 3
text = "Nothing yet
"
readonly = true
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="button_up" from="Background/MarginContainer/Rows/ItemList/But_MoreOptions" to="Background/MarginContainer/Rows/ItemList/But_MoreOptions" method="_on_But_MoreOptions_button_up"]