mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-22 16:20:19 +01:00
Try to point edges downward
This commit is contained in:
parent
f4990dedca
commit
1ea6e3b4ac
3 changed files with 33 additions and 34 deletions
11
arrow.gd
11
arrow.gd
|
@ -8,13 +8,14 @@ func _ready():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
|
var end = global_position + Vector2(0, 50)
|
||||||
if repository and repository.objects.has(target):
|
if repository and repository.objects.has(target):
|
||||||
var t = repository.objects[target]
|
var t = repository.objects[target]
|
||||||
#print(t)
|
end = t.global_position
|
||||||
$Line.points[1] = t.global_position - global_position
|
$Line.points[1] = end - global_position
|
||||||
$Label.position = ($Line.points[0] + $Line.points[1])/2
|
$Label.position = ($Line.points[0] + $Line.points[1])/2
|
||||||
$Tip.position = ($Line.points[0] + $Line.points[1])/2
|
$Tip.position = ($Line.points[0] + $Line.points[1])/2
|
||||||
$Tip.rotation = PI+$Line.points[0].angle_to($Line.points[1])
|
$Tip.rotation = PI+$Line.points[0].angle_to($Line.points[1])
|
||||||
|
|
||||||
func label_set(new_label):
|
func label_set(new_label):
|
||||||
label = new_label
|
label = new_label
|
||||||
|
|
8
node.gd
8
node.gd
|
@ -18,12 +18,14 @@ func _process(_delta):
|
||||||
if held:
|
if held:
|
||||||
global_position = get_global_mouse_position()
|
global_position = get_global_mouse_position()
|
||||||
|
|
||||||
|
var offset = Vector2(0, 80)
|
||||||
|
|
||||||
for c in children.keys():
|
for c in children.keys():
|
||||||
if get_node("..").objects.has(c):
|
if get_node("..").objects.has(c):
|
||||||
var other = get_node("..").objects[c]
|
var other = get_node("..").objects[c]
|
||||||
var d = other.position.distance_to(position)
|
var d = other.position.distance_to(position+offset)
|
||||||
var dir = (other.position - position).normalized()
|
var dir = (other.position - (position+offset)).normalized()
|
||||||
var f = (d*0.01)
|
var f = (d*0.03)
|
||||||
position += dir*f
|
position += dir*f
|
||||||
other.position -= dir*f
|
other.position -= dir*f
|
||||||
|
|
||||||
|
|
|
@ -50,29 +50,16 @@ func update_objects():
|
||||||
n.id = o
|
n.id = o
|
||||||
n.type = object_type(o)
|
n.type = object_type(o)
|
||||||
n.content = object_content(o)
|
n.content = object_content(o)
|
||||||
n.position = random_position()
|
|
||||||
n.repository = self
|
n.repository = self
|
||||||
|
|
||||||
if true:
|
if true:
|
||||||
#print(" ")
|
|
||||||
#print(o)
|
|
||||||
var type = object_type(o)
|
var type = object_type(o)
|
||||||
#print(type)
|
|
||||||
#print(object_content(o))
|
|
||||||
match type:
|
match type:
|
||||||
"blob":
|
"blob":
|
||||||
pass
|
pass
|
||||||
"tree":
|
"tree":
|
||||||
#print("Children:")
|
|
||||||
#print(tree_children(o))
|
|
||||||
n.children = tree_children(o)
|
n.children = tree_children(o)
|
||||||
"commit":
|
"commit":
|
||||||
#print("Tree:")
|
|
||||||
#print(commit_tree(o))
|
|
||||||
|
|
||||||
#print("Parents:")
|
|
||||||
#print(commit_parents(o))
|
|
||||||
|
|
||||||
var c = {}
|
var c = {}
|
||||||
c[commit_tree(o)] = ""
|
c[commit_tree(o)] = ""
|
||||||
for p in commit_parents(o):
|
for p in commit_parents(o):
|
||||||
|
@ -81,6 +68,8 @@ func update_objects():
|
||||||
"tag":
|
"tag":
|
||||||
print("tag")
|
print("tag")
|
||||||
n.children = tag_target(o)
|
n.children = tag_target(o)
|
||||||
|
|
||||||
|
n.position = find_position(n)
|
||||||
add_child(n)
|
add_child(n)
|
||||||
objects[o] = n
|
objects[o] = n
|
||||||
|
|
||||||
|
@ -92,8 +81,9 @@ func update_refs():
|
||||||
n.type = "ref"
|
n.type = "ref"
|
||||||
n.content = ""
|
n.content = ""
|
||||||
n.repository = self
|
n.repository = self
|
||||||
n.position = random_position()
|
|
||||||
objects[r] = n
|
objects[r] = n
|
||||||
|
n.children = {ref_target(r): ""}
|
||||||
|
n.position = find_position(n)
|
||||||
add_child(n)
|
add_child(n)
|
||||||
var n = objects[r]
|
var n = objects[r]
|
||||||
n.children = {ref_target(r): ""}
|
n.children = {ref_target(r): ""}
|
||||||
|
@ -105,7 +95,7 @@ func apply_forces():
|
||||||
continue
|
continue
|
||||||
var d = o.position.distance_to(o2.position)
|
var d = o.position.distance_to(o2.position)
|
||||||
var dir = (o.global_position - o2.global_position).normalized()
|
var dir = (o.global_position - o2.global_position).normalized()
|
||||||
var f = 3000/pow(d+0.00001,1.5)
|
var f = 2000/pow(d+0.00001,1.5)
|
||||||
o.position += dir*f
|
o.position += dir*f
|
||||||
o2.position -= dir*f
|
o2.position -= dir*f
|
||||||
var center_of_gravity = rect_size/2
|
var center_of_gravity = rect_size/2
|
||||||
|
@ -113,6 +103,21 @@ func apply_forces():
|
||||||
var dir = (o.position - center_of_gravity).normalized()
|
var dir = (o.position - center_of_gravity).normalized()
|
||||||
var f = (d+0.00001)*Vector2(0.03, 0.01)
|
var f = (d+0.00001)*Vector2(0.03, 0.01)
|
||||||
o.position -= dir*f
|
o.position -= dir*f
|
||||||
|
|
||||||
|
func find_position(n):
|
||||||
|
var position = Vector2.ZERO
|
||||||
|
var count = 0
|
||||||
|
for child in n.children:
|
||||||
|
if objects.has(child):
|
||||||
|
position += objects[child].position
|
||||||
|
count += 1
|
||||||
|
if count > 0:
|
||||||
|
print(count)
|
||||||
|
position /= count
|
||||||
|
n.position = position + Vector2(0, -150)
|
||||||
|
else:
|
||||||
|
n.position = random_position()
|
||||||
|
return n.position
|
||||||
|
|
||||||
func git(args, splitlines = false):
|
func git(args, splitlines = false):
|
||||||
var o = shell.run("git " + args)
|
var o = shell.run("git " + args)
|
||||||
|
@ -133,21 +138,12 @@ func update_head():
|
||||||
n.type = "head"
|
n.type = "head"
|
||||||
n.content = ""
|
n.content = ""
|
||||||
n.repository = self
|
n.repository = self
|
||||||
n.position = random_position()
|
n.position = find_position(n)
|
||||||
|
|
||||||
objects["HEAD"] = n
|
objects["HEAD"] = n
|
||||||
add_child(n)
|
add_child(n)
|
||||||
var n = objects["HEAD"]
|
var n = objects["HEAD"]
|
||||||
n.children = {ref_target("HEAD"): ""}
|
n.children = {ref_target("HEAD"): ""}
|
||||||
if not objects.has(ref_target("HEAD")):
|
|
||||||
var n2 = node.instance()
|
|
||||||
var r = ref_target("HEAD")
|
|
||||||
n2.id = r
|
|
||||||
n2.type = "ref"
|
|
||||||
n2.content = ""
|
|
||||||
n2.repository = self
|
|
||||||
n2.position = random_position()
|
|
||||||
objects[r] = n2
|
|
||||||
add_child(n2)
|
|
||||||
|
|
||||||
func all_objects():
|
func all_objects():
|
||||||
return git("cat-file --batch-check='%(objectname)' --batch-all-objects", true)
|
return git("cat-file --batch-check='%(objectname)' --batch-all-objects", true)
|
||||||
|
|
Loading…
Reference in a new issue