Clear button, show arrow target if there's no node, add some goals

This commit is contained in:
Sebastian Morr 2020-09-14 15:35:30 +02:00
parent 1ea6e3b4ac
commit b1d2536bcc
10 changed files with 61 additions and 9 deletions

View file

@ -12,6 +12,10 @@ func _process(_delta):
if repository and repository.objects.has(target):
var t = repository.objects[target]
end = t.global_position
$Target.hide()
else:
$Target.text = target
$Target.show()
$Line.points[1] = end - global_position
$Label.position = ($Line.points[0] + $Line.points[1])/2
$Tip.position = ($Line.points[0] + $Line.points[1])/2

View file

@ -38,3 +38,16 @@ align = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Target" type="Label" parent="."]
margin_left = -229.024
margin_top = 63.3118
margin_right = 232.976
margin_bottom = 89.3118
custom_fonts/font = ExtResource( 2 )
custom_colors/font_color = Color( 0.356863, 0.356863, 0.356863, 1 )
text = "label"
align = 1
__meta__ = {
"_edit_use_anchors_": false
}

11
levels/05-ref/goal Normal file
View file

@ -0,0 +1,11 @@
echo hello > hello
echo world > world
BLOB1=$(git hash-object -w hello)
BLOB2=$(git hash-object -w world)
git add .
TREE=$(git write-tree)
COMMIT=$(git commit-tree $TREE -m "Initial commit")
git update-ref refs/a $BLOB1
git update-ref refs/b $BLOB2
git update-ref refs/c $TREE
git update-ref refs/d $COMMIT

View file

@ -4,6 +4,6 @@ When that happens, they are called "symbolic refs". You can create or update a s
git symbolic-ref <name> <ref>
Usually, you will only encounter a special symbolic ref called "HEAD". This ref is special in that it doesn't start with "refs/"!
Usually, you will only encounter a special symbolic ref called "HEAD". This ref is special in that it doesn't start with "refs/"! You might already have seen it in the other levels - it's the only thing that's always there!
Try pointing HEAD to the refs in this repository!

5
levels/06-symref/goal Normal file
View file

@ -0,0 +1,5 @@
TREE=$(git write-tree)
COMMIT=$(git commit-tree $TREE -m "Initial commit")
git update-ref refs/best_commit $COMMIT
git update-ref refs/worst_commit $COMMIT
git symbolic-ref HEAD refs/best_commit

View file

@ -6,6 +6,7 @@ var server
var client_connection
var current_level = 0
onready var terminal = $Terminal
onready var input = $Terminal/Control/Input
onready var output = $Terminal/Control/Output
onready var goal_repository = $Repositories/GoalRepository
@ -85,6 +86,8 @@ func load_level(id):
var dir = Directory.new()
dir.copy(win_script, win_script_target)
terminal.clear()
func reload_level():
load_level(current_level)

View file

@ -37,7 +37,7 @@ func set_label(new_label):
$Label.text = new_label
func update_index():
$Index.text = git("ls-files")
$Index.text = git("ls-files -s --abbrev=8").replace("\t", " ")
func random_position():
return Vector2(rand_range(0, rect_size.x), rand_range(0, rect_size.y))
@ -66,7 +66,6 @@ func update_objects():
c[p] = ""
n.children = c
"tag":
print("tag")
n.children = tag_target(o)
n.position = find_position(n)
@ -112,7 +111,6 @@ func find_position(n):
position += objects[child].position
count += 1
if count > 0:
print(count)
position /= count
n.position = position + Vector2(0, -150)
else:
@ -200,5 +198,8 @@ func ref_target(ref):
var ret = git("symbolic-ref -q "+ref+" || true")
# If it's not, it's probably a regular ref.
if ret == "":
if ref == "HEAD":
ret = git("show-ref --head "+ref).split(" ")[0]
else:
ret = git("show-ref "+ref).split(" ")[0]
return ret

View file

@ -18,7 +18,7 @@ __meta__ = {
}
[node name="Index" type="Label" parent="."]
margin_left = 32.0
margin_left = 24.0
margin_top = 80.0
margin_right = 375.079
margin_bottom = 1044.0
@ -30,6 +30,7 @@ __meta__ = {
}
[node name="IndexLabel" type="Label" parent="."]
visible = false
margin_left = 21.0
margin_top = 65.0
margin_right = 377.0

View file

@ -56,6 +56,10 @@ func run_command_in_a_thread(command):
func receive_output(text):
output.text += text
func clear():
input.text = ""
output.text = ""
func check_win_condition():
if repo.shell.run("bash /tmp/win 2>&1 >/dev/null && echo yes || echo no") == "yes\n":
main.show_win_status()

View file

@ -66,6 +66,7 @@ text = "echo $RANDOM | git hash-object -w --stdin"
align = 0
[node name="Button6" parent="Control" instance=ExtResource( 4 )]
visible = false
margin_left = 0.0
margin_top = 1019.0
margin_right = 1920.0
@ -74,11 +75,10 @@ text = "git update-index --add noises; git write-tree"
align = 0
[node name="Button2" parent="Control" instance=ExtResource( 4 )]
visible = false
margin_left = 0.0
margin_top = 979.0
margin_top = 1019.0
margin_right = 1920.0
margin_bottom = 999.0
margin_bottom = 1039.0
text = "git switch -c $RANDOM"
align = 0
@ -111,4 +111,14 @@ caret_blink = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ClearButton" type="Button" parent="."]
anchor_left = 0.9
anchor_right = 1.0
margin_left = -10.0
margin_top = 10.0
margin_right = -10.0
custom_fonts/font = ExtResource( 1 )
text = "Clear"
[connection signal="text_entered" from="Control/Input" to="." method="send_command"]
[connection signal="pressed" from="ClearButton" to="." method="clear"]