| 1 | /**************************************************************************/ |
| 2 | /* import_dock.h */ |
| 3 | /**************************************************************************/ |
| 4 | /* This file is part of: */ |
| 5 | /* GODOT ENGINE */ |
| 6 | /* https://godotengine.org */ |
| 7 | /**************************************************************************/ |
| 8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
| 9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
| 10 | /* */ |
| 11 | /* Permission is hereby granted, free of charge, to any person obtaining */ |
| 12 | /* a copy of this software and associated documentation files (the */ |
| 13 | /* "Software"), to deal in the Software without restriction, including */ |
| 14 | /* without limitation the rights to use, copy, modify, merge, publish, */ |
| 15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ |
| 16 | /* permit persons to whom the Software is furnished to do so, subject to */ |
| 17 | /* the following conditions: */ |
| 18 | /* */ |
| 19 | /* The above copyright notice and this permission notice shall be */ |
| 20 | /* included in all copies or substantial portions of the Software. */ |
| 21 | /* */ |
| 22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
| 23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
| 24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
| 25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
| 26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
| 27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
| 28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 29 | /**************************************************************************/ |
| 30 | |
| 31 | #ifndef IMPORT_DOCK_H |
| 32 | #define IMPORT_DOCK_H |
| 33 | |
| 34 | #include "core/io/config_file.h" |
| 35 | #include "core/io/resource_importer.h" |
| 36 | #include "editor/editor_file_system.h" |
| 37 | #include "editor/editor_inspector.h" |
| 38 | #include "scene/gui/box_container.h" |
| 39 | #include "scene/gui/dialogs.h" |
| 40 | #include "scene/gui/menu_button.h" |
| 41 | #include "scene/gui/option_button.h" |
| 42 | #include "scene/gui/popup_menu.h" |
| 43 | |
| 44 | class ImportDockParameters; |
| 45 | class ImportDock : public VBoxContainer { |
| 46 | GDCLASS(ImportDock, VBoxContainer); |
| 47 | |
| 48 | Label *imported = nullptr; |
| 49 | OptionButton *import_as = nullptr; |
| 50 | MenuButton *preset = nullptr; |
| 51 | EditorInspector *import_opts = nullptr; |
| 52 | |
| 53 | List<PropertyInfo> properties; |
| 54 | HashMap<StringName, Variant> property_values; |
| 55 | |
| 56 | ConfirmationDialog *reimport_confirm = nullptr; |
| 57 | Label *cleanup_warning = nullptr; |
| 58 | Label *label_warning = nullptr; |
| 59 | Button *import = nullptr; |
| 60 | List<String> need_cleanup; |
| 61 | |
| 62 | Control *advanced_spacer = nullptr; |
| 63 | Button *advanced = nullptr; |
| 64 | |
| 65 | ImportDockParameters *params = nullptr; |
| 66 | |
| 67 | VBoxContainer *content = nullptr; |
| 68 | Label *select_a_resource = nullptr; |
| 69 | |
| 70 | void _preset_selected(int p_idx); |
| 71 | void _importer_selected(int i_idx); |
| 72 | void _update_options(const String &p_path, const Ref<ConfigFile> &p_config = Ref<ConfigFile>()); |
| 73 | void (); |
| 74 | void _add_keep_import_option(const String &p_importer_name); |
| 75 | |
| 76 | void _property_edited(const StringName &p_prop); |
| 77 | void _property_toggled(const StringName &p_prop, bool p_checked); |
| 78 | void _set_dirty(bool p_dirty); |
| 79 | void _reimport_attempt(); |
| 80 | void _reimport_and_cleanup(); |
| 81 | void _reimport(); |
| 82 | |
| 83 | void _replace_resource_in_object(Object *p_object, const Ref<Resource> &old_resource, const Ref<Resource> &new_resource); |
| 84 | |
| 85 | void _advanced_options(); |
| 86 | enum { |
| 87 | ITEM_SET_AS_DEFAULT = 100, |
| 88 | ITEM_LOAD_DEFAULT, |
| 89 | ITEM_CLEAR_DEFAULT, |
| 90 | }; |
| 91 | |
| 92 | private: |
| 93 | static ImportDock *singleton; |
| 94 | |
| 95 | public: |
| 96 | static ImportDock *get_singleton() { return singleton; } |
| 97 | |
| 98 | protected: |
| 99 | static void _bind_methods(); |
| 100 | void _notification(int p_what); |
| 101 | |
| 102 | public: |
| 103 | void set_edit_path(const String &p_path); |
| 104 | void set_edit_multiple_paths(const Vector<String> &p_paths); |
| 105 | void reimport_resources(const Vector<String> &p_paths); |
| 106 | void initialize_import_options() const; |
| 107 | void clear(); |
| 108 | |
| 109 | ImportDock(); |
| 110 | ~ImportDock(); |
| 111 | }; |
| 112 | |
| 113 | #endif // IMPORT_DOCK_H |
| 114 | |