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