This commit is contained in:
2026-03-04 22:52:02 -08:00
parent a675902d72
commit a2eb4de815
6 changed files with 59 additions and 24 deletions

View File

@@ -1,20 +1,20 @@
extends Node2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var hovered_setpieces: Array[String] = []
@onready var label : Label = $"label"
func _ready():
_connect_setpieces(get_parent())
func _on_transitioned(s):
hovered_setpieces.clear()
$label.hide()
_connect_setpieces(get_parent())
func _connect_setpieces(scene: Node) -> void:
for n in scene.find_children("*", "SetPiece"):
for n in scene.find_children("*", "SetPiece", true, false):
print("LOOKING AT", n)
n.connect("entered", Callable(self, "_on_setpiece_entered"))
n.connect("exited", Callable(self, "_on_setpiece_exited"))
@@ -64,20 +64,33 @@ func _process(delta):
var s = label.size
mouse_pos.x = clamp(mouse_pos.x, cam_top_left.x + margin, cam_bottom_right.x - label.size.x - margin)
mouse_pos.y = clamp(mouse_pos.y, cam_top_left.y, cam_bottom_right.y)
if $label.visible:
print("LABEL VISIBLE", $label.text)
# Update label position
global_position = mouse_pos
func _on_setpiece_entered(lab):
print("LABEL ENTERED ", lab)
$label.show()
$label.text = lab
func _on_setpiece_entered(lab: String) -> void:
if lab not in hovered_setpieces:
hovered_setpieces.append(lab)
_update_label()
func _on_setpiece_exited(lab: String) -> void:
hovered_setpieces.erase(lab)
_update_label()
func _update_label() -> void:
if hovered_setpieces.is_empty():
$label.hide()
return
var size = label.label_settings.font.get_string_size(lab,HORIZONTAL_ALIGNMENT_LEFT,200,32)
var top_label = hovered_setpieces[0]
$label.show()
$label.text = top_label
var size = label.label_settings.font.get_string_size(top_label, HORIZONTAL_ALIGNMENT_LEFT, 200, 32)
label.size = size
func _on_setpiece_exited():
$label.hide()
pass # Replace with function body.