From 9a9541a8585b2b44de8963680a95c327840df514 Mon Sep 17 00:00:00 2001 From: blinry Date: Tue, 10 Nov 2020 22:52:48 +0100 Subject: [PATCH] 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. --- scenes/file_browser.tscn | 4 +++- scenes/terminal.gd | 5 +++++ scenes/text_editor.tscn | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/scenes/file_browser.tscn b/scenes/file_browser.tscn index 072e620..ed8f98c 100644 --- a/scenes/file_browser.tscn +++ b/scenes/file_browser.tscn @@ -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 ) diff --git a/scenes/terminal.gd b/scenes/terminal.gd index 99939af..76aa7a3 100644 --- a/scenes/terminal.gd +++ b/scenes/terminal.gd @@ -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() diff --git a/scenes/text_editor.tscn b/scenes/text_editor.tscn index f134f1d..732784f 100644 --- a/scenes/text_editor.tscn +++ b/scenes/text_editor.tscn @@ -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 )