Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix browse_dialog in Blender scene importer to accept files #93411

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions modules/gltf/editor/editor_scene_importer_blend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
static bool _get_blender_version(const String &p_path, int &r_major, int &r_minor, String *r_err = nullptr) {
if (!FileAccess::exists(p_path)) {
if (r_err) {
*r_err = TTR("Path does not contain a Blender installation.");
*r_err = TTR("Path does not point to a valid executable.");
}
return false;
}
Expand All @@ -67,14 +67,14 @@ static bool _get_blender_version(const String &p_path, int &r_major, int &r_mino
Error err = OS::get_singleton()->execute(p_path, args, &pipe);
if (err != OK) {
if (r_err) {
*r_err = TTR("Can't execute Blender binary.");
*r_err = TTR("Couldn't run Blender executable.");
}
return false;
}
int bl = pipe.find("Blender ");
if (bl == -1) {
if (r_err) {
*r_err = vformat(TTR("Unexpected --version output from Blender binary at: %s."), p_path);
*r_err = vformat(TTR("Unexpected --version output from Blender executable at: %s."), p_path);
}
return false;
}
Expand All @@ -83,15 +83,15 @@ static bool _get_blender_version(const String &p_path, int &r_major, int &r_mino
int pp = pipe.find(".");
if (pp == -1) {
if (r_err) {
*r_err = TTR("Path supplied lacks a Blender binary.");
*r_err = vformat(TTR("Couldn't extract version information from Blender executable at: %s."), p_path);
}
return false;
}
String v = pipe.substr(0, pp);
r_major = v.to_int();
if (r_major < 3) {
if (r_err) {
*r_err = TTR("This Blender installation is too old for this importer (not 3.0+).");
*r_err = vformat(TTR("Found Blender version %d.x, which is too old for this importer (3.0+ is required)."), r_major);
}
return false;
}
Expand Down Expand Up @@ -392,9 +392,9 @@ void EditorFileSystemImportFormatSupportQueryBlend::_validate_path(String p_path
if (_test_blender_path(p_path, &error)) {
success = true;
if (auto_detected_path == p_path) {
error = TTR("Path to Blender installation is valid (Autodetected).");
error = TTR("Path to Blender executable is valid (Autodetected).");
} else {
error = TTR("Path to Blender installation is valid.");
error = TTR("Path to Blender executable is valid.");
}
}
}
Expand Down Expand Up @@ -490,11 +490,15 @@ bool EditorFileSystemImportFormatSupportQueryBlend::query() {
if (!configure_blender_dialog) {
configure_blender_dialog = memnew(ConfirmationDialog);
configure_blender_dialog->set_title(TTR("Configure Blender Importer"));
configure_blender_dialog->set_flag(Window::FLAG_BORDERLESS, true); // Avoid closing accidentally .
configure_blender_dialog->set_flag(Window::FLAG_BORDERLESS, true); // Avoid closing accidentally.
configure_blender_dialog->set_close_on_escape(false);

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

HBoxContainer *hb = memnew(HBoxContainer);

Expand Down Expand Up @@ -528,8 +532,8 @@ bool EditorFileSystemImportFormatSupportQueryBlend::query() {

browse_dialog = memnew(EditorFileDialog);
browse_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
browse_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_DIR);
browse_dialog->connect("dir_selected", callable_mp(this, &EditorFileSystemImportFormatSupportQueryBlend::_select_install));
browse_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
browse_dialog->connect("file_selected", callable_mp(this, &EditorFileSystemImportFormatSupportQueryBlend::_select_install));

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

Expand Down
Loading