mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-20 16:20:18 +01:00
Enable actual command execution again, when playing cards
This commit is contained in:
parent
977a085940
commit
751434c4d8
4 changed files with 19 additions and 32 deletions
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -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"]
|
||||
|
|
Loading…
Reference in a new issue