oh-my-git/scenes/arrow.gd

37 lines
863 B
GDScript3
Raw Normal View History

2020-03-18 16:20:55 +01:00
extends Node2D
var source: String
var target: String
var repository: Control
2020-03-18 16:20:55 +01:00
func _ready():
pass
2020-03-18 16:20:55 +01:00
2020-09-08 20:26:14 +02:00
func _process(_delta):
position = Vector2(0,0)
if not (repository and repository.objects.has(source)):
return
var start = repository.objects[source].position
var end = start + Vector2(0, 60)
2020-09-14 16:03:01 +02:00
if repository and repository.objects.has(target) and repository.objects[target].visible:
var t = repository.objects[target]
end = t.position
$Target.hide()
else:
$Target.text = target
2020-09-14 16:03:01 +02:00
if $Target.text.substr(0, 5) != "refs/":
2020-10-26 18:56:35 +01:00
$Target.text = ""
$Target.show()
2020-10-23 16:52:03 +02:00
$Line.hide()
$Tip.hide()
$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
$Tip.position = $Line.points[1]
2020-09-14 14:54:30 +02:00
$Tip.rotation = PI+$Line.points[0].angle_to($Line.points[1])