Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/docks/import_dock.h
9896 views
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
#pragma once
32
33
#include "core/io/config_file.h"
34
#include "core/io/resource_importer.h"
35
#include "editor/file_system/editor_file_system.h"
36
#include "editor/inspector/editor_inspector.h"
37
#include "scene/gui/box_container.h"
38
#include "scene/gui/dialogs.h"
39
#include "scene/gui/menu_button.h"
40
#include "scene/gui/option_button.h"
41
#include "scene/gui/popup_menu.h"
42
43
class ImportDockParameters;
44
class ImportDock : public VBoxContainer {
45
GDCLASS(ImportDock, VBoxContainer);
46
47
Label *imported = nullptr;
48
OptionButton *import_as = nullptr;
49
MenuButton *preset = nullptr;
50
EditorInspector *import_opts = nullptr;
51
52
List<PropertyInfo> properties;
53
HashMap<StringName, Variant> property_values;
54
55
ConfirmationDialog *reimport_confirm = nullptr;
56
Label *cleanup_warning = nullptr;
57
Label *label_warning = nullptr;
58
Button *import = nullptr;
59
List<String> need_cleanup;
60
61
Control *advanced_spacer = nullptr;
62
Button *advanced = nullptr;
63
64
ImportDockParameters *params = nullptr;
65
66
VBoxContainer *content = nullptr;
67
Label *select_a_resource = nullptr;
68
69
void _preset_selected(int p_idx);
70
void _importer_selected(int i_idx);
71
void _update_options(const String &p_path, const Ref<ConfigFile> &p_config = Ref<ConfigFile>());
72
void _update_preset_menu();
73
void _add_keep_import_option(const String &p_importer_name);
74
75
void _property_edited(const StringName &p_prop);
76
void _property_toggled(const StringName &p_prop, bool p_checked);
77
void _set_dirty(bool p_dirty);
78
void _reimport_pressed();
79
void _reimport_attempt();
80
void _reimport_and_cleanup();
81
void _reimport();
82
83
void _advanced_options();
84
enum {
85
ITEM_SET_AS_DEFAULT = 100,
86
ITEM_LOAD_DEFAULT,
87
ITEM_CLEAR_DEFAULT,
88
};
89
90
private:
91
static ImportDock *singleton;
92
93
public:
94
static ImportDock *get_singleton() { return singleton; }
95
96
protected:
97
static void _bind_methods();
98
void _notification(int p_what);
99
100
public:
101
void set_edit_path(const String &p_path);
102
void set_edit_multiple_paths(const Vector<String> &p_paths);
103
void reimport_resources(const Vector<String> &p_paths);
104
void initialize_import_options() const;
105
void clear();
106
107
ImportDock();
108
~ImportDock();
109
};
110
111