Skip to content

Commit 0830fb3

Browse files
authored
Jump Event: Allows label to be a variable (#2495)
* Allows label to be a variable, making the jump event dynamic * Updated event_jump so visual editor works
1 parent be5019b commit 0830fb3

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

addons/dialogic/Modules/Jump/event_jump.gd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ func get_label_suggestions(_filter:String="") -> Dictionary:
134134
if timeline_identifier in DialogicResourceUtil.get_label_cache().keys():
135135
for label in DialogicResourceUtil.get_label_cache()[timeline_identifier]:
136136
suggestions[label] = {'value': label, 'tooltip':label, 'editor_icon': ["ArrowRight", "EditorIcons"]}
137+
if _filter.begins_with("{"):
138+
for var_path in DialogicUtil.list_variables(DialogicUtil.get_default_variables()):
139+
suggestions["{"+var_path+"}"] = {'value':"{"+var_path+"}", 'icon':load("res://addons/dialogic/Editor/Images/Pieces/variable.svg")}
137140
return suggestions
138141

139142

@@ -144,6 +147,8 @@ func _get_code_completion(CodeCompletionHelper:Node, TextNode:TextEdit, line:Str
144147
if symbol == ' ' and line.count(' ') == 1:
145148
CodeCompletionHelper.suggest_labels(TextNode, '', '\n', event_color.lerp(TextNode.syntax_highlighter.normal_color, 0.6))
146149
CodeCompletionHelper.suggest_timelines(TextNode, CodeEdit.KIND_MEMBER, event_color.lerp(TextNode.syntax_highlighter.normal_color, 0.6))
150+
if symbol == "{":
151+
CodeCompletionHelper.suggest_variables(TextNode)
147152
if symbol == '/':
148153
CodeCompletionHelper.suggest_labels(TextNode, line.strip_edges().trim_prefix('jump ').trim_suffix('/'+String.chr(0xFFFF)).strip_edges(), '\n', event_color.lerp(TextNode.syntax_highlighter.normal_color, 0.6))
149154

addons/dialogic/Modules/Jump/subsystem_jump.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ func jump_to_label(label:String) -> void:
3131
dialogic.current_event_idx = 0
3232
jumped_to_label.emit({'timeline':dialogic.current_timeline, 'label':"TOP"})
3333
return
34+
## Allows label to be a variable, making the jump event dynamic
35+
label = str(dialogic.VAR.parse_variables(label))
3436

3537
var idx: int = -1
3638
while true:

0 commit comments

Comments
 (0)