2023-01-05 12:25:55 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
/* project_manager.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-04 23:50:27 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#ifndef PROJECT_MANAGER_H
|
|
|
|
#define PROJECT_MANAGER_H
|
|
|
|
|
|
|
|
#include "scene/gui/dialogs.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "scene/gui/scroll_container.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-11-19 11:45:49 +00:00
|
|
|
class CheckBox;
|
2024-01-16 18:50:38 +00:00
|
|
|
class EditorAbout;
|
2023-03-10 12:57:32 +00:00
|
|
|
class EditorAssetLibrary;
|
|
|
|
class EditorFileDialog;
|
2023-03-17 22:30:21 +00:00
|
|
|
class HFlowContainer;
|
2024-01-16 18:50:38 +00:00
|
|
|
class LineEdit;
|
|
|
|
class LinkButton;
|
2024-01-30 16:35:46 +00:00
|
|
|
class MarginContainer;
|
2024-01-16 18:50:38 +00:00
|
|
|
class OptionButton;
|
2023-03-10 14:22:33 +00:00
|
|
|
class PanelContainer;
|
2024-01-16 18:50:38 +00:00
|
|
|
class ProjectDialog;
|
2023-03-17 22:30:21 +00:00
|
|
|
class ProjectList;
|
2024-01-30 16:35:46 +00:00
|
|
|
class QuickSettingsDialog;
|
2024-01-30 16:35:46 +00:00
|
|
|
class RichTextLabel;
|
2024-01-16 18:50:38 +00:00
|
|
|
class TabContainer;
|
2024-01-30 16:35:46 +00:00
|
|
|
class VBoxContainer;
|
2020-08-27 13:43:49 +00:00
|
|
|
|
2024-01-16 18:50:38 +00:00
|
|
|
class ProjectManager : public Control {
|
|
|
|
GDCLASS(ProjectManager, Control);
|
2023-03-10 12:57:32 +00:00
|
|
|
|
2024-01-16 18:50:38 +00:00
|
|
|
static ProjectManager *singleton;
|
2023-03-10 12:57:32 +00:00
|
|
|
|
2024-01-16 18:50:38 +00:00
|
|
|
// Utility data.
|
2023-03-10 12:57:32 +00:00
|
|
|
|
2024-01-16 18:50:38 +00:00
|
|
|
static Ref<Texture2D> _file_dialog_get_icon(const String &p_path);
|
|
|
|
static Ref<Texture2D> _file_dialog_get_thumbnail(const String &p_path);
|
2023-03-10 12:57:32 +00:00
|
|
|
|
2024-01-16 18:50:38 +00:00
|
|
|
HashMap<String, Ref<Texture2D>> icon_type_cache;
|
2023-03-10 12:57:32 +00:00
|
|
|
|
2024-01-16 18:50:38 +00:00
|
|
|
void _build_icon_type_cache(Ref<Theme> p_theme);
|
2023-03-10 12:57:32 +00:00
|
|
|
|
2024-01-16 18:50:38 +00:00
|
|
|
// Main layout.
|
2023-03-10 12:57:32 +00:00
|
|
|
|
2024-01-30 16:35:46 +00:00
|
|
|
Ref<Theme> theme;
|
|
|
|
|
2024-01-16 18:50:38 +00:00
|
|
|
void _update_size_limits();
|
2024-01-30 16:35:46 +00:00
|
|
|
void _update_theme(bool p_skip_creation = false);
|
2023-03-10 12:57:32 +00:00
|
|
|
|
2024-01-30 16:35:46 +00:00
|
|
|
MarginContainer *root_container = nullptr;
|
2024-01-16 18:50:38 +00:00
|
|
|
Panel *background_panel = nullptr;
|
2024-01-30 16:35:46 +00:00
|
|
|
VBoxContainer *main_vbox = nullptr;
|
2023-03-10 12:57:32 +00:00
|
|
|
|
2024-01-30 16:35:46 +00:00
|
|
|
HBoxContainer *title_bar = nullptr;
|
|
|
|
Button *title_bar_logo = nullptr;
|
|
|
|
HBoxContainer *main_view_toggles = nullptr;
|
2024-01-30 16:35:46 +00:00
|
|
|
Button *quick_settings_button = nullptr;
|
2023-03-10 12:57:32 +00:00
|
|
|
|
2024-01-30 16:35:46 +00:00
|
|
|
enum MainViewTab {
|
|
|
|
MAIN_VIEW_PROJECTS,
|
|
|
|
MAIN_VIEW_ASSETLIB,
|
|
|
|
MAIN_VIEW_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
MainViewTab current_main_view = MAIN_VIEW_PROJECTS;
|
|
|
|
HashMap<MainViewTab, Control *> main_view_map;
|
|
|
|
HashMap<MainViewTab, Button *> main_view_toggle_map;
|
|
|
|
|
|
|
|
PanelContainer *main_view_container = nullptr;
|
|
|
|
Ref<ButtonGroup> main_view_toggles_group;
|
|
|
|
|
|
|
|
Button *_add_main_view(MainViewTab p_id, const String &p_name, const Ref<Texture2D> &p_icon, Control *p_view_control);
|
|
|
|
void _set_main_view_icon(MainViewTab p_id, const Ref<Texture2D> &p_icon);
|
|
|
|
void _select_main_view(int p_id);
|
2023-03-10 12:57:32 +00:00
|
|
|
|
2024-01-16 18:50:38 +00:00
|
|
|
VBoxContainer *local_projects_vb = nullptr;
|
|
|
|
EditorAssetLibrary *asset_library = nullptr;
|
2023-03-10 12:57:32 +00:00
|
|
|
|
2024-01-30 16:35:46 +00:00
|
|
|
EditorAbout *about_dialog = nullptr;
|
2024-01-30 16:35:46 +00:00
|
|
|
|
|
|
|
void _show_about();
|
2024-01-30 16:35:46 +00:00
|
|
|
void _open_asset_library_confirmed();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2024-01-30 16:35:46 +00:00
|
|
|
AcceptDialog *error_dialog = nullptr;
|
|
|
|
|
|
|
|
void _show_error(const String &p_message, const Size2 &p_min_size = Size2());
|
2024-01-30 16:35:46 +00:00
|
|
|
void _dim_window();
|
|
|
|
|
2024-01-16 18:50:38 +00:00
|
|
|
// Quick settings.
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2024-01-30 16:35:46 +00:00
|
|
|
QuickSettingsDialog *quick_settings_dialog = nullptr;
|
2022-02-12 19:55:11 +00:00
|
|
|
|
2024-01-30 16:35:46 +00:00
|
|
|
void _show_quick_settings();
|
|
|
|
void _restart_confirmed();
|
2022-02-03 00:21:52 +00:00
|
|
|
|
2024-01-30 16:35:46 +00:00
|
|
|
// Footer.
|
|
|
|
|
|
|
|
LinkButton *version_btn = nullptr;
|
|
|
|
|
|
|
|
void _version_button_pressed();
|
|
|
|
|
2024-01-16 18:50:38 +00:00
|
|
|
// Project list.
|
2023-12-20 12:19:21 +00:00
|
|
|
|
2024-01-30 16:35:46 +00:00
|
|
|
VBoxContainer *empty_list_placeholder = nullptr;
|
|
|
|
Button *empty_list_create_project = nullptr;
|
|
|
|
Button *empty_list_import_project = nullptr;
|
|
|
|
Button *empty_list_open_assetlib = nullptr;
|
|
|
|
Label *empty_list_online_warning = nullptr;
|
|
|
|
|
|
|
|
void _update_list_placeholder();
|
|
|
|
|
|
|
|
ProjectList *project_list = nullptr;
|
2020-08-27 13:43:49 +00:00
|
|
|
|
2022-03-29 18:15:31 +00:00
|
|
|
LineEdit *search_box = nullptr;
|
|
|
|
Label *loading_label = nullptr;
|
|
|
|
OptionButton *filter_option = nullptr;
|
2024-01-30 16:35:46 +00:00
|
|
|
PanelContainer *project_list_panel = nullptr;
|
2020-08-27 13:43:49 +00:00
|
|
|
|
2022-06-15 07:04:48 +00:00
|
|
|
Button *create_btn = nullptr;
|
|
|
|
Button *import_btn = nullptr;
|
|
|
|
Button *scan_btn = nullptr;
|
2022-03-29 18:15:31 +00:00
|
|
|
Button *open_btn = nullptr;
|
2022-06-15 07:04:48 +00:00
|
|
|
Button *run_btn = nullptr;
|
2022-03-29 18:15:31 +00:00
|
|
|
Button *rename_btn = nullptr;
|
2023-03-17 22:30:21 +00:00
|
|
|
Button *manage_tags_btn = nullptr;
|
2022-03-29 18:15:31 +00:00
|
|
|
Button *erase_btn = nullptr;
|
|
|
|
Button *erase_missing_btn = nullptr;
|
2023-03-17 22:30:21 +00:00
|
|
|
|
2022-03-29 18:15:31 +00:00
|
|
|
EditorFileDialog *scan_dir = nullptr;
|
2021-03-20 18:31:49 +00:00
|
|
|
|
2022-03-29 18:15:31 +00:00
|
|
|
ConfirmationDialog *erase_ask = nullptr;
|
|
|
|
Label *erase_ask_label = nullptr;
|
2023-03-15 22:48:52 +00:00
|
|
|
// Comment out for now until we have a better warning system to
|
|
|
|
// ensure users delete their project only.
|
|
|
|
//CheckBox *delete_project_contents = nullptr;
|
2022-03-29 18:15:31 +00:00
|
|
|
ConfirmationDialog *erase_missing_ask = nullptr;
|
|
|
|
ConfirmationDialog *multi_open_ask = nullptr;
|
|
|
|
ConfirmationDialog *multi_run_ask = nullptr;
|
2020-08-27 13:43:49 +00:00
|
|
|
|
2024-01-30 16:35:46 +00:00
|
|
|
ProjectDialog *project_dialog = nullptr;
|
2018-12-21 11:20:48 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void _scan_projects();
|
|
|
|
void _run_project();
|
2014-05-11 01:45:52 +00:00
|
|
|
void _run_project_confirm();
|
2018-12-21 11:20:48 +00:00
|
|
|
void _open_selected_projects();
|
|
|
|
void _open_selected_projects_ask();
|
2024-01-16 18:50:38 +00:00
|
|
|
|
|
|
|
void _install_project(const String &p_zip_path, const String &p_title);
|
2014-02-10 01:10:30 +00:00
|
|
|
void _import_project();
|
|
|
|
void _new_project();
|
2017-09-07 00:04:41 +00:00
|
|
|
void _rename_project();
|
2014-02-10 01:10:30 +00:00
|
|
|
void _erase_project();
|
2019-02-11 16:44:23 +00:00
|
|
|
void _erase_missing_projects();
|
2014-02-10 01:10:30 +00:00
|
|
|
void _erase_project_confirm();
|
2019-02-11 16:44:23 +00:00
|
|
|
void _erase_missing_projects_confirm();
|
2016-07-29 00:33:59 +00:00
|
|
|
void _update_project_buttons();
|
2024-01-16 18:50:38 +00:00
|
|
|
|
|
|
|
void _on_project_created(const String &dir);
|
|
|
|
void _on_projects_updated();
|
|
|
|
|
|
|
|
void _on_order_option_changed(int p_idx);
|
|
|
|
void _on_search_term_changed(const String &p_term);
|
|
|
|
void _on_search_term_submitted(const String &p_text);
|
|
|
|
|
|
|
|
// Project tag management.
|
|
|
|
|
|
|
|
HashSet<String> tag_set;
|
|
|
|
PackedStringArray current_project_tags;
|
|
|
|
PackedStringArray forbidden_tag_characters{ "/", "\\", "-" };
|
|
|
|
|
|
|
|
ConfirmationDialog *tag_manage_dialog = nullptr;
|
|
|
|
HFlowContainer *project_tags = nullptr;
|
|
|
|
HFlowContainer *all_tags = nullptr;
|
|
|
|
Label *tag_edit_error = nullptr;
|
|
|
|
|
|
|
|
Button *create_tag_btn = nullptr;
|
|
|
|
ConfirmationDialog *create_tag_dialog = nullptr;
|
|
|
|
LineEdit *new_tag_name = nullptr;
|
|
|
|
Label *tag_error = nullptr;
|
2018-12-21 11:20:48 +00:00
|
|
|
|
2023-03-17 22:30:21 +00:00
|
|
|
void _manage_project_tags();
|
|
|
|
void _add_project_tag(const String &p_tag);
|
|
|
|
void _delete_project_tag(const String &p_tag);
|
|
|
|
void _apply_project_tags();
|
|
|
|
void _set_new_tag_name(const String p_name);
|
|
|
|
void _create_new_tag();
|
|
|
|
|
2024-01-16 18:50:38 +00:00
|
|
|
// Project converter/migration tool.
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2024-01-16 18:50:38 +00:00
|
|
|
ConfirmationDialog *ask_full_convert_dialog = nullptr;
|
|
|
|
ConfirmationDialog *ask_update_settings = nullptr;
|
|
|
|
Button *full_convert_button = nullptr;
|
2016-07-12 00:34:02 +00:00
|
|
|
|
2024-01-16 18:50:38 +00:00
|
|
|
void _full_convert_button_pressed();
|
|
|
|
void _perform_full_project_conversion();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2024-01-16 18:50:38 +00:00
|
|
|
// Input and I/O.
|
2019-07-19 21:37:45 +00:00
|
|
|
|
2024-01-16 18:50:38 +00:00
|
|
|
virtual void shortcut_input(const Ref<InputEvent> &p_ev) override;
|
|
|
|
|
|
|
|
void _files_dropped(PackedStringArray p_files);
|
2022-02-03 00:21:52 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
protected:
|
2015-12-14 19:31:37 +00:00
|
|
|
void _notification(int p_what);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
public:
|
2022-02-12 19:55:11 +00:00
|
|
|
static ProjectManager *get_singleton() { return singleton; }
|
|
|
|
|
2024-01-16 18:50:38 +00:00
|
|
|
// Project list.
|
|
|
|
|
2023-03-17 22:30:21 +00:00
|
|
|
LineEdit *get_search_box();
|
2024-01-16 18:50:38 +00:00
|
|
|
|
|
|
|
// Project tag management.
|
|
|
|
|
2023-03-17 22:30:21 +00:00
|
|
|
void add_new_tag(const String &p_tag);
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
ProjectManager();
|
|
|
|
~ProjectManager();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PROJECT_MANAGER_H
|