From 2aefdf83912b56baf34daf51f6abd21206cfdf0a Mon Sep 17 00:00:00 2001 From: Sebastian Morr Date: Fri, 11 Sep 2020 10:33:44 +0200 Subject: [PATCH] Fix all warnings --- game.gd | 8 ++++---- main.gd | 5 +---- shell.gd | 2 +- terminal.gd | 6 +++++- terminal.tscn | 10 +++++++++- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/game.gd b/game.gd index eb43aa2..273021a 100644 --- a/game.gd +++ b/game.gd @@ -2,7 +2,7 @@ extends Node var tmp_prefix = _tmp_prefix() var global_shell -var debug = false +var debug_file_io = false var fake_editor func _ready(): @@ -16,7 +16,7 @@ func _ready(): global_shell.run("chmod u+x " + fake_editor) func read_file(path): - if debug: + if debug_file_io: print("reading " + path) var file = File.new() file.open(path, File.READ) @@ -25,7 +25,7 @@ func read_file(path): return content func write_file(path, content): - if debug: + if debug_file_io: print("writing " + path) var file = File.new() file.open(path, File.WRITE) @@ -47,7 +47,7 @@ func _tmp_prefix(): # Run a simple command with arguments, blocking, using OS.execute. func exec(command, args=[]): - var debug = true + var debug = false if debug: print("exec: %s [%s]" % [command, PoolStringArray(args).join(", ")]) diff --git a/main.gd b/main.gd index 6a39fb3..e74486d 100644 --- a/main.gd +++ b/main.gd @@ -99,10 +99,7 @@ func construct_repo(script, path): game.global_shell.run("mkdir " + path) game.global_shell.cd(path) game.global_shell.run("git init") - var o = game.global_shell.run("sh "+script_path) - - if game.debug: - print(o) + game.global_shell.run("sh "+script_path) func _process(_delta): if server.is_connection_available(): diff --git a/shell.gd b/shell.gd index 849cd95..0e2cd9b 100644 --- a/shell.gd +++ b/shell.gd @@ -59,7 +59,7 @@ func run_async_thread(command): var port = 1000 + (randi() % 1000) var s = TCP_Server.new() 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(): pass var c = s.take_connection() diff --git a/terminal.gd b/terminal.gd index cbfc4bb..7e0ad18 100644 --- a/terminal.gd +++ b/terminal.gd @@ -33,6 +33,10 @@ func send_command(command): history.push_back(command) history_position = history.size() + input.editable = false + + if thread != null: + thread.wait_to_finish() thread = Thread.new() thread.start(self, "run_command_in_a_thread", command) @@ -45,6 +49,7 @@ func run_command_in_a_thread(command): check_win_condition() input.text = "" + input.editable = true output.text = output.text + "$ " + command + "\n" + o repo.update_everything() @@ -54,4 +59,3 @@ func receive_output(text): func check_win_condition(): if repo.shell.run("bash /tmp/win && echo yes || echo no") == "yes\n": main.load_next_level() - print("you win!") diff --git a/terminal.tscn b/terminal.tscn index e24ea09..b8a03b1 100644 --- a/terminal.tscn +++ b/terminal.tscn @@ -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://terminal.gd" type="Script" id=2] @@ -11,6 +11,13 @@ content_margin_top = 10.0 content_margin_bottom = 10.0 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] content_margin_left = 10.0 content_margin_right = 10.0 @@ -89,6 +96,7 @@ align = 0 margin_top = 1039.0 margin_right = 1920.0 margin_bottom = 1080.0 +custom_styles/read_only = SubResource( 3 ) custom_styles/normal = SubResource( 2 ) custom_fonts/font = ExtResource( 1 ) caret_blink = true