2016-06-18 20:46:12 +08:00
|
|
|
/*************************************************************************/
|
|
|
|
/* dependency_editor.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 20:16:55 +08:00
|
|
|
/* https://godotengine.org */
|
2016-06-18 20:46:12 +08:00
|
|
|
/*************************************************************************/
|
2022-01-04 04:27:34 +08:00
|
|
|
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
2016-06-18 20:46:12 +08:00
|
|
|
/* */
|
|
|
|
/* 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. */
|
|
|
|
/*************************************************************************/
|
2018-01-05 07:50:27 +08:00
|
|
|
|
2015-08-24 07:15:56 +08:00
|
|
|
#ifndef DEPENDENCY_EDITOR_H
|
|
|
|
#define DEPENDENCY_EDITOR_H
|
|
|
|
|
|
|
|
#include "scene/gui/dialogs.h"
|
2022-02-12 09:46:22 +08:00
|
|
|
#include "scene/gui/item_list.h"
|
2015-08-24 07:15:56 +08:00
|
|
|
#include "scene/gui/tab_container.h"
|
2017-03-05 23:44:50 +08:00
|
|
|
#include "scene/gui/tree.h"
|
2015-08-24 07:15:56 +08:00
|
|
|
|
2017-12-02 08:37:32 +08:00
|
|
|
class EditorFileDialog;
|
2015-08-24 07:15:56 +08:00
|
|
|
class EditorFileSystemDirectory;
|
|
|
|
|
|
|
|
class DependencyEditor : public AcceptDialog {
|
2017-03-05 23:44:50 +08:00
|
|
|
GDCLASS(DependencyEditor, AcceptDialog);
|
2015-08-24 07:15:56 +08:00
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
Tree *tree = nullptr;
|
|
|
|
Button *fixdeps = nullptr;
|
2015-08-24 07:15:56 +08:00
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
EditorFileDialog *search = nullptr;
|
2015-08-24 07:15:56 +08:00
|
|
|
|
|
|
|
String replacing;
|
|
|
|
String editing;
|
|
|
|
List<String> missing;
|
|
|
|
|
2020-03-17 14:33:00 +08:00
|
|
|
void _fix_and_find(EditorFileSystemDirectory *efsd, Map<String, Map<String, String>> &candidates);
|
2015-08-24 07:15:56 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void _searched(const String &p_path);
|
|
|
|
void _load_pressed(Object *p_item, int p_cell, int p_button);
|
2015-08-24 07:15:56 +08:00
|
|
|
void _fix_all();
|
|
|
|
void _update_list();
|
|
|
|
|
|
|
|
void _update_file();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
public:
|
|
|
|
void edit(const String &p_path);
|
2015-08-24 07:15:56 +08:00
|
|
|
DependencyEditor();
|
|
|
|
};
|
|
|
|
|
|
|
|
class DependencyEditorOwners : public AcceptDialog {
|
2017-03-05 23:44:50 +08:00
|
|
|
GDCLASS(DependencyEditorOwners, AcceptDialog);
|
2015-08-24 07:15:56 +08:00
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
ItemList *owners = nullptr;
|
|
|
|
PopupMenu *file_options = nullptr;
|
2015-08-24 07:15:56 +08:00
|
|
|
String editing;
|
2017-11-15 12:05:49 +08:00
|
|
|
|
2015-08-24 07:15:56 +08:00
|
|
|
void _fill_owners(EditorFileSystemDirectory *efsd);
|
|
|
|
|
2017-11-15 12:05:49 +08:00
|
|
|
static void _bind_methods();
|
|
|
|
void _list_rmb_select(int p_item, const Vector2 &p_pos);
|
|
|
|
void _select_file(int p_idx);
|
|
|
|
void _file_option(int p_option);
|
|
|
|
|
|
|
|
private:
|
|
|
|
enum FileMenu {
|
|
|
|
FILE_OPEN
|
|
|
|
};
|
|
|
|
|
2015-08-24 07:15:56 +08:00
|
|
|
public:
|
2017-03-05 23:44:50 +08:00
|
|
|
void show(const String &p_path);
|
2022-01-27 17:36:51 +08:00
|
|
|
DependencyEditorOwners();
|
2015-08-24 07:15:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class DependencyRemoveDialog : public ConfirmationDialog {
|
2017-03-05 23:44:50 +08:00
|
|
|
GDCLASS(DependencyRemoveDialog, ConfirmationDialog);
|
2015-08-24 07:15:56 +08:00
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
Label *text = nullptr;
|
|
|
|
Tree *owners = nullptr;
|
2017-10-02 06:24:49 +08:00
|
|
|
|
|
|
|
Map<String, String> all_remove_files;
|
2018-02-26 15:59:49 +08:00
|
|
|
Vector<String> dirs_to_delete;
|
|
|
|
Vector<String> files_to_delete;
|
2017-10-02 06:24:49 +08:00
|
|
|
|
|
|
|
struct RemovedDependency {
|
|
|
|
String file;
|
|
|
|
String file_type;
|
|
|
|
String dependency;
|
|
|
|
String dependency_folder;
|
|
|
|
|
|
|
|
bool operator<(const RemovedDependency &p_other) const {
|
2020-12-15 20:04:21 +08:00
|
|
|
if (dependency_folder.is_empty() != p_other.dependency_folder.is_empty()) {
|
|
|
|
return p_other.dependency_folder.is_empty();
|
2017-10-02 06:24:49 +08:00
|
|
|
} else {
|
|
|
|
return dependency < p_other.dependency;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void _find_files_in_removed_folder(EditorFileSystemDirectory *efsd, const String &p_folder);
|
|
|
|
void _find_all_removed_dependencies(EditorFileSystemDirectory *efsd, Vector<RemovedDependency> &p_removed);
|
|
|
|
void _build_removed_dependency_tree(const Vector<RemovedDependency> &p_removed);
|
2015-08-24 07:15:56 +08:00
|
|
|
|
2020-07-10 18:34:39 +08:00
|
|
|
void ok_pressed() override;
|
2015-08-24 07:15:56 +08:00
|
|
|
|
2018-11-14 03:17:33 +08:00
|
|
|
static void _bind_methods();
|
|
|
|
|
2015-08-24 07:15:56 +08:00
|
|
|
public:
|
2017-10-02 06:24:49 +08:00
|
|
|
void show(const Vector<String> &p_folders, const Vector<String> &p_files);
|
2015-08-24 07:15:56 +08:00
|
|
|
DependencyRemoveDialog();
|
|
|
|
};
|
|
|
|
|
|
|
|
class DependencyErrorDialog : public ConfirmationDialog {
|
2017-03-05 23:44:50 +08:00
|
|
|
GDCLASS(DependencyErrorDialog, ConfirmationDialog);
|
2015-08-24 07:15:56 +08:00
|
|
|
|
2018-11-02 11:44:40 +08:00
|
|
|
public:
|
|
|
|
enum Mode {
|
|
|
|
MODE_SCENE,
|
|
|
|
MODE_RESOURCE,
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2015-08-24 07:15:56 +08:00
|
|
|
String for_file;
|
2018-11-02 11:44:40 +08:00
|
|
|
Mode mode;
|
2022-04-04 21:06:57 +08:00
|
|
|
Button *fdep = nullptr;
|
|
|
|
Label *text = nullptr;
|
|
|
|
Tree *files = nullptr;
|
2020-07-10 18:34:39 +08:00
|
|
|
void ok_pressed() override;
|
|
|
|
void custom_action(const String &) override;
|
2015-08-24 07:15:56 +08:00
|
|
|
|
|
|
|
public:
|
2018-11-02 11:44:40 +08:00
|
|
|
void show(Mode p_mode, const String &p_for_file, const Vector<String> &report);
|
2015-08-24 07:15:56 +08:00
|
|
|
DependencyErrorDialog();
|
|
|
|
};
|
|
|
|
|
2015-11-29 12:08:31 +08:00
|
|
|
class OrphanResourcesDialog : public ConfirmationDialog {
|
2017-03-05 23:44:50 +08:00
|
|
|
GDCLASS(OrphanResourcesDialog, ConfirmationDialog);
|
2015-11-29 12:08:31 +08:00
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
DependencyEditor *dep_edit = nullptr;
|
|
|
|
Tree *files = nullptr;
|
|
|
|
ConfirmationDialog *delete_confirm = nullptr;
|
2020-07-10 18:34:39 +08:00
|
|
|
void ok_pressed() override;
|
2015-11-29 12:08:31 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
bool _fill_owners(EditorFileSystemDirectory *efsd, HashMap<String, int> &refs, TreeItem *p_parent);
|
2015-11-29 12:08:31 +08:00
|
|
|
|
|
|
|
List<String> paths;
|
2017-03-05 23:44:50 +08:00
|
|
|
void _find_to_delete(TreeItem *p_item, List<String> &paths);
|
2015-11-29 12:08:31 +08:00
|
|
|
void _delete_confirm();
|
2017-03-05 23:44:50 +08:00
|
|
|
void _button_pressed(Object *p_item, int p_column, int p_id);
|
2015-11-29 12:08:31 +08:00
|
|
|
|
|
|
|
void refresh();
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
public:
|
2015-11-29 12:08:31 +08:00
|
|
|
void show();
|
|
|
|
OrphanResourcesDialog();
|
|
|
|
};
|
|
|
|
|
2015-08-24 07:15:56 +08:00
|
|
|
#endif // DEPENDENCY_EDITOR_H
|