/**************************************************************************/ /* plugin_config_dialog.cpp */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /**************************************************************************/ /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of the Software, and to */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ #include "plugin_config_dialog.h" #include "core/io/config_file.h" #include "core/io/dir_access.h" #include "core/object/script_language.h" #include "editor/editor_node.h" #include "editor/editor_plugin.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() { name_edit->set_text(""); subfolder_edit->set_text(""); desc_edit->set_text(""); author_edit->set_text(""); version_edit->set_text(""); script_edit->set_text(""); } void PluginConfigDialog::_on_confirmed() { String path = "res://addons/" + _get_subfolder(); if (!_edit_mode) { Ref d = DirAccess::create(DirAccess::ACCESS_RESOURCES); if (d.is_null() || d->make_dir_recursive(path) != OK) { return; } } int lang_idx = script_option_edit->get_selected(); ScriptLanguage *language = ScriptServer::get_language(lang_idx); if (language == nullptr) { return; } String ext = language->get_extension(); String script_name = script_edit->get_text().is_empty() ? _get_subfolder() : script_edit->get_text(); if (script_name.get_extension() != ext) { script_name += "." + ext; } String script_path = path.path_join(script_name); Ref cf = memnew(ConfigFile); cf->load(path.path_join("plugin.cfg")); cf->set_value("plugin", "name", name_edit->get_text()); cf->set_value("plugin", "description", desc_edit->get_text()); cf->set_value("plugin", "author", author_edit->get_text()); cf->set_value("plugin", "version", version_edit->get_text()); cf->set_value("plugin", "script", script_name); cf->save(path.path_join("plugin.cfg")); if (!_edit_mode) { String class_name = script_name.get_basename(); String template_content = ""; Vector templates = language->get_built_in_templates("EditorPlugin"); if (!templates.is_empty()) { template_content = templates[0].content; } Ref