2020-03-18 16:20:55 +01:00
|
|
|
extends Node2D
|
|
|
|
|
|
|
|
var id setget id_set
|
2020-03-18 16:28:48 +01:00
|
|
|
var content setget content_set
|
2020-03-18 16:20:55 +01:00
|
|
|
var type setget type_set
|
2020-09-01 17:24:21 +02:00
|
|
|
var repository: Node2D
|
2020-03-18 16:20:55 +01:00
|
|
|
|
2020-03-18 20:03:17 +01:00
|
|
|
var children = {} setget children_set
|
2020-09-01 21:25:24 +02:00
|
|
|
var id_always_visible = false
|
2020-03-18 16:20:55 +01:00
|
|
|
|
|
|
|
var arrow = preload("res://arrow.tscn")
|
|
|
|
|
|
|
|
func _ready():
|
2020-08-24 16:48:30 +02:00
|
|
|
pass
|
2020-03-18 16:20:55 +01:00
|
|
|
|
|
|
|
func _process(delta):
|
2020-08-24 16:48:30 +02:00
|
|
|
for c in children.keys():
|
2020-09-01 19:32:33 +02:00
|
|
|
if get_node("..").objects.has(c):
|
|
|
|
var other = get_node("..").objects[c]
|
|
|
|
var d = other.position.distance_to(position)
|
|
|
|
var dir = (other.position - position).normalized()
|
2020-09-01 21:25:24 +02:00
|
|
|
var f = (d*0.01)
|
2020-09-01 19:32:33 +02:00
|
|
|
position += dir*f
|
|
|
|
other.position -= dir*f
|
2020-08-24 16:48:30 +02:00
|
|
|
|
2020-03-18 16:20:55 +01:00
|
|
|
func id_set(new_id):
|
2020-08-24 16:48:30 +02:00
|
|
|
id = new_id
|
|
|
|
$ID.text = id
|
|
|
|
|
2020-03-18 16:28:48 +01:00
|
|
|
func content_set(new_content):
|
2020-08-24 16:48:30 +02:00
|
|
|
content = new_content
|
|
|
|
$Content.text = content
|
2020-03-18 16:20:55 +01:00
|
|
|
|
|
|
|
func type_set(new_type):
|
2020-08-24 16:48:30 +02:00
|
|
|
type = new_type
|
|
|
|
if type != "ref":
|
|
|
|
$ID.text = $ID.text.substr(0,8)
|
|
|
|
match new_type:
|
|
|
|
"blob":
|
2020-09-01 21:25:24 +02:00
|
|
|
$Rect.color = Color("#333333")
|
2020-08-24 16:48:30 +02:00
|
|
|
"tree":
|
|
|
|
$Rect.color = Color.darkgreen
|
|
|
|
"commit":
|
|
|
|
$Rect.color = Color.orange
|
|
|
|
"tag":
|
|
|
|
$Rect.color = Color.blue
|
2020-09-01 21:25:24 +02:00
|
|
|
id_always_visible = true
|
2020-08-24 16:48:30 +02:00
|
|
|
"ref":
|
|
|
|
$Rect.color = Color("#6680ff")
|
2020-09-01 21:25:24 +02:00
|
|
|
id_always_visible = true
|
2020-08-24 16:48:30 +02:00
|
|
|
"head":
|
|
|
|
$Rect.color = Color.red
|
2020-09-01 21:25:24 +02:00
|
|
|
id_always_visible = true
|
|
|
|
if id_always_visible:
|
|
|
|
$ID.show()
|
2020-03-18 16:20:55 +01:00
|
|
|
|
|
|
|
func children_set(new_children):
|
2020-08-24 16:48:30 +02:00
|
|
|
for c in $Arrows.get_children():
|
|
|
|
if not new_children.has(c.target):
|
|
|
|
c.queue_free()
|
|
|
|
for c in new_children:
|
|
|
|
if not children.has(c):
|
|
|
|
var a = arrow.instance()
|
|
|
|
a.label = new_children[c]
|
|
|
|
a.target = c
|
2020-09-01 17:24:21 +02:00
|
|
|
a.repository = repository
|
2020-08-24 16:48:30 +02:00
|
|
|
$Arrows.add_child(a)
|
|
|
|
children = new_children
|
2020-03-18 16:28:48 +01:00
|
|
|
|
|
|
|
func _on_hover():
|
2020-08-24 16:48:30 +02:00
|
|
|
$Content.visible = true
|
2020-09-01 21:25:24 +02:00
|
|
|
$ID.visible = true
|
2020-08-24 16:48:30 +02:00
|
|
|
|
2020-03-18 16:28:48 +01:00
|
|
|
func _on_unhover():
|
2020-09-01 21:25:24 +02:00
|
|
|
if not id_always_visible:
|
|
|
|
$Content.visible = false
|
|
|
|
$ID.visible = false
|
2020-03-18 16:28:48 +01:00
|
|
|
|