Compare commits

...

3 commits

Author SHA1 Message Date
Morten M. Neergaard 8f2a27c3fa
Merge 1fa435eedd into 9da0bd1fbd 2024-02-19 07:17:15 -07:00
Marcel Ribeiro-Dantas 9da0bd1fbd Fix typos 2024-02-13 15:20:04 +01:00
Morten Minde Neergaard 1fa435eedd terminal: Change input handling
1. Handle page up / down for scrolling terminal history
2. Handle repeat keypresses, so e.g. holding pgdn will scroll
3. _input is passed a single event, so we save some CPU cycles by using
   `elif` for all branches
2022-11-03 09:36:26 +01:00
5 changed files with 32 additions and 24 deletions

View file

@ -21,7 +21,7 @@ Wanna build your own level? Great! Here's how to do it:
1. Run the game the easiest way to do so is to run `godot scenes/main.tscn` from the project directory.
1. Get a bit familiar with the levels which are currently there.
1. Take a look into the `levels` directory. It's split into chapters, and each level is a file.
1. Make a copy of an existing level or start writing your own. See the documention of the format below.
1. Make a copy of an existing level or start writing your own. See the documentation of the format below.
1. Write and test your level. If you're happy with it, feel free to send it to us in a pull request! <3
### Level format

View file

@ -35,4 +35,4 @@ test "$(git show main^:c)" != "c"
[congrats]
Well done! Try tavelling between the commits using `git checkout`, so you can look at their contents again!
Well done! Try travelling between the commits using `git checkout`, so you can look at their contents again!

View file

@ -39,7 +39,7 @@ git add recipe
[win]
# Did you resolve the confict and commit?
# Did you resolve the conflict and commit?
{ git show HEAD | grep "Flour"; } && { git show HEAD | grep "Salt"; }
# Did you clear stash stack?

View file

@ -74,7 +74,7 @@ func shell_received(text):
func _notification(what):
if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST:
#get_tree().quit() # default behavio
#get_tree().quit() # default behavior
get_tree().change_scene("res://scenes/survey.tscn")

View file

@ -34,29 +34,14 @@ func _ready():
history_position = game.state["history"].size()
func _input(event):
if not input.has_focus():
if not input.has_focus() or not event.is_pressed():
return
if game.state["history"].size() > 0:
if event.is_action_pressed("ui_up"):
if history_position > 0:
history_position -= 1
input.text = game.state["history"][history_position]
input.caret_position = input.text.length()
# This prevents the Input taking the arrow as a "skip to beginning" command.
get_tree().set_input_as_handled()
if event.is_action_pressed("ui_down"):
if history_position < game.state["history"].size()-1:
history_position += 1
input.text = game.state["history"][history_position]
input.caret_position = input.text.length()
get_tree().set_input_as_handled()
if event.is_action_pressed("tab_complete"):
if event.is_action("tab_complete"):
if completions.visible:
completions.get_root().get_children().select(0)
get_tree().set_input_as_handled()
if event.is_action_pressed("delete_word"):
elif event.is_action("delete_word"):
var first_half = input.text.substr(0,input.caret_position)
var second_half = input.text.substr(input.caret_position)
@ -66,9 +51,32 @@ func _input(event):
input.caret_position = idx+1
else:
input.text = "" + second_half
if event.is_action_pressed("clear"):
elif event.is_action("clear"):
clear()
elif event.is_action("ui_page_up"):
var scroll = output.get_v_scroll()
scroll.set_value(scroll.value - output.get_rect().size.y / 2)
elif event.is_action("ui_page_down"):
var scroll = output.get_v_scroll()
scroll.set_value(scroll.value + output.get_rect().size.y / 2)
elif game.state["history"].size() > 0:
if event.is_action("ui_up"):
if history_position > 0:
history_position -= 1
input.text = game.state["history"][history_position]
input.caret_position = input.text.length()
# This prevents the Input taking the arrow as a "skip to beginning" command.
get_tree().set_input_as_handled()
elif event.is_action("ui_down"):
if history_position < game.state["history"].size():
history_position += 1
if history_position == game.state["history"].size():
input.text = ""
else:
input.text = game.state["history"][history_position]
input.caret_position = input.text.length()
get_tree().set_input_as_handled()
func load_command(id):
input.text = premade_commands[id]
input.caret_position = input.text.length()