From 3eb5d1b52587b5608f7b3f73a30cb86ec592fdbe Mon Sep 17 00:00:00 2001 From: Michael Alexsander Silva Dias Date: Tue, 30 Apr 2019 16:18:08 -0300 Subject: [PATCH] Hide "Built-in Script" option in the script creation dialog when not possible --- editor/script_create_dialog.cpp | 21 ++++++++++----------- editor/script_create_dialog.h | 1 + 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index fac5bccd173..751ae4fcf75 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -567,23 +567,22 @@ void ScriptCreateDialog::_update_dialog() { } } - if (!_can_be_built_in()) - internal->set_pressed(false); - /* Is Script created or loaded from existing file */ if (is_built_in) { get_ok()->set_text(TTR("Create")); parent_name->set_editable(true); parent_browse_button->set_disabled(false); - internal->set_disabled(!_can_be_built_in()); + internal->set_visible(_can_be_built_in()); + internal_label->set_visible(_can_be_built_in()); _msg_path_valid(true, TTR("Built-in script (into scene file).")); } else if (is_new_script_created) { // New Script Created get_ok()->set_text(TTR("Create")); parent_name->set_editable(true); parent_browse_button->set_disabled(false); - internal->set_disabled(!_can_be_built_in()); + internal->set_visible(_can_be_built_in()); + internal_label->set_visible(_can_be_built_in()); if (is_path_valid) { _msg_path_valid(true, TTR("Will create a new script file.")); } @@ -753,13 +752,13 @@ ScriptCreateDialog::ScriptCreateDialog() { /* Built-in Script */ internal = memnew(CheckButton); + internal->set_h_size_flags(0); internal->connect("pressed", this, "_built_in_pressed"); - hb = memnew(HBoxContainer); - hb->add_child(internal); - l = memnew(Label(TTR("Built-in Script"))); - l->set_align(Label::ALIGN_RIGHT); - gc->add_child(l); - gc->add_child(hb); + internal_label = memnew(Label(TTR("Built-in Script"))); + internal_label->set_text(TTR("Built-in Script")); + internal_label->set_align(Label::ALIGN_RIGHT); + gc->add_child(internal_label); + gc->add_child(internal); /* Path */ diff --git a/editor/script_create_dialog.h b/editor/script_create_dialog.h index 1a3ba3d371c..c6dba78f560 100644 --- a/editor/script_create_dialog.h +++ b/editor/script_create_dialog.h @@ -58,6 +58,7 @@ class ScriptCreateDialog : public ConfirmationDialog { Button *path_button; EditorFileDialog *file_browse; CheckButton *internal; + Label *internal_label; VBoxContainer *path_vb; AcceptDialog *alert; CreateDialog *select_class;