Path: blob/master/editor/asset_library/editor_asset_installer.h
9900 views
/**************************************************************************/1/* editor_asset_installer.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/dialogs.h"33#include "scene/gui/tree.h"3435class CheckBox;36class EditorFileDialog;37class Label;38class LinkButton;3940class EditorAssetInstaller : public ConfirmationDialog {41GDCLASS(EditorAssetInstaller, ConfirmationDialog);4243VBoxContainer *source_tree_vb = nullptr;44Tree *source_tree = nullptr;45Tree *destination_tree = nullptr;46Label *asset_title_label = nullptr;47Label *asset_conflicts_label = nullptr;48LinkButton *asset_conflicts_link = nullptr;4950Button *show_source_files_button = nullptr;51CheckBox *skip_toplevel_check = nullptr;52EditorFileDialog *target_dir_dialog = nullptr;5354String package_path;55String asset_name;56HashSet<String> asset_files;57HashMap<String, String> mapped_files;58HashMap<String, TreeItem *> file_item_map;5960TreeItem *first_file_conflict = nullptr;6162Ref<Texture2D> generic_extension_icon;63HashMap<String, Ref<Texture2D>> extension_icon_map;6465bool updating_source = false;66String toplevel_prefix;67bool skip_toplevel = false;68String target_dir_path = "res://";6970void _check_has_toplevel();71void _set_skip_toplevel(bool p_checked);7273void _open_target_dir_dialog();74void _target_dir_selected(const String &p_target_path);7576void _update_file_mappings();77void _rebuild_source_tree();78void _update_source_tree();79bool _update_source_item_status(TreeItem *p_item, const String &p_path);80void _rebuild_destination_tree();81TreeItem *_create_dir_item(Tree *p_tree, TreeItem *p_parent, const String &p_path, HashMap<String, TreeItem *> &p_item_map);82TreeItem *_create_file_item(Tree *p_tree, TreeItem *p_parent, const String &p_path, int *r_conflicts);8384void _update_conflict_status(int p_conflicts);85void _update_confirm_button();86void _toggle_source_tree(bool p_visible, bool p_scroll_to_error = false);8788void _item_checked_cbk();89bool _fix_conflicted_indeterminate_state(TreeItem *p_item, int p_column);90bool _is_item_checked(const String &p_source_path) const;9192void _install_asset();93virtual void ok_pressed() override;9495protected:96void _notification(int p_what);9798public:99void open_asset(const String &p_path, bool p_autoskip_toplevel = false);100101void set_asset_name(const String &p_asset_name);102String get_asset_name() const;103104EditorAssetInstaller();105};106107108