]> Untitled Git - wolf-seeking-sheep.git/blob - addons/dialogic/Modules/Comment/event_comment.gd
Initial Godot project with Dialogic 2.0-Alpha-17
[wolf-seeking-sheep.git] / addons / dialogic / Modules / Comment / event_comment.gd
1 @tool
2 class_name DialogicCommentEvent
3 extends DialogicEvent
4
5 ## Event that does nothing but store a comment string. Will print the comment in debug builds.
6
7
8 ### Settings
9
10 ## Content of the comment.
11 var text := ""
12
13
14 ################################################################################
15 ##                                              EXECUTE
16 ################################################################################
17
18 func _execute() -> void:
19         print("[Dialogic Comment] #",  text)
20         finish()
21
22
23 ################################################################################
24 ##                                              INITIALIZE
25 ################################################################################
26
27 func _init() -> void:
28         event_name = "Comment"
29         set_default_color('Color9')
30         event_category = "Helpers"
31         event_sorting_index = 0
32
33
34 ################################################################################
35 ##                                              SAVING/LOADING
36 ################################################################################
37
38 func to_text() -> String:
39         return "# "+text
40
41
42 func from_text(string:String) -> void:
43         text = string.trim_prefix("# ")
44
45
46 func is_valid_event(string:String) -> bool:
47         if string.strip_edges().begins_with('#'):
48                 return true
49         return false
50
51
52 ################################################################################
53 ##                                              EDITOR REPRESENTATION
54 ################################################################################
55
56 func build_event_editor() -> void:
57         add_header_edit('text', ValueType.SINGLELINE_TEXT, {'left_text':'#', 'autofocus':true})
58
59
60 #################### SYNTAX HIGHLIGHTING #######################################
61 ################################################################################
62
63 func _get_syntax_highlighting(Highlighter:SyntaxHighlighter, dict:Dictionary, _line:String) -> Dictionary:
64         dict[0] = {'color':event_color.lerp(Highlighter.normal_color, 0.3)}
65         return dict