2016-06-18 20:46:12 +08: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-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"
|
|
|
|
#include "scene/gui/tree.h"
|
|
|
|
|
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-01-03 10:03:46 +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;
|
|
|
|
|
2022-05-13 21:04:37 +08:00
|
|
|
void _fix_and_find(EditorFileSystemDirectory *efsd, HashMap<String, HashMap<String, String>> &candidates);
|
2015-08-24 07:15:56 +08:00
|
|
|
|
|
|
|
void _searched(const String &p_path);
|
2021-09-18 15:33:18 +08:00
|
|
|
void _load_pressed(Object *p_item, int p_cell, int p_button, MouseButton p_mouse_button);
|
2015-08-24 07:15:56 +08:00
|
|
|
void _fix_all();
|
|
|
|
void _update_list();
|
|
|
|
|
|
|
|
void _update_file();
|
|
|
|
|
|
|
|
public:
|
|
|
|
void edit(const String &p_path);
|
|
|
|
DependencyEditor();
|
|
|
|
};
|
|
|
|
|
2023-11-18 03:44:38 +08:00
|
|
|
#ifdef MINGW_ENABLED
|
|
|
|
#undef FILE_OPEN
|
|
|
|
#endif
|
|
|
|
|
2015-08-24 07:15:56 +08:00
|
|
|
class DependencyEditorOwners : public AcceptDialog {
|
2017-01-03 10:03:46 +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);
|
|
|
|
|
2021-11-26 07:53:27 +08:00
|
|
|
void _list_rmb_clicked(int p_item, const Vector2 &p_pos, MouseButton p_mouse_button_index);
|
2017-11-15 12:05:49 +08:00
|
|
|
void _select_file(int p_idx);
|
2022-11-16 04:53:04 +08:00
|
|
|
void _empty_clicked(const Vector2 &p_pos, MouseButton p_mouse_button_index);
|
2017-11-15 12:05:49 +08:00
|
|
|
void _file_option(int p_option);
|
|
|
|
|
|
|
|
private:
|
|
|
|
enum FileMenu {
|
|
|
|
FILE_OPEN
|
|
|
|
};
|
|
|
|
|
2015-08-24 07:15:56 +08:00
|
|
|
public:
|
|
|
|
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-01-03 10:03:46 +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
|
|
|
|
2022-05-13 21:04:37 +08:00
|
|
|
HashMap<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);
|
2022-01-05 01:52:32 +08:00
|
|
|
void _find_localization_remaps_of_removed_files(Vector<RemovedDependency> &p_removed);
|
2017-10-02 06:24:49 +08:00
|
|
|
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-01-03 10:03:46 +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-01-03 10:03:46 +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
|
|
|
|
|
|
|
bool _fill_owners(EditorFileSystemDirectory *efsd, HashMap<String, int> &refs, TreeItem *p_parent);
|
|
|
|
|
|
|
|
List<String> paths;
|
2022-09-29 17:53:28 +08:00
|
|
|
void _find_to_delete(TreeItem *p_item, List<String> &r_paths);
|
2015-11-29 12:08:31 +08:00
|
|
|
void _delete_confirm();
|
2021-09-18 15:33:18 +08:00
|
|
|
void _button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
|
2015-11-29 12:08:31 +08:00
|
|
|
|
|
|
|
void refresh();
|
|
|
|
|
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
|