Restrict movement to arrow keys, switch to terminal by typing letters

This commit is contained in:
blinry 2020-11-18 20:12:15 +01:00
parent b5143ec906
commit 61325b7a97
4 changed files with 25 additions and 7 deletions

View file

@ -79,25 +79,21 @@ window/stretch/aspect="keep"
left={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null)
]
}
right={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"unicode":0,"echo":false,"script":null)
]
}
up={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null)
]
}
down={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"unicode":0,"echo":false,"script":null)
]
}
click={
@ -142,8 +138,12 @@ clear={
}
pickup={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":69,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null)
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null)
]
}
tab={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777218,"unicode":0,"echo":false,"script":null)
]
}

View file

@ -34,7 +34,7 @@ func _input(event):
if text_edit.visible:
save()
if has_focus():
if Input.is_action_pressed("pickup"):
if event.is_action_pressed("pickup"):
if player.held:
player.held = null
else:
@ -43,6 +43,9 @@ func _input(event):
if item.position.distance_to(player.position) < 150:
player.held = item
if event.is_action_pressed("up") or event.is_action_pressed("down") or event.is_action_pressed("left") or event.is_action_pressed("right"):
get_tree().set_input_as_handled()
func clear():
pass
for item in world.get_children():

View file

@ -46,6 +46,14 @@ func _ready():
load_chapter(current_chapter)
input.grab_focus()
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()
@ -144,6 +152,7 @@ func update_repos():
repo.update_everything()
file_browser.update()
#index.update()
file_browser.grab_focus()
if levels.chapters[current_chapter].levels[current_level].check_win():
show_win_status()

View file

@ -32,6 +32,12 @@ func _ready():
history_position = game.state["history"].size()
func _input(event):
if not $TextEditor.visible:
if event is InputEventKey:
var u = event.unicode
if u >= 97 && u <= 122:
input.grab_focus()
if not input.has_focus():
return