@@ -12,6 +12,7 @@ const new_file_icon: CompressedTexture2D = preload("./assets/New.svg")
1212const load_file_icon : CompressedTexture2D = preload ("./assets/Load.svg" )
1313const export_icon : CompressedTexture2D = preload ("./assets/Export.svg" )
1414const import_icon : CompressedTexture2D = preload ("./assets/Import.svg" )
15+ const generate_icon : CompressedTexture2D = preload ("./assets/Generate.svg" )
1516const insert_after_icon : CompressedTexture2D = preload ("./assets/InsertAfter.svg" )
1617const dialogue_icon : CompressedTexture2D = preload ("./assets/Dialogue.svg" )
1718const dialogue_option_icon : CompressedTexture2D = preload ("./assets/DialogueOption.svg" )
@@ -235,27 +236,27 @@ func _setup(on_ready: bool = false) -> void:
235236func _setup_file_menu () -> void :
236237 var popup : PopupMenu = file_menu .get_popup ()
237238 popup .clear ()
238- popup .add_icon_item (new_file_icon , "New Dialogue Sequence..." , 0 )
239- popup .add_icon_item (load_file_icon , "Open Dialogue Sequence..." , 1 )
240- popup .add_separator ("Export" )
241- popup .add_icon_item (export_icon , "Export to CSV..." , 2 )
239+ popup .add_icon_item (new_file_icon , & "New Dialogue Sequence..." , 0 )
240+ popup .add_icon_item (load_file_icon , & "Open Dialogue Sequence..." , 1 )
241+ popup .add_separator (& "Export" )
242+ popup .add_icon_item (export_icon , & "Export to CSV..." , 2 )
242243 ParleyUtils .signals .safe_connect (popup .id_pressed , _on_file_id_pressed )
243244
244245
245246## Set up the insert menu
246247func _setup_insert_menu () -> void :
247248 var popup : PopupMenu = insert_menu .get_popup ()
248249 popup .clear ()
249- popup .add_separator ("Dialogue" )
250+ popup .add_separator (& "Dialogue" )
250251 popup .add_icon_item (dialogue_icon , ParleyDialogueSequenceAst .get_type_name (ParleyDialogueSequenceAst .Type .DIALOGUE ), ParleyDialogueSequenceAst .Type .DIALOGUE )
251252 popup .add_icon_item (dialogue_option_icon , ParleyDialogueSequenceAst .get_type_name (ParleyDialogueSequenceAst .Type .DIALOGUE_OPTION ), ParleyDialogueSequenceAst .Type .DIALOGUE_OPTION )
252- popup .add_separator ("Conditions" )
253+ popup .add_separator (& "Conditions" )
253254 popup .add_icon_item (condition_icon , ParleyDialogueSequenceAst .get_type_name (ParleyDialogueSequenceAst .Type .CONDITION ), ParleyDialogueSequenceAst .Type .CONDITION )
254255 popup .add_icon_item (condition_icon , ParleyDialogueSequenceAst .get_type_name (ParleyDialogueSequenceAst .Type .MATCH ), ParleyDialogueSequenceAst .Type .MATCH )
255- popup .add_separator ("Actions" )
256+ popup .add_separator (& "Actions" )
256257 popup .add_icon_item (action_icon , ParleyDialogueSequenceAst .get_type_name (ParleyDialogueSequenceAst .Type .ACTION ), ParleyDialogueSequenceAst .Type .ACTION )
257258 popup .add_icon_item (jump_node_icon , ParleyDialogueSequenceAst .get_type_name (ParleyDialogueSequenceAst .Type .JUMP ), ParleyDialogueSequenceAst .Type .JUMP )
258- popup .add_separator ("Misc" )
259+ popup .add_separator (& "Misc" )
259260 popup .add_icon_item (start_node_icon , ParleyDialogueSequenceAst .get_type_name (ParleyDialogueSequenceAst .Type .START ), ParleyDialogueSequenceAst .Type .START )
260261 popup .add_icon_item (end_node_icon , ParleyDialogueSequenceAst .get_type_name (ParleyDialogueSequenceAst .Type .END ), ParleyDialogueSequenceAst .Type .END )
261262 popup .add_icon_item (group_node_icon , ParleyDialogueSequenceAst .get_type_name (ParleyDialogueSequenceAst .Type .GROUP ), ParleyDialogueSequenceAst .Type .GROUP )
@@ -266,14 +267,20 @@ func _render_translations_menu() -> void:
266267 var popup : PopupMenu = translations_menu .get_popup ()
267268 popup .clear ()
268269
269- popup .add_icon_item (export_icon , "Export Dialogue to CSV..." , 0 )
270- popup .set_item_tooltip (0 , "Export Dialogue Text Translations to CSV" )
270+ popup .add_separator (& "Exports" )
271+ popup .add_icon_item (export_icon , & "Export Dialogue to CSV..." , 0 )
272+ popup .set_item_tooltip (0 , & "Export Dialogue Text Translations to CSV" )
271273
272- popup .add_icon_item (export_icon , "Export Characters to CSV..." , 1 )
273- popup .set_item_tooltip (1 , "Export Character Translations to CSV" )
274+ popup .add_icon_item (export_icon , & "Export Characters to CSV..." , 1 )
275+ popup .set_item_tooltip (1 , & "Export Character Translations to CSV" )
274276
275- popup .add_icon_item (import_icon , "Import Dialogue from CSV..." , 2 )
276- popup .set_item_tooltip (2 , "Import Dialogue Text Translations from CSV" )
277+ popup .add_separator (& "Imports" )
278+ popup .add_icon_item (import_icon , & "Import Dialogue from CSV..." , 2 )
279+ popup .set_item_tooltip (2 , & "Import Dialogue Text Translations from CSV" )
280+
281+ popup .add_separator (& "Generators" )
282+ popup .add_icon_item (generate_icon , & "Generate Text Translation keys..." , 3 )
283+ popup .set_item_tooltip (3 , & "Generate Text Translation keys for Dialogue Sequence Nodes" )
277284
278285 ParleyUtils .signals .safe_connect (popup .id_pressed , _on_translations_menu_id_pressed )
279286#endregion
@@ -351,6 +358,20 @@ func _on_translations_menu_id_pressed(id: int) -> void:
351358 export_modal .render (ParleyExportModal .ExportType .CharacterNameTranslation , ParleyExportModal .FileType .Csv , dialogue_ast )
352359 2 :
353360 import_modal .render (ParleyImportModal .ImportType .DialogueTextTranslation , ParleyImportModal .FileType .Csv , dialogue_ast )
361+ 3 :
362+ if dialogue_ast :
363+ var ast_changed : bool = dialogue_ast .generate_text_translation_keys ()
364+ # TODO: This is currently to make sure that the currently open editor updates when the dialogue sequence updates.
365+ # However, to improve future maintainability and better software patterns, we should do this
366+ # generically by just noting that the Dialogue Sequence AST has changed and inferring everything from there
367+ if ast_changed and selected_node_ast and selected_node_id :
368+ node_selected .emit (selected_node_ast )
369+ if selected_node_id :
370+ var currently_selected_node_id : String = selected_node_id
371+ var currently_selected_node_ast : ParleyNodeAst = dialogue_ast .find_node_by_id (currently_selected_node_id )
372+ if currently_selected_node_ast :
373+ node_selected .emit (currently_selected_node_ast )
374+ print_rich (ParleyUtils .log .info_msg ("Generated Text Translation Keys for Dialogue Sequence AST: {dialogue_ast} " .format ({'dialogue_ast' : dialogue_ast })))
354375 _ :
355376 print_rich (ParleyUtils .log .info_msg ("Unknown option ID pressed: {id} " .format ({'id' : id })))
356377
@@ -386,6 +407,7 @@ func _save_dialogue() -> int:
386407 EditorInterface .get_resource_filesystem ().reimport_files ([dialogue_ast .resource_path ])
387408 return OK
388409
410+
389411func _on_arrange_nodes_button_pressed () -> void :
390412 selected_node_id = null
391413 await refresh ()
@@ -404,6 +426,7 @@ func _on_test_dialogue_from_start_button_pressed() -> void:
404426 if parley_manager :
405427 parley_manager .run_test_dialogue_from_start (dialogue_ast )
406428
429+
407430func _on_test_dialogue_from_selected_button_pressed () -> void :
408431 # TODO: dialogue is technically async so we should ideally wait here
409432 var result : int = _save_dialogue ()
@@ -802,9 +825,9 @@ func _add_edge(from_node_name: StringName, from_slot: int, to_node_name: StringN
802825 if added_edge :
803826 graph_view .add_edge (added_edge , from_node_name , to_node_name )
804827
805- func _is_selected_node (id : String ) -> bool :
828+ func _is_selected_node (id : String , should_log : bool = true ) -> bool :
806829 var is_selected_node : bool = selected_node_id == id
807- if not is_selected_node :
830+ if not is_selected_node and should_log :
808831 push_warning (ParleyUtils .log .warn_msg ("Node with ID %s is not selected" % id ))
809832 return is_selected_node
810833#endregion
0 commit comments