Skip to content

Commit f96f5cd

Browse files
committed
Fix #9
1 parent 128138d commit f96f5cd

File tree

4 files changed

+84
-34
lines changed

4 files changed

+84
-34
lines changed

addons/tree-tools/Scripts/treetool.gd

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ func _load_data( path ):
7474
file.close()
7575

7676
# parse json
77-
var jsonData = {}
78-
jsonData.parse_json(jsonString)
79-
load_from_json(jsonData)
77+
load_from_json(jsonString)
8078

8179
# Helper function to clear the GraphEdit
8280
func clear():
@@ -94,6 +92,7 @@ func load_from_json(jsonDataString):
9492
load_from_dict(jsonData)
9593
else:
9694
print("ERROR: invalid json string.")
95+
print(jsonDataString)
9796

9897
# Load graph data from dictionary
9998
func load_from_dict(dict):
@@ -121,8 +120,8 @@ func is_jsondata_valid(jsonDataString):
121120
else:
122121
var jsonData = {}
123122
jsonData.parse_json(jsonDataString)
124-
# print("JSONDATASTRING IS NOT NULL - OK")
125123
if (!jsonData.has("nodes") or !jsonData.has("connections")):
124+
print("ERROR: JSON dict doesn't contain required keys.")
126125
isValid = false
127126
return isValid
128127

addons/tree-tools/resources/treenode_resource.tres

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,5 @@
55
[resource]
66

77
script/script = ExtResource( 1 )
8-
dict = {
9-
"connections": [ ],
10-
"nodes": [ {
11-
"id": "node1",
12-
"name": "start",
13-
"type": "startnode",
14-
"x": 0,
15-
"y": 0
16-
} ]
17-
}
8+
dict = null
189

mainscene.tscn

Lines changed: 79 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
[gd_scene load_steps=9 format=1]
1+
[gd_scene load_steps=12 format=1]
22

33
[ext_resource path="res://icon.png" type="Texture" id=1]
44
[ext_resource path="res://addons/tree-tools/TreeNode/TreeNode.gd" type="Script" id=2]
55
[ext_resource path="res://addons/tree-tools/TreeNode/icons/gear.png" type="Texture" id=3]
66
[ext_resource path="res://addons/tree-tools/TreeNode/TreeNodeResource.gd" type="Script" id=4]
7-
[ext_resource path="res://run_dialog.gd" type="Script" id=5]
7+
[ext_resource path="res://addons/tree-tools/resources/treenode_resource.tres" type="Resource" id=5]
88
[ext_resource path="res://dialog_manager.gd" type="Script" id=6]
99
[ext_resource path="res://option_chooser.tscn" type="PackedScene" id=7]
10+
[ext_resource path="res://run_dialog.gd" type="Script" id=8]
1011

1112
[sub_resource type="Resource" id=1]
1213

@@ -236,6 +237,40 @@ dict = {
236237
} ]
237238
}
238239

240+
[sub_resource type="Animation" id=2]
241+
242+
resource/name = "reset"
243+
length = 0.01
244+
loop = false
245+
step = 0.1
246+
tracks/0/type = "value"
247+
tracks/0/path = NodePath(".:transform/pos")
248+
tracks/0/interp = 1
249+
tracks/0/imported = false
250+
tracks/0/keys = {
251+
"times": FloatArray( 0 ),
252+
"transitions": FloatArray( 1 ),
253+
"update": 0,
254+
"values": [ Vector2( 122.583, 90.4986 ) ]
255+
}
256+
257+
[sub_resource type="Animation" id=3]
258+
259+
resource/name = "talk"
260+
length = 1.0
261+
loop = true
262+
step = 0.1
263+
tracks/0/type = "value"
264+
tracks/0/path = NodePath(".:transform/pos")
265+
tracks/0/interp = 1
266+
tracks/0/imported = false
267+
tracks/0/keys = {
268+
"times": FloatArray( 0, 0.5, 1 ),
269+
"transitions": FloatArray( 1, 1, 1 ),
270+
"update": 0,
271+
"values": [ Vector2( 122.583, 90.4986 ), Vector2( 122.583, 73.351 ), Vector2( 122.583, 90.4986 ) ]
272+
}
273+
239274
[node name="Node2D" type="Node2D"]
240275

241276
[node name="Sprite" type="Sprite" parent="."]
@@ -266,23 +301,6 @@ percent_visible = 1.0
266301
lines_skipped = 0
267302
max_lines_visible = -1
268303

269-
[node name="run_dlg_1_btn" type="Button" parent="Sprite"]
270-
271-
focus/ignore_mouse = false
272-
focus/stop_mouse = true
273-
size_flags/horizontal = 2
274-
size_flags/vertical = 2
275-
margin/left = -40.583
276-
margin/top = 44.5014
277-
margin/right = 49.417
278-
margin/bottom = 64.5014
279-
toggle_mode = false
280-
enabled_focus_mode = 2
281-
shortcut = null
282-
text = "Run dialog 1"
283-
flat = false
284-
script/script = ExtResource( 5 )
285-
286304
[node name="Label" type="Label" parent="Sprite"]
287305

288306
focus/ignore_mouse = true
@@ -298,6 +316,18 @@ percent_visible = 1.0
298316
lines_skipped = 0
299317
max_lines_visible = -1
300318

319+
[node name="anim" type="AnimationPlayer" parent="Sprite"]
320+
321+
playback/process_mode = 1
322+
playback/default_blend_time = 0.0
323+
root/root = NodePath("..")
324+
anims/reset = SubResource( 2 )
325+
anims/talk = SubResource( 3 )
326+
playback/active = true
327+
playback/speed = 1.0
328+
blend_times = [ ]
329+
autoplay = ""
330+
301331
[node name="player" type="Sprite" parent="."]
302332

303333
transform/pos = Vector2( 266, 332 )
@@ -318,6 +348,19 @@ percent_visible = 1.0
318348
lines_skipped = 0
319349
max_lines_visible = -1
320350

351+
[node name="Sprite 2" type="Sprite" parent="."]
352+
353+
transform/pos = Vector2( 404.321, 88.4453 )
354+
texture = ExtResource( 1 )
355+
356+
[node name="TreeNode" type="Node" parent="Sprite 2"]
357+
358+
script/script = ExtResource( 2 )
359+
__meta__ = {
360+
"_editor_icon": ExtResource( 3 )
361+
}
362+
resource = ExtResource( 5 )
363+
321364
[node name="dialog_manager" type="Node" parent="."]
322365

323366
script/script = ExtResource( 6 )
@@ -329,5 +372,22 @@ script/script = ExtResource( 6 )
329372
margin/right = 0.0
330373
margin/bottom = 0.0
331374

375+
[node name="run_dlg_1_btn" type="Button" parent="."]
376+
377+
focus/ignore_mouse = false
378+
focus/stop_mouse = true
379+
size_flags/horizontal = 2
380+
size_flags/vertical = 2
381+
margin/left = 82.0
382+
margin/top = 135.0
383+
margin/right = 172.0
384+
margin/bottom = 155.0
385+
toggle_mode = false
386+
enabled_focus_mode = 2
387+
shortcut = null
388+
text = "Run dialog 1"
389+
flat = false
390+
script/script = ExtResource( 8 )
391+
332392

333393
[editable path="dialog_manager/option_chooser"]

run_dialog.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ extends Button
66

77
func _ready():
88
print(get_tree().get_root().get_node("dialog_manager"))
9-
connect("pressed", get_node("../../dialog_manager"), "execute_dialog", [self.get_parent()])
9+
connect("pressed", get_node("../dialog_manager"), "execute_dialog", [get_node("../Sprite")])
1010

0 commit comments

Comments
 (0)