Skip to content

Commit 8a0fe64

Browse files
committed
Split up main processing and get main translation support working
1 parent 763c454 commit 8a0fe64

35 files changed

+1311
-458
lines changed

addons/parley/components/default_balloon.gd

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,12 @@ func start(p_ctx: ParleyContext, p_dialogue_sequence_ast: ParleyDialogueSequence
4040
is_waiting_for_input = false
4141
ctx = p_ctx
4242
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
43+
# TODO: remove
44+
ctx.start_of_run = true
45+
var run_result: ParleyRunResult = await ParleyDialogueSequenceAst.run(ctx, dialogue_sequence_ast, p_start_node if p_start_node else null)
46+
current_node_asts = run_result.node_asts
47+
dialogue_sequence_ast = run_result.dialogue_sequence
48+
run_result.free() # Needed to ensure that everything is correctly freed up at exit
5549

5650

5751
## Process the next Nodes
@@ -83,31 +77,6 @@ func _set_current_node_asts(p_current_node_asts: Array[ParleyNodeAst]) -> void:
8377
await ready
8478

8579
balloon.show()
86-
# TODO: remove
87-
# current_node_asts = []
88-
# for node_ast: ParleyNodeAst in p_current_node_asts:
89-
# # TODO: add a resolve method to each node
90-
# var resolved_node_ast: ParleyNodeAst
91-
# if node_ast is ParleyDialogueNodeAst:
92-
# var dialogue_node_ast: ParleyDialogueNodeAst = node_ast
93-
# var resolved_text: String = dialogue_sequence_ast.resolve_value(ctx, dialogue_node_ast.text, true, dialogue_node_ast, 'text')
94-
# resolved_node_ast = ParleyDialogueNodeAst.new(
95-
# dialogue_node_ast.id,
96-
# dialogue_node_ast.position,
97-
# dialogue_node_ast.character,
98-
# resolved_text,
99-
# )
100-
# elif node_ast is ParleyDialogueOptionNodeAst:
101-
# var dialogue_option_node_ast: ParleyDialogueOptionNodeAst = node_ast
102-
# var resolved_text: String = dialogue_sequence_ast.resolve_value(ctx, dialogue_option_node_ast.text, true, dialogue_option_node_ast, 'text')
103-
# resolved_node_ast = ParleyDialogueOptionNodeAst.new(
104-
# dialogue_option_node_ast.id,
105-
# dialogue_option_node_ast.position,
106-
# dialogue_option_node_ast.character,
107-
# resolved_text,
108-
# )
109-
# if resolved_node_ast:
110-
# current_node_asts.append(resolved_node_ast)
11180
current_node_asts = p_current_node_asts
11281
var current_children: Array[Node] = balloon_container.get_children()
11382
var first_node: ParleyNodeAst = current_node_asts.front()

addons/parley/constants.gd

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,58 @@
22

33
@tool
44

5+
56
#region General
67
# TODO: figure out better way of getting this version as it is duplicated
7-
const VERSION: String = "2.1.0"
8-
const AST_VERSION: String = "1.1.0"
9-
const USER_CONFIG_PATH: String = "user://parley_user_config.json"
8+
const VERSION: StringName = &"2.1.0"
9+
const AST_VERSION: StringName = &"1.1.0"
10+
const USER_CONFIG_PATH: StringName = &"user://parley_user_config.json"
1011
#endregion
1112

13+
1214
#region Parley Plugin
13-
const PLUGIN_NAME: String = "Parley"
14-
const PARLEY_PLUGIN_METADATA: String = "ParleyPlugin"
15-
const PARLEY_RUNTIME_AUTOLOAD: String = "Parley"
16-
const PARLEY_MANAGER_SINGLETON: String = "ParleyManager"
17-
const PARLEY_RUNTIME_SINGLETON: String = "ParleyRuntime"
15+
const PLUGIN_NAME: StringName = &"Parley"
16+
const PARLEY_PLUGIN_METADATA: StringName = &"ParleyPlugin"
17+
const PARLEY_RUNTIME_AUTOLOAD: StringName = &"Parley"
18+
const PARLEY_MANAGER_SINGLETON: StringName = &"ParleyManager"
19+
const PARLEY_RUNTIME_SINGLETON: StringName = &"ParleyRuntime"
1820
#endregion
1921

22+
2023
#region Editor
2124
# User settings
22-
const EDITOR_CURRENT_DIALOGUE_SEQUENCE_PATH: String = "parley/editor/current_dialogue_sequence_path"
25+
const EDITOR_CURRENT_DIALOGUE_SEQUENCE_PATH: StringName = &"parley/editor/current_dialogue_sequence_path"
2326
#endregion
2427

28+
2529
#region Dialogue
2630
# Project settings
27-
const DIALOGUE_BALLOON_PATH: String = "parley/dialogue/dialogue_balloon_path"
31+
const DIALOGUE_BALLOON_PATH: StringName = &"parley/dialogue/dialogue_balloon_path"
2832
#endregion
2933

34+
3035
#region Internationalisation
3136
# Project settings
32-
const TRANSLATION_MODE: String = "parley/translations/mode"
33-
const TRANSLATIONS_POT_FILES: String = "internationalization/locale/translations_pot_files"
37+
const TRANSLATION_MODE: StringName = &"parley/translations/mode"
38+
const TRANSLATION_FILES: StringName = &"internationalization/locale/translations"
39+
const TRANSLATIONS_POT_FILES: StringName = &"internationalization/locale/translations_pot_files"
3440
#endregion
3541

42+
3643
#region Stores
3744
# Project settings
38-
const ACTION_STORE_PATH: String = "parley/stores/action_store_path"
39-
const CHARACTER_STORE_PATH: String = "parley/stores/character_store_path"
40-
const FACT_STORE_PATH: String = "parley/stores/fact_store_path"
45+
const ACTION_STORE_PATH: StringName = &"parley/stores/action_store_path"
46+
const CHARACTER_STORE_PATH: StringName = &"parley/stores/character_store_path"
47+
const FACT_STORE_PATH: StringName = &"parley/stores/fact_store_path"
4148
#endregion
4249

50+
4351
#region Test Dialogue Sequence
4452
# Project settings
45-
const TEST_DIALOGUE_SEQUENCE_TEST_SCENE_PATH: String = "parley/test_dialogue_sequence/test_scene_path"
53+
const TEST_DIALOGUE_SEQUENCE_TEST_SCENE_PATH: StringName = &"parley/test_dialogue_sequence/test_scene_path"
4654
# User settings
47-
const TEST_DIALOGUE_SEQUENCE_IS_RUNNING_DIALOGUE_TEST: String = "parley/test_dialogue_sequence/is_running_test_scene"
48-
const TEST_DIALOGUE_SEQUENCE_DIALOGUE_AST_RESOURCE_PATH: String = "parley/test_dialogue_sequence/dialogue_ast_resource_path"
49-
const TEST_DIALOGUE_SEQUENCE_FROM_START: String = "parley/test_dialogue_sequence/from_start"
50-
const TEST_DIALOGUE_SEQUENCE_START_NODE_ID: String = "parley/test_dialogue_sequence/start_node_id"
55+
const TEST_DIALOGUE_SEQUENCE_IS_RUNNING_DIALOGUE_TEST: StringName = &"parley/test_dialogue_sequence/is_running_test_scene"
56+
const TEST_DIALOGUE_SEQUENCE_DIALOGUE_AST_RESOURCE_PATH: StringName = &"parley/test_dialogue_sequence/dialogue_ast_resource_path"
57+
const TEST_DIALOGUE_SEQUENCE_FROM_START: StringName = &"parley/test_dialogue_sequence/from_start"
58+
const TEST_DIALOGUE_SEQUENCE_START_NODE_ID: StringName = &"parley/test_dialogue_sequence/start_node_id"
5159
#endregion
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[remap]
2+
3+
importer="csv_translation"
4+
type="Translation"
5+
uid="uid://wc2udkydnpmq"
6+
7+
[deps]
8+
9+
files=["res://addons/parley/locale/tooltip_translations.en.translation"]
10+
11+
source_file="res://addons/parley/locale/tooltip_translations.csv"
12+
dest_files=["res://addons/parley/locale/tooltip_translations.en.translation"]
13+
14+
[params]
15+
16+
compress=true
17+
delimiter=0

addons/parley/main_panel.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ func _on_graph_view_node_deselected(_node: Node) -> void:
278278

279279
#region BUTTONS
280280
func _on_open_dialog_file_selected(path: String) -> void:
281-
dialogue_ast = load(path)
281+
dialogue_ast = ResourceLoader.load(path, 'ParleyDialogueSequenceAst')
282282
# TODO: emit as a signal and handle in the plugin
283283
if parley_manager:
284284
parley_manager.set_current_dialogue_sequence(path)
@@ -549,7 +549,7 @@ func _on_jump_node_editor_action_node_changed(id: String, dialogue_sequence_ast_
549549
# Graph View
550550
# TODO: move into Graph View
551551
var jump_node: ParleyJumpNode = parley_graph_node_variant
552-
jump_node.dialogue_sequence_ast = load(jump_node_ast.dialogue_sequence_ast_ref) if ResourceLoader.exists(jump_node_ast.dialogue_sequence_ast_ref) else ParleyDialogueSequenceAst.new()
552+
jump_node.dialogue_sequence_ast = ResourceLoader.load(jump_node_ast.dialogue_sequence_ast_ref, 'ParleyDialogueSequenceAst') if ResourceLoader.exists(jump_node_ast.dialogue_sequence_ast_ref) else ParleyDialogueSequenceAst.new()
553553

554554

555555
func _on_group_node_editor_group_node_changed(id: String, group_name: String, colour: Color) -> void:

addons/parley/models/dialogue_node_ast.gd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ class_name ParleyDialogueNodeAst extends ParleyNodeAst
1414
@export_multiline var text: String
1515

1616

17+
## The translation id for the text field of the Dialogue Node AST.
18+
## Example: "world_dialect__I_need_some_coffee"
19+
@export var text_translation_key: String
20+
21+
1722
## Create a new instance of a Dialogue Node AST.
1823
## Example: ParleyDialogueNodeAst.new("1", Vector2.ZERO, "Alice", "I need some coffee.")
1924
func _init(

addons/parley/models/dialogue_option_node_ast.gd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ class_name ParleyDialogueOptionNodeAst extends ParleyNodeAst
1414
@export var text: String
1515

1616

17+
## The translation id for the text field of the Dialogue Node AST.
18+
## Example: "world_dialect__I_need_some_coffee"
19+
@export var text_translation_key: String
20+
21+
1722
## Create a new instance of a Dialogue Option Node AST.
1823
## Example: ParleyDialogueOptionNodeAst.new("1", Vector2.ZERO, "Alice", "Slurp some coffee.")
1924
func _init(

0 commit comments

Comments
 (0)