diff options
Diffstat (limited to 'editor/script_create_dialog.cpp')
-rw-r--r-- | editor/script_create_dialog.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 00f44ad9b0..c19b80e649 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -145,9 +145,13 @@ void ScriptCreateDialog::ok_pressed() { void ScriptCreateDialog::_create_new() { - String cname; - if (has_named_classes) - cname = class_name->get_text(); + String cname_param; + + if (has_named_classes) { + cname_param = class_name->get_text(); + } else { + cname_param = ProjectSettings::get_singleton()->localize_path(file_path->get_text()).get_file().get_basename(); + } Ref<Script> scr; if (script_template != "") { @@ -159,13 +163,16 @@ void ScriptCreateDialog::_create_new() { return; } scr = scr->duplicate(); - ScriptServer::get_language(language_menu->get_selected())->make_template(cname, parent_name->get_text(), scr); + ScriptServer::get_language(language_menu->get_selected())->make_template(cname_param, parent_name->get_text(), scr); } else { - scr = ScriptServer::get_language(language_menu->get_selected())->get_template(cname, parent_name->get_text()); + scr = ScriptServer::get_language(language_menu->get_selected())->get_template(cname_param, parent_name->get_text()); } - if (cname != "") - scr->set_name(cname); + if (has_named_classes) { + String cname = class_name->get_text(); + if (cname.length()) + scr->set_name(cname); + } if (!is_built_in) { String lpath = ProjectSettings::get_singleton()->localize_path(file_path->get_text()); @@ -201,12 +208,20 @@ void ScriptCreateDialog::_lang_changed(int l) { l = language_menu->get_selected(); ScriptLanguage *language = ScriptServer::get_language(l); + if (language->has_named_classes()) { has_named_classes = true; } else { has_named_classes = false; } + if (language->supports_builtin_mode()) { + supports_built_in = true; + } else { + supports_built_in = false; + is_built_in = false; + } + if (ScriptServer::get_language(l)->can_inherit_from_file()) { can_inherit_from_file = true; } else { @@ -496,6 +511,9 @@ void ScriptCreateDialog::_update_dialog() { } } + if (!supports_built_in) + internal->set_pressed(false); + /* Is Script created or loaded from existing file */ if (is_new_script_created) { @@ -503,7 +521,7 @@ void ScriptCreateDialog::_update_dialog() { get_ok()->set_text(TTR("Create")); parent_name->set_editable(true); parent_browse_button->set_disabled(false); - internal->set_disabled(false); + internal->set_disabled(!supports_built_in); if (is_built_in) { _msg_path_valid(true, TTR("Built-in script (into scene file)")); } else { @@ -734,6 +752,7 @@ ScriptCreateDialog::ScriptCreateDialog() { is_path_valid = false; has_named_classes = false; + supports_built_in = false; can_inherit_from_file = false; is_built_in = false; |