From f8db8a3faa30b71dca33ced38be16d3f93f43e8a Mon Sep 17 00:00:00 2001 From: Rémi Verschelde Date: Sun, 19 Mar 2017 00:36:26 +0100 Subject: Bring that Whole New World to the Old Continent too Applies the clang-format style to the 2.1 branch as done for master in 5dbf1809c6e3e905b94b8764e99491e608122261. --- editor/project_manager.cpp | 754 +++++++++++++++++++++------------------------ 1 file changed, 354 insertions(+), 400 deletions(-) (limited to 'editor/project_manager.cpp') diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 3ef3c95c2..9502b0af0 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -26,47 +26,46 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "version.h" #include "project_manager.h" -#include "os/os.h" +#include "editor_settings.h" +#include "io/config_file.h" #include "os/dir_access.h" #include "os/file_access.h" #include "os/keyboard.h" -#include "editor_settings.h" +#include "os/os.h" #include "scene/gui/separator.h" #include "scene/gui/tool_button.h" -#include "io/config_file.h" +#include "version.h" +#include "io/stream_peer_ssl.h" +#include "scene/gui/center_container.h" #include "scene/gui/line_edit.h" #include "scene/gui/panel_container.h" -#include "scene/gui/center_container.h" -#include "io/stream_peer_ssl.h" -#include "scene/gui/texture_frame.h" -#include "scene/gui/margin_container.h" #include "io/resource_saver.h" +#include "scene/gui/margin_container.h" +#include "scene/gui/texture_frame.h" -#include "editor_themes.h" #include "editor_initialize_ssl.h" #include "editor_scale.h" +#include "editor_themes.h" #include "io/zip_io.h" class NewProjectDialog : public ConfirmationDialog { - OBJ_TYPE(NewProjectDialog,ConfirmationDialog); + OBJ_TYPE(NewProjectDialog, ConfirmationDialog); public: - enum Mode { MODE_NEW, MODE_IMPORT, MODE_INSTALL }; -private: +private: Mode mode; - Label *pp,*pn; + Label *pp, *pn; Label *error; LineEdit *project_path; LineEdit *project_name; @@ -81,10 +80,10 @@ private: get_ok()->set_disabled(true); DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); String valid_path; - if (d->change_dir(project_path->get_text())==OK){ - valid_path=project_path->get_text(); - } else if (d->change_dir(project_path->get_text().strip_edges())==OK) { - valid_path=project_path->get_text().strip_edges(); + if (d->change_dir(project_path->get_text()) == OK) { + valid_path = project_path->get_text(); + } else if (d->change_dir(project_path->get_text().strip_edges()) == OK) { + valid_path = project_path->get_text().strip_edges(); } if (valid_path == "") { @@ -93,7 +92,7 @@ private: return ""; } - if (mode!=MODE_IMPORT) { + if (mode != MODE_IMPORT) { if (d->file_exists("engine.cfg")) { @@ -115,34 +114,33 @@ private: memdelete(d); get_ok()->set_disabled(false); return valid_path; - } - void _path_text_changed(const String& p_path) { + void _path_text_changed(const String &p_path) { - String sp=_test_path(); - if ( sp!="" ) { + String sp = _test_path(); + if (sp != "") { - sp=sp.replace("\\","/"); - int lidx=sp.find_last("/"); + sp = sp.replace("\\", "/"); + int lidx = sp.find_last("/"); - if (lidx!=-1) { - sp=sp.substr(lidx+1,sp.length()); + if (lidx != -1) { + sp = sp.substr(lidx + 1, sp.length()); } - if (sp=="" && mode==MODE_IMPORT ) - sp=TTR("Imported Project"); + if (sp == "" && mode == MODE_IMPORT) + sp = TTR("Imported Project"); project_name->set_text(sp); } } - void _file_selected(const String& p_path) { + void _file_selected(const String &p_path) { String p = p_path; - if (mode==MODE_IMPORT) { + if (mode == MODE_IMPORT) { if (p.ends_with("engine.cfg")) { - p=p.get_base_dir(); + p = p.get_base_dir(); } } String sp = p.simplify_path(); @@ -151,7 +149,7 @@ private: get_ok()->call_deferred("grab_focus"); } - void _path_selected(const String& p_path) { + void _path_selected(const String &p_path) { String p = p_path; String sp = p.simplify_path(); @@ -162,7 +160,7 @@ private: void _browse_path() { - if (mode==MODE_IMPORT) { + if (mode == MODE_IMPORT) { fdialog->set_mode(FileDialog::MODE_OPEN_FILE); fdialog->clear_filters(); @@ -173,27 +171,24 @@ private: fdialog->popup_centered_ratio(); } - void _text_changed(const String& p_text) { + void _text_changed(const String &p_text) { _test_path(); } void ok_pressed() { - String dir=_test_path(); - if (dir=="") { + String dir = _test_path(); + if (dir == "") { error->set_text(TTR("Invalid project path (changed anything?).")); return; } - if (mode==MODE_IMPORT) { + if (mode == MODE_IMPORT) { // nothing to do } else { - if (mode==MODE_NEW) { - + if (mode == MODE_NEW) { - - - FileAccess *f = FileAccess::open(dir.plus_file("/engine.cfg"),FileAccess::WRITE); + FileAccess *f = FileAccess::open(dir.plus_file("/engine.cfg"), FileAccess::WRITE); if (!f) { error->set_text(TTR("Couldn't create engine.cfg in project path.")); } else { @@ -208,18 +203,17 @@ private: f->store_line("\n"); f->store_line("[application]"); f->store_line("\n"); - f->store_line("name=\""+project_name->get_text()+"\""); + f->store_line("name=\"" + project_name->get_text() + "\""); f->store_line("icon=\"res://icon.png\""); memdelete(f); - ResourceSaver::save(dir.plus_file("/icon.png"),get_icon("DefaultProjectIcon","EditorIcons")); + ResourceSaver::save(dir.plus_file("/icon.png"), get_icon("DefaultProjectIcon", "EditorIcons")); } - } else if (mode==MODE_INSTALL) { + } else if (mode == MODE_INSTALL) { - - FileAccess *src_f=NULL; + FileAccess *src_f = NULL; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); unzFile pkg = unzOpen2(zip_path.utf8().get_data(), &io); @@ -233,34 +227,33 @@ private: Vector failed_files; - int idx=0; - while(ret==UNZ_OK) { + 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, NULL, 0, NULL, 0); - String path=fname; + String path = fname; - int depth=1; //stuff from github comes with tag - bool skip=false; - while(depth>0) { + int depth = 1; //stuff from github comes with tag + bool skip = false; + while (depth > 0) { int pp = path.find("/"); - if (pp==-1) { - skip=true; + if (pp == -1) { + skip = true; break; } - path=path.substr(pp+1,path.length()); + path = path.substr(pp + 1, path.length()); depth--; } - - if (skip || path==String()) { + if (skip || path == String()) { // } else if (path.ends_with("/")) { // a dir - path=path.substr(0,path.length()-1); + path = path.substr(0, path.length() - 1); DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); da->make_dir(dir.plus_file(path)); @@ -273,19 +266,17 @@ private: //read unzOpenCurrentFile(pkg); - unzReadCurrentFile(pkg,data.ptr(),data.size()); + unzReadCurrentFile(pkg, data.ptr(), data.size()); unzCloseCurrentFile(pkg); - FileAccess *f=FileAccess::open(dir.plus_file(path),FileAccess::WRITE); + FileAccess *f = FileAccess::open(dir.plus_file(path), FileAccess::WRITE); if (f) { - f->store_buffer(data.ptr(),data.size()); + f->store_buffer(data.ptr(), data.size()); memdelete(f); } else { failed_files.push_back(path); } - - } idx++; @@ -295,14 +286,14 @@ private: unzClose(pkg); if (failed_files.size()) { - String msg=TTR("The following files failed extraction from package:")+"\n\n"; - for(int i=0;i15) { - msg+="\nAnd "+itos(failed_files.size()-i)+" more files."; + if (i > 15) { + msg += "\nAnd " + itos(failed_files.size() - i) + " more files."; break; } - msg+=failed_files[i]+"\n"; + msg += failed_files[i] + "\n"; } dialog_error->set_text(msg); @@ -312,58 +303,50 @@ private: dialog_error->set_text(TTR("Package Installed Successfully!")); dialog_error->popup_centered_minsize(); } - } - } - dir=dir.replace("\\","/"); + dir = dir.replace("\\", "/"); if (dir.ends_with("/")) - dir=dir.substr(0,dir.length()-1); - String proj=dir.replace("/","::"); - EditorSettings::get_singleton()->set("projects/"+proj,dir); + dir = dir.substr(0, dir.length() - 1); + String proj = dir.replace("/", "::"); + EditorSettings::get_singleton()->set("projects/" + proj, dir); EditorSettings::get_singleton()->save(); - - hide(); emit_signal("project_created", dir); - } protected: - static void _bind_methods() { - ObjectTypeDB::bind_method("_browse_path",&NewProjectDialog::_browse_path); - ObjectTypeDB::bind_method("_text_changed",&NewProjectDialog::_text_changed); - ObjectTypeDB::bind_method("_path_text_changed",&NewProjectDialog::_path_text_changed); - ObjectTypeDB::bind_method("_path_selected",&NewProjectDialog::_path_selected); - ObjectTypeDB::bind_method("_file_selected",&NewProjectDialog::_file_selected); - ADD_SIGNAL( MethodInfo("project_created") ); + ObjectTypeDB::bind_method("_browse_path", &NewProjectDialog::_browse_path); + ObjectTypeDB::bind_method("_text_changed", &NewProjectDialog::_text_changed); + ObjectTypeDB::bind_method("_path_text_changed", &NewProjectDialog::_path_text_changed); + ObjectTypeDB::bind_method("_path_selected", &NewProjectDialog::_path_selected); + ObjectTypeDB::bind_method("_file_selected", &NewProjectDialog::_file_selected); + ADD_SIGNAL(MethodInfo("project_created")); } public: - - void set_zip_path(const String& p_path) { - zip_path=p_path; + void set_zip_path(const String &p_path) { + zip_path = p_path; } - void set_zip_title(const String& p_title) { - zip_title=p_title; + void set_zip_title(const String &p_title) { + zip_title = p_title; } void set_mode(Mode p_mode) { - mode=p_mode; + mode = p_mode; } void show_dialog() { - project_path->clear(); project_name->clear(); - if (mode==MODE_IMPORT) { + if (mode == MODE_IMPORT) { set_title(TTR("Import Existing Project")); get_ok()->set_text(TTR("Import")); pp->set_text(TTR("Project Path (Must Exist):")); @@ -371,9 +354,9 @@ public: pn->hide(); project_name->hide(); - popup_centered(Size2(500,125)*EDSCALE); + popup_centered(Size2(500, 125) * EDSCALE); - } else if (mode==MODE_NEW){ + } else if (mode == MODE_NEW) { set_title(TTR("Create New Project")); get_ok()->set_text(TTR("Create")); @@ -382,17 +365,16 @@ public: pn->show(); project_name->show(); - popup_centered(Size2(500,145)*EDSCALE); - } else if (mode==MODE_INSTALL){ + popup_centered(Size2(500, 145) * EDSCALE); + } else if (mode == MODE_INSTALL) { - set_title(TTR("Install Project:")+" "+zip_title); + set_title(TTR("Install Project:") + " " + zip_title); get_ok()->set_text(TTR("Install")); pp->set_text(TTR("Project Path:")); pn->hide(); project_name->hide(); - popup_centered(Size2(500,125)*EDSCALE); - + popup_centered(Size2(500, 125) * EDSCALE); } project_path->grab_focus(); @@ -401,69 +383,65 @@ public: NewProjectDialog() { - - VBoxContainer *vb = memnew( VBoxContainer ); + VBoxContainer *vb = memnew(VBoxContainer); add_child(vb); set_child_rect(vb); - Label* l = memnew(Label); + Label *l = memnew(Label); l->set_text(TTR("Project Path:")); vb->add_child(l); - pp=l; + pp = l; - project_path = memnew( LineEdit ); - MarginContainer *mc = memnew( MarginContainer ); + project_path = memnew(LineEdit); + MarginContainer *mc = memnew(MarginContainer); vb->add_child(mc); - HBoxContainer *pphb = memnew( HBoxContainer ); + HBoxContainer *pphb = memnew(HBoxContainer); mc->add_child(pphb); pphb->add_child(project_path); project_path->set_h_size_flags(SIZE_EXPAND_FILL); - Button* browse = memnew( Button ); + Button *browse = memnew(Button); pphb->add_child(browse); browse->set_text(TTR("Browse")); - browse->connect("pressed", this,"_browse_path"); + browse->connect("pressed", this, "_browse_path"); l = memnew(Label); l->set_text(TTR("Project Name:")); - l->set_pos(Point2(5,50)); + l->set_pos(Point2(5, 50)); vb->add_child(l); - pn=l; + pn = l; - project_name = memnew( LineEdit ); - mc = memnew( MarginContainer ); + project_name = memnew(LineEdit); + mc = memnew(MarginContainer); vb->add_child(mc); mc->add_child(project_name); project_name->set_text(TTR("New Game Project")); - l = memnew(Label); l->set_text(TTR("That's a BINGO!")); vb->add_child(l); - error=l; - l->add_color_override("font_color",Color(1,0.4,0.3,0.8)); + error = l; + l->add_color_override("font_color", Color(1, 0.4, 0.3, 0.8)); l->set_align(Label::ALIGN_CENTER); DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); project_path->set_text(d->get_current_dir()); memdelete(d); - fdialog = memnew( FileDialog ); + fdialog = memnew(FileDialog); add_child(fdialog); fdialog->set_access(FileDialog::ACCESS_FILESYSTEM); - fdialog->set_current_dir( EditorSettings::get_singleton()->get("global/default_project_path") ); - project_name->connect("text_changed", this,"_text_changed"); - project_path->connect("text_changed", this,"_path_text_changed"); - fdialog->connect("dir_selected", this,"_path_selected"); - fdialog->connect("file_selected", this,"_file_selected"); + fdialog->set_current_dir(EditorSettings::get_singleton()->get("global/default_project_path")); + project_name->connect("text_changed", this, "_text_changed"); + project_path->connect("text_changed", this, "_path_text_changed"); + fdialog->connect("dir_selected", this, "_path_selected"); + fdialog->connect("file_selected", this, "_file_selected"); set_hide_on_ok(false); - mode=MODE_NEW; + mode = MODE_NEW; - dialog_error = memnew( AcceptDialog ); + dialog_error = memnew(AcceptDialog); add_child(dialog_error); } - - }; struct ProjectItem { @@ -473,20 +451,24 @@ struct ProjectItem { uint64_t last_modified; bool favorite; ProjectItem() {} - ProjectItem(const String &p_project, const String &p_path, const String &p_conf, uint64_t p_last_modified, bool p_favorite=false) { - project = p_project; path = p_path; conf = p_conf; last_modified = p_last_modified; favorite=p_favorite; + ProjectItem(const String &p_project, const String &p_path, const String &p_conf, uint64_t p_last_modified, bool p_favorite = false) { + project = p_project; + path = p_path; + conf = p_conf; + last_modified = p_last_modified; + favorite = p_favorite; } - _FORCE_INLINE_ bool operator <(const ProjectItem& l) const { return last_modified > l.last_modified; } - _FORCE_INLINE_ bool operator ==(const ProjectItem& l) const { return project==l.project; } + _FORCE_INLINE_ bool operator<(const ProjectItem &l) const { return last_modified > l.last_modified; } + _FORCE_INLINE_ bool operator==(const ProjectItem &l) const { return project == l.project; } }; void ProjectManager::_notification(int p_what) { - if (p_what==NOTIFICATION_ENTER_TREE) { + if (p_what == NOTIFICATION_ENTER_TREE) { get_tree()->set_editor_hint(true); - } else if (p_what==NOTIFICATION_VISIBILITY_CHANGED) { + } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { set_process_unhandled_input(is_visible()); } @@ -496,61 +478,60 @@ void ProjectManager::_panel_draw(Node *p_hb) { HBoxContainer *hb = p_hb->cast_to(); - hb->draw_line(Point2(0,hb->get_size().y+1),Point2(hb->get_size().x-10,hb->get_size().y+1),get_color("guide_color","Tree")); + hb->draw_line(Point2(0, hb->get_size().y + 1), Point2(hb->get_size().x - 10, hb->get_size().y + 1), get_color("guide_color", "Tree")); if (selected_list.has(hb->get_meta("name"))) { - hb->draw_style_box(get_stylebox("selected","Tree"),Rect2(Point2(),hb->get_size()-Size2(10,0))); + hb->draw_style_box(get_stylebox("selected", "Tree"), Rect2(Point2(), hb->get_size() - Size2(10, 0))); } } -void ProjectManager::_update_project_buttons() -{ - for(int i=0;iget_child_count();i++) { +void ProjectManager::_update_project_buttons() { + for (int i = 0; i < scroll_childs->get_child_count(); i++) { CanvasItem *item = scroll_childs->get_child(i)->cast_to(); item->update(); } bool has_runnable_scene = false; - for (Map::Element *E=selected_list.front(); E; E=E->next()) { + for (Map::Element *E = selected_list.front(); E; E = E->next()) { const String &selected_main = E->get(); if (selected_main == "") continue; has_runnable_scene = true; break; } - erase_btn->set_disabled(selected_list.size()<1); - open_btn->set_disabled(selected_list.size()<1); + erase_btn->set_disabled(selected_list.size() < 1); + open_btn->set_disabled(selected_list.size() < 1); run_btn->set_disabled(!has_runnable_scene); } -void ProjectManager::_panel_input(const InputEvent& p_ev,Node *p_hb) { +void ProjectManager::_panel_input(const InputEvent &p_ev, Node *p_hb) { - if (p_ev.type==InputEvent::MOUSE_BUTTON && p_ev.mouse_button.pressed && p_ev.mouse_button.button_index==BUTTON_LEFT) { + if (p_ev.type == InputEvent::MOUSE_BUTTON && p_ev.mouse_button.pressed && p_ev.mouse_button.button_index == BUTTON_LEFT) { String clicked = p_hb->get_meta("name"); String clicked_main_scene = p_hb->get_meta("main_scene"); - if (p_ev.key.mod.shift && selected_list.size()>0 && last_clicked!="" && clicked != last_clicked) { + if (p_ev.key.mod.shift && selected_list.size() > 0 && last_clicked != "" && clicked != last_clicked) { int clicked_id = -1; int last_clicked_id = -1; - for(int i=0;iget_child_count();i++) { + for (int i = 0; i < scroll_childs->get_child_count(); i++) { HBoxContainer *hb = scroll_childs->get_child(i)->cast_to(); if (!hb) continue; if (hb->get_meta("name") == clicked) clicked_id = i; if (hb->get_meta("name") == last_clicked) last_clicked_id = i; } - if (last_clicked_id!=-1 && clicked_id!=-1) { - int min = clicked_id < last_clicked_id? clicked_id : last_clicked_id; - int max = clicked_id > last_clicked_id? clicked_id : last_clicked_id; - for(int i=0; iget_child_count(); ++i) { + if (last_clicked_id != -1 && clicked_id != -1) { + int min = clicked_id < last_clicked_id ? clicked_id : last_clicked_id; + int max = clicked_id > last_clicked_id ? clicked_id : last_clicked_id; + for (int i = 0; i < scroll_childs->get_child_count(); ++i) { HBoxContainer *hb = scroll_childs->get_child(i)->cast_to(); if (!hb) continue; - if (i!=clicked_id && (imax) && !p_ev.key.mod.control) { + if (i != clicked_id && (i < min || i > max) && !p_ev.key.mod.control) { selected_list.erase(hb->get_meta("name")); - } else if (i>=min && i<=max) { + } else if (i >= min && i <= max) { selected_list.insert(hb->get_meta("name"), hb->get_meta("main_scene")); } } @@ -563,7 +544,7 @@ void ProjectManager::_panel_input(const InputEvent& p_ev,Node *p_hb) { } else { last_clicked = clicked; - if (p_ev.key.mod.control || selected_list.size()==0) { + if (p_ev.key.mod.control || selected_list.size() == 0) { selected_list.insert(clicked, clicked_main_scene); } else { selected_list.clear(); @@ -575,13 +556,12 @@ void ProjectManager::_panel_input(const InputEvent& p_ev,Node *p_hb) { if (p_ev.mouse_button.doubleclick) _open_project(); //open if doubleclicked - } } -void ProjectManager::_unhandled_input(const InputEvent& p_ev) { +void ProjectManager::_unhandled_input(const InputEvent &p_ev) { - if (p_ev.type==InputEvent::KEY) { + if (p_ev.type == InputEvent::KEY) { const InputEventKey &k = p_ev.key; @@ -598,7 +578,7 @@ void ProjectManager::_unhandled_input(const InputEvent& p_ev) { } break; case KEY_HOME: { - for (int i=0; iget_child_count(); i++) { + for (int i = 0; i < scroll_childs->get_child_count(); i++) { HBoxContainer *hb = scroll_childs->get_child(i)->cast_to(); if (hb) { @@ -613,7 +593,7 @@ void ProjectManager::_unhandled_input(const InputEvent& p_ev) { } break; case KEY_END: { - for (int i=scroll_childs->get_child_count()-1; i>=0; i--) { + for (int i = scroll_childs->get_child_count() - 1; i >= 0; i--) { HBoxContainer *hb = scroll_childs->get_child(i)->cast_to(); if (hb) { @@ -635,7 +615,7 @@ void ProjectManager::_unhandled_input(const InputEvent& p_ev) { bool found = false; - for (int i=scroll_childs->get_child_count()-1; i>=0; i--) { + for (int i = scroll_childs->get_child_count() - 1; i >= 0; i--) { HBoxContainer *hb = scroll_childs->get_child(i)->cast_to(); if (!hb) continue; @@ -655,7 +635,7 @@ void ProjectManager::_unhandled_input(const InputEvent& p_ev) { break; - } else if (current==selected_list.back()->key()) { + } else if (current == selected_list.back()->key()) { found = true; } @@ -672,7 +652,7 @@ void ProjectManager::_unhandled_input(const InputEvent& p_ev) { bool found = selected_list.empty(); - for (int i=0; iget_child_count(); i++) { + for (int i = 0; i < scroll_childs->get_child_count(); i++) { HBoxContainer *hb = scroll_childs->get_child(i)->cast_to(); if (!hb) continue; @@ -693,7 +673,7 @@ void ProjectManager::_unhandled_input(const InputEvent& p_ev) { break; - } else if (current==selected_list.back()->key()) { + } else if (current == selected_list.back()->key()) { found = true; } @@ -701,8 +681,10 @@ void ProjectManager::_unhandled_input(const InputEvent& p_ev) { } break; case KEY_F: { - if (k.mod.command) this->project_filter->search_box->grab_focus(); - else scancode_handled = false; + if (k.mod.command) + this->project_filter->search_box->grab_focus(); + else + scancode_handled = false; } break; default: { scancode_handled = false; @@ -719,26 +701,25 @@ void ProjectManager::_favorite_pressed(Node *p_hb) { String clicked = p_hb->get_meta("name"); bool favorite = !p_hb->get_meta("favorite"); - String proj=clicked.replace(":::",":/"); - proj=proj.replace("::","/"); + String proj = clicked.replace(":::", ":/"); + proj = proj.replace("::", "/"); if (favorite) { - EditorSettings::get_singleton()->set("favorite_projects/"+clicked,proj); + EditorSettings::get_singleton()->set("favorite_projects/" + clicked, proj); } else { - EditorSettings::get_singleton()->erase("favorite_projects/"+clicked); + EditorSettings::get_singleton()->erase("favorite_projects/" + clicked); } EditorSettings::get_singleton()->save(); call_deferred("_load_recent_projects"); } - void ProjectManager::_load_recent_projects() { ProjectListFilter::FilterOption filter_option = project_filter->get_filter_option(); String search_term = project_filter->get_search_term(); - while(scroll_childs->get_child_count()>0) { - memdelete( scroll_childs->get_child(0)); + while (scroll_childs->get_child_count() > 0) { + memdelete(scroll_childs->get_child(0)); } Map selected_list_copy = selected_list; @@ -746,24 +727,24 @@ void ProjectManager::_load_recent_projects() { List properties; EditorSettings::get_singleton()->get_property_list(&properties); - Color font_color = get_color("font_color","Tree"); + Color font_color = get_color("font_color", "Tree"); List projects; List favorite_projects; - for(List::Element *E=properties.front();E;E=E->next()) { + for (List::Element *E = properties.front(); E; E = E->next()) { String _name = E->get().name; if (!_name.begins_with("projects/") && !_name.begins_with("favorite_projects/")) continue; String path = EditorSettings::get_singleton()->get(_name); - if (filter_option == ProjectListFilter::FILTER_PATH && search_term!="" && path.findn(search_term)==-1) + if (filter_option == ProjectListFilter::FILTER_PATH && search_term != "" && path.findn(search_term) == -1) continue; - String project = _name.get_slice("/",1); - String conf=path.plus_file("engine.cfg"); - bool favorite = (_name.begins_with("favorite_projects/"))?true:false; + String project = _name.get_slice("/", 1); + String conf = path.plus_file("engine.cfg"); + bool favorite = (_name.begins_with("favorite_projects/")) ? true : false; uint64_t last_modified = 0; if (FileAccess::exists(conf)) { @@ -772,7 +753,7 @@ void ProjectManager::_load_recent_projects() { String fscache = path.plus_file(".fscache"); if (FileAccess::exists(fscache)) { uint64_t cache_modified = FileAccess::get_modified_time(fscache); - if ( cache_modified > last_modified ) + if (cache_modified > last_modified) last_modified = cache_modified; } @@ -790,19 +771,19 @@ void ProjectManager::_load_recent_projects() { projects.sort(); favorite_projects.sort(); - for(List::Element *E=projects.front();E;) { + for (List::Element *E = projects.front(); E;) { List::Element *next = E->next(); if (favorite_projects.find(E->get()) != NULL) projects.erase(E->get()); - E=next; + E = next; } - for(List::Element *E=favorite_projects.back();E;E=E->prev()) { + for (List::Element *E = favorite_projects.back(); E; E = E->prev()) { projects.push_front(E->get()); } - Ref favorite_icon = get_icon("Favorites","EditorIcons"); + Ref favorite_icon = get_icon("Favorites", "EditorIcons"); - for(List::Element *E=projects.front();E;E=E->next()) { + for (List::Element *E = projects.front(); E; E = E->next()) { ProjectItem &item = E->get(); String project = item.project; @@ -810,88 +791,87 @@ void ProjectManager::_load_recent_projects() { String conf = item.conf; bool is_favorite = item.favorite; - Ref cf = memnew( ConfigFile ); + Ref cf = memnew(ConfigFile); Error err = cf->load(conf); - ERR_CONTINUE(err!=OK); + ERR_CONTINUE(err != OK); + String project_name = TTR("Unnamed Project"); - String project_name=TTR("Unnamed Project"); - - if (cf->has_section_key("application","name")) { - project_name = static_cast(cf->get_value("application","name")).xml_unescape(); + if (cf->has_section_key("application", "name")) { + project_name = static_cast(cf->get_value("application", "name")).xml_unescape(); } - if (filter_option==ProjectListFilter::FILTER_NAME && search_term!="" && project_name.findn(search_term)==-1) + if (filter_option == ProjectListFilter::FILTER_NAME && search_term != "" && project_name.findn(search_term) == -1) continue; Ref icon; - if (cf->has_section_key("application","icon")) { - String appicon = cf->get_value("application","icon"); - if (appicon!="") { + if (cf->has_section_key("application", "icon")) { + String appicon = cf->get_value("application", "icon"); + if (appicon != "") { Image img; - Error err = img.load(appicon.replace_first("res://",path+"/")); - if (err==OK) { + Error err = img.load(appicon.replace_first("res://", path + "/")); + if (err == OK) { - img.resize(64,64); - Ref it = memnew( ImageTexture ); + img.resize(64, 64); + Ref it = memnew(ImageTexture); it->create_from_image(img); - icon=it; + icon = it; } } } if (icon.is_null()) { - icon=get_icon("DefaultProjectIcon","EditorIcons"); + icon = get_icon("DefaultProjectIcon", "EditorIcons"); } String main_scene; - if (cf->has_section_key("application","main_scene")) { - main_scene = cf->get_value("application","main_scene"); + if (cf->has_section_key("application", "main_scene")) { + main_scene = cf->get_value("application", "main_scene"); } selected_list_copy.erase(project); - HBoxContainer *hb = memnew( HBoxContainer ); - hb->set_meta("name",project); - hb->set_meta("main_scene",main_scene); - hb->set_meta("favorite",is_favorite); - hb->connect("draw",this,"_panel_draw",varray(hb)); - hb->connect("input_event",this,"_panel_input",varray(hb)); + HBoxContainer *hb = memnew(HBoxContainer); + hb->set_meta("name", project); + hb->set_meta("main_scene", main_scene); + hb->set_meta("favorite", is_favorite); + hb->connect("draw", this, "_panel_draw", varray(hb)); + hb->connect("input_event", this, "_panel_input", varray(hb)); - VBoxContainer *favorite_box = memnew( VBoxContainer ); - TextureButton *favorite = memnew( TextureButton ); + VBoxContainer *favorite_box = memnew(VBoxContainer); + TextureButton *favorite = memnew(TextureButton); favorite->set_normal_texture(favorite_icon); if (!is_favorite) favorite->set_opacity(0.2); favorite->set_v_size_flags(SIZE_EXPAND); - favorite->connect("pressed",this,"_favorite_pressed",varray(hb)); + favorite->connect("pressed", this, "_favorite_pressed", varray(hb)); favorite_box->add_child(favorite); hb->add_child(favorite_box); - TextureFrame *tf = memnew( TextureFrame ); + TextureFrame *tf = memnew(TextureFrame); tf->set_texture(icon); hb->add_child(tf); VBoxContainer *vb = memnew(VBoxContainer); vb->set_name("project"); hb->add_child(vb); - Control *ec = memnew( Control ); - ec->set_custom_minimum_size(Size2(0,1)); + Control *ec = memnew(Control); + ec->set_custom_minimum_size(Size2(0, 1)); vb->add_child(ec); - Label *title = memnew( Label(project_name) ); - title->add_font_override("font",get_font("large","Fonts")); - title->add_color_override("font_color",font_color); + Label *title = memnew(Label(project_name)); + title->add_font_override("font", get_font("large", "Fonts")); + title->add_color_override("font_color", font_color); vb->add_child(title); - Label *fpath = memnew( Label(path) ); + Label *fpath = memnew(Label(path)); fpath->set_name("path"); vb->add_child(fpath); fpath->set_opacity(0.5); - fpath->add_color_override("font_color",font_color); + fpath->add_color_override("font_color", font_color); scroll_childs->add_child(hb); } - for (Map::Element *E = selected_list_copy.front();E;E = E->next()) { + for (Map::Element *E = selected_list_copy.front(); E; E = E->next()) { String key = E->key(); selected_list.erase(key); } @@ -905,13 +885,13 @@ void ProjectManager::_load_recent_projects() { tabs->set_current_tab(0); } -void ProjectManager::_on_project_created(const String& dir) { - bool has_already=false; - for (int i=0;iget_child_count();i++) { - HBoxContainer *hb=scroll_childs->get_child(i)->cast_to(); - Label *fpath=hb->get_node(NodePath("project/path"))->cast_to