From a9f096636a8177dd4cbe8d18ddb33ea1b0e3d7b0 Mon Sep 17 00:00:00 2001 From: Sebastian Morr Date: Tue, 22 Sep 2020 15:55:01 +0200 Subject: [PATCH] Add a close button to the text editor --- text_editor.gd | 6 +++++- text_editor.tscn | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/text_editor.gd b/text_editor.gd index 210ce27..5c4e58f 100644 --- a/text_editor.gd +++ b/text_editor.gd @@ -35,6 +35,10 @@ func open(filename): func save(): var fixme_path = game.tmp_prefix+"/active/" game.write_file(fixme_path+path, text) - _client_connection.disconnect_from_host() + close() + +func close(): + if _client_connection.is_connected_to_host(): + _client_connection.disconnect_from_host() text = "" hide() diff --git a/text_editor.tscn b/text_editor.tscn index 68ccab6..740122c 100644 --- a/text_editor.tscn +++ b/text_editor.tscn @@ -30,4 +30,20 @@ text = "Save" __meta__ = { "_edit_use_anchors_": false } + +[node name="CloseButton" type="Button" parent="."] +anchor_left = 1.0 +anchor_right = 1.0 +margin_left = -50.0 +margin_top = 12.0 +margin_right = -10.0 +margin_bottom = 52.0 +focus_mode = 0 +custom_fonts/font = ExtResource( 1 ) +enabled_focus_mode = 0 +text = "x" +__meta__ = { +"_edit_use_anchors_": false +} [connection signal="pressed" from="SaveButton" to="." method="save"] +[connection signal="pressed" from="CloseButton" to="." method="close"]