/*************************************************************************/ /* plugin_config_dialog.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* 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/os/dir_access.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/project_settings_editor.h" #include "scene/gui/grid_container.h" #include "modules/modules_enabled.gen.h" // For gdscript. #include "core/object/class_db.h" #include "core/error/error_list.h" #include "core/error/error_macros.h" #include "core/io/resource_saver.h" #include "core/math/vector2.h" #include "core/os/memory.h" #include "core/object/reference.h" #include "core/object/script_language.h" #include "core/variant/variant.h" #include "scene/gui/button.h" #include "scene/gui/check_box.h" #include "scene/gui/label.h" #include "scene/gui/line_edit.h" #include "scene/gui/option_button.h" #include "scene/gui/popup.h" #include "scene/gui/text_edit.h" #include "scene/main/node.h" #ifdef MODULE_GDSCRIPT_ENABLED #include "modules/gdscript/gdscript.h" #endif 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/" + subfolder_edit->get_text(); if (!_edit_mode) { DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES); if (!d || d->make_dir_recursive(path) != OK) { return; } } Ref cf = memnew(ConfigFile); 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_edit->get_text()); cf->save(path.plus_file("plugin.cfg")); if (!_edit_mode) { int lang_idx = script_option_edit->get_selected(); String lang_name = ScriptServer::get_language(lang_idx)->get_name(); Ref