Path: blob/master/editor/project_manager/project_manager.h
9902 views
/**************************************************************************/1/* project_manager.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/scroll_container.h"3435class CheckBox;36class EditorAbout;37class EditorAssetLibrary;38class EditorFileDialog;39class EditorTitleBar;40class HFlowContainer;41class LineEdit;42class MarginContainer;43class OptionButton;44class PanelContainer;45class PopupMenu;46class ProjectDialog;47class ProjectList;48class QuickSettingsDialog;49class RichTextLabel;50class TabContainer;51class VBoxContainer;5253class ProjectManager : public Control {54GDCLASS(ProjectManager, Control);5556static ProjectManager *singleton;5758// Utility data.5960static Ref<Texture2D> _file_dialog_get_icon(const String &p_path);61static Ref<Texture2D> _file_dialog_get_thumbnail(const String &p_path);6263HashMap<String, Ref<Texture2D>> icon_type_cache;6465void _build_icon_type_cache(Ref<Theme> p_theme);6667enum PostDuplicateAction {68POST_DUPLICATE_ACTION_NONE,69POST_DUPLICATE_ACTION_OPEN,70POST_DUPLICATE_ACTION_FULL_CONVERSION,71};7273PostDuplicateAction post_duplicate_action = POST_DUPLICATE_ACTION_NONE;7475// Main layout.7677Ref<Theme> theme;7879void _update_size_limits();80void _update_theme(bool p_skip_creation = false);81void _titlebar_resized();8283MarginContainer *root_container = nullptr;84Panel *background_panel = nullptr;85VBoxContainer *main_vbox = nullptr;8687EditorTitleBar *title_bar = nullptr;88Control *left_menu_spacer = nullptr;89Control *left_spacer = nullptr;90Control *right_menu_spacer = nullptr;91Control *right_spacer = nullptr;92Button *title_bar_logo = nullptr;93HBoxContainer *main_view_toggles = nullptr;94Button *quick_settings_button = nullptr;9596enum MainViewTab {97MAIN_VIEW_PROJECTS,98MAIN_VIEW_ASSETLIB,99MAIN_VIEW_MAX100};101102MainViewTab current_main_view = MAIN_VIEW_PROJECTS;103HashMap<MainViewTab, Control *> main_view_map;104HashMap<MainViewTab, Button *> main_view_toggle_map;105106PanelContainer *main_view_container = nullptr;107Ref<ButtonGroup> main_view_toggles_group;108109Button *_add_main_view(MainViewTab p_id, const String &p_name, const Ref<Texture2D> &p_icon, Control *p_view_control);110void _set_main_view_icon(MainViewTab p_id, const Ref<Texture2D> &p_icon);111void _select_main_view(int p_id);112113VBoxContainer *local_projects_vb = nullptr;114EditorAssetLibrary *asset_library = nullptr;115116EditorAbout *about_dialog = nullptr;117118void _show_about();119void _open_asset_library_confirmed();120121AcceptDialog *error_dialog = nullptr;122123void _show_error(const String &p_message, const Size2 &p_min_size = Size2());124void _dim_window();125126// Quick settings.127128QuickSettingsDialog *quick_settings_dialog = nullptr;129130void _show_quick_settings();131void _restart_confirmed();132133// Project list.134135VBoxContainer *empty_list_placeholder = nullptr;136RichTextLabel *empty_list_message = nullptr;137Button *empty_list_create_project = nullptr;138Button *empty_list_import_project = nullptr;139Button *empty_list_open_assetlib = nullptr;140Label *empty_list_online_warning = nullptr;141142void _update_list_placeholder();143144ProjectList *project_list = nullptr;145bool initialized = false;146147LineEdit *search_box = nullptr;148Label *loading_label = nullptr;149Label *sort_label = nullptr;150OptionButton *filter_option = nullptr;151PanelContainer *project_list_panel = nullptr;152153Button *create_btn = nullptr;154Button *import_btn = nullptr;155Button *scan_btn = nullptr;156Button *open_btn = nullptr;157Button *open_options_btn = nullptr;158Button *run_btn = nullptr;159Button *rename_btn = nullptr;160Button *duplicate_btn = nullptr;161Button *manage_tags_btn = nullptr;162Button *erase_btn = nullptr;163Button *erase_missing_btn = nullptr;164165HBoxContainer *open_btn_container = nullptr;166PopupMenu *open_options_popup = nullptr;167168EditorFileDialog *scan_dir = nullptr;169170ConfirmationDialog *erase_ask = nullptr;171Label *erase_ask_label = nullptr;172// Comment out for now until we have a better warning system to173// ensure users delete their project only.174//CheckBox *delete_project_contents = nullptr;175ConfirmationDialog *erase_missing_ask = nullptr;176ConfirmationDialog *multi_open_ask = nullptr;177ConfirmationDialog *multi_run_ask = nullptr;178ConfirmationDialog *open_recovery_mode_ask = nullptr;179180ProjectDialog *project_dialog = nullptr;181182void _scan_projects();183void _run_project();184void _run_project_confirm();185void _open_selected_projects();186void _open_selected_projects_with_migration();187void _open_selected_projects_check_warnings();188void _open_selected_projects_check_recovery_mode();189190void _install_project(const String &p_zip_path, const String &p_title);191void _import_project();192void _new_project();193void _rename_project();194void _duplicate_project();195void _duplicate_project_with_action(PostDuplicateAction p_action);196void _erase_project();197void _erase_missing_projects();198void _erase_project_confirm();199void _erase_missing_projects_confirm();200void _update_project_buttons();201void _open_options_popup();202void _open_recovery_mode_ask(bool manual = false);203204void _on_project_created(const String &dir, bool edit);205void _on_project_duplicated(const String &p_original_path, const String &p_duplicate_path, bool p_edit);206void _on_projects_updated();207void _on_open_options_selected(int p_option);208void _on_recovery_mode_popup_open_normal();209void _on_recovery_mode_popup_open_recovery();210211void _on_order_option_changed(int p_idx);212void _on_search_term_changed(const String &p_term);213void _on_search_term_submitted(const String &p_text);214215// Project tag management.216217HashSet<String> tag_set;218PackedStringArray current_project_tags;219PackedStringArray forbidden_tag_characters{ "/", "\\", "-" };220221ConfirmationDialog *tag_manage_dialog = nullptr;222HFlowContainer *project_tags = nullptr;223HFlowContainer *all_tags = nullptr;224Label *tag_edit_error = nullptr;225226Button *create_tag_btn = nullptr;227ConfirmationDialog *create_tag_dialog = nullptr;228LineEdit *new_tag_name = nullptr;229Label *tag_error = nullptr;230231void _manage_project_tags();232void _add_project_tag(const String &p_tag);233void _delete_project_tag(const String &p_tag);234void _apply_project_tags();235void _set_new_tag_name(const String p_name);236void _create_new_tag();237238// Project converter/migration tool.239240ConfirmationDialog *ask_full_convert_dialog = nullptr;241ConfirmationDialog *ask_update_settings = nullptr;242VBoxContainer *ask_update_vb = nullptr;243Label *ask_update_label = nullptr;244CheckBox *ask_update_backup = nullptr;245Button *full_convert_button = nullptr;246Button *migration_guide_button = nullptr;247248String version_convert_feature;249bool open_in_recovery_mode = false;250bool open_in_verbose_mode = false;251252#ifndef DISABLE_DEPRECATED253void _minor_project_migrate();254#endif255void _full_convert_button_pressed();256void _migration_guide_button_pressed();257void _perform_full_project_conversion();258259// Input and I/O.260261virtual void shortcut_input(const Ref<InputEvent> &p_ev) override;262263void _files_dropped(PackedStringArray p_files);264265protected:266void _notification(int p_what);267268public:269static ProjectManager *get_singleton() { return singleton; }270271static constexpr int DEFAULT_WINDOW_WIDTH = 1152;272static constexpr int DEFAULT_WINDOW_HEIGHT = 800;273274// Project list.275276bool is_initialized() const { return initialized; }277LineEdit *get_search_box();278279// Project tag management.280281void add_new_tag(const String &p_tag);282283ProjectManager();284~ProjectManager();285};286287288