Skip to content

Commit 66ed849

Browse files
committed
Get imports working
1 parent 0e7579f commit 66ed849

23 files changed

+1010
-107
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export_presets.cfg
99

1010
# Imported translations (automatically generated from CSV files)
1111
*.translation
12+
exports
1213

1314
# Mono-specific ignores
1415
.mono/

addons/parley/assets/Import.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://bl5h6uohpmt6t"
6+
path="res://.godot/imported/Import.svg-03e08cc35f6e411246290f9e4e846fc2.ctex"
7+
metadata={
8+
"has_editor_variant": true,
9+
"vram_texture": false
10+
}
11+
12+
[deps]
13+
14+
source_file="res://addons/parley/assets/Import.svg"
15+
dest_files=["res://.godot/imported/Import.svg-03e08cc35f6e411246290f9e4e846fc2.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/dialogue/dialogue_container.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ func _ready() -> void:
2222
func _render() -> void:
2323
if dialogue_text_label:
2424
var character: ParleyCharacter = dialogue_node.resolve_character()
25-
dialogue_text_label.text = "[b]%s[/b] – %s" % [tr(character.name if character.name != '' else 'Unknown'), dialogue_node.text]
25+
dialogue_text_label.text = "[b]%s[/b] – %s" % [tr(character.name if character.name != '' else 'Unknown', 'DIALOGUE'), dialogue_node.text]

addons/parley/main_panel.gd

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ class_name ParleyMainPanel extends VBoxContainer
55

66

77
const ParleyExport = preload("./parley_export.gd")
8+
const ParleyImport = preload("./parley_import.gd")
89

910

1011
const new_file_icon: CompressedTexture2D = preload("./assets/New.svg")
1112
const load_file_icon: CompressedTexture2D = preload("./assets/Load.svg")
1213
const export_icon: CompressedTexture2D = preload("./assets/Export.svg")
14+
const import_icon: CompressedTexture2D = preload("./assets/Import.svg")
1315
const insert_after_icon: CompressedTexture2D = preload("./assets/InsertAfter.svg")
1416
const dialogue_icon: CompressedTexture2D = preload("./assets/Dialogue.svg")
1517
const dialogue_option_icon: CompressedTexture2D = preload("./assets/DialogueOption.svg")
@@ -46,6 +48,7 @@ var parley_manager: ParleyManager
4648
@onready var new_dialogue_sequence_modal: ParleyNewDialogueSequenceModal = %NewDialogueSequenceModal
4749
@onready var edit_dialogue_sequence_modal: ParleyEditDialogueSequenceModal = %EditDialogueSequenceModal
4850
@onready var export_modal: ParleyExportModal = %ExportModal
51+
@onready var import_modal: ParleyImportModal = %ImportModal
4952
@onready var select_locale_modal: Window = %SelectLocaleModal
5053
@onready var editor: HSplitContainer = %EditorView
5154
@onready var sidebar: ParleySidebar = %Sidebar
@@ -269,7 +272,7 @@ func _render_translations_menu() -> void:
269272
popup.add_icon_item(export_icon, "Export Characters to CSV...", 1)
270273
popup.set_item_tooltip(1, "Export Character Translations to CSV")
271274

272-
popup.add_icon_item(export_icon, "Import Dialogue from CSV...", 2)
275+
popup.add_icon_item(import_icon, "Import Dialogue from CSV...", 2)
273276
popup.set_item_tooltip(2, "Import Dialogue Text Translations from CSV")
274277

275278
ParleyUtils.signals.safe_connect(popup.id_pressed, _on_translations_menu_id_pressed)
@@ -346,14 +349,17 @@ func _on_translations_menu_id_pressed(id: int) -> void:
346349
export_modal.render(ParleyExportModal.ExportType.DialogueTextTranslation, ParleyExportModal.FileType.Csv, dialogue_ast)
347350
1:
348351
export_modal.render(ParleyExportModal.ExportType.CharacterNameTranslation, ParleyExportModal.FileType.Csv, dialogue_ast)
349-
1:
350-
# IMPORT
351-
return
352+
2:
353+
import_modal.render(ParleyImportModal.ImportType.DialogueTextTranslation, ParleyImportModal.FileType.Csv, dialogue_ast)
352354
_:
353355
print_rich(ParleyUtils.log.info_msg("Unknown option ID pressed: {id}".format({'id': id})))
354356

355357

356358
func _on_save_pressed() -> void:
359+
await _save_and_refresh_dialogue()
360+
361+
362+
func _save_and_refresh_dialogue() -> void:
357363
var result: int = _save_dialogue()
358364
if result != OK:
359365
return
@@ -737,14 +743,46 @@ func _on_export_requested(export_type: ParleyExportModal.ExportType, file_type:
737743
var export_type_name: String = ParleyUtils.string.get_enum_key_name(ParleyExportModal.ExportType, export_type)
738744
match export_type:
739745
ParleyExportModal.ExportType.Node:
740-
ParleyExport.export_node(file_type, dialogue_sequence_ast, path)
746+
var result: Array = ParleyExport.export_node(file_type, dialogue_sequence_ast, path)
747+
var code: int = result[0]
748+
if code != OK:
749+
parley_manager.push_toast("Unable to export Nodes from current Dialogue Sequence (code:%s): %s" % [error_string(code), result[1]], EditorToaster.SEVERITY_ERROR)
750+
return
751+
parley_manager.push_toast(&"Successfully exported Nodes from current Dialogue Sequence")
741752
ParleyExportModal.ExportType.DialogueTextTranslation:
742-
ParleyExport.export_dialogue_text_translation(file_type, dialogue_sequence_ast, path)
753+
var result: Array = ParleyExport.export_dialogue_text_translation(file_type, dialogue_sequence_ast, path)
754+
var code: int = result[0]
755+
if code != OK:
756+
parley_manager.push_toast("Unable to export Text Translations from current Dialogue Sequence (code:%s): %s" % [error_string(code), result[1]], EditorToaster.SEVERITY_ERROR)
757+
return
758+
parley_manager.push_toast(&"Successfully exported Text Translations from current Dialogue Sequence")
743759
ParleyExportModal.ExportType.CharacterNameTranslation:
744-
ParleyExport.export_character_name_translation(file_type, dialogue_sequence_ast, path)
760+
var result: Array = ParleyExport.export_character_name_translation(file_type, dialogue_sequence_ast, path)
761+
var code: int = result[0]
762+
if code != OK:
763+
parley_manager.push_toast("Unable to export Character Names from current Dialogue Sequence (code:%s): %s" % [error_string(code), result[1]], EditorToaster.SEVERITY_ERROR)
764+
return
765+
parley_manager.push_toast(&"Successfully exported Character Names from current Dialogue Sequence")
745766
_:
746767
push_error(ParleyUtils.log.error_msg("Unable to export data: unknown export type (file_type:%s, export_type:%s)" % [file_type_name, export_type_name]))
747768
return
769+
770+
771+
func _on_import_modal_import_requested(import_type: ParleyImportModal.ImportType, file_type: ParleyImportModal.FileType, dialogue_sequence_ast: ParleyDialogueSequenceAst, path: String) -> void:
772+
var file_type_name: String = ParleyUtils.string.get_enum_key_name(ParleyImportModal.FileType, file_type)
773+
var import_type_name: String = ParleyUtils.string.get_enum_key_name(ParleyImportModal.ImportType, import_type)
774+
match import_type:
775+
ParleyImportModal.ImportType.DialogueTextTranslation:
776+
var result: Array = ParleyImport.import_dialogue_text_translation(file_type, dialogue_sequence_ast, path)
777+
var code: int = result[0]
778+
if code != OK:
779+
parley_manager.push_toast("Unable to import Text Translations into current Dialogue Sequence (code:%s): %s" % [error_string(code), result[1]], EditorToaster.SEVERITY_ERROR)
780+
return
781+
await _save_and_refresh_dialogue()
782+
parley_manager.push_toast(&"Successfully imported Text Translations into current Dialogue Sequence", EditorToaster.SEVERITY_INFO)
783+
_:
784+
push_error(ParleyUtils.log.error_msg("Unable to import data: unknown import type (file_type:%s, import_type:%s)" % [file_type_name, import_type_name]))
785+
return
748786
#endregion
749787

750788

addons/parley/main_panel.tscn

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=41 format=3 uid="uid://ckubjbp3e7yy3"]
1+
[gd_scene load_steps=42 format=3 uid="uid://ckubjbp3e7yy3"]
22

33
[ext_resource type="Script" uid="uid://ctp441gxhvg80" path="res://addons/parley/main_panel.gd" id="1_06n3w"]
44
[ext_resource type="Texture2D" uid="uid://ct6iywe1qjuh3" path="res://addons/parley/assets/New.svg" id="3_4ui00"]
@@ -34,6 +34,7 @@
3434
[ext_resource type="Script" uid="uid://3nqtsewsmim0" path="res://addons/parley/models/node_ast.gd" id="31_tp54n"]
3535
[ext_resource type="Script" uid="uid://btn7s5anok7p4" path="res://addons/parley/models/dialogue_sequence_ast.gd" id="32_pogw7"]
3636
[ext_resource type="PackedScene" uid="uid://d3d5w0atvk7y1" path="res://addons/parley/modals/select_locale_modal.tscn" id="33_s5oy3"]
37+
[ext_resource type="PackedScene" uid="uid://dm8p6rjl3h1km" path="res://addons/parley/modals/import_modal.tscn" id="35_8yxrj"]
3738

3839
[sub_resource type="Resource" id="Resource_s5oy3"]
3940
script = ExtResource("26_anq7l")
@@ -50,7 +51,7 @@ script = ExtResource("28_anq7l")
5051
characters = Array[ExtResource("11_7jaih")]([])
5152
id = ""
5253

53-
[sub_resource type="Image" id="Image_owjo5"]
54+
[sub_resource type="Image" id="Image_8yxrj"]
5455
data = {
5556
"data": PackedByteArray(255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 255, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 231, 255, 90, 90, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 90, 90, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 42, 255, 90, 90, 0, 255, 94, 94, 0, 255, 91, 91, 42, 255, 93, 93, 233, 255, 92, 92, 232, 255, 93, 93, 41, 255, 90, 90, 0, 255, 94, 94, 0, 255, 91, 91, 42, 255, 93, 93, 233, 255, 92, 92, 232, 255, 92, 92, 0, 255, 92, 92, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 45, 255, 93, 93, 44, 255, 91, 91, 0, 255, 91, 91, 42, 255, 91, 91, 42, 255, 93, 93, 0, 255, 91, 91, 45, 255, 93, 93, 44, 255, 91, 91, 0, 255, 91, 91, 42, 255, 91, 91, 42, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 45, 255, 92, 92, 235, 255, 92, 92, 234, 255, 89, 89, 43, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 45, 255, 92, 92, 235, 255, 92, 92, 234, 255, 89, 89, 43, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 91, 91, 59, 255, 92, 92, 61, 255, 92, 92, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 91, 91, 59, 255, 92, 92, 61, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0),
5657
"format": "RGBA8",
@@ -59,8 +60,8 @@ data = {
5960
"width": 16
6061
}
6162

62-
[sub_resource type="ImageTexture" id="ImageTexture_8yxrj"]
63-
image = SubResource("Image_owjo5")
63+
[sub_resource type="ImageTexture" id="ImageTexture_h2jtb"]
64+
image = SubResource("Image_8yxrj")
6465

6566
[sub_resource type="Resource" id="Resource_7hjis"]
6667
script = ExtResource("32_pogw7")
@@ -272,7 +273,7 @@ unique_name_in_owner = true
272273
layout_mode = 2
273274
tooltip_text = "Navigate to the Parley Documentation."
274275
text = "Docs"
275-
icon = SubResource("ImageTexture_8yxrj")
276+
icon = SubResource("ImageTexture_h2jtb")
276277
flat = true
277278

278279
[node name="EditorView" type="HSplitContainer" parent="MarginContainer/MainContainer/HSplitContainer/MainViewPanel/MainViewContainer"]
@@ -324,6 +325,10 @@ visible = false
324325
unique_name_in_owner = true
325326
visible = false
326327

328+
[node name="ImportModal" parent="." instance=ExtResource("35_8yxrj")]
329+
unique_name_in_owner = true
330+
visible = false
331+
327332
[connection signal="pressed" from="MarginContainer/MainContainer/HSplitContainer/MainViewPanel/MainViewContainer/Toolbar/EditorActions/SaveButton" to="." method="_on_save_pressed"]
328333
[connection signal="pressed" from="MarginContainer/MainContainer/HSplitContainer/MainViewPanel/MainViewContainer/Toolbar/EditorActions/ArrangeNodesButton" to="." method="_on_arrange_nodes_button_pressed"]
329334
[connection signal="pressed" from="MarginContainer/MainContainer/HSplitContainer/MainViewPanel/MainViewContainer/Toolbar/EditorActions/RefreshButton" to="." method="_on_refresh_button_pressed"]
@@ -346,3 +351,4 @@ visible = false
346351
[connection signal="export_requested" from="ExportModal" to="." method="_on_export_requested"]
347352
[connection signal="dialogue_ast_edited" from="EditDialogueSequenceModal" to="." method="_on_edit_dialogue_sequence_modal_dialogue_ast_edited"]
348353
[connection signal="locale_changed" from="SelectLocaleModal" to="." method="_on_select_locale_modal_locale_changed"]
354+
[connection signal="import_requested" from="ImportModal" to="." method="_on_import_modal_import_requested"]

addons/parley/modals/export_modal.gd

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ signal export_requested(export_type: ExportType, file_type: FileType, dialogue_s
3737
#endregion
3838

3939

40+
#region LIFECYCLE
41+
func _ready() -> void:
42+
_render_title()
43+
_render_status()
44+
#endregion
45+
46+
4047
#region SETTERS
4148
func _set_export_type(new_export_type: ExportType) -> void:
4249
export_type = new_export_type
@@ -51,7 +58,7 @@ func _set_file_type(new_file_type: FileType) -> void:
5158
#endregion
5259

5360

54-
#region LIFECYCLE
61+
#region RENDERERS
5562
# TODO: check where this is called
5663
func render(p_export_type: ExportType, p_file_type: FileType, p_dialogue_sequence_ast: ParleyDialogueSequenceAst) -> void:
5764
file_type = p_file_type

addons/parley/modals/export_modal.tscn

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
[node name="ExportModal" type="Window"]
77
auto_translate_mode = 1
8-
title = "Export to CSV"
8+
title = "Export Dialogue Text Translations to CSV"
99
initial_position = 2
1010
size = Vector2i(1400, 800)
1111
min_size = Vector2i(1400, 800)
@@ -39,7 +39,6 @@ unique_name_in_owner = true
3939
layout_mode = 2
4040
size_flags_horizontal = 3
4141
text = "res://export/export.csv"
42-
expand_to_text_length = true
4342

4443
[node name="ChoosePathButton" type="Button" parent="ExportMarginContainer/ExportContainer/PathContainer"]
4544
layout_mode = 2
@@ -53,7 +52,7 @@ size_flags_vertical = 3
5352
bbcode_enabled = true
5453
text = "[color=#19e34f]
5554
[ul]CSV path name is valid[/ul][/color][color=#19e34f]
56-
[ul]Will export the current Dialogue Sequence to CSV[/ul][/color]
55+
[ul]Will export the Dialogue Text Translations to CSV[/ul][/color]
5756
"
5857
fit_content = true
5958

0 commit comments

Comments
 (0)