mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-13 19:04:54 +01:00
Set up goal and active level from template repos
This commit is contained in:
parent
eb53163676
commit
1b5cbe9cb0
5 changed files with 37 additions and 22 deletions
6
game.gd
6
game.gd
|
@ -30,3 +30,9 @@ func load_state() -> bool:
|
|||
state[key] = new_state[key]
|
||||
savegame.close()
|
||||
return true
|
||||
|
||||
func run(command):
|
||||
var output = []
|
||||
OS.execute(command, [], true, output, true)
|
||||
# Remove trailing newline.
|
||||
return output[0].substr(0,len(output[0])-1)
|
||||
|
|
24
main.gd
24
main.gd
|
@ -2,13 +2,21 @@ extends Node2D
|
|||
|
||||
var dragged = null
|
||||
|
||||
var viewport_size
|
||||
|
||||
var server
|
||||
var client_connection
|
||||
|
||||
func _ready():
|
||||
viewport_size = get_viewport_rect().size
|
||||
var level = "first"
|
||||
var goal_repository_path = "goal"
|
||||
var start_repository_path = "start"
|
||||
var active_repository_path = "active"
|
||||
var active_prefix = "/tmp/"
|
||||
var levels_prefix = game.run("pwd")+"/levels/"+level+"/"
|
||||
|
||||
OS.execute("rm", ["-r", active_prefix+active_repository_path], true)
|
||||
OS.execute("cp", ["-ra", levels_prefix+start_repository_path, active_prefix+active_repository_path], true)
|
||||
$GoalRepository.path = levels_prefix+goal_repository_path
|
||||
$ActiveRepository.path = active_prefix+active_repository_path
|
||||
|
||||
server = TCP_Server.new()
|
||||
server.listen(1234)
|
||||
|
@ -29,7 +37,15 @@ func _process(delta):
|
|||
# dragged = null
|
||||
# if dragged:
|
||||
# dragged.position = get_global_mouse_position()
|
||||
|
||||
|
||||
#func run(command):
|
||||
# var a = command.split(" ")
|
||||
# var cmd = a[0]
|
||||
# a.remove(0)
|
||||
# var output = []
|
||||
# OS.execute(cmd, a, true, output, true)
|
||||
# print(command)
|
||||
# print(output[0])
|
||||
|
||||
func read_commit_message():
|
||||
$CommitMessage.show()
|
||||
|
|
10
main.tscn
10
main.tscn
|
@ -50,14 +50,12 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Repository" parent="." instance=ExtResource( 3 )]
|
||||
position = Vector2( 264.285, 118.658 )
|
||||
path = "/tmp/githydragit/"
|
||||
[node name="GoalRepository" parent="." instance=ExtResource( 3 )]
|
||||
position = Vector2( 21.5742, 19.4168 )
|
||||
size = Vector2( 500, 1000 )
|
||||
|
||||
[node name="Repository2" parent="." instance=ExtResource( 3 )]
|
||||
position = Vector2( 880.229, 135.918 )
|
||||
path = "/tmp/githydragit/"
|
||||
[node name="ActiveRepository" parent="." instance=ExtResource( 3 )]
|
||||
position = Vector2( 704.399, 17.2594 )
|
||||
size = Vector2( 500, 1000 )
|
||||
[connection signal="text_entered" from="Terminal/Input" to="Terminal" method="send_command"]
|
||||
[connection signal="pressed" from="CommitMessage/Button" to="." method="save_commit_message"]
|
||||
|
|
|
@ -9,11 +9,12 @@ func _ready():
|
|||
pass
|
||||
|
||||
func _process(delta):
|
||||
update_head()
|
||||
update_refs()
|
||||
update_index()
|
||||
update_objects()
|
||||
apply_forces()
|
||||
if path:
|
||||
update_head()
|
||||
update_refs()
|
||||
update_index()
|
||||
update_objects()
|
||||
apply_forces()
|
||||
|
||||
func set_path(new_path):
|
||||
path = new_path
|
||||
|
|
|
@ -7,7 +7,7 @@ func send_command(command):
|
|||
thread.start(self, "run_command_in_a_thread", command)
|
||||
|
||||
func run_command_in_a_thread(command):
|
||||
var cwd = run("pwd")
|
||||
var cwd = game.run("pwd")
|
||||
var output = []
|
||||
|
||||
var hacky_command = command
|
||||
|
@ -19,9 +19,3 @@ func run_command_in_a_thread(command):
|
|||
$Input.text = ""
|
||||
$Output.text = $Output.text + "$ " + command + "\n" + output[0]
|
||||
$Output.scroll_vertical = 999999
|
||||
|
||||
func run(command):
|
||||
var output = []
|
||||
OS.execute(command, [], true, output, true)
|
||||
# Remove trailing newline.
|
||||
return output[0].substr(0,len(output[0])-1)
|
||||
|
|
Loading…
Reference in a new issue