2 class_name DialogicLabelEvent
5 ## Event that is used as an anchor. You can use the DialogicJumpEvent to jump to this point.
10 ## Used to identify the label. Duplicate names in a timeline will mean it always chooses the first.
12 var display_name := ""
16 ################################################################################
18 ################################################################################
20 func _execute() -> void:
21 # This event is mainly implemented in the Jump subsystem.
22 dialogic.Jump.passed_label.emit(
25 "display_name": get_property_translated("display_name"),
26 "display_name_orig": display_name,
27 "timeline": DialogicResourceUtil.get_unique_identifier(dialogic.current_timeline.resource_path)
32 ################################################################################
34 ################################################################################
38 set_default_color('Color4')
39 event_category = "Flow"
40 event_sorting_index = 3
43 func _get_icon() -> Resource:
44 return load(self.get_script().get_path().get_base_dir().path_join('icon_label.png'))
47 ################################################################################
49 ################################################################################
50 func to_text() -> String:
51 if display_name.is_empty():
54 return "label "+name+ " ("+display_name+")"
58 func from_text(string:String) -> void:
59 var regex := RegEx.create_from_string(r'label +(?<name>[^(]+)(\((?<display_name>.+)\))?')
60 var result := regex.search(string.strip_edges())
62 name = result.get_string('name').strip_edges()
63 display_name = result.get_string('display_name').strip_edges()
66 func is_valid_event(string:String) -> bool:
67 if string.strip_edges().begins_with("label"):
72 # this is only here to provide a list of default values
73 # this way the module manager can add custom default overrides to this event.
74 func get_shortcode_parameters() -> Dictionary:
76 #param_name : property_info
77 "name" : {"property": "name", "default": ""},
78 "display" : {"property": "display_name", "default": ""},
82 func _get_translatable_properties() -> Array:
83 return ["display_name"]
86 func _get_property_original_translation(property_name:String) -> String:
92 ################################################################################
93 ## EDITOR REPRESENTATION
94 ################################################################################
96 func build_event_editor() -> void:
97 add_header_edit('name', ValueType.SINGLELINE_TEXT, {'left_text':'Label', 'autofocus':true})
98 add_body_edit('display_name', ValueType.SINGLELINE_TEXT, {'left_text':'Display Name:'})
101 ####################### CODE COMPLETION ########################################
102 ################################################################################
104 func _get_start_code_completion(_CodeCompletionHelper:Node, TextNode:TextEdit) -> void:
105 TextNode.add_code_completion_option(CodeEdit.KIND_PLAIN_TEXT, 'label', 'label ', event_color.lerp(TextNode.syntax_highlighter.normal_color, 0.3))
108 #################### SYNTAX HIGHLIGHTING #######################################
109 ################################################################################
111 func _get_syntax_highlighting(Highlighter:SyntaxHighlighter, dict:Dictionary, line:String) -> Dictionary:
112 dict[line.find('label')] = {"color":event_color.lerp(Highlighter.normal_color, 0.3)}
113 dict[line.find('label')+5] = {"color":event_color.lerp(Highlighter.normal_color, 0.5)}