2 class_name DialogicSignalEvent
5 ## Event that emits the Dialogic.signal_event signal with an argument.
6 ## You can connect to this signal like this: `Dialogic.signal_event.connect(myfunc)`
11 enum ArgumentTypes {STRING, DICTIONARY}
12 var argument_type := ArgumentTypes.STRING
14 ## The argument that will be provided with the signal.
15 var argument: Variant = ""
17 ################################################################################
19 ################################################################################
21 func _execute() -> void:
22 if argument_type == ArgumentTypes.DICTIONARY:
23 var result: Variant = JSON.parse_string(argument)
25 var dict := result as Dictionary
27 dialogic.emit_signal('signal_event', dict)
29 push_error("[Dialogic] Encountered invalid dictionary in signal event.")
31 dialogic.emit_signal('signal_event', argument)
35 ################################################################################
37 ################################################################################
41 set_default_color('Color6')
42 event_category = "Logic"
43 event_sorting_index = 8
44 help_page_path = "https://docs.dialogic.pro/dialogic-signals.html#1-signal-event"
48 ################################################################################
50 ################################################################################
52 func get_shortcode() -> String:
56 func get_shortcode_parameters() -> Dictionary:
58 #param_name : property_info
59 "arg_type" : {"property": "argument_type", "default": ArgumentTypes.STRING,
60 "suggestions": func(): return {"String":{'value':ArgumentTypes.STRING, 'text_alt':['string']}, "Dictionary":{'value':ArgumentTypes.DICTIONARY, 'text_alt':['dict', 'dictionary']}}},
61 "arg" : {"property": "argument", "default": ""}
64 ################################################################################
65 ## EDITOR REPRESENTATION
66 ################################################################################
68 func build_event_editor() -> void:
69 add_header_label("Emit dialogic signal with argument")
70 add_header_label("(Dictionary in body)", 'argument_type == ArgumentTypes.DICTIONARY')
71 add_header_edit('argument', ValueType.SINGLELINE_TEXT, {}, 'argument_type == ArgumentTypes.STRING')
72 add_body_edit('argument_type',ValueType.FIXED_OPTIONS, {'left_text':'Argument Type:', 'options': [
75 'value': ArgumentTypes.STRING,
78 'label': 'Dictionary',
79 'value': ArgumentTypes.DICTIONARY,
82 add_body_line_break('argument_type == ArgumentTypes.DICTIONARY')
83 add_body_edit('argument', ValueType.DICTIONARY, {'left_text': 'Dictionary'},'argument_type == ArgumentTypes.DICTIONARY')