Path: blob/master/editor/project_manager/project_manager.h
20969 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();120void _project_list_menu_option(int p_option);121122AcceptDialog *error_dialog = nullptr;123124void _show_error(const String &p_message, const Size2 &p_min_size = Size2());125void _dim_window();126127// Quick settings.128129QuickSettingsDialog *quick_settings_dialog = nullptr;130131void _show_quick_settings();132void _restart_confirmed();133134// Project list.135136VBoxContainer *empty_list_placeholder = nullptr;137RichTextLabel *empty_list_message = nullptr;138Button *empty_list_create_project = nullptr;139Button *empty_list_import_project = nullptr;140Button *empty_list_open_assetlib = nullptr;141Label *empty_list_online_warning = nullptr;142143void _update_list_placeholder();144145ProjectList *project_list = nullptr;146bool initialized = false;147148LineEdit *search_box = nullptr;149Label *loading_label = nullptr;150Label *sort_label = nullptr;151OptionButton *filter_option = nullptr;152PanelContainer *project_list_panel = nullptr;153154Button *create_btn = nullptr;155Button *import_btn = nullptr;156Button *scan_btn = nullptr;157Button *open_btn = nullptr;158Button *open_options_btn = nullptr;159Button *run_btn = nullptr;160Button *rename_btn = nullptr;161Button *duplicate_btn = nullptr;162Button *manage_tags_btn = nullptr;163Button *erase_btn = nullptr;164Button *erase_missing_btn = nullptr;165Button *donate_btn = nullptr;166167HBoxContainer *open_btn_container = nullptr;168PopupMenu *open_options_popup = nullptr;169170EditorFileDialog *scan_dir = nullptr;171172ConfirmationDialog *erase_ask = nullptr;173Label *erase_ask_label = nullptr;174// Comment out for now until we have a better warning system to175// ensure users delete their project only.176//CheckBox *delete_project_contents = nullptr;177ConfirmationDialog *erase_missing_ask = nullptr;178ConfirmationDialog *multi_open_ask = nullptr;179ConfirmationDialog *multi_run_ask = nullptr;180ConfirmationDialog *open_recovery_mode_ask = nullptr;181182ProjectDialog *project_dialog = nullptr;183184void _scan_projects();185void _run_project();186void _run_project_confirm();187void _open_selected_projects();188void _open_selected_projects_with_migration();189void _open_selected_projects_check_warnings();190void _open_selected_projects_check_recovery_mode();191192void _install_project(const String &p_zip_path, const String &p_title);193void _import_project();194void _new_project();195void _rename_project();196void _duplicate_project();197void _duplicate_project_with_action(PostDuplicateAction p_action);198void _show_project_in_file_manager();199void _erase_project();200void _erase_missing_projects();201void _erase_project_confirm();202void _erase_missing_projects_confirm();203void _update_project_buttons();204void _open_options_popup();205void _open_recovery_mode_ask(bool manual = false);206void _open_donate_page();207208void _on_project_created(const String &dir, bool edit);209void _on_project_duplicated(const String &p_original_path, const String &p_duplicate_path, bool p_edit);210void _on_projects_updated();211void _on_open_options_selected(int p_option);212void _on_recovery_mode_popup_open_normal();213void _on_recovery_mode_popup_open_recovery();214215void _on_order_option_changed(int p_idx);216void _on_search_term_changed(const String &p_term);217void _on_search_term_submitted(const String &p_text);218219// Project tag management.220221HashSet<String> tag_set;222PackedStringArray current_project_tags;223PackedStringArray forbidden_tag_characters{ "/", "\\", "-" };224225ConfirmationDialog *tag_manage_dialog = nullptr;226HFlowContainer *project_tags = nullptr;227HFlowContainer *all_tags = nullptr;228Label *tag_edit_error = nullptr;229230Button *create_tag_btn = nullptr;231ConfirmationDialog *create_tag_dialog = nullptr;232LineEdit *new_tag_name = nullptr;233Label *tag_error = nullptr;234235void _manage_project_tags();236void _add_project_tag(const String &p_tag);237void _delete_project_tag(const String &p_tag);238void _apply_project_tags();239void _set_new_tag_name(const String p_name);240void _create_new_tag();241242// Project converter/migration tool.243244ConfirmationDialog *ask_full_convert_dialog = nullptr;245ConfirmationDialog *ask_update_settings = nullptr;246VBoxContainer *ask_update_vb = nullptr;247Label *ask_update_label = nullptr;248CheckBox *ask_update_backup = nullptr;249Button *full_convert_button = nullptr;250Button *migration_guide_button = nullptr;251252String version_convert_feature;253bool open_in_recovery_mode = false;254bool open_in_verbose_mode = false;255256#ifndef DISABLE_DEPRECATED257void _minor_project_migrate();258#endif259void _full_convert_button_pressed();260void _migration_guide_button_pressed();261void _perform_full_project_conversion();262263// Input and I/O.264265virtual void shortcut_input(const Ref<InputEvent> &p_ev) override;266267void _files_dropped(PackedStringArray p_files);268269protected:270void _notification(int p_what);271272public:273static ProjectManager *get_singleton() { return singleton; }274275static constexpr int DEFAULT_WINDOW_WIDTH = 1152;276static constexpr int DEFAULT_WINDOW_HEIGHT = 800;277278// Project list.279280bool is_initialized() const { return initialized; }281LineEdit *get_search_box();282283// Project tag management.284285void add_new_tag(const String &p_tag);286287ProjectManager();288~ProjectManager();289};290291292