Skip to content

Commit

Permalink
Fix #9
Browse files Browse the repository at this point in the history
  • Loading branch information
StraToN committed Oct 2, 2017
1 parent 128138d commit f96f5cd
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 34 deletions.
7 changes: 3 additions & 4 deletions addons/tree-tools/Scripts/treetool.gd
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ func _load_data( path ):
file.close()

# parse json
var jsonData = {}
jsonData.parse_json(jsonString)
load_from_json(jsonData)
load_from_json(jsonString)

# Helper function to clear the GraphEdit
func clear():
Expand All @@ -94,6 +92,7 @@ func load_from_json(jsonDataString):
load_from_dict(jsonData)
else:
print("ERROR: invalid json string.")
print(jsonDataString)

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

Expand Down
11 changes: 1 addition & 10 deletions addons/tree-tools/resources/treenode_resource.tres
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,5 @@
[resource]

script/script = ExtResource( 1 )
dict = {
"connections": [ ],
"nodes": [ {
"id": "node1",
"name": "start",
"type": "startnode",
"x": 0,
"y": 0
} ]
}
dict = null

98 changes: 79 additions & 19 deletions mainscene.tscn
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[gd_scene load_steps=9 format=1]
[gd_scene load_steps=12 format=1]

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

[sub_resource type="Resource" id=1]

Expand Down Expand Up @@ -236,6 +237,40 @@ dict = {
} ]
}

[sub_resource type="Animation" id=2]

resource/name = "reset"
length = 0.01
loop = false
step = 0.1
tracks/0/type = "value"
tracks/0/path = NodePath(".:transform/pos")
tracks/0/interp = 1
tracks/0/imported = false
tracks/0/keys = {
"times": FloatArray( 0 ),
"transitions": FloatArray( 1 ),
"update": 0,
"values": [ Vector2( 122.583, 90.4986 ) ]
}

[sub_resource type="Animation" id=3]

resource/name = "talk"
length = 1.0
loop = true
step = 0.1
tracks/0/type = "value"
tracks/0/path = NodePath(".:transform/pos")
tracks/0/interp = 1
tracks/0/imported = false
tracks/0/keys = {
"times": FloatArray( 0, 0.5, 1 ),
"transitions": FloatArray( 1, 1, 1 ),
"update": 0,
"values": [ Vector2( 122.583, 90.4986 ), Vector2( 122.583, 73.351 ), Vector2( 122.583, 90.4986 ) ]
}

[node name="Node2D" type="Node2D"]

[node name="Sprite" type="Sprite" parent="."]
Expand Down Expand Up @@ -266,23 +301,6 @@ percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1

[node name="run_dlg_1_btn" type="Button" parent="Sprite"]

focus/ignore_mouse = false
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = -40.583
margin/top = 44.5014
margin/right = 49.417
margin/bottom = 64.5014
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
text = "Run dialog 1"
flat = false
script/script = ExtResource( 5 )

[node name="Label" type="Label" parent="Sprite"]

focus/ignore_mouse = true
Expand All @@ -298,6 +316,18 @@ percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1

[node name="anim" type="AnimationPlayer" parent="Sprite"]

playback/process_mode = 1
playback/default_blend_time = 0.0
root/root = NodePath("..")
anims/reset = SubResource( 2 )
anims/talk = SubResource( 3 )
playback/active = true
playback/speed = 1.0
blend_times = [ ]
autoplay = ""

[node name="player" type="Sprite" parent="."]

transform/pos = Vector2( 266, 332 )
Expand All @@ -318,6 +348,19 @@ percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1

[node name="Sprite 2" type="Sprite" parent="."]

transform/pos = Vector2( 404.321, 88.4453 )
texture = ExtResource( 1 )

[node name="TreeNode" type="Node" parent="Sprite 2"]

script/script = ExtResource( 2 )
__meta__ = {
"_editor_icon": ExtResource( 3 )
}
resource = ExtResource( 5 )

[node name="dialog_manager" type="Node" parent="."]

script/script = ExtResource( 6 )
Expand All @@ -329,5 +372,22 @@ script/script = ExtResource( 6 )
margin/right = 0.0
margin/bottom = 0.0

[node name="run_dlg_1_btn" type="Button" parent="."]

focus/ignore_mouse = false
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = 82.0
margin/top = 135.0
margin/right = 172.0
margin/bottom = 155.0
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
text = "Run dialog 1"
flat = false
script/script = ExtResource( 8 )


[editable path="dialog_manager/option_chooser"]
2 changes: 1 addition & 1 deletion run_dialog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ extends Button

func _ready():
print(get_tree().get_root().get_node("dialog_manager"))
connect("pressed", get_node("../../dialog_manager"), "execute_dialog", [self.get_parent()])
connect("pressed", get_node("../dialog_manager"), "execute_dialog", [get_node("../Sprite")])

0 comments on commit f96f5cd

Please sign in to comment.