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