oh-my-git/node.gd

58 lines
1.2 KiB
GDScript3
Raw Normal View History

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
var children = [] setget children_set
var arrow = preload("res://arrow.tscn")
func _ready():
pass
func _process(delta):
2020-03-18 16:42:19 +01:00
for c in children:
var other = get_node("..").objects[c]
var d = other.position.distance_to(position)
var dir = (other.position - position).normalized()
var f = ((d-400)*0.01)
position += dir*f
other.position -= dir*f
2020-03-18 16:20:55 +01:00
func id_set(new_id):
id = new_id
$ID.text = id
2020-03-18 16:28:48 +01:00
func content_set(new_content):
content = new_content
$Content.text = content
2020-03-18 16:20:55 +01:00
func type_set(new_type):
type = new_type
$ID.text = new_type + " " + $ID.text.substr(0,8)
match new_type:
"blob":
$Rect.color = Color.gray
"tree":
$Rect.color = Color.darkgreen
"commit":
$Rect.color = Color.orange
"tag":
$Rect.color = Color.blue
func children_set(new_children):
children = new_children
for c in children:
var a = arrow.instance()
a.label = "test"
a.target = c
add_child(a)
2020-03-18 16:28:48 +01:00
func _on_hover():
$Content.visible = true
func _on_unhover():
$Content.visible = false