Merge pull request #74293 from akien-mga/fbx-dialog-disable-importer
FBX: Disable importer when canceling FBX2glTF setup
This commit is contained in:
commit
6941ffaef3
4 changed files with 33 additions and 5 deletions
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include "fbx_importer_manager.h"
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_scale.h"
|
||||
#include "editor/editor_settings.h"
|
||||
#include "scene/gui/link_button.h"
|
||||
|
@ -47,9 +49,19 @@ void FBXImporterManager::show_dialog(bool p_exclusive) {
|
|||
fbx_path->set_text(fbx2gltf_path);
|
||||
_validate_path(fbx2gltf_path);
|
||||
|
||||
// If exclusive, we're importing a FBX file, there's no exit.
|
||||
is_importing = p_exclusive;
|
||||
set_flag(Window::FLAG_BORDERLESS, p_exclusive); // Avoid closing accidentally.
|
||||
set_close_on_escape(!p_exclusive);
|
||||
|
||||
if (is_importing) {
|
||||
get_cancel_button()->set_text(TTR("Disable FBX & Restart"));
|
||||
get_cancel_button()->set_tooltip_text(TTR("Canceling this dialog will disable the FBX importer.\nYou can re-enable it in the Project Settings under Filesystem > Import > FBX > Enabled.\n\nThe editor will restart as importers are registered when the editor starts."));
|
||||
} else {
|
||||
get_cancel_button()->set_text(TTR("Cancel"));
|
||||
get_cancel_button()->set_tooltip_text("");
|
||||
}
|
||||
|
||||
popup_centered();
|
||||
}
|
||||
|
||||
|
@ -96,6 +108,17 @@ void FBXImporterManager::_path_confirmed() {
|
|||
EditorSettings::get_singleton()->save();
|
||||
}
|
||||
|
||||
void FBXImporterManager::_cancel_setup() {
|
||||
if (!is_importing) {
|
||||
return; // No worry.
|
||||
}
|
||||
// No escape.
|
||||
ProjectSettings::get_singleton()->set("filesystem/import/fbx/enabled", false);
|
||||
ProjectSettings::get_singleton()->save();
|
||||
EditorNode::get_singleton()->save_all_scenes();
|
||||
EditorNode::get_singleton()->restart_editor();
|
||||
}
|
||||
|
||||
void FBXImporterManager::_browse_install() {
|
||||
if (fbx_path->get_text() != String()) {
|
||||
browse_dialog->set_current_file(fbx_path->get_text());
|
||||
|
@ -140,6 +163,7 @@ FBXImporterManager::FBXImporterManager() {
|
|||
fbx_path->connect("text_changed", callable_mp(this, &FBXImporterManager::_validate_path));
|
||||
|
||||
get_ok_button()->set_text(TTR("Confirm Path"));
|
||||
get_cancel_button()->connect("pressed", callable_mp(this, &FBXImporterManager::_cancel_setup));
|
||||
|
||||
browse_dialog = memnew(EditorFileDialog);
|
||||
browse_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
class FBXImporterManager : public ConfirmationDialog {
|
||||
GDCLASS(FBXImporterManager, ConfirmationDialog)
|
||||
|
||||
bool is_importing = false;
|
||||
|
||||
Label *message = nullptr;
|
||||
LineEdit *fbx_path = nullptr;
|
||||
Button *fbx_path_browse = nullptr;
|
||||
|
@ -47,6 +49,7 @@ class FBXImporterManager : public ConfirmationDialog {
|
|||
void _validate_path(const String &p_path);
|
||||
void _select_file(const String &p_path);
|
||||
void _path_confirmed();
|
||||
void _cancel_setup();
|
||||
void _browse_install();
|
||||
void _link_clicked();
|
||||
|
||||
|
|
|
@ -143,8 +143,8 @@ void initialize_gltf_module(ModuleInitializationLevel p_level) {
|
|||
EditorPlugins::add_by_type<SceneExporterGLTFPlugin>();
|
||||
|
||||
// Project settings defined here so doctool finds them.
|
||||
GLOBAL_DEF_RST("filesystem/import/blender/enabled", true);
|
||||
GLOBAL_DEF_RST("filesystem/import/fbx/enabled", true);
|
||||
GLOBAL_DEF_RST_BASIC("filesystem/import/blender/enabled", true);
|
||||
GLOBAL_DEF_RST_BASIC("filesystem/import/fbx/enabled", true);
|
||||
GDREGISTER_CLASS(EditorSceneFormatImporterBlend);
|
||||
GDREGISTER_CLASS(EditorSceneFormatImporterFBX);
|
||||
// Can't (a priori) run external app on these platforms.
|
||||
|
|
|
@ -243,11 +243,12 @@ void LinkButton::_notification(int p_what) {
|
|||
if (do_underline) {
|
||||
int underline_spacing = theme_cache.underline_spacing + text_buf->get_line_underline_position();
|
||||
int y = text_buf->get_line_ascent() + underline_spacing;
|
||||
int underline_thickness = MAX(1, text_buf->get_line_underline_thickness());
|
||||
|
||||
if (is_layout_rtl()) {
|
||||
draw_line(Vector2(size.width - width, y), Vector2(size.width, y), color, text_buf->get_line_underline_thickness());
|
||||
draw_line(Vector2(size.width - width, y), Vector2(size.width, y), color, underline_thickness);
|
||||
} else {
|
||||
draw_line(Vector2(0, y), Vector2(width, y), color, text_buf->get_line_underline_thickness());
|
||||
draw_line(Vector2(0, y), Vector2(width, y), color, underline_thickness);
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
|
Loading…
Reference in a new issue