oh-my-git/arrow.gd

32 lines
900 B
GDScript3
Raw Normal View History

2020-03-18 16:20:55 +01:00
extends Node2D
var label = "label" setget label_set
2020-09-01 17:24:21 +02:00
var target: String setget target_set
var repository: Container
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):
2020-09-14 14:54:30 +02:00
var end = global_position + Vector2(0, 50)
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]
2020-09-14 14:54:30 +02:00
end = t.global_position
$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)
$Target.show()
2020-09-21 20:06:09 +02:00
$Line.points[1] = (end - global_position)/repository.find_node("Nodes").rect_scale.x
$Label.position = ($Line.points[0] + $Line.points[1])/1.3
$Tip.position = ($Line.points[0] + $Line.points[1])/1.3
2020-09-14 14:54:30 +02:00
$Tip.rotation = PI+$Line.points[0].angle_to($Line.points[1])
2020-03-18 16:20:55 +01:00
func label_set(new_label):
label = new_label
$Label/ID.text = label
2020-03-18 16:20:55 +01:00
func target_set(new_target):
target = new_target