]> Untitled Git - wolf-seeking-sheep.git/blob - addons/dialogic/Modules/TextInput/subsystem_text_input.gd
Initial Godot project with Dialogic 2.0-Alpha-17
[wolf-seeking-sheep.git] / addons / dialogic / Modules / TextInput / subsystem_text_input.gd
1 extends DialogicSubsystem
2
3 ## Subsystem that handles showing of input promts.
4
5 ## Signal that is fired when a confirmation button was pressed.
6 signal input_confirmed(input:String)
7 signal input_shown(info:Dictionary)
8
9
10 #region STATE
11 ####################################################################################################
12
13 func clear_game_state(_clear_flag:=DialogicGameHandler.ClearFlags.FULL_CLEAR) -> void:
14         hide_text_input()
15
16 #endregion
17
18
19 #region MAIN METHODS
20 ####################################################################################################
21
22 func show_text_input(text:= "", default:= "", placeholder:= "", allow_empty:= false) -> void:
23         for node in get_tree().get_nodes_in_group('dialogic_text_input'):
24                 node.show()
25                 if node.has_method('set_allow_empty'): node.set_allow_empty(allow_empty)
26                 if node.has_method('set_text'): node.set_text(text)
27                 if node.has_method('set_default'): node.set_default(default)
28                 if node.has_method('set_placeholder'): node.set_placeholder(placeholder)
29         input_shown.emit({'text':text, 'default':default, 'placeholder':placeholder, 'allow_empty':allow_empty})
30
31
32 func hide_text_input() -> void:
33         for node in get_tree().get_nodes_in_group('dialogic_text_input'):
34                 node.hide()
35
36 #endregion