mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-12-22 20:32:38 +01:00
Adding inverted arrows that point along time
This commit is contained in:
parent
10a130a913
commit
85ad33a028
3 changed files with 105 additions and 0 deletions
|
@ -15,6 +15,7 @@ var hovered = false
|
|||
var start_pos = null
|
||||
|
||||
var arrow = preload("res://scenes/arrow.tscn")
|
||||
var time_arrow = preload("res://scenes/time_arrow.tscn")
|
||||
|
||||
func _ready():
|
||||
content_set(content)
|
||||
|
@ -87,6 +88,8 @@ func children_set(new_children):
|
|||
for c in new_children:
|
||||
if not children.has(c):
|
||||
var a = arrow.instance()
|
||||
if type == "commit":
|
||||
a = time_arrow.instance()
|
||||
a.source = id
|
||||
a.target = c
|
||||
a.repository = repository
|
||||
|
|
40
scenes/time_arrow.gd
Normal file
40
scenes/time_arrow.gd
Normal file
|
@ -0,0 +1,40 @@
|
|||
extends Node2D
|
||||
|
||||
var source: String
|
||||
var target: String
|
||||
|
||||
var repository: Control
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
func _process(_delta):
|
||||
position = Vector2(0,0)
|
||||
|
||||
if not (repository and repository.objects.has(source)):
|
||||
return
|
||||
|
||||
var start = repository.objects[source].position
|
||||
var end = start + Vector2(0, 60)
|
||||
|
||||
if repository and repository.objects.has(target) and repository.objects[target].visible:
|
||||
var t = repository.objects[target]
|
||||
end = t.position
|
||||
$Target.hide()
|
||||
$Line.show()
|
||||
$Tip.show()
|
||||
else:
|
||||
$Target.text = target
|
||||
if $Target.text.substr(0, 5) != "refs/":
|
||||
$Target.text = ""
|
||||
$Target.show()
|
||||
$Line.hide()
|
||||
$Tip.hide()
|
||||
|
||||
$Line.points[1] = end - repository.objects[source].position
|
||||
# Move the tip away from the object a bit.
|
||||
#$Line.points[1] -= $Line.points[1].normalized()*30
|
||||
#$Tip.position = $Line.points[0]
|
||||
#$Tip.rotation = PI+$Line.points[1].angle_to($Line.points[0])
|
||||
print($Line.points[1].angle_to($Line.points[0]))
|
||||
$Tip.rotation = PI-$Line.points[1].angle_to($Line.points[0])+0.25
|
62
scenes/time_arrow.tscn
Normal file
62
scenes/time_arrow.tscn
Normal file
|
@ -0,0 +1,62 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=1]
|
||||
[ext_resource path="res://scenes/time_arrow.gd" type="Script" id=2]
|
||||
|
||||
[node name="Arrow" type="Node2D"]
|
||||
show_behind_parent = true
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Line" type="Line2D" parent="."]
|
||||
z_index = -1
|
||||
points = PoolVector2Array( -0.480499, -0.11055, 158.301, 0.581757 )
|
||||
default_color = Color( 0.811765, 0.811765, 0.811765, 1 )
|
||||
|
||||
[node name="Tip" type="Node2D" parent="."]
|
||||
position = Vector2( 0.175903, -0.0836948 )
|
||||
z_index = 1
|
||||
|
||||
[node name="Polygon" type="Polygon2D" parent="Tip"]
|
||||
position = Vector2( -0.0332336, 0.422104 )
|
||||
rotation = 2.86234
|
||||
z_index = -1
|
||||
color = Color( 0.811765, 0.811765, 0.811765, 1 )
|
||||
offset = Vector2( -52.4162, -12.5157 )
|
||||
polygon = PoolVector2Array( -8.50021, 20.4619, 36.1874, 8.44903, 0.869781, -21.8232 )
|
||||
|
||||
[node name="Polygon2" type="Polygon2D" parent="Tip"]
|
||||
visible = false
|
||||
position = Vector2( -9.66138, -2.89842 )
|
||||
z_index = -1
|
||||
color = Color( 0.2, 0.2, 0.2, 1 )
|
||||
polygon = PoolVector2Array( -8.50021, 20.4619, 22.2526, 5.80623, 2.31131, -19.9012, -12.104, -23.7453, 4.95413, 1.72188, -21.9546, 16.1372 )
|
||||
|
||||
[node name="Label" type="Node2D" parent="."]
|
||||
visible = false
|
||||
position = Vector2( 102, 46 )
|
||||
|
||||
[node name="ID" type="Label" parent="Label"]
|
||||
margin_left = -19.374
|
||||
margin_top = -5.93085
|
||||
margin_right = 20.626
|
||||
margin_bottom = 8.06915
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
custom_colors/font_color = Color( 1, 1, 1, 1 )
|
||||
text = "label"
|
||||
align = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Target" type="Label" parent="."]
|
||||
margin_left = -230.84
|
||||
margin_top = 42.1225
|
||||
margin_right = 231.16
|
||||
margin_bottom = 68.1225
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
custom_colors/font_color = Color( 0.356863, 0.356863, 0.356863, 1 )
|
||||
text = "label"
|
||||
align = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
Loading…
Reference in a new issue