From 751434c4d8de82a978591982c25745ad427f9b79 Mon Sep 17 00:00:00 2001 From: blinry Date: Tue, 3 Nov 2020 13:08:07 +0100 Subject: [PATCH] Enable actual command execution again, when playing cards --- scenes/card.gd | 36 +++++++++++++----------------------- scenes/drop_area.gd | 5 +---- scenes/drop_area.tscn | 6 +++--- scenes/node.tscn | 4 ++-- 4 files changed, 19 insertions(+), 32 deletions(-) diff --git a/scenes/card.gd b/scenes/card.gd index 0e718dd..d71e08e 100644 --- a/scenes/card.gd +++ b/scenes/card.gd @@ -53,15 +53,11 @@ func _unhandled_input(event): _turn_off_highlights() modulate.a = 1 - if get_viewport().get_mouse_position().y < get_viewport().size.y/3*2: -# if arg_number == 0 : -# try_play($Label.text) -# else: -# move_back() - pass - else: + if "[" in command: move_back() - + else: + try_play(command) + func _turn_on_highlights(): var arg_regex = RegEx.new() arg_regex.compile("\\[(.*)\\]") @@ -109,21 +105,15 @@ func move_back(): $ReturnSound.play() func dropped_on(other): - var full_command = "" -# match arg_number: -# 1: -# 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 -# try_play(full_command) -# 2: -# if _first_argument: -# full_command = $Label.text + " " + _first_argument + " " + other.id -# $"../Terminal".send_command(full_command) -# move_back() -# else: -# _first_argument = other.id + if "[" in command: + var argument = other.id + if (command.begins_with("git checkout") or command.begins_with("git rebase")) and other.id.begins_with("refs/heads"): + argument = Array(other.id.split("/")).pop_back() + + var arg_regex = RegEx.new() + arg_regex.compile("\\[(.*)\\]") + var full_command = arg_regex.sub(command, argument) + try_play(full_command) func try_play(full_command): if game.energy >= energy: diff --git a/scenes/drop_area.gd b/scenes/drop_area.gd index 0624628..c620dde 100644 --- a/scenes/drop_area.gd +++ b/scenes/drop_area.gd @@ -15,7 +15,7 @@ func _mouse_exited(): func _input(event): if event is InputEventMouseButton: if event.button_index == BUTTON_LEFT and !event.pressed and hovered: - if game.dragged_object: + if highlighted and game.dragged_object: game.dragged_object.dropped_on($"..") func _set_highlighted(new_highlighted): @@ -23,8 +23,5 @@ func _set_highlighted(new_highlighted): $Highlight.visible = highlighted func highlight(type): - print("highlight:") - print(type) - print(get_parent().type) if get_parent().type == type: _set_highlighted(true) diff --git a/scenes/drop_area.tscn b/scenes/drop_area.tscn index 27881eb..b0eeb77 100644 --- a/scenes/drop_area.tscn +++ b/scenes/drop_area.tscn @@ -10,6 +10,7 @@ radius = 23.5871 "drop_areas", ]] position = Vector2( -0.197731, 0.0673599 ) +z_index = -2 script = ExtResource( 1 ) [node name="Area2D" type="Area2D" parent="."] @@ -18,12 +19,11 @@ script = ExtResource( 1 ) shape = SubResource( 1 ) [node name="Highlight" type="Node2D" parent="."] -visible = false [node name="Sprite" type="Sprite" parent="Highlight"] modulate = Color( 0.65098, 0.560784, 0.890196, 0.533333 ) -position = Vector2( -0.302719, 0.302704 ) -scale = Vector2( 1.64865, 1.64865 ) +position = Vector2( -0.302734, -1.13884 ) +scale = Vector2( 0.921018, 0.921018 ) texture = ExtResource( 2 ) [connection signal="mouse_entered" from="Area2D" to="." method="_mouse_entered"] [connection signal="mouse_exited" from="Area2D" to="." method="_mouse_exited"] diff --git a/scenes/node.tscn b/scenes/node.tscn index 88d5f9c..d335ec1 100644 --- a/scenes/node.tscn +++ b/scenes/node.tscn @@ -23,6 +23,8 @@ corner_radius_bottom_left = 5 [node name="Node" type="Node2D"] script = ExtResource( 2 ) +[node name="DropArea" parent="." instance=ExtResource( 6 )] + [node name="Arrows" type="Node2D" parent="."] z_index = -1 @@ -58,8 +60,6 @@ __meta__ = { [node name="Pop" type="AudioStreamPlayer2D" parent="."] stream = ExtResource( 5 ) -[node name="DropArea" parent="." instance=ExtResource( 6 )] - [node name="Area2D" type="Area2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]