extends ESCTooltip

var id: int


export(Texture) var iconTexture: Texture = null \
		setget ,_get_icon_texture

func _init(tooltip_id = 0):
	id = tooltip_id
	
	#$icon.texture = iconTexture


	

signal tooltip2_size_updated


func update_tooltip_text():
	# Need to update size of bbcode rect before updating the text itself otherwise on the
	# first frame the text is wider than the default of 0 and ends up being really tall
	# and setting the wrong vertical margin for the tooltip
	update_size()
	#var texturePath = get_constant()
	var texturePath = null
	# We signal this here since the processing in this class happens AFTER input
	# processing. We signal here to avoid "lagging" behind a frame since
	# tooltips are presently dependent on the size of the bounding box around
	# the rendered string.
	emit_signal("tooltip2_size_updated")
	bbcode_text = "";
	#bbcode_text += "[img]" + "res://gymkhana/addons/escoria-ui-return-monkey-island/cursors/mouse_right.png" + "[/img]"
	#bbcode_text += "[color=#" + color.to_html(false) + "]"
	bbcode_text += "[color=#" + color.to_html(false) + "]"
	bbcode_text += current_target
	bbcode_text += "[/color]"
#	push_align(RichTextLabel.ALIGN_CENTER)
#	push_color(color)
#	append_bbcode(current_target)
#	pop()
#	pop()


func _on_room_ready():
	escoria.main.current_scene.game.tooltip2_node = self
	_room_is_ready = true
	
func _get_icon_texture() -> Texture:
	if iconTexture == null:
		for c in get_children():
			if c is TextureRect or c is Sprite:
				return c.texture
		return null
	else:
		return iconTexture
