Merged Game Demo Web Version (further updates)

Continues updating the web version of the module demo. Game can now be played online, but requires a new character be created. Select New Game, then Create Character. Add a name, and save the file (such as test.csv) to surface layer. Click Temp: Start New Game to begin game. Note that only the character name is being maintained at this time.

This version adds a Die Roller output with the params of a D4 and D6 (taken from JSON module content pre-loaded). This can be viewed in-game by selecting another option on the boat first, and then finding and clicking the "Run die roll test" option.
This commit is contained in:
MacDugRPG 2023-08-20 15:29:13 -04:00
parent d5057836e5
commit 64ecb2ba5a
6 changed files with 259 additions and 12 deletions

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:
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 ""

View File

@ -5,6 +5,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
func _ready() -> void: func _ready() -> void:
theme=load(settings.themeFile) theme=load(settings.themeFile)
@ -13,10 +14,16 @@ func _ready() -> void:
func _on_But_SaveChar_pressed() -> void: func _on_But_SaveChar_pressed() -> void:
$Title/FileDialog.popup() $Title/FileDialog.popup()
#DKM TEMP: just text for now from text edit #DKM TEMP: this code was inherited and it needs pretty substantial
# overhaul for use in the module, depending on toolset use.
# For now all the labels are individual lineEdits we need to grab.
func _on_FileDialog_file_selected(path: String) -> void: func _on_FileDialog_file_selected(path: String) -> void:
var pc = get_node("/root/PlayerCharacter") var pc = get_node("/root/PlayerCharacter")
var newCharFile = File.new() var newCharFile = File.new()
newCharFile.open(path, 2) newCharFile.open(path, 2)
newCharFile.store_string($TextEdit.text)
pc.playerCharacterSingleton.pcText = $TextEdit.text #DKM TEMP: getting something to work with as text
var newCharStr = $Title/VBoxContainer/LabelName/LE_Name.text
newCharFile.store_string(newCharStr)
pSingleton.pcText = "Name: " + newCharStr
print("PC text: " + pSingleton.pcText )

View File

@ -1,5 +1,6 @@
[gd_scene load_steps=3 format=2] [gd_scene load_steps=4 format=2]
[ext_resource path="res://Screens/But_StartNewGame.gd" type="Script" id=1]
[ext_resource path="res://Screens/Character_Add.gd" type="Script" id=3] [ext_resource path="res://Screens/Character_Add.gd" type="Script" id=3]
[ext_resource path="res://UserInterface/But_ChangeScene.gd" type="Script" id=4] [ext_resource path="res://UserInterface/But_ChangeScene.gd" type="Script" id=4]
@ -8,6 +9,15 @@ anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
script = ExtResource( 3 ) script = ExtResource( 3 )
[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="TextEdit" type="TextEdit" parent="."] [node name="TextEdit" type="TextEdit" parent="."]
margin_left = 215.0 margin_left = 215.0
margin_top = 23.0 margin_top = 23.0
@ -41,9 +51,8 @@ margin_right = 159.0
margin_bottom = 122.0 margin_bottom = 122.0
size_flags_vertical = 3 size_flags_vertical = 3
text = "Temp: Start New Game" text = "Temp: Start New Game"
__meta__ = { script = ExtResource( 1 )
"_edit_use_anchors_": false next_scene_path = "res://gamePlay/Game.tscn"
}
[node name="FileDialog" type="FileDialog" parent="Title"] [node name="FileDialog" type="FileDialog" parent="Title"]
margin_left = 164.0 margin_left = 164.0
@ -51,7 +60,7 @@ margin_top = 35.0
margin_right = 741.0 margin_right = 741.0
margin_bottom = 426.0 margin_bottom = 426.0
rect_min_size = Vector2( 400, 140 ) rect_min_size = Vector2( 400, 140 )
access = 1 access = 2
[node name="VBoxContainer" type="VBoxContainer" parent="Title"] [node name="VBoxContainer" type="VBoxContainer" parent="Title"]
anchor_left = 0.5 anchor_left = 0.5
@ -67,7 +76,7 @@ margin_bottom = 31.0
text = "NAME text = "NAME
" "
[node name="LineEdit" type="LineEdit" parent="Title/VBoxContainer/LabelName"] [node name="LE_Name" type="LineEdit" parent="Title/VBoxContainer/LabelName"]
margin_top = 15.0 margin_top = 15.0
margin_right = 58.0 margin_right = 58.0
margin_bottom = 24.0 margin_bottom = 24.0

View File

@ -0,0 +1,200 @@
[gd_scene load_steps=6 format=2]
[ext_resource path="res://gamePlay/But_MoreOptions.gd" type="Script" id=1]
[ext_resource path="res://gamePlay/Game.gd" type="Script" id=2]
[ext_resource path="res://gamePlay/But_Option.tscn" type="PackedScene" id=3]
[ext_resource path="res://assets/ui_controlNode_dark_theme.tres" type="Theme" id=4]
[ext_resource path="res://assets/liberation_serif_30pt.tres" type="DynamicFont" id=5]
[node name="Game" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
theme = ExtResource( 4 )
script = ExtResource( 2 )
[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( 1 )
__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" type="Button" parent="Background/MarginContainer/Rows/InputArea/ScrollContainer/OptionsContainer" instance=ExtResource( 3 )]
margin_right = 108.0
margin_bottom = 36.0
custom_fonts/font = ExtResource( 5 )
text = "Option 1"
align = 0
__meta__ = {
"_edit_use_anchors_": false
}
[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"]

View File

@ -5,7 +5,7 @@ platform="HTML5"
runnable=true runnable=true
custom_features="" custom_features=""
export_filter="all_resources" export_filter="all_resources"
include_filter="" include_filter="*.json, *.csv"
exclude_filter="" exclude_filter=""
export_path="../../Godot_Outputs/Godot_35_Outputs/Web/Web_Demo_Game_Base_2023_0806/index.html" export_path="../../Godot_Outputs/Godot_35_Outputs/Web/Web_Demo_Game_Base_2023_0806/index.html"
script_export_mode=1 script_export_mode=1

View File

@ -157,8 +157,10 @@ func change_node(destinationNode: String, _destinationParams: Array = []) -> voi
elif target_Locale.locale_action == "TestDieRollAction" && target_Locale.destinations_array.size() == 1: elif target_Locale.locale_action == "TestDieRollAction" && target_Locale.destinations_array.size() == 1:
print("Running test action " + target_Locale.locale_action + "; with parameters of: ") print("Running test action " + target_Locale.locale_action + "; with parameters of: ")
var nodeParameters = [] var nodeParameters = []
var outputText = "Die types to be rolled: "
for param in target_Locale.locale_action_params: for param in target_Locale.locale_action_params:
print(param) print(param)
outputText = outputText + str(param) + " sided; "
nodeParameters.append(param) nodeParameters.append(param)
#DKM TEST: testing the die roller with Andrew's code; randomly assigning percentage to pass. #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? # Should this param be optional if you purely want to roll dice?
@ -167,7 +169,8 @@ func change_node(destinationNode: String, _destinationParams: Array = []) -> voi
DiceRoller.dieManager.setDieManager(dieParams, 0.5) DiceRoller.dieManager.setDieManager(dieParams, 0.5)
var result = DiceRoller.dieManager.rollDice() var result = DiceRoller.dieManager.rollDice()
print("Rolled values: " + str(result[0])) print("Rolled values: " + str(result[0]))
outputText = outputText + "with values: " + str(result[0])
create_response(outputText)
#DKM TEMP: Andrew's code for ref: #DKM TEMP: Andrew's code for ref:
#assigning variable names to each of them for better clarity #assigning variable names to each of them for better clarity
# var rolledValues = result[0] # var rolledValues = result[0]
@ -177,7 +180,7 @@ func change_node(destinationNode: String, _destinationParams: Array = []) -> voi
# var degreeOfSuccess = result[4] # var degreeOfSuccess = result[4]
# var dice = result[5] # var dice = result[5]
change_node(target_Locale.destinations_array[0]) #change_node(target_Locale.destinations_array[0])
options_container.get_child(0).grab_focus() options_container.get_child(0).grab_focus()