2023-01-05 13:25:55 +01: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-05 00:50:27 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
#ifndef PROJECT_MANAGER_H
|
|
|
|
#define PROJECT_MANAGER_H
|
|
|
|
|
|
|
|
#include "scene/gui/dialogs.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "scene/gui/scroll_container.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2022-11-19 12:45:49 +01:00
|
|
|
class CheckBox;
|
2024-01-16 19:50:38 +01:00
|
|
|
class EditorAbout;
|
2023-03-10 13:57:32 +01:00
|
|
|
class EditorAssetLibrary;
|
|
|
|
class EditorFileDialog;
|
2023-03-17 23:30:21 +01:00
|
|
|
class HFlowContainer;
|
2024-01-16 19:50:38 +01:00
|
|
|
class LineEdit;
|
|
|
|
class LinkButton;
|
2024-01-30 17:35:46 +01:00
|
|
|
class MarginContainer;
|
2024-01-16 19:50:38 +01:00
|
|
|
class OptionButton;
|
2023-03-10 15:22:33 +01:00
|
|
|
class PanelContainer;
|
2024-01-16 19:50:38 +01:00
|
|
|
class ProjectDialog;
|
2023-03-17 23:30:21 +01:00
|
|
|
class ProjectList;
|
2024-01-30 17:35:46 +01:00
|
|
|
class QuickSettingsDialog;
|
2024-01-30 17:35:46 +01:00
|
|
|
class RichTextLabel;
|
2024-01-16 19:50:38 +01:00
|
|
|
class TabContainer;
|
2024-01-30 17:35:46 +01:00
|
|
|
class VBoxContainer;
|
2020-08-27 15:43:49 +02:00
|
|
|
|
2024-01-16 19:50:38 +01:00
|
|
|
class ProjectManager : public Control {
|
|
|
|
GDCLASS(ProjectManager, Control);
|
2023-03-10 13:57:32 +01:00
|
|
|
|
2024-01-16 19:50:38 +01:00
|
|
|
static ProjectManager *singleton;
|
2023-03-10 13:57:32 +01:00
|
|
|
|
2024-01-16 19:50:38 +01:00
|
|
|
// Utility data.
|
2023-03-10 13:57:32 +01:00
|
|
|
|
2024-01-16 19:50:38 +01: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 13:57:32 +01:00
|
|
|
|
2024-01-16 19:50:38 +01:00
|
|
|
HashMap<String, Ref<Texture2D>> icon_type_cache;
|
2023-03-10 13:57:32 +01:00
|
|
|
|
2024-01-16 19:50:38 +01:00
|
|
|
void _build_icon_type_cache(Ref<Theme> p_theme);
|
2023-03-10 13:57:32 +01:00
|
|
|
|
2024-01-16 19:50:38 +01:00
|
|
|
// Main layout.
|
2023-03-10 13:57:32 +01:00
|
|
|
|
2024-01-30 17:35:46 +01:00
|
|
|
Ref<Theme> theme;
|
|
|
|
|
2024-01-16 19:50:38 +01:00
|
|
|
void _update_size_limits();
|
2024-01-30 17:35:46 +01:00
|
|
|
void _update_theme(bool p_skip_creation = false);
|
2023-03-10 13:57:32 +01:00
|
|
|
|
2024-01-30 17:35:46 +01:00
|
|
|
MarginContainer *root_container = nullptr;
|
2024-01-16 19:50:38 +01:00
|
|
|
Panel *background_panel = nullptr;
|
2024-01-30 17:35:46 +01:00
|
|
|
VBoxContainer *main_vbox = nullptr;
|
2023-03-10 13:57:32 +01:00
|
|
|
|
2024-01-30 17:35:46 +01:00
|
|
|
HBoxContainer *title_bar = nullptr;
|
|
|
|
Button *title_bar_logo = nullptr;
|
|
|
|
HBoxContainer *main_view_toggles = nullptr;
|
2024-01-30 17:35:46 +01:00
|
|
|
Button *quick_settings_button = nullptr;
|
2023-03-10 13:57:32 +01:00
|
|
|
|
2024-01-30 17:35:46 +01: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 13:57:32 +01:00
|
|
|
|
2024-01-16 19:50:38 +01:00
|
|
|
VBoxContainer *local_projects_vb = nullptr;
|
|
|
|
EditorAssetLibrary *asset_library = nullptr;
|
2023-03-10 13:57:32 +01:00
|
|
|
|
2024-01-30 17:35:46 +01:00
|
|
|
EditorAbout *about_dialog = nullptr;
|
2024-01-30 17:35:46 +01:00
|
|
|
|
|
|
|
void _show_about();
|
2024-01-30 17:35:46 +01:00
|
|
|
void _open_asset_library_confirmed();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2024-01-30 17:35:46 +01:00
|
|
|
AcceptDialog *error_dialog = nullptr;
|
|
|
|
|
|
|
|
void _show_error(const String &p_message, const Size2 &p_min_size = Size2());
|
2024-01-30 17:35:46 +01:00
|
|
|
void _dim_window();
|
|
|
|
|
2024-01-16 19:50:38 +01:00
|
|
|
// Quick settings.
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2024-01-30 17:35:46 +01:00
|
|
|
QuickSettingsDialog *quick_settings_dialog = nullptr;
|
2022-02-12 20:55:11 +01:00
|
|
|
|
2024-01-30 17:35:46 +01:00
|
|
|
void _show_quick_settings();
|
|
|
|
void _restart_confirmed();
|
2022-02-03 01:21:52 +01:00
|
|
|
|
2024-01-30 17:35:46 +01:00
|
|
|
// Footer.
|
|
|
|
|
|
|
|
LinkButton *version_btn = nullptr;
|
|
|
|
|
|
|
|
void _version_button_pressed();
|
|
|
|
|
2024-01-16 19:50:38 +01:00
|
|
|
// Project list.
|
2023-12-20 13:19:21 +01:00
|
|
|
|
2024-01-30 17:35:46 +01: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 15:43:49 +02:00
|
|
|
|
2022-03-29 20:15:31 +02:00
|
|
|
LineEdit *search_box = nullptr;
|
|
|
|
Label *loading_label = nullptr;
|
|
|
|
OptionButton *filter_option = nullptr;
|
2024-01-30 17:35:46 +01:00
|
|
|
PanelContainer *project_list_panel = nullptr;
|
2020-08-27 15:43:49 +02:00
|
|
|
|
2022-06-15 09:04:48 +02:00
|
|
|
Button *create_btn = nullptr;
|
|
|
|
Button *import_btn = nullptr;
|
|
|
|
Button *scan_btn = nullptr;
|
2022-03-29 20:15:31 +02:00
|
|
|
Button *open_btn = nullptr;
|
2022-06-15 09:04:48 +02:00
|
|
|
Button *run_btn = nullptr;
|
2022-03-29 20:15:31 +02:00
|
|
|
Button *rename_btn = nullptr;
|
2023-03-17 23:30:21 +01:00
|
|
|
Button *manage_tags_btn = nullptr;
|
2022-03-29 20:15:31 +02:00
|
|
|
Button *erase_btn = nullptr;
|
|
|
|
Button *erase_missing_btn = nullptr;
|
2023-03-17 23:30:21 +01:00
|
|
|
|
2022-03-29 20:15:31 +02:00
|
|
|
EditorFileDialog *scan_dir = nullptr;
|
2021-03-20 19:31:49 +01:00
|
|
|
|
2022-03-29 20:15:31 +02:00
|
|
|
ConfirmationDialog *erase_ask = nullptr;
|
|
|
|
Label *erase_ask_label = nullptr;
|
2023-03-15 23:48:52 +01: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 20:15:31 +02:00
|
|
|
ConfirmationDialog *erase_missing_ask = nullptr;
|
|
|
|
ConfirmationDialog *multi_open_ask = nullptr;
|
|
|
|
ConfirmationDialog *multi_run_ask = nullptr;
|
2020-08-27 15:43:49 +02:00
|
|
|
|
2024-01-30 17:35:46 +01:00
|
|
|
ProjectDialog *project_dialog = nullptr;
|
2018-12-21 12:20:48 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void _scan_projects();
|
|
|
|
void _run_project();
|
2014-05-11 03:45:52 +02:00
|
|
|
void _run_project_confirm();
|
2018-12-21 12:20:48 +01:00
|
|
|
void _open_selected_projects();
|
|
|
|
void _open_selected_projects_ask();
|
2024-01-16 19:50:38 +01:00
|
|
|
|
|
|
|
void _install_project(const String &p_zip_path, const String &p_title);
|
2014-02-10 02:10:30 +01:00
|
|
|
void _import_project();
|
|
|
|
void _new_project();
|
2017-09-07 02:04:41 +02:00
|
|
|
void _rename_project();
|
2014-02-10 02:10:30 +01:00
|
|
|
void _erase_project();
|
2019-02-11 17:44:23 +01:00
|
|
|
void _erase_missing_projects();
|
2014-02-10 02:10:30 +01:00
|
|
|
void _erase_project_confirm();
|
2019-02-11 17:44:23 +01:00
|
|
|
void _erase_missing_projects_confirm();
|
2016-07-29 02:33:59 +02:00
|
|
|
void _update_project_buttons();
|
2024-01-16 19:50:38 +01: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 12:20:48 +01:00
|
|
|
|
2023-03-17 23:30:21 +01: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 19:50:38 +01:00
|
|
|
// Project converter/migration tool.
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2024-01-16 19:50:38 +01:00
|
|
|
ConfirmationDialog *ask_full_convert_dialog = nullptr;
|
|
|
|
ConfirmationDialog *ask_update_settings = nullptr;
|
|
|
|
Button *full_convert_button = nullptr;
|
2016-07-12 02:34:02 +02:00
|
|
|
|
2024-01-16 19:50:38 +01:00
|
|
|
void _full_convert_button_pressed();
|
|
|
|
void _perform_full_project_conversion();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2024-01-16 19:50:38 +01:00
|
|
|
// Input and I/O.
|
2019-07-19 23:37:45 +02:00
|
|
|
|
2024-01-16 19:50:38 +01:00
|
|
|
virtual void shortcut_input(const Ref<InputEvent> &p_ev) override;
|
|
|
|
|
|
|
|
void _files_dropped(PackedStringArray p_files);
|
2022-02-03 01:21:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
protected:
|
2015-12-14 20:31:37 +01:00
|
|
|
void _notification(int p_what);
|
2017-03-05 16:44:50 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
public:
|
2022-02-12 20:55:11 +01:00
|
|
|
static ProjectManager *get_singleton() { return singleton; }
|
|
|
|
|
2024-01-16 19:50:38 +01:00
|
|
|
// Project list.
|
|
|
|
|
2023-03-17 23:30:21 +01:00
|
|
|
LineEdit *get_search_box();
|
2024-01-16 19:50:38 +01:00
|
|
|
|
|
|
|
// Project tag management.
|
|
|
|
|
2023-03-17 23:30:21 +01:00
|
|
|
void add_new_tag(const String &p_tag);
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
ProjectManager();
|
|
|
|
~ProjectManager();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PROJECT_MANAGER_H
|