Only drag one file with drag and drop, pretty ordering when taking/dropping

This commit is contained in:
blinry 2020-11-25 14:39:52 +01:00
parent f27faabcba
commit 1289ce19a3
5 changed files with 17 additions and 18 deletions

View file

@ -37,13 +37,16 @@ func _input(event):
get_parent_with_type().dropped_on(area.get_parent_with_type())
_turn_off_highlights()
dragged = false
if game.dragged_object:
game.dragged_object = null
elif game.dragged_object and game.dragged_object.has_method("try_play"):
if hovered and highlighted:
game.dragged_object.dropped_on(get_parent_with_type())
if event.button_index == BUTTON_LEFT and event.pressed and hovered:
if not game.dragged_object:
if get_parent().type == "file" and get_parent().item_type == "wd":
dragged = true
game.dragged_object = self
_turn_on_highlights()
func _set_highlighted(new_highlighted):

View file

@ -127,6 +127,6 @@ margin_right = 20.0
margin_bottom = 20.0
[node name="DropArea" parent="." instance=ExtResource( 4 )]
position = Vector2( 121.101, 116.61 )
position = Vector2( 79.9581, 82.3243 )
[connection signal="pressed" from="Panel/TextEdit/SaveButton" to="." method="save"]
[connection signal="pressed" from="Panel/TextEdit/CloseButton" to="." method="close"]

View file

@ -118,6 +118,6 @@ func dropped_on(other):
if other.type == "inventory":
file_browser.shell.run("take '%s'" % label)
else:
other.shell.run("drop '%s'" % label)
other.shell.run("drop '%s' %d %d" % [label, rand_range(50, 400), rand_range(50, 200)])
file_browser.update()
other.update()

View file

@ -45,20 +45,10 @@ func _ready():
# Load first chapter.
load_chapter(current_chapter)
file_browser.grab_focus()
inventory.shell = Shell.new()
inventory.shell.cd(game.tmp_prefix + "inventory")
func _input(event):
if event.is_action_pressed("tab"):
print("ha")
if file_browser.has_focus():
terminal.grab_focus()
else:
file_browser.grab_focus()
func load_chapter(id):
current_chapter = id
repopulate_levels()
@ -156,8 +146,7 @@ func update_repos():
var repo = repositories[r]
repo.update_everything()
file_browser.update()
#index.update()
file_browser.grab_focus()
inventory.update()
if levels.chapters[current_chapter].levels[current_level].check_win():
show_win_status()

View file

@ -3,3 +3,10 @@
echo "Taking $1!"
mkdir -p ~/inventory
mv "$1" ~/inventory
X=50
for file in ~/inventory/*; do
echo "x = $X" > $file
echo "y = 50" >> $file
X=$(expr $X + 100)
done