diff options
Diffstat (limited to 'editor/project_manager.cpp')
-rw-r--r-- | editor/project_manager.cpp | 98 |
1 files changed, 77 insertions, 21 deletions
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index da283b16dc..de98c89db5 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -304,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(); @@ -530,8 +531,9 @@ public: 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); @@ -687,7 +689,7 @@ void ProjectManager::_notification(int p_what) { } break; case NOTIFICATION_READY: { - if (scroll_children->get_child_count() == 0) + if (scroll_children->get_child_count() == 0 && StreamPeerSSL::is_available()) open_templates->popup_centered_minsize(); } break; case NOTIFICATION_VISIBILITY_CHANGED: { @@ -713,6 +715,12 @@ void ProjectManager::_update_project_buttons() { CanvasItem *item = Object::cast_to<CanvasItem>(scroll_children->get_child(i)); item->update(); + + Button *show = Object::cast_to<Button>(item->get_node(NodePath("project/path_box/show"))); + if (show) { + String current = item->get_meta("name"); + show->set_visible(selected_list.has(current)); + } } erase_btn->set_disabled(selected_list.size() < 1); @@ -1092,9 +1100,26 @@ void ProjectManager::_load_recent_projects() { title->add_color_override("font_color", font_color); title->set_clip_text(true); vb->add_child(title); + + HBoxContainer *path_hb = memnew(HBoxContainer); + path_hb->set_name("path_box"); + path_hb->set_h_size_flags(SIZE_EXPAND_FILL); + vb->add_child(path_hb); + + Button *show = memnew(Button); + show->set_name("show"); + show->set_icon(get_icon("Filesystem", "EditorIcons")); + show->set_flat(true); + show->set_modulate(Color(1, 1, 1, 0.5)); + path_hb->add_child(show); + show->connect("pressed", this, "_show_project", varray(path)); + show->set_tooltip(TTR("Show In File Manager")); + show->set_visible(false); + Label *fpath = memnew(Label(path)); fpath->set_name("path"); - vb->add_child(fpath); + path_hb->add_child(fpath); + fpath->set_h_size_flags(SIZE_EXPAND_FILL); fpath->set_modulate(Color(1, 1, 1, 0.5)); fpath->add_color_override("font_color", font_color); fpath->set_clip_text(true); @@ -1124,7 +1149,7 @@ void ProjectManager::_on_project_created(const String &dir) { bool has_already = false; 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"))); + Label *fpath = Object::cast_to<Label>(hb->get_node(NodePath("project/path_box/path"))); if (fpath->get_text() == dir) { has_already = true; break; @@ -1142,7 +1167,7 @@ void ProjectManager::_on_project_created(const String &dir) { void ProjectManager::_update_scroll_position(const String &dir) { 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"))); + Label *fpath = Object::cast_to<Label>(hb->get_node(NodePath("project/path_box/path"))); if (fpath->get_text() == dir) { last_clicked = hb->get_meta("name"); selected_list.clear(); @@ -1260,6 +1285,11 @@ void ProjectManager::_run_project() { } } +void ProjectManager::_show_project(const String &p_path) { + + OS::get_singleton()->shell_open(String("file://") + p_path); +} + void ProjectManager::_scan_dir(DirAccess *da, float pos, float total, List<String> *r_projects) { List<String> subdirs; @@ -1448,6 +1478,7 @@ void ProjectManager::_bind_methods() { ClassDB::bind_method("_open_project_confirm", &ProjectManager::_open_project_confirm); ClassDB::bind_method("_run_project", &ProjectManager::_run_project); ClassDB::bind_method("_run_project_confirm", &ProjectManager::_run_project_confirm); + ClassDB::bind_method("_show_project", &ProjectManager::_show_project); ClassDB::bind_method("_scan_projects", &ProjectManager::_scan_projects); ClassDB::bind_method("_scan_begin", &ProjectManager::_scan_begin); ClassDB::bind_method("_import_project", &ProjectManager::_import_project); @@ -1486,18 +1517,43 @@ ProjectManager::ProjectManager() { EditorSettings::get_singleton()->set_optimize_save(false); //just write settings as they came { - int dpi_mode = EditorSettings::get_singleton()->get("interface/editor/hidpi_mode"); - if (dpi_mode == 0) { - const int screen = OS::get_singleton()->get_current_screen(); - editor_set_scale(OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).x > 2000 ? 2.0 : 1.0); - } else if (dpi_mode == 1) { - editor_set_scale(0.75); - } else if (dpi_mode == 2) { - editor_set_scale(1.0); - } else if (dpi_mode == 3) { - editor_set_scale(1.5); - } else if (dpi_mode == 4) { - editor_set_scale(2.0); + int display_scale = EditorSettings::get_singleton()->get("interface/editor/display_scale"); + float custom_display_scale = EditorSettings::get_singleton()->get("interface/editor/custom_display_scale"); + + switch (display_scale) { + case 0: { + // Try applying a suitable display scale automatically + const int screen = OS::get_singleton()->get_current_screen(); + editor_set_scale(OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).x > 2000 ? 2.0 : 1.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); + } break; } } @@ -1539,7 +1595,7 @@ ProjectManager::ProjectManager() { String hash = String(VERSION_HASH); if (hash.length() != 0) hash = "." + hash.left(7); - l->set_text("v" VERSION_MKSTRING "" + hash); + l->set_text("v" VERSION_FULL_BUILD "" + hash); l->set_align(Label::ALIGN_CENTER); top_hb->add_child(l); |