mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-22 16:20:19 +01:00
Add checkbox to hide trees and blobs
This commit is contained in:
parent
b1d2536bcc
commit
6d0fff27ad
7 changed files with 71 additions and 32 deletions
4
arrow.gd
4
arrow.gd
|
@ -9,12 +9,14 @@ func _ready():
|
||||||
|
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
var end = global_position + Vector2(0, 50)
|
var end = global_position + Vector2(0, 50)
|
||||||
if repository and repository.objects.has(target):
|
if repository and repository.objects.has(target) and repository.objects[target].visible:
|
||||||
var t = repository.objects[target]
|
var t = repository.objects[target]
|
||||||
end = t.global_position
|
end = t.global_position
|
||||||
$Target.hide()
|
$Target.hide()
|
||||||
else:
|
else:
|
||||||
$Target.text = target
|
$Target.text = target
|
||||||
|
if $Target.text.substr(0, 5) != "refs/":
|
||||||
|
$Target.text = ""#$Target.text.substr(0,8)
|
||||||
$Target.show()
|
$Target.show()
|
||||||
$Line.points[1] = end - 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
|
||||||
|
|
14
main.tscn
14
main.tscn
|
@ -74,8 +74,8 @@ __meta__ = {
|
||||||
[node name="Repositories" type="HBoxContainer" parent="."]
|
[node name="Repositories" type="HBoxContainer" parent="."]
|
||||||
margin_left = 5.0
|
margin_left = 5.0
|
||||||
margin_top = 5.0
|
margin_top = 5.0
|
||||||
margin_right = 1203.0
|
margin_right = 1218.0
|
||||||
margin_bottom = 1038.0
|
margin_bottom = 1076.0
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
custom_constants/separation = 0
|
custom_constants/separation = 0
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
|
@ -87,8 +87,8 @@ anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 0.0
|
margin_left = 0.0
|
||||||
margin_top = 0.0
|
margin_top = 0.0
|
||||||
margin_right = 599.0
|
margin_right = 606.0
|
||||||
margin_bottom = 1033.0
|
margin_bottom = 1071.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
label = "Goal"
|
label = "Goal"
|
||||||
|
@ -96,10 +96,10 @@ label = "Goal"
|
||||||
[node name="ActiveRepository" parent="Repositories" instance=ExtResource( 3 )]
|
[node name="ActiveRepository" parent="Repositories" instance=ExtResource( 3 )]
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 599.0
|
margin_left = 606.0
|
||||||
margin_top = 0.0
|
margin_top = 0.0
|
||||||
margin_right = 1198.0
|
margin_right = 1213.0
|
||||||
margin_bottom = 1033.0
|
margin_bottom = 1071.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
label = "Your repository"
|
label = "Your repository"
|
||||||
|
|
5
node.gd
5
node.gd
|
@ -18,11 +18,16 @@ func _process(_delta):
|
||||||
if held:
|
if held:
|
||||||
global_position = get_global_mouse_position()
|
global_position = get_global_mouse_position()
|
||||||
|
|
||||||
|
if visible:
|
||||||
|
apply_forces()
|
||||||
|
|
||||||
|
func apply_forces():
|
||||||
var offset = Vector2(0, 80)
|
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]
|
||||||
|
if other.visible:
|
||||||
var d = other.position.distance_to(position+offset)
|
var d = other.position.distance_to(position+offset)
|
||||||
var dir = (other.position - (position+offset)).normalized()
|
var dir = (other.position - (position+offset)).normalized()
|
||||||
var f = (d*0.03)
|
var f = (d*0.03)
|
||||||
|
|
|
@ -8,6 +8,8 @@ var node = preload("res://node.tscn")
|
||||||
var shell = Shell.new()
|
var shell = Shell.new()
|
||||||
var objects = {}
|
var objects = {}
|
||||||
|
|
||||||
|
var _simplified_view = false
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -46,14 +48,18 @@ func update_objects():
|
||||||
for o in all_objects():
|
for o in all_objects():
|
||||||
if objects.has(o):
|
if objects.has(o):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
var type = object_type(o)
|
||||||
|
if _simplified_view:
|
||||||
|
if type == "tree" or type == "blob":
|
||||||
|
continue
|
||||||
|
|
||||||
var n = node.instance()
|
var n = node.instance()
|
||||||
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.repository = self
|
n.repository = self
|
||||||
|
|
||||||
if true:
|
|
||||||
var type = object_type(o)
|
|
||||||
match type:
|
match type:
|
||||||
"blob":
|
"blob":
|
||||||
pass
|
pass
|
||||||
|
@ -89,8 +95,10 @@ func update_refs():
|
||||||
|
|
||||||
func apply_forces():
|
func apply_forces():
|
||||||
for o in objects.values():
|
for o in objects.values():
|
||||||
|
if not o.visible:
|
||||||
|
continue
|
||||||
for o2 in objects.values():
|
for o2 in objects.values():
|
||||||
if o == o2:
|
if o == o2 or not o2.visible:
|
||||||
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()
|
||||||
|
@ -203,3 +211,14 @@ func ref_target(ref):
|
||||||
else:
|
else:
|
||||||
ret = git("show-ref "+ref).split(" ")[0]
|
ret = git("show-ref "+ref).split(" ")[0]
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
func simplify_view(pressed):
|
||||||
|
_simplified_view = pressed
|
||||||
|
|
||||||
|
for o in objects:
|
||||||
|
var obj = objects[o]
|
||||||
|
if obj.type == "tree" or obj.type == "blob":
|
||||||
|
obj.visible = not pressed
|
||||||
|
|
||||||
|
update_objects()
|
||||||
|
|
|
@ -56,4 +56,13 @@ margin_left = 20.0
|
||||||
margin_top = 20.0
|
margin_top = 20.0
|
||||||
custom_fonts/font = ExtResource( 3 )
|
custom_fonts/font = ExtResource( 3 )
|
||||||
text = "Repo name"
|
text = "Repo name"
|
||||||
|
|
||||||
|
[node name="SimplifyCheckbox" type="CheckBox" parent="."]
|
||||||
|
anchor_top = 0.968
|
||||||
|
anchor_bottom = 0.968
|
||||||
|
margin_right = 24.0
|
||||||
|
margin_bottom = 24.0
|
||||||
|
custom_fonts/font = ExtResource( 2 )
|
||||||
|
text = "Hide trees and blobs"
|
||||||
[connection signal="pressed" from="Button" to="." method="update_everything"]
|
[connection signal="pressed" from="Button" to="." method="update_everything"]
|
||||||
|
[connection signal="toggled" from="SimplifyCheckbox" to="." method="simplify_view"]
|
||||||
|
|
|
@ -14,6 +14,8 @@ func _ready():
|
||||||
repo.shell.connect("output", self, "receive_output")
|
repo.shell.connect("output", self, "receive_output")
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
|
if event is InputEventKey:
|
||||||
|
input.grab_focus()
|
||||||
if history.size() > 0:
|
if history.size() > 0:
|
||||||
if event.is_action_pressed("ui_up"):
|
if event.is_action_pressed("ui_up"):
|
||||||
if history_position > 0:
|
if history_position > 0:
|
||||||
|
@ -57,7 +59,6 @@ func receive_output(text):
|
||||||
output.text += text
|
output.text += text
|
||||||
|
|
||||||
func clear():
|
func clear():
|
||||||
input.text = ""
|
|
||||||
output.text = ""
|
output.text = ""
|
||||||
|
|
||||||
func check_win_condition():
|
func check_win_condition():
|
||||||
|
|
|
@ -44,10 +44,13 @@ __meta__ = {
|
||||||
[node name="Output" type="RichTextLabel" parent="Control"]
|
[node name="Output" type="RichTextLabel" parent="Control"]
|
||||||
margin_right = 1920.0
|
margin_right = 1920.0
|
||||||
margin_bottom = 979.0
|
margin_bottom = 979.0
|
||||||
|
focus_mode = 2
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
custom_styles/normal = SubResource( 1 )
|
custom_styles/normal = SubResource( 1 )
|
||||||
custom_fonts/normal_font = ExtResource( 1 )
|
custom_fonts/normal_font = ExtResource( 1 )
|
||||||
|
custom_colors/selection_color = Color( 0.14902, 0.368627, 0.168627, 0.690196 )
|
||||||
scroll_following = true
|
scroll_following = true
|
||||||
|
selection_enabled = true
|
||||||
|
|
||||||
[node name="Button" parent="Control" instance=ExtResource( 4 )]
|
[node name="Button" parent="Control" instance=ExtResource( 4 )]
|
||||||
margin_left = 0.0
|
margin_left = 0.0
|
||||||
|
|
Loading…
Reference in a new issue