Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 813dc1e99200da844e79fb1c7b434bc48b61f78c
Author: AnidemDex <[email protected]>
Date:   Sat Nov 20 15:48:08 2021 -0500

    Add docs in script for DialogNode

commit e4ac4b4849c8762682c19b5a903a216e28ee531c
Author: AnidemDex <[email protected]>
Date:   Sat Nov 20 15:47:58 2021 -0500

    Add docs in script for PortraitManager

commit cf72db73923f2fd59d41ba683a6b0b9e1f12d834
Author: AnidemDex <[email protected]>
Date:   Sat Nov 20 15:47:43 2021 -0500

    Add docs in script for OptionsManager

commit be6403dbfefa0e36ab717b1e2e7c0900239015be
Author: AnidemDex <[email protected]>
Date:   Sat Nov 20 15:47:30 2021 -0500

    Add documentation in script for DialogManager
  • Loading branch information
AnidemDex committed Nov 20, 2021
1 parent b34c855 commit f1993fe
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,48 @@ class_name DialogManager
## @tutorial(Online Documentation): https://anidemdex.gitbook.io/godot-dialog-plugin/documentation/node-class/class_dialog-dialogue-node
##

## Anchor points that the bubble can take as reference
enum BubblePosition {CENTER_LEFT,CENTER_RIGHT,CENTER_TOP,CENTER_DOWN}

## Emmited when the text is fully displayed
signal text_displayed
## Emmited eveytime that a character is displayed
signal character_displayed(character)

## The speed that the node uses to wait before adding another character.
## Values between 0.02 and 0.08 are good ones to use.
export(float) var text_speed:float = 0.02
## If true, DialogManager will try to scroll the text to fit new content
export(bool) var text_autoscroll:bool = true
## If true and [member text_autoscroll] is false, DialogManager will scale its size
## to fit its content.
export(bool) var text_fit_content_height:bool = true
## If true, DialogManager will show an VScroll to scroll its content
export(bool) var text_show_scroll_at_end:bool = true
## The [member BubblePosition] that the bubble will take as reference point.
export(BubblePosition) var bubble_anchor:int = BubblePosition.CENTER_DOWN setget _set_bubble_anchor
## Offset of the bubble relative to the selected [member bubble_anchor]
export(Vector2) var bubble_offset:Vector2 = Vector2() setget _set_bubble_offset

var text_node:RichTextLabel
## The node that actually displays the text
var text_node:RichTextLabel setget ,get_text_node
var _text_timer:Timer


## Calling this method will make to all text to be visible inmediatly
func display_all_text() -> void:
if text_node.visible_characters >= text_node.get_total_character_count():
return
text_node.visible_characters = text_node.get_total_character_count() -1
_update_displayed_text()


## Starts displaying the text setted by [method set_text]
func display_text() -> void:
_text_timer.start(text_speed)


## Set the text that this node will display. Call [method display_text]
## after using this method to display the text.
func set_text(text:String) -> void:
text_node.bbcode_text = text
text_node.visible_characters = 0
Expand All @@ -51,10 +66,13 @@ func set_text(text:String) -> void:
text_node.get_v_scroll().value = 0


## Adds text to the current one at the end. No need to call
## [method display_text] if the node is already displaying text
func add_text(text:String) -> void:
text_node.append_bbcode(text)


## Returns the used text_node
func get_text_node() -> RichTextLabel:
if is_instance_valid(text_node):
return text_node
Expand Down
11 changes: 11 additions & 0 deletions addons/textalog/nodes/dialogue_base_node/dialogue_base_node.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,28 @@ tool
extends Control
class_name DialogNode

## Emmited when the text was fully displayed
signal text_displayed

## Emmited when a portrait was added
signal portrait_added(character, portrait)
## Emmited when a portrait that is already in the scene, changes
signal portrait_changed(character, portrait)
## Emmited when a portrait is removed from scene
signal portrait_removed(character)

## Emmited when an option is added
signal option_added(option_button)
## Emmited when an option is selected
signal option_selected(option_string)

## Path to [Class DialogManager] node
export(NodePath) var DialogNode_Path:NodePath
## Path to [Class PortraitManager] node
export(NodePath) var PortraitNode_Path:NodePath
## Path to [Class OptionsManager] node
export(NodePath) var OptionsNode_Path:NodePath
## Path to name node
export(NodePath) var NameNode_path:NodePath

var dialog_manager:DialogManager
Expand Down Expand Up @@ -41,6 +51,7 @@ func add_option(option:String) -> void:
options_manager.add_option(option)


## Make an instance of this class. Required since you can't call .new() directly
static func instance() -> Node:
var _default_scene := load("res://addons/textalog/nodes/dialogue_base_node/dialogue_base_node.tscn") as PackedScene
return _default_scene.instance()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
extends Container
class_name OptionsManager

## Emmited when an option is selected
signal option_selected(option)
## Emmited when an option is added
signal option_added(option_button)

## Option button scene used
var OptionButtonScene:PackedScene = load("res://addons/textalog/nodes/dialogue_base_node/options_node/option_button/option_button.tscn")

## Adds an option and display it inmediatly to scene
func add_option(option:String) -> void:
var option_button:Button = OptionButtonScene.instance() as Button
option_button.connect("ready", self, "emit_signal", ["option_added", option_button])
Expand All @@ -19,6 +23,7 @@ func _on_OptionButton_pressed(option:String) -> void:
emit_signal("option_selected", option)


## Removes all option buttons in scene
func remove_options() -> void:
for child in get_children():
child.queue_free()
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class_name PortraitManager
## @tutorial(Online Documentation): https://anidemdex.gitbook.io/godot-dialog-plugin/documentation/node-class/class_dialog-portrait-manager
##

## Emmited when a character[DialogCharacterResource] portrait was added.
## Emmited when a character portrait was added.
signal portrait_added(character, new_portrait)

## Emmited when a portrait was changed with a new one.
## Emmited when a [Class Portrait] was changed with a new one.
signal portrait_changed(character, new_portrait)

## Emmited when a character portrait was removed from scene.
Expand All @@ -27,6 +27,7 @@ onready var size_reference_node:Control = get_node(ReferenceSize) as Control
# {CharacterResource: PortraitNode(TextureRect)}
var portraits:Dictionary = {}

## Adds a portrait for character to the scene
func add_portrait(
character:Character,
portrait:Portrait,
Expand Down

0 comments on commit f1993fe

Please sign in to comment.