summaryrefslogtreecommitdiff
path: root/editor/project_manager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/project_manager.cpp')
-rw-r--r--editor/project_manager.cpp218
1 files changed, 72 insertions, 146 deletions
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index d3856cf778..dc5ff6a5eb 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -59,7 +59,6 @@ static inline String get_project_key_from_path(const String &dir) {
}
class ProjectDialog : public ConfirmationDialog {
-
GDCLASS(ProjectDialog, ConfirmationDialog);
public:
@@ -107,30 +106,25 @@ private:
String created_folder_path;
void set_message(const String &p_msg, MessageType p_type = MESSAGE_SUCCESS, InputType input_type = PROJECT_PATH) {
-
msg->set_text(p_msg);
Ref<Texture2D> current_path_icon = status_rect->get_texture();
Ref<Texture2D> current_install_icon = install_status_rect->get_texture();
Ref<Texture2D> new_icon;
switch (p_type) {
-
case MESSAGE_ERROR: {
-
msg->add_theme_color_override("font_color", msg->get_theme_color("error_color", "Editor"));
msg->set_modulate(Color(1, 1, 1, 1));
new_icon = msg->get_theme_icon("StatusError", "EditorIcons");
} break;
case MESSAGE_WARNING: {
-
msg->add_theme_color_override("font_color", msg->get_theme_color("warning_color", "Editor"));
msg->set_modulate(Color(1, 1, 1, 1));
new_icon = msg->get_theme_icon("StatusWarning", "EditorIcons");
} break;
case MESSAGE_SUCCESS: {
-
msg->set_modulate(Color(1, 1, 1, 0));
new_icon = msg->get_theme_icon("StatusSuccess", "EditorIcons");
@@ -147,7 +141,6 @@ private:
}
String _test_path() {
-
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
String valid_path, valid_install_path;
if (d->change_dir(project_path->get_text()) == OK) {
@@ -187,16 +180,13 @@ private:
}
if (mode == MODE_IMPORT || mode == MODE_RENAME) {
-
if (valid_path != "" && !d->file_exists("project.godot")) {
-
if (valid_path.ends_with(".zip")) {
- FileAccess *src_f = NULL;
+ FileAccess *src_f = nullptr;
zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
unzFile pkg = unzOpen2(valid_path.utf8().get_data(), &io);
if (!pkg) {
-
set_message(TTR("Error opening package file (it's not in ZIP format)."), MESSAGE_ERROR);
memdelete(d);
get_ok()->set_disabled(true);
@@ -208,7 +198,7 @@ private:
while (ret == UNZ_OK) {
unz_file_info info;
char fname[16384];
- ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);
+ ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0);
if (String(fname).ends_with("project.godot")) {
break;
@@ -245,7 +235,6 @@ private:
d->list_dir_end();
if (!is_empty) {
-
set_message(TTR("Please choose an empty folder."), MESSAGE_WARNING, INSTALL_PATH);
memdelete(d);
get_ok()->set_disabled(true);
@@ -261,7 +250,6 @@ private:
}
} else if (valid_path.ends_with("zip")) {
-
set_message(TTR("This directory already contains a Godot project."), MESSAGE_ERROR, INSTALL_PATH);
memdelete(d);
get_ok()->set_disabled(true);
@@ -269,7 +257,6 @@ private:
}
} else {
-
// check if the specified folder is empty, even though this is not an error, it is good to check here
d->list_dir_begin();
bool is_empty = true;
@@ -288,7 +275,6 @@ private:
d->list_dir_end();
if (!is_empty) {
-
set_message(TTR("Please choose an empty folder."), MESSAGE_ERROR);
memdelete(d);
get_ok()->set_disabled(true);
@@ -304,10 +290,8 @@ private:
}
void _path_text_changed(const String &p_path) {
-
String sp = _test_path();
if (sp != "") {
-
// If the project name is empty or default, infer the project name from the selected folder name
if (project_name->get_text() == "" || project_name->get_text() == TTR("New Game Project")) {
sp = sp.replace("\\", "/");
@@ -316,8 +300,9 @@ private:
if (lidx != -1) {
sp = sp.substr(lidx + 1, sp.length()).capitalize();
}
- if (sp == "" && mode == MODE_IMPORT)
+ if (sp == "" && mode == MODE_IMPORT) {
sp = TTR("Imported Project");
+ }
project_name->set_text(sp);
_text_changed(sp);
@@ -330,7 +315,6 @@ private:
}
void _file_selected(const String &p_path) {
-
String p = p_path;
if (mode == MODE_IMPORT) {
if (p.ends_with("project.godot")) {
@@ -358,7 +342,6 @@ private:
}
void _path_selected(const String &p_path) {
-
String sp = p_path.simplify_path();
project_path->set_text(sp);
_path_text_changed(sp);
@@ -366,7 +349,6 @@ private:
}
void _install_path_selected(const String &p_path) {
-
String sp = p_path.simplify_path();
install_path->set_text(sp);
_path_text_changed(sp);
@@ -374,11 +356,9 @@ private:
}
void _browse_path() {
-
fdialog->set_current_dir(project_path->get_text());
if (mode == MODE_IMPORT) {
-
fdialog->set_file_mode(FileDialog::FILE_MODE_OPEN_FILE);
fdialog->clear_filters();
fdialog->add_filter(vformat("project.godot ; %s %s", VERSION_NAME, TTR("Project")));
@@ -396,7 +376,6 @@ private:
}
void _create_folder() {
-
if (project_name->get_text() == "" || created_folder_path != "" || project_name->get_text().ends_with(".") || project_name->get_text().ends_with(" ")) {
set_message(TTR("Invalid Project Name."), MESSAGE_WARNING);
return;
@@ -404,11 +383,8 @@ private:
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
if (d->change_dir(project_path->get_text()) == OK) {
-
if (!d->dir_exists(project_name->get_text())) {
-
if (d->make_dir(project_name->get_text()) == OK) {
-
d->change_dir(project_name->get_text());
String dir_str = d->get_current_dir();
project_path->set_text(dir_str);
@@ -416,12 +392,10 @@ private:
created_folder_path = d->get_current_dir();
create_dir->set_disabled(true);
} else {
-
dialog_error->set_text(TTR("Couldn't create folder."));
dialog_error->popup_centered();
}
} else {
-
dialog_error->set_text(TTR("There is already a folder in this path with the specified name."));
dialog_error->popup_centered();
}
@@ -431,22 +405,21 @@ private:
}
void _text_changed(const String &p_text) {
-
- if (mode != MODE_NEW)
+ if (mode != MODE_NEW) {
return;
+ }
_test_path();
- if (p_text == "")
+ if (p_text == "") {
set_message(TTR("It would be a good idea to name your project."), MESSAGE_WARNING);
+ }
}
void ok_pressed() {
-
String dir = project_path->get_text();
if (mode == MODE_RENAME) {
-
String dir2 = _test_path();
if (dir2 == "") {
set_message(TTR("Invalid project path (changed anything?)."), MESSAGE_ERROR);
@@ -471,11 +444,8 @@ private:
emit_signal("projects_updated");
} else {
-
if (mode == MODE_IMPORT) {
-
if (project_path->get_text().ends_with(".zip")) {
-
mode = MODE_INSTALL;
ok_pressed();
@@ -484,7 +454,6 @@ private:
} else {
if (mode == MODE_NEW) {
-
ProjectSettings::CustomMap initial_settings;
if (rasterizer_button_group->get_pressed_button()->get_meta("driver_name") == "Vulkan") {
initial_settings["rendering/quality/driver/driver_name"] = "Vulkan";
@@ -516,18 +485,16 @@ private:
}
} else if (mode == MODE_INSTALL) {
-
if (project_path->get_text().ends_with(".zip")) {
dir = install_path->get_text();
zip_path = project_path->get_text();
}
- FileAccess *src_f = NULL;
+ FileAccess *src_f = nullptr;
zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
unzFile pkg = unzOpen2(zip_path.utf8().get_data(), &io);
if (!pkg) {
-
dialog_error->set_text(TTR("Error opening package file, not in ZIP format."));
dialog_error->popup_centered();
return;
@@ -539,11 +506,10 @@ private:
int idx = 0;
while (ret == UNZ_OK) {
-
//get filename
unz_file_info info;
char fname[16384];
- ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);
+ ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0);
String path = fname;
@@ -570,7 +536,6 @@ private:
memdelete(da);
} else {
-
Vector<uint8_t> data;
data.resize(info.uncompressed_size);
@@ -598,7 +563,6 @@ private:
if (failed_files.size()) {
String msg = TTR("The following files failed extraction from package:") + "\n\n";
for (int i = 0; i < failed_files.size(); i++) {
-
if (i > 15) {
msg += "\nAnd " + itos(failed_files.size() - i) + " more files.";
break;
@@ -617,8 +581,9 @@ private:
}
dir = dir.replace("\\", "/");
- if (dir.ends_with("/"))
+ if (dir.ends_with("/")) {
dir = dir.substr(0, dir.length() - 1);
+ }
String proj = get_project_key_from_path(dir);
EditorSettings::get_singleton()->set("projects/" + proj, dir);
EditorSettings::get_singleton()->save();
@@ -629,7 +594,6 @@ private:
}
void _remove_created_folder() {
-
if (created_folder_path != "") {
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
d->remove(created_folder_path);
@@ -641,7 +605,6 @@ private:
}
void cancel_pressed() {
-
_remove_created_folder();
project_path->clear();
@@ -649,22 +612,23 @@ private:
project_name->clear();
_text_changed("");
- if (status_rect->get_texture() == msg->get_theme_icon("StatusError", "EditorIcons"))
+ if (status_rect->get_texture() == msg->get_theme_icon("StatusError", "EditorIcons")) {
msg->show();
+ }
- if (install_status_rect->get_texture() == msg->get_theme_icon("StatusError", "EditorIcons"))
+ if (install_status_rect->get_texture() == msg->get_theme_icon("StatusError", "EditorIcons")) {
msg->show();
+ }
}
void _notification(int p_what) {
-
- if (p_what == NOTIFICATION_WM_CLOSE_REQUEST)
+ if (p_what == NOTIFICATION_WM_CLOSE_REQUEST) {
_remove_created_folder();
+ }
}
protected:
static void _bind_methods() {
-
ClassDB::bind_method("_browse_path", &ProjectDialog::_browse_path);
ClassDB::bind_method("_create_folder", &ProjectDialog::_create_folder);
ClassDB::bind_method("_text_changed", &ProjectDialog::_text_changed);
@@ -686,7 +650,6 @@ public:
}
void set_mode(Mode p_mode) {
-
mode = p_mode;
}
@@ -695,9 +658,7 @@ public:
}
void show_dialog() {
-
if (mode == MODE_RENAME) {
-
project_path->set_editable(false);
browse->hide();
install_browse->hide();
@@ -731,7 +692,6 @@ public:
create_dir->hide();
} else {
-
fav_dir = EditorSettings::get_singleton()->get("filesystem/directories/default_project_path");
if (fav_dir != "") {
project_path->set_text(fav_dir);
@@ -765,7 +725,6 @@ public:
project_path->grab_focus();
} else if (mode == MODE_NEW) {
-
set_title(TTR("Create New Project"));
get_ok()->set_text(TTR("Create & Edit"));
name_container->show();
@@ -775,7 +734,6 @@ public:
project_name->call_deferred("select_all");
} else if (mode == MODE_INSTALL) {
-
set_title(TTR("Install Project:") + " " + zip_title);
get_ok()->set_text(TTR("Install & Edit"));
project_name->set_text(zip_title);
@@ -792,7 +750,6 @@ public:
}
ProjectDialog() {
-
VBoxContainer *vb = memnew(VBoxContainer);
add_child(vb);
@@ -955,8 +912,8 @@ public:
bool hover;
ProjectListItemControl() {
- favorite_button = NULL;
- icon = NULL;
+ favorite_button = nullptr;
+ icon = nullptr;
icon_needs_reload = true;
hover = false;
}
@@ -1024,7 +981,6 @@ public:
bool p_grayed,
bool p_missing,
int p_version) {
-
project_key = p_project;
project_name = p_name;
description = p_description;
@@ -1036,7 +992,7 @@ public:
grayed = p_grayed;
missing = p_missing;
version = p_version;
- control = NULL;
+ control = nullptr;
}
_FORCE_INLINE_ bool operator==(const Item &l) const {
@@ -1137,7 +1093,6 @@ void ProjectList::update_icons_async() {
void ProjectList::_notification(int p_what) {
if (p_what == NOTIFICATION_PROCESS) {
-
// Load icons as a coroutine to speed up launch when you have hundreds of projects
if (_icon_load_index < _projects.size()) {
Item &item = _projects.write[_icon_load_index];
@@ -1162,7 +1117,6 @@ void ProjectList::load_project_icon(int p_index) {
img.instance();
Error err = img->load(item.icon.replace_first("res://", item.path + "/"));
if (err == OK) {
-
img->resize(default_icon->get_width(), default_icon->get_height(), Image::INTERPOLATE_LANCZOS);
Ref<ImageTexture> it = memnew(ImageTexture);
it->create_from_image(img);
@@ -1178,7 +1132,6 @@ void ProjectList::load_project_icon(int p_index) {
}
void ProjectList::load_project_data(const String &p_property_key, Item &p_item, bool p_favorite) {
-
String path = EditorSettings::get_singleton()->get(p_property_key);
String conf = path.plus_file("project.godot");
bool grayed = false;
@@ -1191,8 +1144,9 @@ void ProjectList::load_project_data(const String &p_property_key, Item &p_item,
String project_name = TTR("Unnamed Project");
if (cf_err == OK) {
String cf_project_name = static_cast<String>(cf->get_value("application", "config/name", ""));
- if (cf_project_name != "")
+ if (cf_project_name != "") {
project_name = cf_project_name.xml_unescape();
+ }
config_version = (int)cf->get_value("", "config_version", 0);
}
@@ -1215,8 +1169,9 @@ void ProjectList::load_project_data(const String &p_property_key, Item &p_item,
String fscache = path.plus_file(".fscache");
if (FileAccess::exists(fscache)) {
uint64_t cache_modified = FileAccess::get_modified_time(fscache);
- if (cache_modified > last_edited)
+ if (cache_modified > last_edited) {
last_edited = cache_modified;
+ }
}
} else {
grayed = true;
@@ -1236,7 +1191,7 @@ void ProjectList::load_projects() {
// Clear whole list
for (int i = 0; i < _projects.size(); ++i) {
Item &project = _projects.write[i];
- CRASH_COND(project.control == NULL);
+ CRASH_COND(project.control == nullptr);
memdelete(project.control); // Why not queue_free()?
}
_projects.clear();
@@ -1262,8 +1217,9 @@ void ProjectList::load_projects() {
for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
// This is actually something like "projects/C:::Documents::Godot::Projects::MyGame"
String property_key = E->get().name;
- if (!property_key.begins_with("projects/"))
+ if (!property_key.begins_with("projects/")) {
continue;
+ }
String project_key = property_key.get_slice("/", 1);
bool favorite = favorites.has("favorite_projects/" + project_key);
@@ -1289,7 +1245,6 @@ void ProjectList::load_projects() {
}
void ProjectList::update_dock_menu() {
-
if (!DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU)) {
return;
}
@@ -1341,12 +1296,11 @@ void ProjectList::_global_menu_open_project(const Variant &p_tag) {
}
void ProjectList::create_project_item_control(int p_index) {
-
// Will be added last in the list, so make sure indexes match
ERR_FAIL_COND(p_index != _scroll_children->get_child_count());
Item &item = _projects.write[p_index];
- ERR_FAIL_COND(item.control != NULL); // Already created
+ ERR_FAIL_COND(item.control != nullptr); // Already created
Ref<Texture2D> favorite_icon = get_theme_icon("Favorites", "EditorIcons");
Color font_color = get_theme_color("font_color", "Tree");
@@ -1383,8 +1337,9 @@ void ProjectList::create_project_item_control(int p_index) {
hb->icon = tf;
VBoxContainer *vb = memnew(VBoxContainer);
- if (item.grayed)
+ if (item.grayed) {
vb->set_modulate(Color(1, 1, 1, 0.5));
+ }
vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hb->add_child(vb);
Control *ec = memnew(Control);
@@ -1442,7 +1397,6 @@ void ProjectList::set_order_option(ProjectListFilter::FilterOption p_option) {
}
void ProjectList::sort_projects() {
-
SortArray<Item, ProjectListComparator> sorter;
sorter.compare.order_option = _order_option;
sorter.sort(_projects.ptrw(), _projects.size());
@@ -1452,7 +1406,6 @@ void ProjectList::sort_projects() {
bool visible = true;
if (_search_term != "") {
-
String search_path;
if (_search_term.find("/") != -1) {
// Search path will match the whole path
@@ -1568,7 +1521,6 @@ bool ProjectList::is_any_project_missing() const {
}
void ProjectList::erase_missing_projects() {
-
if (_projects.empty()) {
return;
}
@@ -1669,7 +1621,6 @@ int ProjectList::get_project_count() const {
}
void ProjectList::select_project(int p_index) {
-
Vector<Item> previous_selected_items = get_selected_projects();
_selected_project_keys.clear();
@@ -1724,7 +1675,6 @@ void ProjectList::toggle_select(int p_index) {
}
void ProjectList::erase_selected_projects() {
-
if (_selected_project_keys.size() == 0) {
return;
}
@@ -1732,7 +1682,6 @@ void ProjectList::erase_selected_projects() {
for (int i = 0; i < _projects.size(); ++i) {
Item &item = _projects.write[i];
if (_selected_project_keys.has(item.project_key) && item.control->is_visible()) {
-
EditorSettings::get_singleton()->erase("projects/" + item.project_key);
EditorSettings::get_singleton()->erase("favorite_projects/" + item.project_key);
@@ -1765,15 +1714,12 @@ void ProjectList::_panel_draw(Node *p_hb) {
// Input for each item in the list
void ProjectList::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) {
-
Ref<InputEventMouseButton> mb = p_ev;
int clicked_index = p_hb->get_index();
const Item &clicked_project = _projects[clicked_index];
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
-
if (mb->get_shift() && _selected_project_keys.size() > 0 && _last_clicked != "" && clicked_project.project_key != _last_clicked) {
-
int anchor_index = -1;
for (int i = 0; i < _projects.size(); ++i) {
const Item &p = _projects[i];
@@ -1802,7 +1748,6 @@ void ProjectList::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) {
}
void ProjectList::_favorite_pressed(Node *p_hb) {
-
ProjectListItemControl *control = Object::cast_to<ProjectListItemControl>(p_hb);
int index = control->get_index();
@@ -1836,7 +1781,6 @@ void ProjectList::_favorite_pressed(Node *p_hb) {
}
void ProjectList::_show_project(const String &p_path) {
-
OS::get_singleton()->shell_open(String("file://") + p_path);
}
@@ -1844,28 +1788,24 @@ const char *ProjectList::SIGNAL_SELECTION_CHANGED = "selection_changed";
const char *ProjectList::SIGNAL_PROJECT_ASK_OPEN = "project_ask_open";
void ProjectList::_bind_methods() {
-
ADD_SIGNAL(MethodInfo(SIGNAL_SELECTION_CHANGED));
ADD_SIGNAL(MethodInfo(SIGNAL_PROJECT_ASK_OPEN));
}
void ProjectManager::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
-
Engine::get_singleton()->set_editor_hint(false);
} break;
case NOTIFICATION_RESIZED: {
-
if (open_templates->is_visible()) {
open_templates->popup_centered();
}
} break;
case NOTIFICATION_READY: {
-
- if (_project_list->get_project_count() == 0 && StreamPeerSSL::is_available())
+ if (_project_list->get_project_count() == 0 && StreamPeerSSL::is_available()) {
open_templates->popup_centered();
+ }
if (_project_list->get_project_count() >= 1) {
// Focus on the search box immediately to allow the user
@@ -1874,18 +1814,15 @@ void ProjectManager::_notification(int p_what) {
}
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
-
set_process_unhandled_input(is_visible_in_tree());
} break;
case NOTIFICATION_WM_CLOSE_REQUEST: {
-
_dim_window();
} break;
}
}
void ProjectManager::_dim_window() {
-
// This method must be called before calling `get_tree()->quit()`.
// Otherwise, its effect won't be visible
@@ -1897,7 +1834,6 @@ void ProjectManager::_dim_window() {
}
void ProjectManager::_update_project_buttons() {
-
Vector<ProjectList::Item> selected_projects = _project_list->get_selected_projects();
bool empty_selection = selected_projects.empty();
@@ -1918,11 +1854,9 @@ void ProjectManager::_update_project_buttons() {
}
void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
-
Ref<InputEventKey> k = p_ev;
if (k.is_valid()) {
-
if (!k->is_pressed()) {
return;
}
@@ -1937,23 +1871,20 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
}
#endif
- if (tabs->get_current_tab() != 0)
+ if (tabs->get_current_tab() != 0) {
return;
+ }
bool keycode_handled = true;
switch (k->get_keycode()) {
-
case KEY_ENTER: {
-
_open_selected_projects_ask();
} break;
case KEY_DELETE: {
-
_erase_project();
} break;
case KEY_HOME: {
-
if (_project_list->get_project_count() > 0) {
_project_list->select_project(0);
_update_project_buttons();
@@ -1961,7 +1892,6 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
} break;
case KEY_END: {
-
if (_project_list->get_project_count() > 0) {
_project_list->select_project(_project_list->get_project_count() - 1);
_update_project_buttons();
@@ -1969,9 +1899,9 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
} break;
case KEY_UP: {
-
- if (k->get_shift())
+ if (k->get_shift()) {
break;
+ }
int index = _project_list->get_single_selected_index();
if (index > 0) {
@@ -1983,9 +1913,9 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
break;
}
case KEY_DOWN: {
-
- if (k->get_shift())
+ if (k->get_shift()) {
break;
+ }
int index = _project_list->get_single_selected_index();
if (index + 1 < _project_list->get_project_count()) {
@@ -1996,10 +1926,11 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
} break;
case KEY_F: {
- if (k->get_command())
+ if (k->get_command()) {
this->project_filter->search_box->grab_focus();
- else
+ } else {
keycode_handled = false;
+ }
} break;
default: {
keycode_handled = false;
@@ -2013,7 +1944,6 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
}
void ProjectManager::_load_recent_projects() {
-
_project_list->set_order_option(project_order_filter->get_filter_option());
_project_list->set_search_term(project_filter->get_search_term());
_project_list->load_projects();
@@ -2051,7 +1981,6 @@ void ProjectManager::_confirm_update_settings() {
}
void ProjectManager::_open_selected_projects() {
-
const Set<String> &selected_list = _project_list->get_selected_project_keys();
for (const Set<String>::Element *E = selected_list.front(); E; E = E->next()) {
@@ -2090,7 +2019,6 @@ void ProjectManager::_open_selected_projects() {
}
void ProjectManager::_open_selected_projects_ask() {
-
const Set<String> &selected_list = _project_list->get_selected_project_keys();
if (selected_list.size() < 1) {
@@ -2136,11 +2064,9 @@ void ProjectManager::_open_selected_projects_ask() {
}
void ProjectManager::_run_project_confirm() {
-
Vector<ProjectList::Item> selected_list = _project_list->get_selected_projects();
for (int i = 0; i < selected_list.size(); ++i) {
-
const String &selected_main = selected_list[i].main_scene;
if (selected_main == "") {
run_error_diag->set_text(TTR("Can't run project: no main scene defined.\nPlease edit the project and set the main scene in the Project Settings under the \"Application\" category."));
@@ -2178,7 +2104,6 @@ void ProjectManager::_run_project_confirm() {
// When you press the "Run" button
void ProjectManager::_run_project() {
-
const Set<String> &selected_list = _project_list->get_selected_project_keys();
if (selected_list.size() < 1) {
@@ -2211,7 +2136,6 @@ void ProjectManager::_scan_dir(const String &path, List<String> *r_projects) {
}
void ProjectManager::_scan_begin(const String &p_base) {
-
print_line("Scanning projects at: " + p_base);
List<String> projects;
_scan_dir(p_base, &projects);
@@ -2226,24 +2150,20 @@ void ProjectManager::_scan_begin(const String &p_base) {
}
void ProjectManager::_scan_projects() {
-
scan_dir->popup_centered_ratio();
}
void ProjectManager::_new_project() {
-
npdialog->set_mode(ProjectDialog::MODE_NEW);
npdialog->show_dialog();
}
void ProjectManager::_import_project() {
-
npdialog->set_mode(ProjectDialog::MODE_IMPORT);
npdialog->show_dialog();
}
void ProjectManager::_rename_project() {
-
const Set<String> &selected_list = _project_list->get_selected_project_keys();
if (selected_list.size() == 0) {
@@ -2270,11 +2190,11 @@ void ProjectManager::_erase_missing_projects_confirm() {
}
void ProjectManager::_erase_project() {
-
const Set<String> &selected_list = _project_list->get_selected_project_keys();
- if (selected_list.size() == 0)
+ if (selected_list.size() == 0) {
return;
+ }
String confirm_message;
if (selected_list.size() >= 2) {
@@ -2288,13 +2208,11 @@ void ProjectManager::_erase_project() {
}
void ProjectManager::_erase_missing_projects() {
-
erase_missing_ask->set_text(TTR("Remove all missing projects from the list?\nThe project folders' contents won't be modified."));
erase_missing_ask->popup_centered();
}
void ProjectManager::_language_selected(int p_id) {
-
String lang = language_btn->get_item_metadata(p_id);
EditorSettings::get_singleton()->set("interface/editor/editor_language", lang);
language_btn->set_text(lang);
@@ -2305,7 +2223,6 @@ void ProjectManager::_language_selected(int p_id) {
}
void ProjectManager::_restart_confirm() {
-
List<String> args = OS::get_singleton()->get_cmdline_args();
String exec = OS::get_singleton()->get_executable_path();
OS::ProcessID pid = 0;
@@ -2317,13 +2234,11 @@ void ProjectManager::_restart_confirm() {
}
void ProjectManager::_exit_dialog() {
-
_dim_window();
get_tree()->quit();
}
void ProjectManager::_install_project(const String &p_zip_path, const String &p_title) {
-
npdialog->set_mode(ProjectDialog::MODE_INSTALL);
npdialog->set_zip_path(p_zip_path);
npdialog->set_zip_title(p_title);
@@ -2395,7 +2310,6 @@ void ProjectManager::_on_filter_option_changed() {
}
void ProjectManager::_bind_methods() {
-
ClassDB::bind_method("_exit_dialog", &ProjectManager::_exit_dialog);
ClassDB::bind_method("_unhandled_input", &ProjectManager::_unhandled_input);
ClassDB::bind_method("_update_project_buttons", &ProjectManager::_update_project_buttons);
@@ -2407,10 +2321,10 @@ void ProjectManager::_open_asset_library() {
}
ProjectManager::ProjectManager() {
-
// load settings
- if (!EditorSettings::get_singleton())
+ if (!EditorSettings::get_singleton()) {
EditorSettings::create();
+ }
EditorSettings::get_singleton()->set_optimize_save(false); //just write settings as they came
@@ -2429,12 +2343,24 @@ ProjectManager::ProjectManager() {
#endif
} break;
- case 1: editor_set_scale(0.75); break;
- case 2: editor_set_scale(1.0); break;
- case 3: editor_set_scale(1.25); break;
- case 4: editor_set_scale(1.5); break;
- case 5: editor_set_scale(1.75); break;
- case 6: editor_set_scale(2.0); break;
+ case 1:
+ editor_set_scale(0.75);
+ break;
+ case 2:
+ editor_set_scale(1.0);
+ break;
+ case 3:
+ editor_set_scale(1.25);
+ break;
+ case 4:
+ editor_set_scale(1.5);
+ break;
+ case 5:
+ editor_set_scale(1.75);
+ break;
+ case 6:
+ editor_set_scale(2.0);
+ break;
default: {
editor_set_scale(custom_display_scale);
@@ -2718,16 +2644,16 @@ ProjectManager::ProjectManager() {
}
ProjectManager::~ProjectManager() {
-
- if (EditorSettings::get_singleton())
+ if (EditorSettings::get_singleton()) {
EditorSettings::destroy();
+ }
}
void ProjectListFilter::_setup_filters(Vector<String> options) {
-
filter_option->clear();
- for (int i = 0; i < options.size(); i++)
+ for (int i = 0; i < options.size(); i++) {
filter_option->add_item(options[i]);
+ }
}
void ProjectListFilter::_search_text_changed(const String &p_newtext) {
@@ -2751,13 +2677,13 @@ void ProjectListFilter::_filter_option_selected(int p_idx) {
FilterOption selected = (FilterOption)(filter_option->get_selected());
if (_current_filter != selected) {
_current_filter = selected;
- if (is_inside_tree())
+ if (is_inside_tree()) {
emit_signal("filter_changed");
+ }
}
}
void ProjectListFilter::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE && has_search_box) {
search_box->set_right_icon(get_theme_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
@@ -2765,7 +2691,6 @@ void ProjectListFilter::_notification(int p_what) {
}
void ProjectListFilter::_bind_methods() {
-
ADD_SIGNAL(MethodInfo("filter_changed"));
}
@@ -2779,6 +2704,8 @@ void ProjectListFilter::add_filter_option() {
void ProjectListFilter::add_search_box() {
search_box = memnew(LineEdit);
search_box->set_placeholder(TTR("Search"));
+ search_box->set_tooltip(
+ TTR("The search box filters projects by name and last path component.\nTo filter projects by name and full path, the query must contain at least one `/` character."));
search_box->connect("text_changed", callable_mp(this, &ProjectListFilter::_search_text_changed));
search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
add_child(search_box);
@@ -2791,7 +2718,6 @@ void ProjectListFilter::set_filter_size(int h_size) {
}
ProjectListFilter::ProjectListFilter() {
-
_current_filter = FILTER_NAME;
has_search_box = false;
}