New Cards and Redraw Button

This commit is contained in:
bleeptrack 2020-10-13 18:13:42 +02:00
parent 0d5c78d2a4
commit af90678d45
4 changed files with 36 additions and 10 deletions

View file

@ -63,7 +63,10 @@ func dropped_on(other):
var full_command = ""
match arg_number:
1:
full_command = $Label.text + " " + other.id
var argument = other.id
if ($Label.text.begins_with("git checkout") or $Label.text.begins_with("git rebase")) and other.id.begins_with("refs/heads"):
argument = Array(other.id.split("/")).pop_back()
full_command = $Label.text + " " + argument
$"../Terminal".send_command(full_command)
buuurn()
2:

View file

@ -6,7 +6,9 @@
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 105.74, 143.46 )
[node name="Card" type="Node2D"]
[node name="Card" type="Node2D" groups=[
"cards",
]]
script = ExtResource( 1 )
[node name="ColorRect" type="ColorRect" parent="."]
@ -28,13 +30,14 @@ position = Vector2( -6.10352e-05, 0.00012207 )
shape = SubResource( 1 )
[node name="Label" type="Label" parent="."]
margin_left = -89.1555
margin_top = -131.488
margin_right = -38.1555
margin_bottom = -117.488
margin_left = -89.0
margin_top = -131.0
margin_right = 85.0
margin_bottom = -29.0
custom_fonts/font = ExtResource( 2 )
custom_colors/font_color = Color( 0, 0, 0, 1 )
text = "git checkout"
autowrap = true
__meta__ = {
"_edit_use_anchors_": false
}

View file

@ -6,7 +6,11 @@ var cards = [
{"command": 'touch "file$RANDOM"', "arg_number": 0},
{"command": 'git commit --allow-empty -m "$RANDOM"', "arg_number": 0},
{"command": 'git checkout -b "$RANDOM"', "arg_number": 0},
{"command": 'git merge', "arg_number": 1}
{"command": 'git merge', "arg_number": 1},
{"command": 'git symbolic-ref HEAD', "arg_number": 1},
{"command": 'git update-ref -d', "arg_number": 1},
{"command": 'git reflog expire --expire=now --all; git prune', "arg_number": 0},
{"command": 'git rebase', "arg_number": 1}
]
func _ready():
@ -24,8 +28,7 @@ func _ready():
$Terminal.repository = $Repository
for i in range(4):
draw_rand_card()
redraw_all_cards()
func _update_repo():
$Repository.update_everything()
@ -38,3 +41,9 @@ func draw_rand_card():
new_card.position = Vector2(rand_range(200, get_viewport().size.x - 200), get_viewport().size.y*3/4 + rand_range(-200,200))
add_child(new_card)
func redraw_all_cards():
for card in get_tree().get_nodes_in_group("cards"):
card.queue_free()
for i in range(10):
draw_rand_card()

View file

@ -41,4 +41,15 @@ margin_left = 1488.0
margin_top = 5.0
margin_right = 1914.0
margin_bottom = 586.0
[node name="Button" type="Button" parent="."]
margin_left = 1726.67
margin_top = 1021.41
margin_right = 1899.67
margin_bottom = 1063.41
text = "redraw cards"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="command_done" from="Terminal" to="." method="_update_repo"]
[connection signal="pressed" from="Button" to="." method="redraw_all_cards"]