fix rich tooltip showing with empty action texts

This commit is contained in:
2023-03-03 19:27:52 +01:00
parent 5cf0db6c21
commit 5b482d99d1

View File

@@ -102,11 +102,11 @@ func set_target_object(target: Object, needs_second_target: bool = false) -> voi
current_target_object = target
waiting_for_target2 = needs_second_target
if _room_is_ready:
update_tooltip_text()
if(target == null):
hide()
return
show()
# show()
update_tooltip_text()
# Set the first target of the label.
@@ -118,11 +118,11 @@ func set_target(target: String, needs_second_target: bool = false) -> void:
current_target = target
waiting_for_target2 = needs_second_target
if _room_is_ready:
update_tooltip_text()
if(target == ""):
hide()
return
show()
update_tooltip_text()
# show()
# Set the second target of the label
@@ -132,26 +132,22 @@ func set_target(target: String, needs_second_target: bool = false) -> void:
func set_target2(target2: String) -> void:
current_target2 = target2
if _room_is_ready:
update_tooltip_text()
if(target2 == ""):
hide()
return
show()
update_tooltip_text()
# show()
# Update the tooltip text.
func update_tooltip_text():
if(current_target_object == null):
return
hide()
if(current_target_object.action1_text != ""):
$tooltip1.visible = true;
$tooltip1.visible = current_target_object.action1_text != "";
$tooltip1/label.text = current_target_object.action1_text
if(current_target_object.action2_text != ""):
$tooltip2.visible = true;
$tooltip2.visible = current_target_object.action2_text != "";
$tooltip2/label.text = current_target_object.action2_text
@@ -167,7 +163,7 @@ func get_tooltip1_size():
if not get_tree():
# We're not in the tree anymore. Return
return
escoria.logger.info(self, "get_string_size: " + String($tooltip1/label.get_font("normal_font").get_string_size(current_target)))
# escoria.logger.info(self, "get_string_size: " + String($tooltip1/label.get_font("normal_font").get_string_size(current_target)))
return $tooltip1/label.get_font("normal_font").get_string_size(current_target)
func get_tooltip2_size():
@@ -237,9 +233,10 @@ func tooltip_distance_to_edge_right(position: Vector2):
return escoria.game_size.x - position.x
func show():
if _room_is_ready:
$tooltip1.visible = true;
$tooltip2.visible = true;
escoria.logger.info(self, "show")
# if _room_is_ready:
# $tooltip1.visible = true;
# $tooltip2.visible = true;
#$icon.visible = true;
#$label.visible = true;
#$background.visible = true;