diff options
Diffstat (limited to 'editor/project_manager.cpp')
-rw-r--r-- | editor/project_manager.cpp | 83 |
1 files changed, 41 insertions, 42 deletions
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 33b538fd48..9c3b09608b 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -152,14 +152,14 @@ private: return ""; } - } else if (mode == MODE_NEW) { + } 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; String n = d->get_next(); while (n != String()) { - if (!n.begins_with(".")) { // i dont know if this is enough to guarantee an empty dir + if (!n.begins_with(".")) { // i don't know if this is enough to guarantee an empty dir is_empty = false; break; } @@ -174,13 +174,6 @@ private: get_ok()->set_disabled(true); return ""; } - - } else if (d->file_exists("project.godot")) { - - set_message(TTR("Please choose a folder that does not contain a 'project.godot' file."), MESSAGE_ERROR); - memdelete(d); - get_ok()->set_disabled(true); - return ""; } set_message(""); @@ -311,8 +304,9 @@ private: ProjectSettings *current = memnew(ProjectSettings); - if (current->setup(dir, "")) { - set_message(TTR("Couldn't get project.godot in project path."), MESSAGE_ERROR); + int err = current->setup(dir, ""); + if (err != OK) { + set_message(vformat(TTR("Couldn't load project.godot in project path (error %d). It may be missing or corrupted."), err), MESSAGE_ERROR); } else { ProjectSettings::CustomMap edited_settings; edited_settings["application/config/name"] = project_name->get_text(); @@ -531,11 +525,18 @@ public: set_title(TTR("Rename Project")); get_ok()->set_text(TTR("Rename")); name_container->show(); + status_rect->hide(); + msg->hide(); + get_ok()->set_disabled(false); ProjectSettings *current = memnew(ProjectSettings); - if (current->setup(project_path->get_text(), "")) { - set_message(TTR("Couldn't get project.godot in the project path."), MESSAGE_ERROR); + int err = current->setup(project_path->get_text(), ""); + if (err != OK) { + set_message(vformat(TTR("Couldn't load project.godot in project path (error %d). It may be missing or corrupted."), err), MESSAGE_ERROR); + status_rect->show(); + msg->show(); + get_ok()->set_disabled(true); } else if (current->has_setting("application/config/name")) { project_name->set_text(current->get("application/config/name")); } @@ -543,8 +544,6 @@ public: project_name->call_deferred("grab_focus"); create_dir->hide(); - status_rect->hide(); - msg->hide(); } else { @@ -632,7 +631,7 @@ public: project_path->set_h_size_flags(SIZE_EXPAND_FILL); pphb->add_child(project_path); - // status button + // status icon status_rect = memnew(TextureRect); status_rect->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED); pphb->add_child(status_rect); @@ -690,7 +689,7 @@ void ProjectManager::_notification(int p_what) { } break; case NOTIFICATION_READY: { - if (scroll_childs->get_child_count() == 0) + if (scroll_children->get_child_count() == 0) open_templates->popup_centered_minsize(); } break; case NOTIFICATION_VISIBILITY_CHANGED: { @@ -712,9 +711,9 @@ void ProjectManager::_panel_draw(Node *p_hb) { } void ProjectManager::_update_project_buttons() { - for (int i = 0; i < scroll_childs->get_child_count(); i++) { + for (int i = 0; i < scroll_children->get_child_count(); i++) { - CanvasItem *item = Object::cast_to<CanvasItem>(scroll_childs->get_child(i)); + CanvasItem *item = Object::cast_to<CanvasItem>(scroll_children->get_child(i)); item->update(); } @@ -736,8 +735,8 @@ void ProjectManager::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) { int clicked_id = -1; int last_clicked_id = -1; - for (int i = 0; i < scroll_childs->get_child_count(); i++) { - HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i)); + for (int i = 0; i < scroll_children->get_child_count(); i++) { + HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i)); if (!hb) continue; if (hb->get_meta("name") == clicked) clicked_id = i; if (hb->get_meta("name") == last_clicked) last_clicked_id = i; @@ -746,8 +745,8 @@ void ProjectManager::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) { 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 = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i)); + for (int i = 0; i < scroll_children->get_child_count(); ++i) { + HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i)); if (!hb) continue; if (i != clicked_id && (i < min || i > max) && !mb->get_control()) { selected_list.erase(hb->get_meta("name")); @@ -801,9 +800,9 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) { } break; case KEY_HOME: { - for (int i = 0; i < scroll_childs->get_child_count(); i++) { + for (int i = 0; i < scroll_children->get_child_count(); i++) { - HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i)); + HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i)); if (hb) { selected_list.clear(); selected_list.insert(hb->get_meta("name"), hb->get_meta("main_scene")); @@ -816,13 +815,13 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) { } break; case KEY_END: { - for (int i = scroll_childs->get_child_count() - 1; i >= 0; i--) { + for (int i = scroll_children->get_child_count() - 1; i >= 0; i--) { - HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i)); + HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i)); if (hb) { selected_list.clear(); selected_list.insert(hb->get_meta("name"), hb->get_meta("main_scene")); - scroll->set_v_scroll(scroll_childs->get_size().y); + scroll->set_v_scroll(scroll_children->get_size().y); _update_project_buttons(); break; } @@ -838,9 +837,9 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) { bool found = false; - for (int i = scroll_childs->get_child_count() - 1; i >= 0; i--) { + for (int i = scroll_children->get_child_count() - 1; i >= 0; i--) { - HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i)); + HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i)); if (!hb) continue; String current = hb->get_meta("name"); @@ -875,9 +874,9 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) { bool found = selected_list.empty(); - for (int i = 0; i < scroll_childs->get_child_count(); i++) { + for (int i = 0; i < scroll_children->get_child_count(); i++) { - HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i)); + HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i)); if (!hb) continue; String current = hb->get_meta("name"); @@ -941,8 +940,8 @@ 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_children->get_child_count() > 0) { + memdelete(scroll_children->get_child(0)); } Map<String, String> selected_list_copy = selected_list; @@ -1102,7 +1101,7 @@ void ProjectManager::_load_recent_projects() { fpath->add_color_override("font_color", font_color); fpath->set_clip_text(true); - scroll_childs->add_child(hb); + scroll_children->add_child(hb); } for (Map<String, String>::Element *E = selected_list_copy.front(); E; E = E->next()) { @@ -1125,8 +1124,8 @@ void ProjectManager::_on_project_renamed() { void ProjectManager::_on_project_created(const String &dir) { bool has_already = false; - for (int i = 0; i < scroll_childs->get_child_count(); i++) { - HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i)); + for (int i = 0; i < scroll_children->get_child_count(); i++) { + HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i)); Label *fpath = Object::cast_to<Label>(hb->get_node(NodePath("project/path"))); if (fpath->get_text() == dir) { has_already = true; @@ -1143,8 +1142,8 @@ void ProjectManager::_on_project_created(const String &dir) { } void ProjectManager::_update_scroll_position(const String &dir) { - for (int i = 0; i < scroll_childs->get_child_count(); i++) { - HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i)); + for (int i = 0; i < scroll_children->get_child_count(); i++) { + HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i)); Label *fpath = Object::cast_to<Label>(hb->get_node(NodePath("project/path"))); if (fpath->get_text() == dir) { last_clicked = hb->get_meta("name"); @@ -1584,9 +1583,9 @@ ProjectManager::ProjectManager() { VBoxContainer *tree_vb = memnew(VBoxContainer); tree_hb->add_child(tree_vb); - scroll_childs = memnew(VBoxContainer); - scroll_childs->set_h_size_flags(SIZE_EXPAND_FILL); - scroll->add_child(scroll_childs); + scroll_children = memnew(VBoxContainer); + scroll_children->set_h_size_flags(SIZE_EXPAND_FILL); + scroll->add_child(scroll_children); Button *open = memnew(Button); open->set_text(TTR("Edit")); |