Close all open editors when running a terminal command

This is a first workaround for the problem that editors are sometimes
out of date. The UI around these will probably continue to change
significantly. Closes #7.
This commit is contained in:
blinry 2020-11-10 22:52:48 +01:00
parent 0e2cacabce
commit 9a9541a858
3 changed files with 11 additions and 2 deletions

View file

@ -4,7 +4,9 @@
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=2]
[ext_resource path="res://styles/theme.tres" type="Theme" id=3]
[node name="FileBrowser" type="Control"]
[node name="FileBrowser" type="Control" groups=[
"editors",
]]
anchor_right = 1.0
anchor_bottom = 1.0
rect_min_size = Vector2( 0, 142 )

View file

@ -72,6 +72,7 @@ func load_command(id):
input.caret_position = input.text.length()
func send_command(command):
close_all_editors()
game.state["history"].push_back(command)
game.save_state()
history_position = game.state["history"].size()
@ -206,3 +207,7 @@ func _completion_selected():
func editor_saved():
emit_signal("command_done")
func close_all_editors():
for editor in get_tree().get_nodes_in_group("editors"):
editor.close()

View file

@ -3,7 +3,9 @@
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=1]
[ext_resource path="res://scenes/text_editor.gd" type="Script" id=2]
[node name="TextEditor" type="TextEdit"]
[node name="TextEditor" type="TextEdit" groups=[
"editors",
]]
anchor_right = 1.0
anchor_bottom = 1.0
custom_colors/background_color = Color( 0, 0, 0, 1 )