Skip to content

Commit 5b931ab

Browse files
Multiple small improvements & Autocompletion for text editor (#1355)
* Variable Editor improvements - spaces in names are replaced with underscores - on focus, the whole name/value is selected - you can enter a name field with ENTER now (previoulsy double-click only) * Warning for empty and duplicate glossary items * Fixing next indicator * Allow adding buttons to events - Adds _event_node reference to event resource. This way you can access the visual editor node from the event, (while in that mode!) - Adds button functionality to EventNode scene as well as add_header_button() method to event resource - Adds functionality to open a specific settings tab by passing it's name as extra_infromation parameter. - Adds a button to the set variable event, that opens the variable editor * Add Button to edit character (on character event) * Fix Condition name and End ui (buttons) * Fix Variables Subsystem name to VAR again (broke set variable event) * Small style fixes (&& ||) * Improve Leave All UI & add "edit character" button (character event) * Allow use of array for icon in event.add_header_button() Usefull for editor icons. (loaded with callv('get_theme_icon')` * Move test_timeline_scene and improve pausing * Add text editor auto-completion # Auto-completion for text editor Adds autocompletion to the text editor. The following things are suggested: - shortcode identifiers - shortcode parameters - if shortcode parameter has a suggesions function setup, those will be suggested as values - Character names - Character Portraits - Text Effects - Join, Leave, Update, VAR, if, elif, else - Variable Names ## Paramter Value suggestions For many events some value suggestions have been added: - true and false for boolean values - audio bus's for bus - timelines for jump event - enum values for History and Position event # Other Changes - Variable Dict to Array method moved to DialogicUtil
1 parent 79d8730 commit 5b931ab

34 files changed

+513
-241
lines changed

addons/dialogic/Editor/Events/EventNode/EventNode.gd

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,17 @@ func build_editor():
239239
editor_node = Label.new()
240240
editor_node.text = p.display_info.text
241241
editor_node.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
242-
242+
elif p.dialogic_type == resource.ValueType.Button:
243+
editor_node = Button.new()
244+
editor_node.text = p.display_info.text
245+
if typeof(p.display_info.icon) == TYPE_ARRAY:
246+
editor_node.icon = callv('get_theme_icon', p.display_info.icon)
247+
else:
248+
editor_node.icon = p.display_info.icon
249+
editor_node.flat = true
250+
editor_node.custom_minimum_size.x = 30*DialogicUtil.get_editor_scale()
251+
editor_node.tooltip_text = p.display_info.tooltip
252+
editor_node.pressed.connect(p.display_info.callable)
243253
## CUSTOM
244254
elif p.dialogic_type == resource.ValueType.Custom:
245255
if p.display_info.has('path'):

addons/dialogic/Editor/Events/Fields/ComplexPicker.gd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func set_right_text(value:String) -> void:
4444
func set_value(value, text : String = '') -> void:
4545
if value == null:
4646
%Search.text = empty_text
47-
elif file_extension != "" && file_extension != ".dch" && file_extension != ".dtl":
47+
elif file_extension != "" and file_extension != ".dch" and file_extension != ".dtl":
4848
%Search.text = value.resource_path
4949
%Search.tooltip_text = value.resource_path
5050
elif value:
@@ -119,7 +119,7 @@ func _on_Search_text_changed(new_text:String, just_update:bool = false) -> void:
119119
if new_text == "" and !just_update:
120120
changed_to_empty()
121121

122-
var suggestions = get_suggestions_func.call(new_text)
122+
var suggestions :Dictionary = get_suggestions_func.call(new_text)
123123

124124
var line_length:int = 0
125125
var idx:int = 0
@@ -176,7 +176,7 @@ func suggestion_selected(index : int, position:=Vector2(), button_index:=MOUSE_B
176176
current_value = null
177177

178178
# if this is a resource, then load it instead of assigning the string:
179-
elif file_extension != "" && file_extension != ".dch" && file_extension != ".dtl":
179+
elif file_extension != "" and file_extension != ".dch" and file_extension != ".dtl":
180180
var file = load(%Suggestions.get_item_metadata(index))
181181
current_value = file
182182
else:

addons/dialogic/Editor/Events/Fields/ConditionPicker.gd

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,24 +114,16 @@ func get_value1_suggestions(filter:String) -> Dictionary:
114114
if filter:
115115
suggestions[filter] = {'value':filter, 'editor_icon':["GuiScrollArrowRight", "EditorIcons"]}
116116
var vars = DialogicUtil.get_project_setting('dialogic/variables', {})
117-
for var_path in list_variables(vars):
117+
for var_path in DialogicUtil.list_variables(vars):
118118
suggestions[var_path] = {'value':'{'+var_path+"}", 'editor_icon':["ClassList", "EditorIcons"]}
119119
return suggestions
120120

121-
func list_variables(dict, path = "") -> Array:
122-
var array = []
123-
for key in dict.keys():
124-
if typeof(dict[key]) == TYPE_DICTIONARY:
125-
array.append_array(list_variables(dict[key], path+key+"."))
126-
else:
127-
array.append(path+key)
128-
return array
129121

130122
func get_value2_suggestions(filter:String) -> Dictionary:
131123
var suggestions = {}
132124
if filter:
133125
suggestions[filter] = {'value':filter, 'editor_icon':["GuiScrollArrowRight", "EditorIcons"]}
134126
var vars = DialogicUtil.get_project_setting('dialogic/variables', {})
135-
for var_path in list_variables(vars):
127+
for var_path in DialogicUtil.list_variables(vars):
136128
suggestions[var_path] = {'value':'{'+var_path+"}", 'editor_icon':["ClassList", "EditorIcons"]}
137129
return suggestions

addons/dialogic/Editor/Settings/SettingsEditor.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ func _ready():
1515

1616
func _open(extra_information:Variant = null) -> void:
1717
refresh()
18+
if typeof(extra_information) == TYPE_STRING and has_node('Tabs/'+extra_information):
19+
$Tabs.current_tab = get_node('Tabs/'+extra_information).get_index()
1820

1921

2022
func _close():

addons/dialogic/Editor/TimelineEditor/TextEditor/syntax_highlighter.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ func _init():
5757
character_name_color = editor_settings.get('text_editor/theme/highlighting/executing_line_color')
5858
character_portrait_color = character_name_color.lightened(0.6)
5959

60-
shortcode_regex.compile("\\W*\\[(?<id>\\w*)(?<args>[^\\]]*)?\\]")
60+
shortcode_regex.compile("\\W*\\[(?<id>\\w*)(?<args>[^\\]]*)?")
6161
shortcode_param_regex.compile('((?<parameter>[^\\s=]*)\\s*=\\s*"(?<value>([^=]|\\\\=)*)(?<!\\\\)")')
6262
text_event_regex.compile("\\W*((\")?(?<name>(?(2)[^\"\\n]*|[^(: \\n]*))(?(2)\"|)(\\W*\\((?<portrait>.*)\\))?\\s*(?<!\\\\):)?(?<text>.*)")
63-
text_effects_regex.compile("(?<!\\\\)\\[\\s*(?<command>mood|portrait|speed|signal|pause)\\s*(=\\s*(?<value>.+?)\\s*)?\\]")
63+
text_effects_regex.compile("(?<!\\\\)\\[\\s*(?<command>mood|portrait|speed|signal|pause|br)\\s*(=\\s*(?<value>.+?)\\s*)?\\]")
6464
character_event_regex.compile("(?<type>Join|Update|Leave)\\s*(\")?(?<name>(?(2)[^\"\\n]*|[^(: \\n]*))(?(2)\"|)(\\W*\\((?<portrait>.*)\\))?(\\s*(?<position>\\d))?(\\s*\\[(?<shortcode>.*)\\])?")
6565

6666
func _get_line_syntax_highlighting(line:int) -> Dictionary:

0 commit comments

Comments
 (0)