From 655acbc13d6b6bc7012839ef76f78c134ad89630 Mon Sep 17 00:00:00 2001 From: Invertex Date: Sat, 27 Jan 2024 15:59:18 -0800 Subject: [PATCH] Allow any Texture type to be assigned as Indicator icon Being restricted to specific filename formats prevented the use of things like AniamtedTexture Made the Texture conditional checking more clear and consistent too. --- .../Layer_VN_Textbox/vn_textbox_layer.gd | 2 +- .../Modules/Text/node_next_indicator.gd | 20 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.gd index 8dcb73a2f..d56030539 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.gd @@ -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") diff --git a/addons/dialogic/Modules/Text/node_next_indicator.gd b/addons/dialogic/Modules/Text/node_next_indicator.gd index 9f7a7fcc4..b624a807f 100644 --- a/addons/dialogic/Modules/Text/node_next_indicator.gd +++ b/addons/dialogic/Modules/Text/node_next_indicator.gd @@ -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): @@ -34,8 +37,9 @@ 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 @@ -43,8 +47,10 @@ func _ready(): 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)