From de608e7c33481f19b094bd6955e5217a42fad9f8 Mon Sep 17 00:00:00 2001 From: MacDugRPG <57243055+MacDugRPG@users.noreply.github.com> Date: Sun, 17 Mar 2024 15:27:33 -0400 Subject: [PATCH] Updates MVP Game Code for XML (cont'd) Updates working XML and continues update on file parser; currently working on building the dict we can use to run our game (as JSON version currently runs game). --- .../_userFiles/Module_Demo_002.xml | 100 +++++++++--------- .../_userFiles/game_01.tscn | 16 +-- .../gamePlay/Game.gd | 59 ++++++++--- 3 files changed, 103 insertions(+), 72 deletions(-) diff --git a/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/_userFiles/Module_Demo_002.xml b/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/_userFiles/Module_Demo_002.xml index 920d629..e0f0b22 100644 --- a/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/_userFiles/Module_Demo_002.xml +++ b/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/_userFiles/Module_Demo_002.xml @@ -1,86 +1,86 @@ - + Boat_000 ShowText The game has begun! You may select from the options below. You are in a boat. You have been shipwrecked. You can leave the boat through a hatch. - Examine Ship - Climb out through hatch - Play the fiddle! - Rest - Meditate - Boat_002 - Shore_001 - Misc_001 - Misc_002 - Misc_003 - - + Examine Ship + Climb out through hatch + Play the fiddle! + Rest + Meditate + Boat_002 + Shore_001 + Misc_001 + Misc_002 + Misc_003 + + Boat_001 ShowText The boat rocks gently. You can leave the boat through a hatch. There is also now a test option. - Examine Ship - Climb out through hatch - Play the fiddle! - Rest - Meditate - Run die roll test - Boat_002 - Shore_001 - Misc_001 - Misc_002 - Misc_003 - Test_000 - - + Examine Ship + Climb out through hatch + Play the fiddle! + Rest + Meditate + Run die roll test + Boat_002 + Shore_001 + Misc_001 + Misc_002 + Misc_003 + Test_000 + + Boat_002 ShowText The boat is old and wrecked. - Continue - Boat_001 - - + Continue + Boat_001 + + Shore_001 ShowText You've reached the shore! - Return to boat - Boat_001 - - + Return to boat + Boat_001 + + Misc_001 ShowText You pull a fiddle from your sack and play it, while dancing around merrily. Great fun is had. - Resume your quest - Boat_001 - - + Resume your quest + Boat_001 + + Misc_002 ShowText You pull out a blanket, settle your burdens and take a short rest. - Resume your quest - Boat_001 - - + Resume your quest + Boat_001 + + Misc_003 ShowText You find a quiet corner on the boat, put down your burden, and feel the rocking of the boat. You rest mind and body, and really I'm experimenting with options and sizes of them, added via JSON here. So in your meditation you have a vision: a sparrow flies high over the mountains and reveals a castle! After this reverie, you awake. - Resume your quest - Boat_001 - - + Resume your quest + Boat_001 + + Test_000 TestDieRollAction 4 6 NA - NA - Boat_001 - + NA + Boat_001 + \ No newline at end of file diff --git a/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/_userFiles/game_01.tscn b/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/_userFiles/game_01.tscn index bd21ff7..da79d1d 100644 --- a/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/_userFiles/game_01.tscn +++ b/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/_userFiles/game_01.tscn @@ -1,16 +1,16 @@ [gd_scene load_steps=6 format=2] -[ext_resource path="res://gamePlay/Game.gd" type="Script" id=1] -[ext_resource path="res://gamePlay/But_MoreOptions.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=1] +[ext_resource path="res://gamePlay/But_Option.tscn" type="PackedScene" id=2] +[ext_resource path="res://gamePlay/Game.gd" type="Script" id=3] [ext_resource path="res://assets/liberation_serif_30pt.tres" type="DynamicFont" id=4] -[ext_resource path="res://assets/ui_controlNode_dark_theme.tres" type="Theme" id=5] +[ext_resource path="res://gamePlay/But_MoreOptions.gd" type="Script" id=5] [node name="Game" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 -theme = ExtResource( 5 ) -script = ExtResource( 1 ) +theme = ExtResource( 1 ) +script = ExtResource( 3 ) [node name="Background" type="PanelContainer" parent="."] anchor_right = 1.0 @@ -46,7 +46,7 @@ rect_min_size = Vector2( 0, 40 ) margin_right = 197.0 margin_bottom = 36.0 text = "More Options" -script = ExtResource( 2 ) +script = ExtResource( 5 ) __meta__ = { "_edit_use_anchors_": false } @@ -84,7 +84,7 @@ 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 )] +[node name="option1" type="Button" parent="Background/MarginContainer/Rows/InputArea/ScrollContainer/OptionsContainer" instance=ExtResource( 2 )] margin_right = 108.0 margin_bottom = 36.0 custom_fonts/font = ExtResource( 4 ) diff --git a/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/gamePlay/Game.gd b/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/gamePlay/Game.gd index 6803e86..8c5bedf 100644 --- a/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/gamePlay/Game.gd +++ b/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/gamePlay/Game.gd @@ -95,7 +95,7 @@ func loadJSONToDict(filepath:String)->Dictionary: func loadXMLDemo(filepath:String): print("TEST! Trying to open xml at " + filepath) - var test_array = [] + var xml_data = {} var parser = XMLParser.new() var error = parser.open(filepath) if error != OK: @@ -111,19 +111,50 @@ func loadXMLDemo(filepath:String): #DKM TEMP: printer; probably don't need the strip_edges, was looking to remove white space. # Looks like it reads the closing tags, too, which is a bummer. - while true: - if parser.read() != OK: - print("Parser read not okay!") - return - else: - var px = parser.get_node_name() - px.strip_edges(true,true) - if(!px.empty()): - print("Node Named: " + px) - px = parser.get_node_data() - px.strip_edges(true,true) - if(!px.empty()): - print("Data: " + px) + + #DKM TEMP: Test print output brute force +# while true: +# if parser.read() != OK: +# print("Parser read not okay!") +# return +# else: +# var px = parser.get_node_name() +# px.strip_edges(true,true) +# if(!px.empty()): +# print("Node Named: " + px) +# px = parser.get_node_data() +# px.strip_edges(true,true) +# if(!px.empty()): +# print("Data: " + px) + while parser.read() == OK: + if parser.get_node_type() == XMLParser.NODE_ELEMENT: + var node_name = parser.get_node_name() + if node_name.strip_edges(true,true).to_upper() == "LOCATION": + while parser.read() == OK: + if parser.get_node_type() == XMLParser.NODE_ELEMENT: + if parser.get_node_name().strip_edges(true,true).to_upper() == "LOCATION": + break + var child_node_name = parser.get_node_name() + #DKM TEMP: we need to switch/match all this, but still wrapping head around this parsing + print(child_node_name.strip_edges(true,true).to_upper()) + if child_node_name.strip_edges(true,true).to_upper() == "ID": + parser.read() + var id_node_data = parser.get_node_data() + print("TEMP: ID found, named: " + str(id_node_data)) + xml_data[id_node_data] = {} + + +# xml_data[node_name] = {} +# for i in range(parser.get_attribute_count()): +# var key = parser.get_attribute_name(i) +# var value = parser.get_attribute_value(i) +# xml_data[node_name][key] = value + + #DKM TEMP: test dictionary output: +# print("TEST: printing XML dictionary values: ") +# for val in xml_data.values(): +# print(val) +