diff options
Diffstat (limited to 'editor/plugin_config_dialog.cpp')
-rw-r--r-- | editor/plugin_config_dialog.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp index 91e95c6006..8391eddc59 100644 --- a/editor/plugin_config_dialog.cpp +++ b/editor/plugin_config_dialog.cpp @@ -35,9 +35,9 @@ #include "core/object/script_language.h" #include "editor/editor_node.h" #include "editor/editor_plugin.h" -#include "editor/editor_scale.h" #include "editor/gui/editor_validation_panel.h" #include "editor/project_settings_editor.h" +#include "editor/themes/editor_scale.h" #include "scene/gui/grid_container.h" void PluginConfigDialog::_clear_fields() { @@ -62,7 +62,7 @@ void PluginConfigDialog::_on_confirmed() { int lang_idx = script_option_edit->get_selected(); String ext = ScriptServer::get_language(lang_idx)->get_extension(); String script_name = script_edit->get_text().is_empty() ? _get_subfolder() : script_edit->get_text(); - if (script_name.get_extension().is_empty()) { + if (script_name.get_extension() != ext) { script_name += "." + ext; } String script_path = path.path_join(script_name); @@ -156,33 +156,30 @@ void PluginConfigDialog::_notification(int p_what) { } void PluginConfigDialog::config(const String &p_config_path) { - if (p_config_path.length()) { + if (!p_config_path.is_empty()) { Ref<ConfigFile> cf = memnew(ConfigFile); Error err = cf->load(p_config_path); ERR_FAIL_COND_MSG(err != OK, "Cannot load config file from path '" + p_config_path + "'."); name_edit->set_text(cf->get_value("plugin", "name", "")); - subfolder_edit->set_text(p_config_path.get_base_dir().get_basename().get_file()); + subfolder_edit->set_text(p_config_path.get_base_dir().get_file()); desc_edit->set_text(cf->get_value("plugin", "description", "")); author_edit->set_text(cf->get_value("plugin", "author", "")); version_edit->set_text(cf->get_value("plugin", "version", "")); script_edit->set_text(cf->get_value("plugin", "script", "")); _edit_mode = true; - active_edit->hide(); - Object::cast_to<Label>(active_edit->get_parent()->get_child(active_edit->get_index() - 1))->hide(); - subfolder_edit->hide(); - Object::cast_to<Label>(subfolder_edit->get_parent()->get_child(subfolder_edit->get_index() - 1))->hide(); set_title(TTR("Edit a Plugin")); } else { _clear_fields(); _edit_mode = false; - active_edit->show(); - Object::cast_to<Label>(active_edit->get_parent()->get_child(active_edit->get_index() - 1))->show(); - subfolder_edit->show(); - Object::cast_to<Label>(subfolder_edit->get_parent()->get_child(subfolder_edit->get_index() - 1))->show(); set_title(TTR("Create a Plugin")); } + + for (Control *control : plugin_edit_hidden_controls) { + control->set_visible(!_edit_mode); + } + validation_panel->update(); get_ok_button()->set_disabled(!_edit_mode); @@ -224,12 +221,14 @@ PluginConfigDialog::PluginConfigDialog() { subfolder_lb->set_text(TTR("Subfolder:")); subfolder_lb->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT); grid->add_child(subfolder_lb); + plugin_edit_hidden_controls.push_back(subfolder_lb); subfolder_edit = memnew(LineEdit); subfolder_edit->set_placeholder("\"my_plugin\" -> res://addons/my_plugin"); subfolder_edit->set_tooltip_text(TTR("Optional. The folder name should generally use `snake_case` naming (avoid spaces and special characters).\nIf left empty, the folder will be named after the plugin name converted to `snake_case`.")); subfolder_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL); grid->add_child(subfolder_edit); + plugin_edit_hidden_controls.push_back(subfolder_edit); // Description Label *desc_lb = memnew(Label); @@ -305,10 +304,12 @@ PluginConfigDialog::PluginConfigDialog() { active_lb->set_text(TTR("Activate now?")); active_lb->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT); grid->add_child(active_lb); + plugin_edit_hidden_controls.push_back(active_lb); active_edit = memnew(CheckBox); active_edit->set_pressed(true); grid->add_child(active_edit); + plugin_edit_hidden_controls.push_back(active_edit); Control *spacing = memnew(Control); vbox->add_child(spacing); |