Path: blob/master/editor/file_system/dependency_editor.h
9896 views
/**************************************************************************/1/* dependency_editor.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "scene/gui/box_container.h"33#include "scene/gui/dialogs.h"34#include "scene/gui/item_list.h"35#include "scene/gui/tree.h"3637class EditorFileDialog;38class EditorFileSystemDirectory;3940class DependencyEditor : public AcceptDialog {41GDCLASS(DependencyEditor, AcceptDialog);4243Tree *tree = nullptr;44Button *fixdeps = nullptr;4546EditorFileDialog *search = nullptr;4748String replacing;49String editing;50List<String> missing;5152void _fix_and_find(EditorFileSystemDirectory *efsd, HashMap<String, HashMap<String, String>> &candidates);5354void _searched(const String &p_path);55void _load_pressed(Object *p_item, int p_cell, int p_button, MouseButton p_mouse_button);56void _fix_all();57void _update_list();5859void _update_file();6061public:62void edit(const String &p_path);63DependencyEditor();64};6566class DependencyEditorOwners : public AcceptDialog {67GDCLASS(DependencyEditorOwners, AcceptDialog);6869ItemList *owners = nullptr;70PopupMenu *file_options = nullptr;71String editing;7273void _fill_owners(EditorFileSystemDirectory *efsd);7475void _list_rmb_clicked(int p_item, const Vector2 &p_pos, MouseButton p_mouse_button_index);76void _select_file(int p_idx);77void _empty_clicked(const Vector2 &p_pos, MouseButton p_mouse_button_index);78void _file_option(int p_option);7980private:81enum FileMenu {82FILE_MENU_OPEN,83};8485public:86void show(const String &p_path);87DependencyEditorOwners();88};8990class DependencyRemoveDialog : public ConfirmationDialog {91GDCLASS(DependencyRemoveDialog, ConfirmationDialog);9293Label *text = nullptr;94Tree *owners = nullptr;95VBoxContainer *vb_owners = nullptr;96ItemList *files_to_delete_list = nullptr;9798HashMap<String, String> all_remove_files;99Vector<String> dirs_to_delete;100Vector<String> files_to_delete;101102struct RemovedDependency {103String file;104String file_type;105String dependency;106String dependency_folder;107108bool operator<(const RemovedDependency &p_other) const {109if (dependency_folder.is_empty() != p_other.dependency_folder.is_empty()) {110return p_other.dependency_folder.is_empty();111} else {112return dependency < p_other.dependency;113}114}115};116117LocalVector<StringName> path_project_settings;118119void _find_files_in_removed_folder(EditorFileSystemDirectory *efsd, const String &p_folder);120void _find_all_removed_dependencies(EditorFileSystemDirectory *efsd, Vector<RemovedDependency> &p_removed);121void _find_localization_remaps_of_removed_files(Vector<RemovedDependency> &p_removed);122void _build_removed_dependency_tree(const Vector<RemovedDependency> &p_removed);123void _show_files_to_delete_list();124125void ok_pressed() override;126127static void _bind_methods();128129public:130void show(const Vector<String> &p_folders, const Vector<String> &p_files);131DependencyRemoveDialog();132};133134class DependencyErrorDialog : public ConfirmationDialog {135GDCLASS(DependencyErrorDialog, ConfirmationDialog);136137private:138String for_file;139Mode mode;140Button *fdep = nullptr;141Label *text = nullptr;142Tree *files = nullptr;143void ok_pressed() override;144void custom_action(const String &) override;145146public:147void show(const String &p_for_file, const Vector<String> &report);148DependencyErrorDialog();149};150151class OrphanResourcesDialog : public ConfirmationDialog {152GDCLASS(OrphanResourcesDialog, ConfirmationDialog);153154DependencyEditor *dep_edit = nullptr;155Tree *files = nullptr;156ConfirmationDialog *delete_confirm = nullptr;157void ok_pressed() override;158159bool _fill_owners(EditorFileSystemDirectory *efsd, HashMap<String, int> &refs, TreeItem *p_parent);160161List<String> paths;162void _find_to_delete(TreeItem *p_item, List<String> &r_paths);163void _delete_confirm();164void _button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);165166void refresh();167168public:169void show();170OrphanResourcesDialog();171};172173174