Skip to content

Commit 75000b9

Browse files
authored
Merge pull request #13 from bisterix-studio/jump-node
Add Jump Nodes and future proof some interfaces
2 parents fcaed46 + 9431950 commit 75000b9

File tree

136 files changed

+2357
-527
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+2357
-527
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"paletteuse",
2828
"printerr",
2929
"printwarn",
30+
"Rect",
3031
"stylebox",
3132
"titlebar",
3233
"Treeware"

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ Write your Dialogue Sequences by defining the graph for your Dialogue Sequence
1111
which are backed by a well-defined Dialogue AST for easy management and
1212
integration within your game.
1313

14-
You can install it via the Asset Library or
14+
You can install it via the
15+
[Asset Library](https://godotengine.org/asset-library/asset/4132) or
1516
[downloading a copy](https://github.com/bisterix-studio/parley/archive/refs/heads/main.zip)
1617
from GitHub.
1718

@@ -22,13 +23,12 @@ from GitHub.
2223

2324
## Table of contents
2425

25-
- [Table of contents](#table-of-contents)
2626
- [Features](#features)
27+
- [Upcoming Features](#upcoming-features)
2728
- [Installation](#installation)
2829
- [Documentation](#documentation)
2930
- [Support](#support)
3031
- [Known Issues and Troubleshooting](#known-issues-and-troubleshooting)
31-
- [Parts of Godot are unresponsive in MacOS after close a test dialogue scene via the close button](#parts-of-godot-are-unresponsive-in-macos-after-close-a-test-dialogue-scene-via-the-close-button)
3232
- [Licence](#licence)
3333
- [Contributions](#contributions)
3434

@@ -37,24 +37,25 @@ Installation Features Examples Support Useful links Licence Contributions
3737
## Features
3838

3939
- An easy-to-use and well-defined Graph Editor
40-
- A wide variety of nodes for maximum flexibility and creativity:
40+
- A wide variety of Nodes for maximum flexibility and creativity:
4141
- [Dialogue](https://parley.bisterixstudio.com/docs/nodes/dialogue-node)
4242
- [Dialogue Option](https://parley.bisterixstudio.com/docs/nodes/dialogue-option-node)
4343
- [Condition](https://parley.bisterixstudio.com/docs/nodes/condition-node)
4444
- [Match](https://parley.bisterixstudio.com/docs/nodes/match-node)
4545
- [Action](https://parley.bisterixstudio.com/docs/nodes/action-node)
46+
- [Jump](https://parley.bisterixstudio.com/docs/nodes/jump-node)
4647
- [Group](https://parley.bisterixstudio.com/docs/nodes/group-node)
4748
- [Start](https://parley.bisterixstudio.com/docs/nodes/start-node)
4849
- [End](https://parley.bisterixstudio.com/docs/nodes/end-node)
49-
- Creation of connections between nodes to easily see the flow of your dialogue
50+
- Creation of connections between Nodes to easily see the flow of your dialogue
5051
sequence
5152
- Easy testing of your dialogue at any stage in the sequence
5253
- Well-defined Dialogue AST for easy review and management of Dialogue Sequences
5354
- Character store for management of characters in Dialogue and Dialogue Options
5455
- Action store for management of actions for use with Action nodes
5556
- Fact store for management of facts for use with Condition and Match nodes
5657
- An out of the box dialogue balloon to get started straight away
57-
- Easy management of your Dialogue Sequences, including node filtering
58+
- Easy management of your Dialogue Sequences, including Node filtering
5859
- Export your Dialogue passages to CSV
5960

6061
## Upcoming Features
@@ -64,7 +65,6 @@ ideas, please don't hesitate to
6465
[get-in-touch](https://github.com/bisterix-studio/parley/issues).
6566

6667
- Translation support
67-
- Jump Nodes
6868
- Dialogue text expressions
6969

7070
## Installation

actions/advance_time_action.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
extends ParleyActionInterface
44

5-
func execute(_ctx: Dictionary, values: Array) -> int:
5+
func run(_ctx: ParleyContext, values: Array) -> int:
66
print("Advancing time by %s" % [values[0]])
77
return OK

actions/found_clue.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
extends ParleyActionInterface
44

5-
func execute(_ctx: Dictionary, values: Array) -> int:
5+
func run(_ctx: ParleyContext, values: Array) -> int:
66
print("Found clue: %s" % [values[0]])
77
return OK

addons/parley/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ Write your Dialogue Sequences by defining the graph for your Dialogue Sequence
1111
which are backed by a well-defined Dialogue AST for easy management and
1212
integration within your game.
1313

14-
You can install it via the Asset Library or
14+
You can install it via the
15+
[Asset Library](https://godotengine.org/asset-library/asset/4132) or
1516
[downloading a copy](https://github.com/bisterix-studio/parley/archive/refs/heads/main.zip)
1617
from GitHub.
1718

@@ -22,13 +23,12 @@ from GitHub.
2223

2324
## Table of contents
2425

25-
- [Table of contents](#table-of-contents)
2626
- [Features](#features)
27+
- [Upcoming Features](#upcoming-features)
2728
- [Installation](#installation)
2829
- [Documentation](#documentation)
2930
- [Support](#support)
3031
- [Known Issues and Troubleshooting](#known-issues-and-troubleshooting)
31-
- [Parts of Godot are unresponsive in MacOS after close a test dialogue scene via the close button](#parts-of-godot-are-unresponsive-in-macos-after-close-a-test-dialogue-scene-via-the-close-button)
3232
- [Licence](#licence)
3333
- [Contributions](#contributions)
3434

@@ -37,24 +37,25 @@ Installation Features Examples Support Useful links Licence Contributions
3737
## Features
3838

3939
- An easy-to-use and well-defined Graph Editor
40-
- A wide variety of nodes for maximum flexibility and creativity:
40+
- A wide variety of Nodes for maximum flexibility and creativity:
4141
- [Dialogue](https://parley.bisterixstudio.com/docs/nodes/dialogue-node)
4242
- [Dialogue Option](https://parley.bisterixstudio.com/docs/nodes/dialogue-option-node)
4343
- [Condition](https://parley.bisterixstudio.com/docs/nodes/condition-node)
4444
- [Match](https://parley.bisterixstudio.com/docs/nodes/match-node)
4545
- [Action](https://parley.bisterixstudio.com/docs/nodes/action-node)
46+
- [Jump](https://parley.bisterixstudio.com/docs/nodes/jump-node)
4647
- [Group](https://parley.bisterixstudio.com/docs/nodes/group-node)
4748
- [Start](https://parley.bisterixstudio.com/docs/nodes/start-node)
4849
- [End](https://parley.bisterixstudio.com/docs/nodes/end-node)
49-
- Creation of connections between nodes to easily see the flow of your dialogue
50+
- Creation of connections between Nodes to easily see the flow of your dialogue
5051
sequence
5152
- Easy testing of your dialogue at any stage in the sequence
5253
- Well-defined Dialogue AST for easy review and management of Dialogue Sequences
5354
- Character store for management of characters in Dialogue and Dialogue Options
5455
- Action store for management of actions for use with Action nodes
5556
- Fact store for management of facts for use with Condition and Match nodes
5657
- An out of the box dialogue balloon to get started straight away
57-
- Easy management of your Dialogue Sequences, including node filtering
58+
- Easy management of your Dialogue Sequences, including Node filtering
5859
- Export your Dialogue passages to CSV
5960

6061
## Upcoming Features
@@ -64,7 +65,6 @@ ideas, please don't hesitate to
6465
[get-in-touch](https://github.com/bisterix-studio/parley/issues).
6566

6667
- Translation support
67-
- Jump Nodes
6868
- Dialogue text expressions
6969

7070
## Installation

addons/parley/assets/Jump.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://cc4snig105irh"
6+
path="res://.godot/imported/Jump.svg-4c8ca648055ae62dca35610bd35b9941.ctex"
7+
metadata={
8+
"has_editor_variant": true,
9+
"vram_texture": false
10+
}
11+
12+
[deps]
13+
14+
source_file="res://addons/parley/assets/Jump.svg"
15+
dest_files=["res://.godot/imported/Jump.svg-4c8ca648055ae62dca35610bd35b9941.ctex"]
16+
17+
[params]
18+
19+
compress/mode=0
20+
compress/high_quality=false
21+
compress/lossy_quality=0.7
22+
compress/hdr_compression=1
23+
compress/normal_map=0
24+
compress/channel_pack=0
25+
mipmaps/generate=false
26+
mipmaps/limit=-1
27+
roughness/mode=0
28+
roughness/src_normal=""
29+
process/fix_alpha_border=true
30+
process/premult_alpha=false
31+
process/normal_map_invert_y=false
32+
process/hdr_as_srgb=false
33+
process/hdr_clamp_exposure=false
34+
process/size_limit=0
35+
detect_3d/compress_to=1
36+
svg/scale=1.0
37+
editor/scale_with_editor_scale=true
38+
editor/convert_colors_with_editor_theme=true

addons/parley/components/condition/condition_node.gd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func select_from_slot(from_slot: int, _colour: Color = Color.CHARTREUSE) -> void
4141
1:
4242
slot = 2
4343
_:
44-
ParleyUtils.log.info("Unknown from slot: %s" % [from_slot])
44+
print_rich(ParleyUtils.log.info_msg("Unknown from slot: %s" % [from_slot]))
4545
return
4646
set_slot_color_right(slot, Color.CORNFLOWER_BLUE)
4747

@@ -58,7 +58,7 @@ func deselect_from_slot(from_slot: int, colour: Color = null_colour) -> void:
5858
slot = 2
5959
slot_colour = colour if colour != null_colour else Color.FIREBRICK
6060
_:
61-
ParleyUtils.log.info("Unknown from slot: %s" % [from_slot])
61+
print_rich(ParleyUtils.log.info_msg("Unknown from slot: %s" % [from_slot]))
6262
return
6363
set_slot_color_right(slot, slot_colour)
6464

@@ -72,6 +72,6 @@ func get_from_slot_colour(from_slot: int) -> Color:
7272
1:
7373
slot = 2
7474
_:
75-
ParleyUtils.log.info("Unknown from slot: %s" % [from_slot])
75+
print_rich(ParleyUtils.log.info_msg("Unknown from slot: %s" % [from_slot]))
7676
return Color.CHARTREUSE
7777
return get_slot_color_right(slot)

addons/parley/components/condition/condition_node_editor.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func _on_condition_removed(condition_id: String) -> void:
146146
var index: int = int(condition_id)
147147
var new_conditions: Array = conditions.duplicate(true)
148148
if index < 0 or index >= new_conditions.size():
149-
ParleyUtils.log.error("Unable to remove Condition from Condition Node (id:%s, index:%i)" % [id, index])
149+
push_error(ParleyUtils.log.error_msg("Unable to remove Condition from Condition Node (id:%s, index:%i)" % [id, index]))
150150
return
151151
new_conditions.remove_at(int(condition_id))
152152
conditions = new_conditions

addons/parley/components/default_balloon.gd

Lines changed: 52 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,57 @@ const next_dialogue_button: PackedScene = preload('./next_dialogue_button.tscn')
1616
@onready var balloon_container: VBoxContainer = %BalloonContainer
1717

1818

19-
var ctx: Dictionary = {}
20-
var dialogue_ast: ParleyDialogueSequenceAst
19+
var ctx: ParleyContext = ParleyContext.new()
20+
var dialogue_sequence_ast: ParleyDialogueSequenceAst
2121
var dialogue_history: Array = []
22-
## Temporary game states
23-
var temporary_game_states: Array = []
2422
## See if we are waiting for the player
2523
var is_waiting_for_input: bool = false
2624
var previous_node_ast: ParleyNodeAst = null
2725
var current_node_asts: Array[ParleyNodeAst]: set = _set_current_node_asts
2826

2927

28+
#region LIFECYCLE
29+
func _exit_tree() -> void:
30+
# Ensure the ctx is fully cleaned up
31+
if ctx and not ctx.is_queued_for_deletion():
32+
ctx.free()
33+
#endregion
34+
35+
36+
#region PROCESSING
37+
## Start some dialogue
38+
func start(p_ctx: ParleyContext, p_dialogue_sequence_ast: ParleyDialogueSequenceAst, p_start_node: ParleyNodeAst = null) -> void:
39+
balloon.show()
40+
is_waiting_for_input = false
41+
ctx = p_ctx
42+
dialogue_sequence_ast = p_dialogue_sequence_ast
43+
if p_start_node is ParleyDialogueNodeAst or p_start_node is ParleyDialogueOptionNodeAst:
44+
current_node_asts = [p_start_node]
45+
elif p_start_node:
46+
var run_result: ParleyRunResult = await ParleyDialogueSequenceAst.run(ctx, dialogue_sequence_ast, p_start_node)
47+
current_node_asts = run_result.node_asts
48+
dialogue_sequence_ast = run_result.dialogue_sequence
49+
run_result.free() # Needed to ensure that everything is correctly freed up at exit
50+
else:
51+
var run_result: ParleyRunResult = await ParleyDialogueSequenceAst.run(ctx, dialogue_sequence_ast)
52+
current_node_asts = run_result.node_asts
53+
dialogue_sequence_ast = run_result.dialogue_sequence
54+
run_result.free() # Needed to ensure that everything is correctly freed up at exit
55+
56+
57+
## Process the next Nodes
58+
func next(current_node_ast: ParleyNodeAst) -> void:
59+
# Probably want to emit at this point? Or maybe earlier
60+
dialogue_history.append(current_node_ast)
61+
previous_node_ast = current_node_ast
62+
var run_result: ParleyRunResult = await ParleyDialogueSequenceAst.run(ctx, dialogue_sequence_ast, current_node_ast)
63+
current_node_asts = run_result.node_asts
64+
dialogue_sequence_ast = run_result.dialogue_sequence
65+
run_result.free() # Needed to ensure that everything is correctly freed up at exit
66+
#endregion
67+
68+
69+
#region SETTERS
3070
func _set_current_node_asts(p_current_node_asts: Array[ParleyNodeAst]) -> void:
3171
is_waiting_for_input = false
3272
balloon.focus_mode = Control.FOCUS_ALL
@@ -46,7 +86,7 @@ func _set_current_node_asts(p_current_node_asts: Array[ParleyNodeAst]) -> void:
4686
current_node_asts = p_current_node_asts
4787
var current_children: Array[Node] = balloon_container.get_children()
4888
var first_node: ParleyNodeAst = p_current_node_asts.front()
49-
var next_children: Array[Node] = _build_next_children(current_children, first_node)
89+
var next_children: Array[Node] = await _build_next_children(current_children, first_node)
5090
if next_children.size() == 0:
5191
return
5292

@@ -59,16 +99,18 @@ func _set_current_node_asts(p_current_node_asts: Array[ParleyNodeAst]) -> void:
5999
if not next_button.is_node_ready():
60100
await next_button.ready
61101
next_button.grab_focus()
102+
#endregion
62103

63104

105+
#region RENDERERS
64106
func _build_next_children(current_children: Array[Node], current_node_ast: ParleyNodeAst) -> Array[Node]:
65107
var next_children: Array[Node] = []
66108
if is_instance_of(current_node_ast, ParleyDialogueNodeAst) and not (current_node_ast as ParleyDialogueNodeAst).text.is_empty():
67-
next_children.append_array(_build_next_dialogue_children(current_node_ast))
109+
next_children.append_array(await _build_next_dialogue_children(current_node_ast))
68110
elif current_node_asts.filter(func(_n: ParleyNodeAst) -> bool: return is_instance_of(current_node_ast, ParleyDialogueOptionNodeAst)).size() == current_node_asts.size():
69111
next_children.append_array(_build_next_dialogue_option_children(current_children))
70112
else:
71-
ParleyUtils.log.error("Invalid dialogue balloon nodes. Stopping processing. Check whether the Dialogue and Dialogue Option Nodes are fully populated with data.")
113+
push_error(ParleyUtils.log.error_msg("Invalid dialogue balloon nodes. Stopping processing. Check whether the Dialogue and Dialogue Option Nodes are fully populated with data."))
72114
return []
73115
return next_children
74116

@@ -90,7 +132,7 @@ func _build_next_dialogue_children(current_node_ast: ParleyNodeAst) -> Array[Nod
90132
next_dialogue_container.set_meta('ast', current_node_ast)
91133
next_children.append(next_dialogue_container)
92134
var next_dialogue_button_control: ParleyNextDialogueButton = next_dialogue_button.instantiate()
93-
if dialogue_ast.is_at_end(ctx, current_node_ast):
135+
if await dialogue_sequence_ast.is_at_end(ctx, current_node_ast):
94136
next_dialogue_button_control.text = 'Leave'
95137
next_children.append(next_dialogue_button_control)
96138
return next_children
@@ -155,6 +197,7 @@ func _create_horizontal_separator(sibling_above: Control) -> Node:
155197
horizontal_separator.add_theme_constant_override('margin_bottom', 0)
156198
horizontal_separator.add_child(HSeparator.new())
157199
return horizontal_separator
200+
#endregion
158201

159202

160203
#region ACTIONS
@@ -216,30 +259,7 @@ func _ready() -> void:
216259
func _unhandled_input(_event: InputEvent) -> void:
217260
# Only the balloon is allowed to handle input while it's showing
218261
get_viewport().set_input_as_handled()
219-
220-
221-
# TODO: add a context param
222-
## Start some dialogue
223-
func start(_ctx: Dictionary, _dialogue_ast: ParleyDialogueSequenceAst, start_node: ParleyNodeAst = null) -> void:
224-
balloon.show()
225-
temporary_game_states = [self]
226-
is_waiting_for_input = false
227-
ctx = _ctx
228-
dialogue_ast = _dialogue_ast
229-
if start_node is ParleyDialogueNodeAst or start_node is ParleyDialogueOptionNodeAst:
230-
current_node_asts = [start_node]
231-
elif start_node:
232-
current_node_asts = dialogue_ast.process_next(ctx, start_node)
233-
else:
234-
current_node_asts = dialogue_ast.process_next(ctx)
235-
236-
237-
## Process the next Nodes
238-
func next(current_node_ast: ParleyNodeAst) -> void:
239-
# Probably want to emit at this point? Or maybe earlier
240-
dialogue_history.append(current_node_ast)
241-
previous_node_ast = current_node_ast
242-
current_node_asts = dialogue_ast.process_next(ctx, current_node_ast)
262+
#endregion
243263

244264

245265
#region Signals

0 commit comments

Comments
 (0)