]> Untitled Git - wolf-seeking-sheep.git/blob - addons/dialogic/Modules/Choice/node_choice_button.gd
Initial Godot project with Dialogic 2.0-Alpha-17
[wolf-seeking-sheep.git] / addons / dialogic / Modules / Choice / node_choice_button.gd
1 class_name DialogicNode_ChoiceButton
2 extends Button
3 ## The button allows the player to make a choice in the Dialogic system.
4 ##
5 ## This class is used in the Choice Layer. [br]
6 ## You may change the [member text_node] to any [class Node] that has a
7 ## `text` property. [br]
8 ## If you don't set the [member text_node], the text will be set on this
9 ## button instead.
10 ##
11 ## Using a different node may allow using rich text effects; they are
12 ## not supported on buttons at this point.
13
14
15 ## Used to identify what choices to put on. If you leave it at -1, choices will be distributed automatically.
16 @export var choice_index: int = -1
17
18 ## Can be set to play this sound when pressed. Requires a sibling DialogicNode_ButtonSound node.
19 @export var sound_pressed: AudioStream
20 ## Can be set to play this sound when hovered. Requires a sibling DialogicNode_ButtonSound node.
21 @export var sound_hover: AudioStream
22 ## Can be set to play this sound when focused. Requires a sibling DialogicNode_ButtonSound node.
23 @export var sound_focus: AudioStream
24 ## If set, the text will be set on this node's `text` property instead.
25 @export var text_node: Node
26
27
28 func _ready() -> void:
29         add_to_group('dialogic_choice_button')
30         shortcut_in_tooltip = false
31         hide()
32
33
34 func _load_info(choice_info: Dictionary) -> void:
35         set_choice_text(choice_info.text)
36         visible = choice_info.visible
37         disabled = choice_info.disabled
38
39
40 ## Called when the text changes.
41 func set_choice_text(new_text: String) -> void:
42         if text_node:
43                 text_node.text = new_text
44         else:
45                 text = new_text