You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-30 16:26:50 +00:00
Prevent built-in-scripts from being made from FileSystem dock
Prevent built-in-scripts from being made from FileSystem dock
This commit is contained in:
@@ -1535,7 +1535,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> p_selected)
|
|||||||
if (!fpath.ends_with("/")) {
|
if (!fpath.ends_with("/")) {
|
||||||
fpath = fpath.get_base_dir();
|
fpath = fpath.get_base_dir();
|
||||||
}
|
}
|
||||||
make_script_dialog_text->config("Node", fpath + "new_script.gd");
|
make_script_dialog_text->config("Node", fpath + "new_script.gd", false);
|
||||||
make_script_dialog_text->popup_centered(Size2(300, 300) * EDSCALE);
|
make_script_dialog_text->popup_centered(Size2(300, 300) * EDSCALE);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,11 @@ void ScriptCreateDialog::_notification(int p_what) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptCreateDialog::config(const String &p_base_name, const String &p_base_path) {
|
bool ScriptCreateDialog::_can_be_built_in() {
|
||||||
|
return (supports_built_in && built_in_enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptCreateDialog::config(const String &p_base_name, const String &p_base_path, bool p_built_in_enabled) {
|
||||||
|
|
||||||
class_name->set_text("");
|
class_name->set_text("");
|
||||||
class_name->deselect();
|
class_name->deselect();
|
||||||
@@ -66,6 +70,8 @@ void ScriptCreateDialog::config(const String &p_base_name, const String &p_base_
|
|||||||
}
|
}
|
||||||
file_path->deselect();
|
file_path->deselect();
|
||||||
|
|
||||||
|
built_in_enabled = p_built_in_enabled;
|
||||||
|
|
||||||
_lang_changed(current_language);
|
_lang_changed(current_language);
|
||||||
_class_name_changed("");
|
_class_name_changed("");
|
||||||
_path_changed(file_path->get_text());
|
_path_changed(file_path->get_text());
|
||||||
@@ -544,7 +550,7 @@ void ScriptCreateDialog::_update_dialog() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!supports_built_in)
|
if (!_can_be_built_in())
|
||||||
internal->set_pressed(false);
|
internal->set_pressed(false);
|
||||||
|
|
||||||
/* Is Script created or loaded from existing file */
|
/* Is Script created or loaded from existing file */
|
||||||
@@ -553,14 +559,14 @@ void ScriptCreateDialog::_update_dialog() {
|
|||||||
get_ok()->set_text(TTR("Create"));
|
get_ok()->set_text(TTR("Create"));
|
||||||
parent_name->set_editable(true);
|
parent_name->set_editable(true);
|
||||||
parent_browse_button->set_disabled(false);
|
parent_browse_button->set_disabled(false);
|
||||||
internal->set_disabled(!supports_built_in);
|
internal->set_disabled(!_can_be_built_in());
|
||||||
_msg_path_valid(true, TTR("Built-in script (into scene file)"));
|
_msg_path_valid(true, TTR("Built-in script (into scene file)"));
|
||||||
} else if (is_new_script_created) {
|
} else if (is_new_script_created) {
|
||||||
// New Script Created
|
// New Script Created
|
||||||
get_ok()->set_text(TTR("Create"));
|
get_ok()->set_text(TTR("Create"));
|
||||||
parent_name->set_editable(true);
|
parent_name->set_editable(true);
|
||||||
parent_browse_button->set_disabled(false);
|
parent_browse_button->set_disabled(false);
|
||||||
internal->set_disabled(!supports_built_in);
|
internal->set_disabled(!_can_be_built_in());
|
||||||
if (is_path_valid) {
|
if (is_path_valid) {
|
||||||
_msg_path_valid(true, TTR("Create new script file"));
|
_msg_path_valid(true, TTR("Create new script file"));
|
||||||
}
|
}
|
||||||
@@ -569,7 +575,7 @@ void ScriptCreateDialog::_update_dialog() {
|
|||||||
get_ok()->set_text(TTR("Load"));
|
get_ok()->set_text(TTR("Load"));
|
||||||
parent_name->set_editable(false);
|
parent_name->set_editable(false);
|
||||||
parent_browse_button->set_disabled(true);
|
parent_browse_button->set_disabled(true);
|
||||||
internal->set_disabled(!supports_built_in);
|
internal->set_disabled(!_can_be_built_in());
|
||||||
if (is_path_valid) {
|
if (is_path_valid) {
|
||||||
_msg_path_valid(true, TTR("Load existing script file"));
|
_msg_path_valid(true, TTR("Load existing script file"));
|
||||||
}
|
}
|
||||||
@@ -588,7 +594,7 @@ void ScriptCreateDialog::_bind_methods() {
|
|||||||
ClassDB::bind_method("_path_entered", &ScriptCreateDialog::_path_entered);
|
ClassDB::bind_method("_path_entered", &ScriptCreateDialog::_path_entered);
|
||||||
ClassDB::bind_method("_template_changed", &ScriptCreateDialog::_template_changed);
|
ClassDB::bind_method("_template_changed", &ScriptCreateDialog::_template_changed);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("config", "inherits", "path"), &ScriptCreateDialog::config);
|
ClassDB::bind_method(D_METHOD("config", "inherits", "path", "built_in_enabled"), &ScriptCreateDialog::config, DEFVAL(true));
|
||||||
|
|
||||||
ADD_SIGNAL(MethodInfo("script_created", PropertyInfo(Variant::OBJECT, "script", PROPERTY_HINT_RESOURCE_TYPE, "Script")));
|
ADD_SIGNAL(MethodInfo("script_created", PropertyInfo(Variant::OBJECT, "script", PROPERTY_HINT_RESOURCE_TYPE, "Script")));
|
||||||
}
|
}
|
||||||
@@ -793,6 +799,7 @@ ScriptCreateDialog::ScriptCreateDialog() {
|
|||||||
has_named_classes = false;
|
has_named_classes = false;
|
||||||
supports_built_in = false;
|
supports_built_in = false;
|
||||||
can_inherit_from_file = false;
|
can_inherit_from_file = false;
|
||||||
|
built_in_enabled = true;
|
||||||
is_built_in = false;
|
is_built_in = false;
|
||||||
|
|
||||||
is_new_script_created = true;
|
is_new_script_created = true;
|
||||||
|
|||||||
@@ -69,11 +69,13 @@ class ScriptCreateDialog : public ConfirmationDialog {
|
|||||||
bool is_parent_name_valid;
|
bool is_parent_name_valid;
|
||||||
bool is_class_name_valid;
|
bool is_class_name_valid;
|
||||||
bool is_built_in;
|
bool is_built_in;
|
||||||
|
bool built_in_enabled;
|
||||||
int current_language;
|
int current_language;
|
||||||
bool re_check_path;
|
bool re_check_path;
|
||||||
String script_template;
|
String script_template;
|
||||||
Vector<String> template_list;
|
Vector<String> template_list;
|
||||||
|
|
||||||
|
bool _can_be_built_in();
|
||||||
void _path_changed(const String &p_path = String());
|
void _path_changed(const String &p_path = String());
|
||||||
void _path_entered(const String &p_path = String());
|
void _path_entered(const String &p_path = String());
|
||||||
void _lang_changed(int l = 0);
|
void _lang_changed(int l = 0);
|
||||||
@@ -96,8 +98,7 @@ protected:
|
|||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void config(const String &p_base_name, const String &p_base_path);
|
void config(const String &p_base_name, const String &p_base_path, bool p_built_in_enabled = true);
|
||||||
|
|
||||||
ScriptCreateDialog();
|
ScriptCreateDialog();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user