]> Untitled Git - wolf-seeking-sheep.git/blob - addons/dialogic/Modules/Jump/event_return.gd
Initial Godot project with Dialogic 2.0-Alpha-17
[wolf-seeking-sheep.git] / addons / dialogic / Modules / Jump / event_return.gd
1 @tool
2 class_name DialogicReturnEvent
3 extends DialogicEvent
4
5 ## Event that will make dialogic jump back to the last jump point.
6
7
8
9 ################################################################################
10 ##                                              EXECUTION
11 ################################################################################
12
13 func _execute() -> void:
14         if !dialogic.Jump.is_jump_stack_empty():
15                 dialogic.Jump.resume_from_last_jump()
16         else:
17                 dialogic.end_timeline()
18
19
20 ################################################################################
21 ##                                              INITIALIZE
22 ################################################################################
23
24 func _init() -> void:
25         event_name = "Return"
26         set_default_color('Color4')
27         event_category = "Flow"
28         event_sorting_index = 5
29
30
31 func _get_icon() -> Resource:
32         return load(self.get_script().get_path().get_base_dir().path_join('icon_return.svg'))
33
34
35 ################################################################################
36 ##                                              SAVING/LOADING
37 ################################################################################
38 func to_text() -> String:
39         return "return"
40
41
42 func from_text(_string:String) -> void:
43         pass
44
45
46 func is_valid_event(string:String) -> bool:
47         if string.strip_edges() == "return":
48                 return true
49         return false
50
51
52 ################################################################################
53 ##                                              EDITOR REPRESENTATION
54 ################################################################################
55
56 func build_event_editor() -> void:
57         add_header_label('Return')
58
59
60 ####################### CODE COMPLETION ########################################
61 ################################################################################
62
63 func _get_start_code_completion(_CodeCompletionHelper:Node, TextNode:TextEdit) -> void:
64         TextNode.add_code_completion_option(CodeEdit.KIND_PLAIN_TEXT, 'return', 'return\n', event_color.lerp(TextNode.syntax_highlighter.normal_color, 0.3))
65
66
67 #################### SYNTAX HIGHLIGHTING #######################################
68 ################################################################################
69
70 func _get_syntax_highlighting(Highlighter:SyntaxHighlighter, dict:Dictionary, line:String) -> Dictionary:
71         dict[line.find('return')] = {"color":event_color.lerp(Highlighter.normal_color, 0.3)}
72         dict[line.find('return')+6] = {"color":event_color.lerp(Highlighter.normal_color, 0.5)}
73         return dict