2020-03-18 16:20:55 +01:00
|
|
|
extends Node2D
|
|
|
|
|
2020-09-22 20:25:45 +02:00
|
|
|
var source: String
|
2023-09-06 16:04:23 +02:00
|
|
|
var target: String: set = set_target
|
|
|
|
var color = Color("333333"): set = set_color
|
2020-09-22 20:25:45 +02:00
|
|
|
|
2020-09-21 20:28:43 +02:00
|
|
|
var repository: Control
|
2020-03-18 16:20:55 +01:00
|
|
|
|
|
|
|
func _ready():
|
2020-10-29 16:59:46 +01:00
|
|
|
set_color(color)
|
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 = 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-10-29 16:59:46 +01:00
|
|
|
var end = start
|
2020-09-22 20:25:45 +02:00
|
|
|
|
2020-10-29 16:59:46 +01:00
|
|
|
var parent_position = get_parent().get_parent().position
|
|
|
|
|
|
|
|
var show_arrow = repository.objects.has(target) and repository.objects[target].visible and repository.objects[source].visible and repository.objects[source].type != "head"
|
|
|
|
|
|
|
|
if show_arrow:
|
|
|
|
end = repository.objects[target].position
|
2020-09-14 15:35:30 +02:00
|
|
|
$Target.hide()
|
2020-10-29 16:59:46 +01:00
|
|
|
|
|
|
|
$Line.visible = show_arrow
|
|
|
|
$Tip.visible = show_arrow
|
2020-09-22 20:25:45 +02:00
|
|
|
|
2020-10-29 17:41:25 +01:00
|
|
|
if $Target.text.substr(0, 5) != "refs/" or repository.objects.has(target):
|
2020-10-29 16:59:46 +01:00
|
|
|
$Target.text = ""
|
|
|
|
|
|
|
|
$Line.points[0] = start - parent_position
|
|
|
|
$Line.points[1] = end - parent_position
|
|
|
|
|
|
|
|
#$Line.points[0] += ($Line.points[1] - $Line.points[0]).normalized()*30
|
|
|
|
$Line.points[1] -= ($Line.points[1] - $Line.points[0]).normalized()*30
|
2020-09-24 10:25:38 +02:00
|
|
|
$Tip.position = $Line.points[1]
|
2020-10-29 16:59:46 +01:00
|
|
|
$Tip.rotation = PI + atan2($Line.points[0].y - $Line.points[1].y, $Line.points[0].x - $Line.points[1].x)
|
|
|
|
|
|
|
|
func set_color(new_color):
|
|
|
|
color = new_color
|
|
|
|
$Line.default_color = new_color
|
|
|
|
$Tip/Polygon.color = new_color
|
2020-10-29 16:06:38 +01:00
|
|
|
|
2020-10-29 16:59:46 +01:00
|
|
|
func set_target(new_target):
|
|
|
|
target = new_target
|
|
|
|
$Target.text = new_target
|