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