Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
fix(conditional) add choice uuid and clean dialogue on disconnection
Browse files Browse the repository at this point in the history
  • Loading branch information
Levrault committed Dec 30, 2020
1 parent e1f8c5c commit dd2bb2d
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 12 deletions.
8 changes: 4 additions & 4 deletions assets/examples/example.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ files=[ {
"name": "example.json",
"path": "/home/luc/Devs/levrault-dialogue-editor/assets/examples/example.json"
}, {
"name": "t.json",
"path": "/home/luc/Devs/levrault-dialogue-editor/t.json"
"name": "test.json",
"path": "/home/luc/Devs/levrault-dialogue-editor/test.json"
} ]

[cache]

last_opened_file={
"name": "t.json",
"path": "/home/luc/Devs/levrault-dialogue-editor/t.json"
"name": "example.json",
"path": "/home/luc/Devs/levrault-dialogue-editor/assets/examples/example.json"
}
Binary file modified packages/banner.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/banner.jpg~
Binary file not shown.
Binary file modified packages/banner.kra
Binary file not shown.
Binary file added packages/banner.kra~
Binary file not shown.
6 changes: 6 additions & 0 deletions src/Editor/GraphEditor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ func _on_Connection_request(from: String, from_slot: int, to: String, to_slot: i
from_node.right_choice_connection = to
to_node.left_conditions_connection.append(from)
to_node.values.__editor["parent"] = from_node.uuid
to_node.values.data["uuid"] = to
connect_node(from, from_slot, to, to_slot)
Events.emit_signal("condition_to_choice_relation_created", from_node.uuid, to_node.uuid)
return
Expand Down Expand Up @@ -392,15 +393,20 @@ func _on_Disconnection_request(from: String, from_slot: int, to: String, to_slot
from_node.right_dialogue_connection = ""
to_node.left_condition_connection = ""
disconnect_node(from, from_slot, to, to_slot)
Events.emit_signal("condition_to_dialogue_relation_deleted", from)
return

# CONDITIONS -- CHOICE
if from_node.TYPE == Editor.Type.condition and to_node.TYPE == Editor.Type.choice:
# remove choice from linked dialogue
from_node.right_choice_connection = ""
# clear choice
to_node.left_conditions_connection.erase(from)
to_node.values.__editor.erase("parent")
to_node.values.data.erase("uuid")

disconnect_node(from, from_slot, to, to_slot)
Events.emit_signal("condition_to_choice_relation_deleted", from, to)
return


Expand Down
13 changes: 10 additions & 3 deletions src/Nodes/Choice/ChoiceNode.gd
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
# Choices are multiple answer/choice/selectables potionhs that the player can choose.
# They can be conditionned, like a certain choice won't be available if conditions aren't met.
# Conditions should prevent to duplicate multiple dialogue and made a more readable tree.
# Conditions should prevent to duplicate multiple dialogue and made a more readable tree. When
# a condition is set, a conditions array is pointing to the choice uuid.
#
# Generated json
# "choices": [
# {
# "text": {
# "uuid": "choice uuid"
# "en": "c1",
# "fr": ""
# },
# "conditions": [],
# "next": ""
# },
# { "text": { "en": "c2", "fr": "" }, "next": "" }
# ]
# ],
# "conditions": [
# {
# "has_meet": { "value": true, "operator": "equal", "type": "boolean" },
# "next": "choice uuid"
# }
# ],
extends GraphEditorNode

const TYPE = Editor.Type.choice
Expand Down
1 change: 0 additions & 1 deletion src/Preview/Timeline.gd
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ func _create_timeline(dialogue: Dictionary, uuid := "") -> void:

var next := ""
var default_next := ""
var can_not_predicate := false

if dialogue.has("conditions") and not dialogue.has("choices"):
var conditions = dialogue.conditions.duplicate(true)
Expand Down
6 changes: 3 additions & 3 deletions src/WorkspaceView/WorkspaceItem.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ __meta__ = {
[node name="Button" parent="." instance=ExtResource( 2 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 193.0
margin_right = 39.0
margin_bottom = 24.0
size_flags_horizontal = 3
icon = ExtResource( 4 )
Expand All @@ -32,8 +32,8 @@ script = ExtResource( 1 )
[node name="WorkspaceItemMenuButton" parent="." instance=ExtResource( 6 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 197.0
margin_right = 225.0
margin_left = 43.0
margin_right = 71.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 14, 12 )
script = ExtResource( 7 )
2 changes: 1 addition & 1 deletion src/WorkspaceView/WorkspaceViewFileContainer.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extends VBoxContainer

const MAX_NAME_SIZE := 25
const MAX_NAME_SIZE := 23

var workspace_item_scene := preload("res://src/WorkspaceView/WorkspaceItem.tscn")

Expand Down

0 comments on commit dd2bb2d

Please sign in to comment.