-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Character: Add Character Prefixes and Suffixes for Text Events (#2460)
This new Feature allows to set text segments before and after a text spoken by a character. For instance, you can set the “ or " for your quotation marks or use rich tags, such as colour.
- Loading branch information
Showing
4 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
addons/dialogic/Editor/CharacterEditor/character_prefix_suffix.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
@tool | ||
class_name DialogicCharacterPrefixSuffixSection | ||
extends DialogicCharacterEditorMainSection | ||
## Character Editor Section for setting the prefix and suffix of a character. | ||
## | ||
## loads and sets the prefix and suffix of a character. | ||
## Provides [const PREFIX_CUSTOM_KEY] and [const SUFFIX_CUSTOM_KEY] to | ||
## access the `custom_info` dictionary of the [class DialogicCharacter]. | ||
|
||
@export var prefix_input: LineEdit | ||
@export var suffix_input: LineEdit | ||
|
||
## We won't force any prefixes or suffixes onto the player, | ||
## to ensure their games are working as previously when updating. | ||
const DEFAULT_PREFIX = "" | ||
const DEFAULT_SUFFIX = "" | ||
|
||
## `custom_info` dictionary keys for the prefix. | ||
const PREFIX_CUSTOM_KEY = "prefix" | ||
|
||
## `custom_info` dictionary keys for the prefix. | ||
const SUFFIX_CUSTOM_KEY = "suffix" | ||
|
||
var suffix := "" | ||
var prefix := "" | ||
|
||
|
||
func _ready() -> void: | ||
suffix_input.text_changed.connect(_suffix_changed) | ||
prefix_input.text_changed.connect(_prefix_changed) | ||
|
||
|
||
func _suffix_changed(text: String) -> void: | ||
suffix = text | ||
|
||
|
||
func _prefix_changed(text: String) -> void: | ||
prefix = text | ||
|
||
|
||
func _get_title() -> String: | ||
return "Character Prefix & Suffix" | ||
|
||
|
||
func _show_title() -> bool: | ||
return true | ||
|
||
|
||
func _start_opened() -> bool: | ||
return false | ||
|
||
|
||
func _load_portrait_data(portrait_data: Dictionary) -> void: | ||
_load_prefix_data(portrait_data) | ||
|
||
|
||
## We load the prefix and suffix from the character's `custom_info` dictionary. | ||
func _load_character(resource: DialogicCharacter) -> void: | ||
_load_prefix_data(resource.custom_info) | ||
|
||
|
||
func _load_prefix_data(data: Dictionary) -> void: | ||
suffix = data.get(SUFFIX_CUSTOM_KEY, DEFAULT_SUFFIX) | ||
prefix = data.get(PREFIX_CUSTOM_KEY, DEFAULT_PREFIX) | ||
|
||
suffix_input.text = suffix | ||
prefix_input.text = prefix | ||
|
||
|
||
## Whenever the user makes a save to the character, we save the prefix and suffix. | ||
func _save_changes(character: DialogicCharacter) -> DialogicCharacter: | ||
if not character.custom_info: | ||
printerr("[Dialogic] Unable to save Prefix and Suffix, the character is missing.") | ||
return character | ||
|
||
character.custom_info[PREFIX_CUSTOM_KEY] = prefix | ||
character.custom_info[SUFFIX_CUSTOM_KEY] = suffix | ||
|
||
return character |
48 changes: 48 additions & 0 deletions
48
addons/dialogic/Editor/CharacterEditor/character_prefix_suffix.tscn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://1ctcs6ywjjtd"] | ||
|
||
[ext_resource type="PackedScene" uid="uid://dbpkta2tjsqim" path="res://addons/dialogic/Editor/Common/hint_tooltip_icon.tscn" id="1_o3alv"] | ||
[ext_resource type="Script" path="res://addons/dialogic/Editor/CharacterEditor/character_prefix_suffix.gd" id="1_tkxff"] | ||
|
||
[node name="CharacterPrefixSuffix" type="GridContainer" node_paths=PackedStringArray("prefix_input", "suffix_input")] | ||
offset_right = 121.0 | ||
offset_bottom = 66.0 | ||
columns = 2 | ||
script = ExtResource("1_tkxff") | ||
prefix_input = NodePath("PrefixInput") | ||
suffix_input = NodePath("SuffixInput") | ||
|
||
[node name="Prefix" type="HBoxContainer" parent="."] | ||
layout_mode = 2 | ||
|
||
[node name="Label" type="Label" parent="Prefix"] | ||
layout_mode = 2 | ||
text = "Prefix" | ||
|
||
[node name="HintTooltip" parent="Prefix" instance=ExtResource("1_o3alv")] | ||
layout_mode = 2 | ||
texture = null | ||
hint_text = "If a character speaks, this appears before their text. | ||
Example: Color Tags or Quotation Marks." | ||
|
||
[node name="PrefixInput" type="LineEdit" parent="."] | ||
layout_mode = 2 | ||
size_flags_horizontal = 3 | ||
caret_blink = true | ||
|
||
[node name="Suffix" type="HBoxContainer" parent="."] | ||
layout_mode = 2 | ||
|
||
[node name="Label" type="Label" parent="Suffix"] | ||
layout_mode = 2 | ||
text = "Suffix" | ||
|
||
[node name="HintTooltip" parent="Suffix" instance=ExtResource("1_o3alv")] | ||
layout_mode = 2 | ||
texture = null | ||
hint_text = "If a character speaks, this appears after their text. | ||
Example: Color Tags or Quotation Marks." | ||
|
||
[node name="SuffixInput" type="LineEdit" parent="."] | ||
layout_mode = 2 | ||
size_flags_horizontal = 3 | ||
caret_blink = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters