Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export_presets.cfg

# Imported translations (automatically generated from CSV files)
*.translation
exports

# Mono-specific ignores
.mono/
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"gutignore",
"lanczos",
"maskable",
"msgctxt",
"neighbor",
"npcs",
"onready",
Expand Down
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ Ensure the following are installed:

- [Godot](https://godotengine.org/)

## Conventions

### GDScript

Parley does not enforce a strict style guide but where possible, it is
recommended to follow the Godot GDScript style guide as described
[here](https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_styleguide.html).

## Documentation

Documentation is a vital part of Parley and should always be included for any
Expand Down
1 change: 1 addition & 0 deletions addons/parley/assets/Generate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions addons/parley/assets/Generate.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://dymfq1lumomnh"
path="res://.godot/imported/Generate.svg-c453b998a82ad5f3f2fd9b38bce67edb.ctex"
metadata={
"has_editor_variant": true,
"vram_texture": false
}

[deps]

source_file="res://addons/parley/assets/Generate.svg"
dest_files=["res://.godot/imported/Generate.svg-c453b998a82ad5f3f2fd9b38bce67edb.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=true
editor/convert_colors_with_editor_theme=true
1 change: 1 addition & 0 deletions addons/parley/assets/Import.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions addons/parley/assets/Import.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://bl5h6uohpmt6t"
path="res://.godot/imported/Import.svg-03e08cc35f6e411246290f9e4e846fc2.ctex"
metadata={
"has_editor_variant": true,
"vram_texture": false
}

[deps]

source_file="res://addons/parley/assets/Import.svg"
dest_files=["res://.godot/imported/Import.svg-03e08cc35f6e411246290f9e4e846fc2.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=true
editor/convert_colors_with_editor_theme=true
1 change: 1 addition & 0 deletions addons/parley/assets/Translation.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions addons/parley/assets/Translation.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://es7k6io6r0lm"
path="res://.godot/imported/Translation.svg-c3e1761c64f8d5efb11ee1054cec6a6c.ctex"
metadata={
"has_editor_variant": true,
"vram_texture": false
}

[deps]

source_file="res://addons/parley/assets/Translation.svg"
dest_files=["res://.godot/imported/Translation.svg-c3e1761c64f8d5efb11ee1054cec6a6c.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=true
editor/convert_colors_with_editor_theme=true
20 changes: 19 additions & 1 deletion addons/parley/components/bottom_panel.gd
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# Copyright 2024-2025 the Bisterix Studio authors. All rights reserved. MIT license.

@tool
extends MarginContainer
class_name ParleyBottomPanel extends MarginContainer

#region DEFS
const back_icon: Texture2D = preload('res://addons/parley/assets/Back.svg')
const forward_icon: Texture2D = preload('res://addons/parley/assets/Forward.svg')

@onready var toggle_sidebar_button: Button = %ToggleSidebarButton
@onready var version_label: LinkButton = %Version

var is_sidebar_open: bool = true: set = _is_sidebar_open_setter
var version: String = "" : set = _set_version
const version_label_tooltip: StringName = &"Click to copy the version information"

signal sidebar_toggled(is_sidebar_open: bool)
#endregion
Expand All @@ -21,6 +24,11 @@ func _ready() -> void:
#endregion

#region SETTERS
func _set_version(new_version: String) -> void:
version = new_version
_render_version_label()


func _is_sidebar_open_setter(new_value: bool) -> void:
is_sidebar_open = new_value
_render_sidebar_button()
Expand All @@ -34,9 +42,19 @@ func _render_sidebar_button() -> void:
toggle_sidebar_button.icon = back_icon
else:
toggle_sidebar_button.icon = forward_icon


func _render_version_label() -> void:
if version_label:
version_label.tooltip_text = version_label_tooltip
version_label.text = "v%s" % version
#endregion

#region SIGNALS
func _on_toggle_sidebar_button_pressed() -> void:
is_sidebar_open = !is_sidebar_open


func _on_version_pressed() -> void:
DisplayServer.clipboard_set("Parley [v%s]" % [version])
#endregion
14 changes: 13 additions & 1 deletion addons/parley/components/bottom_panel.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
[ext_resource type="Script" uid="uid://gu5an32ya6bh" path="res://addons/parley/components/bottom_panel.gd" id="1_v1no1"]

[node name="BottomPanel" type="MarginContainer"]
offset_right = 286.0
offset_bottom = 73.0
size_flags_horizontal = 3
theme_override_constants/margin_top = 0
theme_override_constants/margin_bottom = 10
theme_override_constants/margin_right = 5
theme_override_constants/margin_bottom = 0
script = ExtResource("1_v1no1")

[node name="BottomPanelContainer" type="HBoxContainer" parent="."]
Expand All @@ -25,4 +28,13 @@ flat = true
[node name="RightContainer" type="HBoxContainer" parent="BottomPanelContainer"]
layout_mode = 2

[node name="Version" type="LinkButton" parent="BottomPanelContainer/RightContainer"]
unique_name_in_owner = true
modulate = Color(1, 1, 1, 0.6)
layout_mode = 2
size_flags_horizontal = 8
size_flags_vertical = 4
underline = 1

[connection signal="pressed" from="BottomPanelContainer/LeftContainer/ToggleSidebarButton" to="." method="_on_toggle_sidebar_button_pressed"]
[connection signal="pressed" from="BottomPanelContainer/RightContainer/Version" to="." method="_on_version_pressed"]
18 changes: 5 additions & 13 deletions addons/parley/components/default_balloon.gd
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,10 @@ func start(p_ctx: ParleyContext, p_dialogue_sequence_ast: ParleyDialogueSequence
is_waiting_for_input = false
ctx = p_ctx
dialogue_sequence_ast = p_dialogue_sequence_ast
if p_start_node is ParleyDialogueNodeAst or p_start_node is ParleyDialogueOptionNodeAst:
current_node_asts = [p_start_node]
elif p_start_node:
var run_result: ParleyRunResult = await ParleyDialogueSequenceAst.run(ctx, dialogue_sequence_ast, p_start_node)
current_node_asts = run_result.node_asts
dialogue_sequence_ast = run_result.dialogue_sequence
run_result.free() # Needed to ensure that everything is correctly freed up at exit
else:
var run_result: ParleyRunResult = await ParleyDialogueSequenceAst.run(ctx, dialogue_sequence_ast)
current_node_asts = run_result.node_asts
dialogue_sequence_ast = run_result.dialogue_sequence
run_result.free() # Needed to ensure that everything is correctly freed up at exit
var run_result: ParleyRunResult = await ParleyDialogueSequenceAst.init(ctx, dialogue_sequence_ast, p_start_node if p_start_node else null)
current_node_asts = run_result.node_asts
dialogue_sequence_ast = run_result.dialogue_sequence
run_result.free() # Needed to ensure that everything is correctly freed up at exit


## Process the next Nodes
Expand Down Expand Up @@ -85,7 +77,7 @@ func _set_current_node_asts(p_current_node_asts: Array[ParleyNodeAst]) -> void:
balloon.show()
current_node_asts = p_current_node_asts
var current_children: Array[Node] = balloon_container.get_children()
var first_node: ParleyNodeAst = p_current_node_asts.front()
var first_node: ParleyNodeAst = current_node_asts.front()
var next_children: Array[Node] = await _build_next_children(current_children, first_node)
if next_children.size() == 0:
return
Expand Down
2 changes: 1 addition & 1 deletion addons/parley/components/dialogue/dialogue_container.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ func _ready() -> void:
func _render() -> void:
if dialogue_text_label:
var character: ParleyCharacter = dialogue_node.resolve_character()
dialogue_text_label.text = "[b]%s[/b] – %s" % [character.name if character.name != '' else 'Unknown', dialogue_node.text]
dialogue_text_label.text = "[b]%s[/b] – %s" % [tr(character.name if character.name != '' else 'Unknown', 'DIALOGUE'), dialogue_node.text]
30 changes: 28 additions & 2 deletions addons/parley/components/dialogue/dialogue_node_editor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@ class_name ParleyDialogueNodeEditor extends ParleyBaseNodeEditor
var character_store: ParleyCharacterStore: set = _set_character_store
@export var character: String = "": set = _set_character
@export var dialogue: String = "": set = _set_dialogue
@export var text_translation_key: String = "": set = _set_text_translation_key


@onready var character_selector: OptionButton = %CharacterSelector
@onready var dialogue_editor: TextEdit = %DialogueEditor
@onready var text_translation_key_editor: ParleyTranslationKeyEditor = %TranslationKeyEditor


signal dialogue_node_changed(id: String, character: String, dialogue: String)
signal dialogue_node_changed(id: String, character: String, dialogue: String, text_translation_key: String)
#endregion


#region LIFECYCLE
func _ready() -> void:
set_title()
_render_dialogue()
_render_text_translation_key_editor(true)
_render_character_options()
if character_store:
ParleyUtils.signals.safe_connect(character_store.changed, _on_character_store_changed)
Expand All @@ -48,6 +51,11 @@ func _set_dialogue(new_dialogue: String) -> void:
func _set_character(new_character: String) -> void:
character = new_character
_render_character()


func _set_text_translation_key(new_text_translation_key: String) -> void:
text_translation_key = new_text_translation_key
_render_text_translation_key_editor()
#endregion


Expand All @@ -57,6 +65,14 @@ func _render_dialogue() -> void:
dialogue_editor.text = dialogue


func _render_text_translation_key_editor(on_ready: bool = false) -> void:
if text_translation_key_editor:
if text_translation_key_editor.key != text_translation_key:
text_translation_key_editor.key = text_translation_key
if on_ready:
text_translation_key_editor.label = &"Text Translation Key: "


func _render_character_options() -> void:
if not character_selector:
return
Expand Down Expand Up @@ -93,6 +109,16 @@ func _on_character_store_changed() -> void:
_render_character_options()


func _on_translation_key_editor_key_changed(new_key: String) -> void:
text_translation_key = new_key
_emit_dialogue_node_changed()


func _on_translation_key_editor_key_generation_requested() -> void:
text_translation_key = ParleyUtils.translation.generate_key(dialogue, dialogue_sequence_ast, node_ast, 'text')
_emit_dialogue_node_changed()


func _emit_dialogue_node_changed() -> void:
dialogue_node_changed.emit(id, character, dialogue)
dialogue_node_changed.emit(id, character, dialogue, text_translation_key)
#endregion
12 changes: 10 additions & 2 deletions addons/parley/components/dialogue/dialogue_node_editor.tscn
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
[gd_scene load_steps=3 format=3 uid="uid://bx0l648bpqw70"]
[gd_scene load_steps=4 format=3 uid="uid://bx0l648bpqw70"]

[ext_resource type="Script" uid="uid://b0qfehwjd3bm7" path="res://addons/parley/components/dialogue/dialogue_node_editor.gd" id="1_ad3ky"]
[ext_resource type="PackedScene" uid="uid://m3v11vm16l8y" path="res://addons/parley/components/node/node_editor.tscn" id="1_okdx1"]
[ext_resource type="PackedScene" uid="uid://n4t3w6dhkt6a" path="res://addons/parley/components/editor/translation_key_editor.tscn" id="3_wbci0"]

[node name="DialogueNodeEditor" instance=ExtResource("1_okdx1")]
script = ExtResource("1_ad3ky")
character = ""
dialogue = ""
text_translation_key = ""
type = 0

[node name="TitleLabel" parent="TitleContainer/TitlePanelContainer/TitleMarginContainer/TitlePartsContainer" index="0"]
Expand All @@ -21,8 +23,8 @@ text = "Character: "

[node name="CharacterSelector" type="OptionButton" parent="BodyMarginContainer/BodyScrollContainer/BodyContainer/CharacterSelectorContainer" index="1"]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(150, 0)
layout_mode = 2
size_flags_horizontal = 3
text_overrun_behavior = 3
clip_text = true
Expand All @@ -43,5 +45,11 @@ size_flags_vertical = 3
placeholder_text = "Dialogue goes here.."
wrap_mode = 1

[node name="TranslationKeyEditor" parent="BodyMarginContainer/BodyScrollContainer/BodyContainer" index="2" instance=ExtResource("3_wbci0")]
unique_name_in_owner = true
layout_mode = 2

[connection signal="item_selected" from="BodyMarginContainer/BodyScrollContainer/BodyContainer/CharacterSelectorContainer/CharacterSelector" to="." method="_on_character_selector_item_selected"]
[connection signal="text_changed" from="BodyMarginContainer/BodyScrollContainer/BodyContainer/DialogueEditorContainer/DialogueEditor" to="." method="_on_dialogue_editor_text_changed"]
[connection signal="key_changed" from="BodyMarginContainer/BodyScrollContainer/BodyContainer/TranslationKeyEditor" to="." method="_on_translation_key_editor_key_changed"]
[connection signal="key_generation_requested" from="BodyMarginContainer/BodyScrollContainer/BodyContainer/TranslationKeyEditor" to="." method="_on_translation_key_editor_key_generation_requested"]
Loading
Loading