mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-22 16:20:19 +01:00
Fix all warnings
This commit is contained in:
parent
41260bc93c
commit
2aefdf8391
5 changed files with 20 additions and 11 deletions
8
game.gd
8
game.gd
|
@ -2,7 +2,7 @@ extends Node
|
||||||
|
|
||||||
var tmp_prefix = _tmp_prefix()
|
var tmp_prefix = _tmp_prefix()
|
||||||
var global_shell
|
var global_shell
|
||||||
var debug = false
|
var debug_file_io = false
|
||||||
var fake_editor
|
var fake_editor
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
@ -16,7 +16,7 @@ func _ready():
|
||||||
global_shell.run("chmod u+x " + fake_editor)
|
global_shell.run("chmod u+x " + fake_editor)
|
||||||
|
|
||||||
func read_file(path):
|
func read_file(path):
|
||||||
if debug:
|
if debug_file_io:
|
||||||
print("reading " + path)
|
print("reading " + path)
|
||||||
var file = File.new()
|
var file = File.new()
|
||||||
file.open(path, File.READ)
|
file.open(path, File.READ)
|
||||||
|
@ -25,7 +25,7 @@ func read_file(path):
|
||||||
return content
|
return content
|
||||||
|
|
||||||
func write_file(path, content):
|
func write_file(path, content):
|
||||||
if debug:
|
if debug_file_io:
|
||||||
print("writing " + path)
|
print("writing " + path)
|
||||||
var file = File.new()
|
var file = File.new()
|
||||||
file.open(path, File.WRITE)
|
file.open(path, File.WRITE)
|
||||||
|
@ -47,7 +47,7 @@ func _tmp_prefix():
|
||||||
|
|
||||||
# Run a simple command with arguments, blocking, using OS.execute.
|
# Run a simple command with arguments, blocking, using OS.execute.
|
||||||
func exec(command, args=[]):
|
func exec(command, args=[]):
|
||||||
var debug = true
|
var debug = false
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
print("exec: %s [%s]" % [command, PoolStringArray(args).join(", ")])
|
print("exec: %s [%s]" % [command, PoolStringArray(args).join(", ")])
|
||||||
|
|
5
main.gd
5
main.gd
|
@ -99,10 +99,7 @@ func construct_repo(script, path):
|
||||||
game.global_shell.run("mkdir " + path)
|
game.global_shell.run("mkdir " + path)
|
||||||
game.global_shell.cd(path)
|
game.global_shell.cd(path)
|
||||||
game.global_shell.run("git init")
|
game.global_shell.run("git init")
|
||||||
var o = game.global_shell.run("sh "+script_path)
|
game.global_shell.run("sh "+script_path)
|
||||||
|
|
||||||
if game.debug:
|
|
||||||
print(o)
|
|
||||||
|
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
if server.is_connection_available():
|
if server.is_connection_available():
|
||||||
|
|
2
shell.gd
2
shell.gd
|
@ -59,7 +59,7 @@ func run_async_thread(command):
|
||||||
var port = 1000 + (randi() % 1000)
|
var port = 1000 + (randi() % 1000)
|
||||||
var s = TCP_Server.new()
|
var s = TCP_Server.new()
|
||||||
s.listen(port)
|
s.listen(port)
|
||||||
OS.execute("ncat", ["127.0.0.1", str(port), "-c", command], false, [], true)
|
var _pid = OS.execute("ncat", ["127.0.0.1", str(port), "-c", command], false, [], true)
|
||||||
while not s.is_connection_available():
|
while not s.is_connection_available():
|
||||||
pass
|
pass
|
||||||
var c = s.take_connection()
|
var c = s.take_connection()
|
||||||
|
|
|
@ -33,6 +33,10 @@ func send_command(command):
|
||||||
history.push_back(command)
|
history.push_back(command)
|
||||||
history_position = history.size()
|
history_position = history.size()
|
||||||
|
|
||||||
|
input.editable = false
|
||||||
|
|
||||||
|
if thread != null:
|
||||||
|
thread.wait_to_finish()
|
||||||
thread = Thread.new()
|
thread = Thread.new()
|
||||||
thread.start(self, "run_command_in_a_thread", command)
|
thread.start(self, "run_command_in_a_thread", command)
|
||||||
|
|
||||||
|
@ -45,6 +49,7 @@ func run_command_in_a_thread(command):
|
||||||
check_win_condition()
|
check_win_condition()
|
||||||
|
|
||||||
input.text = ""
|
input.text = ""
|
||||||
|
input.editable = true
|
||||||
output.text = output.text + "$ " + command + "\n" + o
|
output.text = output.text + "$ " + command + "\n" + o
|
||||||
repo.update_everything()
|
repo.update_everything()
|
||||||
|
|
||||||
|
@ -54,4 +59,3 @@ func receive_output(text):
|
||||||
func check_win_condition():
|
func check_win_condition():
|
||||||
if repo.shell.run("bash /tmp/win && echo yes || echo no") == "yes\n":
|
if repo.shell.run("bash /tmp/win && echo yes || echo no") == "yes\n":
|
||||||
main.load_next_level()
|
main.load_next_level()
|
||||||
print("you win!")
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=6 format=2]
|
[gd_scene load_steps=7 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=1]
|
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=1]
|
||||||
[ext_resource path="res://terminal.gd" type="Script" id=2]
|
[ext_resource path="res://terminal.gd" type="Script" id=2]
|
||||||
|
@ -11,6 +11,13 @@ content_margin_top = 10.0
|
||||||
content_margin_bottom = 10.0
|
content_margin_bottom = 10.0
|
||||||
bg_color = Color( 0, 0, 0, 1 )
|
bg_color = Color( 0, 0, 0, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id=3]
|
||||||
|
content_margin_left = 10.0
|
||||||
|
content_margin_right = 10.0
|
||||||
|
content_margin_top = 10.0
|
||||||
|
content_margin_bottom = 5.0
|
||||||
|
bg_color = Color( 0.0862745, 0.0862745, 0.0862745, 1 )
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id=2]
|
[sub_resource type="StyleBoxFlat" id=2]
|
||||||
content_margin_left = 10.0
|
content_margin_left = 10.0
|
||||||
content_margin_right = 10.0
|
content_margin_right = 10.0
|
||||||
|
@ -89,6 +96,7 @@ align = 0
|
||||||
margin_top = 1039.0
|
margin_top = 1039.0
|
||||||
margin_right = 1920.0
|
margin_right = 1920.0
|
||||||
margin_bottom = 1080.0
|
margin_bottom = 1080.0
|
||||||
|
custom_styles/read_only = SubResource( 3 )
|
||||||
custom_styles/normal = SubResource( 2 )
|
custom_styles/normal = SubResource( 2 )
|
||||||
custom_fonts/font = ExtResource( 1 )
|
custom_fonts/font = ExtResource( 1 )
|
||||||
caret_blink = true
|
caret_blink = true
|
||||||
|
|
Loading…
Reference in a new issue