Skip to content

Commit

Permalink
Allow any Texture type to be assigned as Indicator icon (#2054)
Browse files Browse the repository at this point in the history
Being restricted to specific filename formats prevented the use of things like AniamtedTexture

Made the Texture conditional checking more clear and consistent too.
  • Loading branch information
Invertex authored Jan 29, 2024
1 parent 17683f8 commit 1cf2582
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
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

0 comments on commit 1cf2582

Please sign in to comment.