2020-03-18 16:20:55 +01:00
|
|
|
extends Node2D
|
|
|
|
|
|
|
|
var label = "label" setget label_set
|
2020-09-22 20:25:45 +02:00
|
|
|
|
|
|
|
var source: String
|
|
|
|
var target: String
|
|
|
|
|
2020-09-21 20:28:43 +02:00
|
|
|
var repository: Control
|
2020-03-18 16:20:55 +01:00
|
|
|
|
|
|
|
func _ready():
|
2020-08-24 16:48:30 +02:00
|
|
|
pass
|
2020-03-18 16:20:55 +01:00
|
|
|
|
2020-09-08 20:26:14 +02:00
|
|
|
func _process(_delta):
|
2020-09-22 20:25:45 +02:00
|
|
|
#position = -repository.objects[source].position
|
|
|
|
position = Vector2(0,0)
|
|
|
|
|
2020-10-13 13:06:22 +02:00
|
|
|
if not (repository and repository.objects.has(source)):
|
|
|
|
return
|
|
|
|
|
2020-09-22 20:25:45 +02:00
|
|
|
var start = repository.objects[source].position
|
2020-09-24 10:31:41 +02:00
|
|
|
var end = start + Vector2(0, 60)
|
2020-09-22 20:25:45 +02:00
|
|
|
|
2020-09-14 16:03:01 +02:00
|
|
|
if repository and repository.objects.has(target) and repository.objects[target].visible:
|
2020-09-01 19:32:33 +02:00
|
|
|
var t = repository.objects[target]
|
2020-09-22 20:25:45 +02:00
|
|
|
end = t.position
|
2020-09-14 15:35:30 +02:00
|
|
|
$Target.hide()
|
|
|
|
else:
|
|
|
|
$Target.text = target
|
2020-09-14 16:03:01 +02:00
|
|
|
if $Target.text.substr(0, 5) != "refs/":
|
|
|
|
$Target.text = ""#$Target.text.substr(0,8)
|
2020-09-14 15:35:30 +02:00
|
|
|
$Target.show()
|
2020-09-22 20:25:45 +02:00
|
|
|
|
|
|
|
$Line.points[1] = end - repository.objects[source].position
|
2020-09-24 10:25:38 +02:00
|
|
|
# Move the tip away from the object a bit.
|
|
|
|
$Line.points[1] -= $Line.points[1].normalized()*30
|
|
|
|
#$Label.position = ($Line.points[0] + $Line.points[1])/1.3
|
|
|
|
$Tip.position = $Line.points[1]
|
2020-09-14 14:54:30 +02:00
|
|
|
$Tip.rotation = PI+$Line.points[0].angle_to($Line.points[1])
|
2020-08-24 16:48:30 +02:00
|
|
|
|
2020-03-18 16:20:55 +01:00
|
|
|
func label_set(new_label):
|
2020-08-24 16:48:30 +02:00
|
|
|
label = new_label
|
|
|
|
$Label/ID.text = label
|