Skip to content

Commit 344ff6f

Browse files
Fix browse_dialog in Blender scene importer to accept files
Co-authored-by: Rémi Verschelde <[email protected]>
1 parent 88d9325 commit 344ff6f

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

modules/gltf/editor/editor_scene_importer_blend.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
static bool _get_blender_version(const String &p_path, int &r_major, int &r_minor, String *r_err = nullptr) {
5858
if (!FileAccess::exists(p_path)) {
5959
if (r_err) {
60-
*r_err = TTR("Path does not contain a Blender installation.");
60+
*r_err = TTR("Path does not point to a valid executable.");
6161
}
6262
return false;
6363
}
@@ -67,14 +67,14 @@ static bool _get_blender_version(const String &p_path, int &r_major, int &r_mino
6767
Error err = OS::get_singleton()->execute(p_path, args, &pipe);
6868
if (err != OK) {
6969
if (r_err) {
70-
*r_err = TTR("Can't execute Blender binary.");
70+
*r_err = TTR("Couldn't run Blender executable.");
7171
}
7272
return false;
7373
}
7474
int bl = pipe.find("Blender ");
7575
if (bl == -1) {
7676
if (r_err) {
77-
*r_err = vformat(TTR("Unexpected --version output from Blender binary at: %s."), p_path);
77+
*r_err = vformat(TTR("Unexpected --version output from Blender executable at: %s."), p_path);
7878
}
7979
return false;
8080
}
@@ -83,15 +83,15 @@ static bool _get_blender_version(const String &p_path, int &r_major, int &r_mino
8383
int pp = pipe.find(".");
8484
if (pp == -1) {
8585
if (r_err) {
86-
*r_err = TTR("Path supplied lacks a Blender binary.");
86+
*r_err = vformat(TTR("Couldn't extract version information from Blender executable at: %s."), p_path);
8787
}
8888
return false;
8989
}
9090
String v = pipe.substr(0, pp);
9191
r_major = v.to_int();
9292
if (r_major < 3) {
9393
if (r_err) {
94-
*r_err = TTR("This Blender installation is too old for this importer (not 3.0+).");
94+
*r_err = vformat(TTR("Found Blender version %d.x, which is too old for this importer (3.0+ is required)."), r_major);
9595
}
9696
return false;
9797
}
@@ -392,9 +392,9 @@ void EditorFileSystemImportFormatSupportQueryBlend::_validate_path(String p_path
392392
if (_test_blender_path(p_path, &error)) {
393393
success = true;
394394
if (auto_detected_path == p_path) {
395-
error = TTR("Path to Blender installation is valid (Autodetected).");
395+
error = TTR("Path to Blender executable is valid (Autodetected).");
396396
} else {
397-
error = TTR("Path to Blender installation is valid.");
397+
error = TTR("Path to Blender executable is valid.");
398398
}
399399
}
400400
}
@@ -490,11 +490,15 @@ bool EditorFileSystemImportFormatSupportQueryBlend::query() {
490490
if (!configure_blender_dialog) {
491491
configure_blender_dialog = memnew(ConfirmationDialog);
492492
configure_blender_dialog->set_title(TTR("Configure Blender Importer"));
493-
configure_blender_dialog->set_flag(Window::FLAG_BORDERLESS, true); // Avoid closing accidentally .
493+
configure_blender_dialog->set_flag(Window::FLAG_BORDERLESS, true); // Avoid closing accidentally.
494494
configure_blender_dialog->set_close_on_escape(false);
495495

496+
String select_exec_label = TTR("Blender 3.0+ is required to import '.blend' files.\nPlease provide a valid path to a Blender executable.");
497+
#ifdef MACOS_ENABLED
498+
select_exec_label += "\n" + TTR("On macOS, this should be the `Contents/MacOS/blender` file within the Blender `.app` folder.");
499+
#endif
496500
VBoxContainer *vb = memnew(VBoxContainer);
497-
vb->add_child(memnew(Label(TTR("Blender 3.0+ is required to import '.blend' files.\nPlease provide a valid path to a Blender installation:"))));
501+
vb->add_child(memnew(Label(select_exec_label)));
498502

499503
HBoxContainer *hb = memnew(HBoxContainer);
500504

@@ -528,8 +532,8 @@ bool EditorFileSystemImportFormatSupportQueryBlend::query() {
528532

529533
browse_dialog = memnew(EditorFileDialog);
530534
browse_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
531-
browse_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_DIR);
532-
browse_dialog->connect("dir_selected", callable_mp(this, &EditorFileSystemImportFormatSupportQueryBlend::_select_install));
535+
browse_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
536+
browse_dialog->connect("file_selected", callable_mp(this, &EditorFileSystemImportFormatSupportQueryBlend::_select_install));
533537

534538
EditorNode::get_singleton()->get_gui_base()->add_child(browse_dialog);
535539

0 commit comments

Comments
 (0)