mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-13 19:04:54 +01:00
Implement very stupid history
This commit is contained in:
parent
8ee7abbc82
commit
590408e54c
3 changed files with 22 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
echo "Hi" > file1
|
||||
echo "Ho" > file1
|
||||
echo "Hu" > file1
|
||||
echo "Ho" > file2
|
||||
echo "Hu" > file3
|
||||
git hash-object -w file1
|
||||
git hash-object -w file2
|
||||
git hash-object -w file3
|
||||
|
|
3
main.gd
3
main.gd
|
@ -18,6 +18,7 @@ func _ready():
|
|||
|
||||
# Load first level.
|
||||
load_level(0)
|
||||
$Terminal/Input.grab_focus()
|
||||
|
||||
func list_levels():
|
||||
var levels = []
|
||||
|
@ -96,6 +97,7 @@ func read_commit_message():
|
|||
$CommitMessage.show()
|
||||
$Terminal/Input.editable = false
|
||||
$CommitMessage.text = game.read_file($ActiveRepository.path+"/.git/COMMIT_EDITMSG")
|
||||
$CommitMessage.grab_focus()
|
||||
|
||||
func save_commit_message():
|
||||
game.write_file($ActiveRepository.path+"/.git/COMMIT_EDITMSG", $CommitMessage.text)
|
||||
|
@ -104,3 +106,4 @@ func save_commit_message():
|
|||
$Terminal/Input.editable = true
|
||||
$CommitMessage.text = ""
|
||||
$CommitMessage.hide()
|
||||
$Terminal/Input.grab_focus()
|
||||
|
|
17
terminal.gd
17
terminal.gd
|
@ -2,7 +2,24 @@ extends Node2D
|
|||
|
||||
var thread
|
||||
|
||||
var history = []
|
||||
var history_position = 0
|
||||
|
||||
func _input(event):
|
||||
if history.size() > 0:
|
||||
if event.is_action_pressed("ui_up"):
|
||||
history_position -= 1
|
||||
history_position %= history.size()
|
||||
$Input.text = history[history_position]
|
||||
if event.is_action_pressed("ui_down"):
|
||||
history_position += 1
|
||||
history_position %= history.size()
|
||||
$Input.text = history[history_position]
|
||||
|
||||
func send_command(command):
|
||||
history.push_back(command)
|
||||
history_position += 1
|
||||
|
||||
thread = Thread.new()
|
||||
thread.start(self, "run_command_in_a_thread", command)
|
||||
|
||||
|
|
Loading…
Reference in a new issue