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
|
|
|
|
|
2023-03-10 13:57:32 +01:00
|
|
|
#include "core/io/config_file.h"
|
2021-04-08 01:05:47 +02:00
|
|
|
#include "editor/editor_about.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "scene/gui/dialogs.h"
|
|
|
|
#include "scene/gui/file_dialog.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;
|
2023-03-10 13:57:32 +01:00
|
|
|
class EditorAssetLibrary;
|
|
|
|
class EditorFileDialog;
|
2023-03-10 15:22:33 +01:00
|
|
|
class PanelContainer;
|
2020-08-27 15:43:49 +02:00
|
|
|
|
2023-03-10 13:57:32 +01:00
|
|
|
class ProjectDialog : public ConfirmationDialog {
|
|
|
|
GDCLASS(ProjectDialog, ConfirmationDialog);
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Mode {
|
|
|
|
MODE_NEW,
|
|
|
|
MODE_IMPORT,
|
|
|
|
MODE_INSTALL,
|
|
|
|
MODE_RENAME,
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
enum MessageType {
|
|
|
|
MESSAGE_ERROR,
|
|
|
|
MESSAGE_WARNING,
|
|
|
|
MESSAGE_SUCCESS,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum InputType {
|
|
|
|
PROJECT_PATH,
|
|
|
|
INSTALL_PATH,
|
|
|
|
};
|
|
|
|
|
|
|
|
Mode mode = MODE_NEW;
|
|
|
|
bool is_folder_empty = true;
|
|
|
|
|
|
|
|
Button *browse = nullptr;
|
|
|
|
Button *install_browse = nullptr;
|
|
|
|
Button *create_dir = nullptr;
|
|
|
|
Container *name_container = nullptr;
|
|
|
|
Container *path_container = nullptr;
|
|
|
|
Container *install_path_container = nullptr;
|
|
|
|
|
|
|
|
Container *renderer_container = nullptr;
|
|
|
|
Label *renderer_info = nullptr;
|
|
|
|
HBoxContainer *default_files_container = nullptr;
|
|
|
|
Ref<ButtonGroup> renderer_button_group;
|
|
|
|
|
|
|
|
Label *msg = nullptr;
|
|
|
|
LineEdit *project_path = nullptr;
|
|
|
|
LineEdit *project_name = nullptr;
|
|
|
|
LineEdit *install_path = nullptr;
|
|
|
|
TextureRect *status_rect = nullptr;
|
|
|
|
TextureRect *install_status_rect = nullptr;
|
|
|
|
|
|
|
|
OptionButton *vcs_metadata_selection = nullptr;
|
|
|
|
|
|
|
|
EditorFileDialog *fdialog = nullptr;
|
|
|
|
EditorFileDialog *fdialog_install = nullptr;
|
|
|
|
AcceptDialog *dialog_error = nullptr;
|
|
|
|
|
|
|
|
String zip_path;
|
|
|
|
String zip_title;
|
|
|
|
String fav_dir;
|
|
|
|
|
|
|
|
String created_folder_path;
|
|
|
|
|
|
|
|
void _set_message(const String &p_msg, MessageType p_type = MESSAGE_SUCCESS, InputType input_type = PROJECT_PATH);
|
|
|
|
|
|
|
|
String _test_path();
|
|
|
|
void _path_text_changed(const String &p_path);
|
|
|
|
void _path_selected(const String &p_path);
|
|
|
|
void _file_selected(const String &p_path);
|
|
|
|
void _install_path_selected(const String &p_path);
|
|
|
|
|
|
|
|
void _browse_path();
|
|
|
|
void _browse_install_path();
|
|
|
|
void _create_folder();
|
|
|
|
|
|
|
|
void _text_changed(const String &p_text);
|
|
|
|
void _nonempty_confirmation_ok_pressed();
|
|
|
|
void _renderer_selected();
|
|
|
|
void _remove_created_folder();
|
|
|
|
|
|
|
|
void ok_pressed() override;
|
|
|
|
void cancel_pressed() override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
|
|
|
void set_zip_path(const String &p_path);
|
|
|
|
void set_zip_title(const String &p_title);
|
|
|
|
void set_mode(Mode p_mode);
|
|
|
|
void set_project_path(const String &p_path);
|
|
|
|
|
|
|
|
void show_dialog();
|
|
|
|
|
|
|
|
ProjectDialog();
|
|
|
|
};
|
|
|
|
|
|
|
|
class ProjectListItemControl : public HBoxContainer {
|
|
|
|
GDCLASS(ProjectListItemControl, HBoxContainer)
|
|
|
|
|
2023-03-10 17:01:08 +01:00
|
|
|
VBoxContainer *main_vbox = nullptr;
|
2023-03-10 13:57:32 +01:00
|
|
|
TextureButton *favorite_button = nullptr;
|
2023-03-10 17:01:08 +01:00
|
|
|
Button *explore_button = nullptr;
|
|
|
|
|
|
|
|
TextureRect *project_icon = nullptr;
|
|
|
|
Label *project_title = nullptr;
|
|
|
|
Label *project_path = nullptr;
|
|
|
|
Label *project_unsupported_features = nullptr;
|
|
|
|
|
|
|
|
bool project_is_missing = false;
|
2023-03-10 13:57:32 +01:00
|
|
|
bool icon_needs_reload = true;
|
2023-03-10 17:01:08 +01:00
|
|
|
bool is_selected = false;
|
|
|
|
bool is_hovering = false;
|
|
|
|
|
|
|
|
void _favorite_button_pressed();
|
|
|
|
void _explore_button_pressed();
|
2023-03-10 13:57:32 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
2023-03-10 17:01:08 +01:00
|
|
|
static void _bind_methods();
|
2023-03-10 13:57:32 +01:00
|
|
|
|
|
|
|
public:
|
2023-03-10 17:01:08 +01:00
|
|
|
void set_project_title(const String &p_title);
|
|
|
|
void set_project_path(const String &p_path);
|
|
|
|
void set_project_icon(const Ref<Texture2D> &p_icon);
|
|
|
|
void set_unsupported_features(const PackedStringArray &p_features);
|
|
|
|
|
|
|
|
bool should_load_project_icon() const;
|
|
|
|
void set_selected(bool p_selected);
|
|
|
|
|
|
|
|
void set_is_favorite(bool p_favorite);
|
|
|
|
void set_is_missing(bool p_missing);
|
|
|
|
void set_is_grayed(bool p_grayed);
|
2023-03-10 13:57:32 +01:00
|
|
|
|
|
|
|
ProjectListItemControl();
|
|
|
|
};
|
|
|
|
|
|
|
|
class ProjectList : public ScrollContainer {
|
|
|
|
GDCLASS(ProjectList, ScrollContainer)
|
|
|
|
|
|
|
|
friend class ProjectManager;
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum FilterOption {
|
|
|
|
EDIT_DATE,
|
|
|
|
NAME,
|
|
|
|
PATH,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Can often be passed by copy
|
|
|
|
struct Item {
|
|
|
|
String project_name;
|
|
|
|
String description;
|
|
|
|
String path;
|
|
|
|
String icon;
|
|
|
|
String main_scene;
|
|
|
|
PackedStringArray unsupported_features;
|
|
|
|
uint64_t last_edited = 0;
|
|
|
|
bool favorite = false;
|
|
|
|
bool grayed = false;
|
|
|
|
bool missing = false;
|
|
|
|
int version = 0;
|
|
|
|
|
|
|
|
ProjectListItemControl *control = nullptr;
|
|
|
|
|
|
|
|
Item() {}
|
|
|
|
|
|
|
|
Item(const String &p_name,
|
|
|
|
const String &p_description,
|
|
|
|
const String &p_path,
|
|
|
|
const String &p_icon,
|
|
|
|
const String &p_main_scene,
|
|
|
|
const PackedStringArray &p_unsupported_features,
|
|
|
|
uint64_t p_last_edited,
|
|
|
|
bool p_favorite,
|
|
|
|
bool p_grayed,
|
|
|
|
bool p_missing,
|
|
|
|
int p_version) {
|
|
|
|
project_name = p_name;
|
|
|
|
description = p_description;
|
|
|
|
path = p_path;
|
|
|
|
icon = p_icon;
|
|
|
|
main_scene = p_main_scene;
|
|
|
|
unsupported_features = p_unsupported_features;
|
|
|
|
last_edited = p_last_edited;
|
|
|
|
favorite = p_favorite;
|
|
|
|
grayed = p_grayed;
|
|
|
|
missing = p_missing;
|
|
|
|
version = p_version;
|
|
|
|
control = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
_FORCE_INLINE_ bool operator==(const Item &l) const {
|
|
|
|
return path == l.path;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool project_opening_initiated = false;
|
|
|
|
|
|
|
|
String _search_term;
|
|
|
|
FilterOption _order_option = FilterOption::EDIT_DATE;
|
|
|
|
HashSet<String> _selected_project_paths;
|
|
|
|
String _last_clicked; // Project key
|
|
|
|
VBoxContainer *_scroll_children = nullptr;
|
|
|
|
int _icon_load_index = 0;
|
|
|
|
|
|
|
|
Vector<Item> _projects;
|
|
|
|
|
|
|
|
ConfigFile _config;
|
|
|
|
String _config_path;
|
|
|
|
|
|
|
|
void _panel_input(const Ref<InputEvent> &p_ev, Node *p_hb);
|
|
|
|
void _favorite_pressed(Node *p_hb);
|
|
|
|
void _show_project(const String &p_path);
|
|
|
|
|
2023-04-04 15:27:13 +02:00
|
|
|
void _clear_project_selection();
|
|
|
|
void _toggle_project(int p_index);
|
|
|
|
void _select_project_nocheck(int p_index);
|
|
|
|
void _deselect_project_nocheck(int p_index);
|
|
|
|
void _select_project_range(int p_begin, int p_end);
|
|
|
|
|
|
|
|
void _create_project_item_control(int p_index);
|
|
|
|
void _remove_project(int p_index, bool p_update_settings);
|
|
|
|
|
2023-03-10 13:57:32 +01:00
|
|
|
static Item load_project_data(const String &p_property_key, bool p_favorite);
|
2023-04-04 15:27:13 +02:00
|
|
|
void _update_icons_async();
|
|
|
|
void _load_project_icon(int p_index);
|
2023-03-10 13:57:32 +01:00
|
|
|
|
|
|
|
void _global_menu_new_window(const Variant &p_tag);
|
|
|
|
void _global_menu_open_project(const Variant &p_tag);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
|
|
|
static const char *SIGNAL_SELECTION_CHANGED;
|
|
|
|
static const char *SIGNAL_PROJECT_ASK_OPEN;
|
|
|
|
|
|
|
|
void load_projects();
|
|
|
|
int get_project_count() const;
|
|
|
|
|
|
|
|
void sort_projects();
|
|
|
|
|
|
|
|
void add_project(const String &dir_path, bool favorite);
|
|
|
|
void set_project_version(const String &p_project_path, int version);
|
|
|
|
int refresh_project(const String &dir_path);
|
|
|
|
void ensure_project_visible(int p_index);
|
|
|
|
|
|
|
|
void select_project(int p_index);
|
|
|
|
void select_first_visible_project();
|
|
|
|
void erase_selected_projects(bool p_delete_project_contents);
|
|
|
|
Vector<Item> get_selected_projects() const;
|
|
|
|
const HashSet<String> &get_selected_project_keys() const;
|
|
|
|
int get_single_selected_index() const;
|
|
|
|
|
|
|
|
bool is_any_project_missing() const;
|
|
|
|
void erase_missing_projects();
|
|
|
|
|
|
|
|
void set_search_term(String p_search_term);
|
|
|
|
void set_order_option(int p_option);
|
|
|
|
|
|
|
|
void update_dock_menu();
|
|
|
|
void migrate_config();
|
|
|
|
void save_config();
|
|
|
|
|
|
|
|
ProjectList();
|
2020-08-27 15:43:49 +02:00
|
|
|
};
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
class ProjectManager : public Control {
|
2017-03-05 16:44:50 +01:00
|
|
|
GDCLASS(ProjectManager, Control);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<String, Ref<Texture2D>> icon_type_cache;
|
2022-02-12 20:55:11 +01:00
|
|
|
void _build_icon_type_cache(Ref<Theme> p_theme);
|
|
|
|
|
|
|
|
static ProjectManager *singleton;
|
2022-02-03 01:21:52 +01:00
|
|
|
|
2023-03-10 15:22:33 +01:00
|
|
|
Panel *background_panel = nullptr;
|
2022-03-29 20:15:31 +02:00
|
|
|
TabContainer *tabs = nullptr;
|
|
|
|
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;
|
2023-03-10 15:22:33 +01:00
|
|
|
PanelContainer *search_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;
|
|
|
|
Button *erase_btn = nullptr;
|
|
|
|
Button *erase_missing_btn = nullptr;
|
|
|
|
Button *about_btn = nullptr;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2022-05-20 06:57:10 +02:00
|
|
|
HBoxContainer *local_projects_hb = nullptr;
|
2022-03-29 20:15:31 +02:00
|
|
|
EditorAssetLibrary *asset_library = nullptr;
|
2016-06-08 14:25:47 +02:00
|
|
|
|
2022-03-29 20:15:31 +02:00
|
|
|
EditorFileDialog *scan_dir = nullptr;
|
|
|
|
ConfirmationDialog *language_restart_ask = 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;
|
2021-03-20 19:31:49 +01:00
|
|
|
|
2022-03-29 20:15:31 +02:00
|
|
|
ConfirmationDialog *erase_missing_ask = nullptr;
|
|
|
|
ConfirmationDialog *multi_open_ask = nullptr;
|
|
|
|
ConfirmationDialog *multi_run_ask = nullptr;
|
|
|
|
ConfirmationDialog *multi_scan_ask = nullptr;
|
2022-08-26 15:22:30 +02:00
|
|
|
ConfirmationDialog *ask_full_convert_dialog = nullptr;
|
2022-03-29 20:15:31 +02:00
|
|
|
ConfirmationDialog *ask_update_settings = nullptr;
|
|
|
|
ConfirmationDialog *open_templates = nullptr;
|
|
|
|
EditorAbout *about = nullptr;
|
2020-08-27 15:43:49 +02:00
|
|
|
|
2022-03-29 20:15:31 +02:00
|
|
|
HBoxContainer *settings_hb = nullptr;
|
2020-09-03 13:22:16 +02:00
|
|
|
|
2022-03-29 20:15:31 +02:00
|
|
|
AcceptDialog *run_error_diag = nullptr;
|
|
|
|
AcceptDialog *dialog_error = nullptr;
|
|
|
|
ProjectDialog *npdialog = nullptr;
|
2018-12-21 12:20:48 +01:00
|
|
|
|
2022-08-26 15:22:30 +02:00
|
|
|
Button *full_convert_button = nullptr;
|
2022-03-29 20:15:31 +02:00
|
|
|
OptionButton *language_btn = nullptr;
|
|
|
|
LinkButton *version_btn = nullptr;
|
2017-11-26 19:31:08 +01:00
|
|
|
|
|
|
|
void _open_asset_library();
|
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();
|
2022-09-15 00:45:59 +02:00
|
|
|
void _full_convert_button_pressed();
|
2022-08-26 15:22:30 +02:00
|
|
|
void _perform_full_project_conversion();
|
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();
|
2021-04-08 01:05:47 +02:00
|
|
|
void _show_about();
|
2016-07-29 02:33:59 +02:00
|
|
|
void _update_project_buttons();
|
2017-10-26 00:02:32 +02:00
|
|
|
void _language_selected(int p_id);
|
|
|
|
void _restart_confirm();
|
2018-12-21 12:20:48 +01:00
|
|
|
void _confirm_update_settings();
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void _load_recent_projects();
|
2017-03-05 16:44:50 +01:00
|
|
|
void _on_project_created(const String &dir);
|
2018-12-21 12:20:48 +01:00
|
|
|
void _on_projects_updated();
|
2020-08-27 15:43:49 +02:00
|
|
|
void _scan_multiple_folders(PackedStringArray p_files);
|
|
|
|
void _scan_begin(const String &p_base);
|
2022-02-24 02:19:27 +01:00
|
|
|
void _scan_dir(const String &path);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void _install_project(const String &p_zip_path, const String &p_title);
|
2016-07-12 02:34:02 +02:00
|
|
|
|
2019-06-09 22:33:50 +02:00
|
|
|
void _dim_window();
|
2022-01-11 14:59:52 +01:00
|
|
|
virtual void shortcut_input(const Ref<InputEvent> &p_ev) override;
|
2022-04-10 21:25:24 +02:00
|
|
|
void _files_dropped(PackedStringArray p_files);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2019-12-24 01:20:54 +01:00
|
|
|
void _version_button_pressed();
|
2020-08-27 15:43:49 +02:00
|
|
|
void _on_order_option_changed(int p_idx);
|
2021-04-04 22:47:44 +02:00
|
|
|
void _on_tab_changed(int p_tab);
|
2020-08-27 15:43:49 +02:00
|
|
|
void _on_search_term_changed(const String &p_term);
|
2019-07-19 23:37:45 +02:00
|
|
|
|
2022-02-03 01:21:52 +01:00
|
|
|
static Ref<Texture2D> _file_dialog_get_icon(const String &p_path);
|
2023-02-17 22:37:38 +01:00
|
|
|
static Ref<Texture2D> _file_dialog_get_thumbnail(const String &p_path);
|
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);
|
2014-02-10 02:10:30 +01:00
|
|
|
static void _bind_methods();
|
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; }
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
ProjectManager();
|
|
|
|
~ProjectManager();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PROJECT_MANAGER_H
|