Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow any Texture type to be assigned as NextIndicator icon #2054

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ enum AnimationsNewText {NONE, WIGGLE}
@export var next_indicator_show_on_questions: bool = true
@export var next_indicator_show_on_autoadvance: bool = false
@export_enum('bounce', 'blink', 'none') var next_indicator_animation: int = 0
@export_file("*.png","*.svg") var next_indicator_texture: String = ''
@export_file("*.png","*.svg","*.tres") var next_indicator_texture: String = ''
@export var next_indicator_size: Vector2 = Vector2(25,25)

@export_subgroup("Autoadvance")
Expand Down
20 changes: 13 additions & 7 deletions addons/dialogic/Modules/Text/node_next_indicator.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ extends Control

## What animation should the indicator do.
@export_enum('bounce', 'blink', 'none') var animation := 0

var texture_rect : TextureRect

## Set the image to use as the indicator.
@export var texture := preload("res://addons/dialogic/Example Assets/next-indicator/next-indicator.png"):
@export var texture : Texture2D = preload("res://addons/dialogic/Example Assets/next-indicator/next-indicator.png") as Texture2D:
set(_texture):
texture = _texture
if has_node('Texture'):
get_node('Texture').texture = texture
if texture_rect:
texture_rect.texture = texture

@export var texture_size := Vector2(32,32):
set(_texture_size):
Expand All @@ -34,17 +37,20 @@ var tween: Tween

func _ready():
add_to_group('dialogic_next_indicator')
# Creating texture
if texture:

# Creating TextureRect if missing
if not texture_rect:
var icon := TextureRect.new()
icon.name = 'Texture'
icon.ignore_texture_size = true
icon.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
icon.size = texture_size
icon.position = -icon.size
add_child(icon)
icon.texture = texture

texture_rect = icon

texture_rect.texture = texture

hide()
visibility_changed.connect(_on_visibility_changed)

Expand Down
Loading