You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Let user fix dependencies in resources
This commit is contained in:
@@ -557,8 +557,9 @@ DependencyRemoveDialog::DependencyRemoveDialog() {
|
|||||||
|
|
||||||
//////////////
|
//////////////
|
||||||
|
|
||||||
void DependencyErrorDialog::show(const String &p_for_file, const Vector<String> &report) {
|
void DependencyErrorDialog::show(Mode p_mode, const String &p_for_file, const Vector<String> &report) {
|
||||||
|
|
||||||
|
mode = p_mode;
|
||||||
for_file = p_for_file;
|
for_file = p_for_file;
|
||||||
set_title(TTR("Error loading:") + " " + p_for_file.get_file());
|
set_title(TTR("Error loading:") + " " + p_for_file.get_file());
|
||||||
files->clear();
|
files->clear();
|
||||||
@@ -584,7 +585,14 @@ void DependencyErrorDialog::show(const String &p_for_file, const Vector<String>
|
|||||||
|
|
||||||
void DependencyErrorDialog::ok_pressed() {
|
void DependencyErrorDialog::ok_pressed() {
|
||||||
|
|
||||||
EditorNode::get_singleton()->load_scene(for_file, true);
|
switch (mode) {
|
||||||
|
case MODE_SCENE:
|
||||||
|
EditorNode::get_singleton()->load_scene(for_file, true);
|
||||||
|
break;
|
||||||
|
case MODE_RESOURCE:
|
||||||
|
EditorNode::get_singleton()->load_resource(for_file, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DependencyErrorDialog::custom_action(const String &) {
|
void DependencyErrorDialog::custom_action(const String &) {
|
||||||
@@ -599,7 +607,7 @@ DependencyErrorDialog::DependencyErrorDialog() {
|
|||||||
|
|
||||||
files = memnew(Tree);
|
files = memnew(Tree);
|
||||||
files->set_hide_root(true);
|
files->set_hide_root(true);
|
||||||
vb->add_margin_child(TTR("Scene failed to load due to missing dependencies:"), files, true);
|
vb->add_margin_child(TTR("Load failed due to missing dependencies:"), files, true);
|
||||||
files->set_v_size_flags(SIZE_EXPAND_FILL);
|
files->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||||
files->set_custom_minimum_size(Size2(1, 200));
|
files->set_custom_minimum_size(Size2(1, 200));
|
||||||
get_ok()->set_text(TTR("Open Anyway"));
|
get_ok()->set_text(TTR("Open Anyway"));
|
||||||
|
|||||||
@@ -134,7 +134,15 @@ public:
|
|||||||
class DependencyErrorDialog : public ConfirmationDialog {
|
class DependencyErrorDialog : public ConfirmationDialog {
|
||||||
GDCLASS(DependencyErrorDialog, ConfirmationDialog);
|
GDCLASS(DependencyErrorDialog, ConfirmationDialog);
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum Mode {
|
||||||
|
MODE_SCENE,
|
||||||
|
MODE_RESOURCE,
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
String for_file;
|
String for_file;
|
||||||
|
Mode mode;
|
||||||
Button *fdep;
|
Button *fdep;
|
||||||
Label *text;
|
Label *text;
|
||||||
Tree *files;
|
Tree *files;
|
||||||
@@ -142,7 +150,7 @@ class DependencyErrorDialog : public ConfirmationDialog {
|
|||||||
void custom_action(const String &);
|
void custom_action(const String &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void show(const String &p_for_file, const Vector<String> &report);
|
void show(Mode p_mode, const String &p_for_file, const Vector<String> &report);
|
||||||
DependencyErrorDialog();
|
DependencyErrorDialog();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -574,13 +574,29 @@ void EditorNode::_editor_select_prev() {
|
|||||||
_editor_select(editor);
|
_editor_select(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
Error EditorNode::load_resource(const String &p_scene) {
|
Error EditorNode::load_resource(const String &p_resource, bool p_ignore_broken_deps) {
|
||||||
|
|
||||||
RES res = ResourceLoader::load(p_scene);
|
dependency_errors.clear();
|
||||||
|
|
||||||
|
Error err;
|
||||||
|
RES res = ResourceLoader::load(p_resource, "", false, &err);
|
||||||
ERR_FAIL_COND_V(!res.is_valid(), ERR_CANT_OPEN);
|
ERR_FAIL_COND_V(!res.is_valid(), ERR_CANT_OPEN);
|
||||||
|
|
||||||
inspector_dock->edit_resource(res);
|
if (!p_ignore_broken_deps && dependency_errors.has(p_resource)) {
|
||||||
|
|
||||||
|
//current_option = -1;
|
||||||
|
Vector<String> errors;
|
||||||
|
for (Set<String>::Element *E = dependency_errors[p_resource].front(); E; E = E->next()) {
|
||||||
|
|
||||||
|
errors.push_back(E->get());
|
||||||
|
}
|
||||||
|
dependency_error->show(DependencyErrorDialog::MODE_RESOURCE, p_resource, errors);
|
||||||
|
dependency_errors.erase(p_resource);
|
||||||
|
|
||||||
|
return ERR_FILE_MISSING_DEPENDENCIES;
|
||||||
|
}
|
||||||
|
|
||||||
|
inspector_dock->edit_resource(res);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2845,7 +2861,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
|
|||||||
|
|
||||||
errors.push_back(E->get());
|
errors.push_back(E->get());
|
||||||
}
|
}
|
||||||
dependency_error->show(lpath, errors);
|
dependency_error->show(DependencyErrorDialog::MODE_SCENE, lpath, errors);
|
||||||
opening_prev = false;
|
opening_prev = false;
|
||||||
|
|
||||||
if (prev != -1) {
|
if (prev != -1) {
|
||||||
|
|||||||
@@ -688,7 +688,7 @@ public:
|
|||||||
void fix_dependencies(const String &p_for_file);
|
void fix_dependencies(const String &p_for_file);
|
||||||
void clear_scene() { _cleanup_scene(); }
|
void clear_scene() { _cleanup_scene(); }
|
||||||
Error load_scene(const String &p_scene, bool p_ignore_broken_deps = false, bool p_set_inherited = false, bool p_clear_errors = true, bool p_force_open_imported = false);
|
Error load_scene(const String &p_scene, bool p_ignore_broken_deps = false, bool p_set_inherited = false, bool p_clear_errors = true, bool p_force_open_imported = false);
|
||||||
Error load_resource(const String &p_scene);
|
Error load_resource(const String &p_resource, bool p_ignore_broken_deps = false);
|
||||||
|
|
||||||
bool is_scene_open(const String &p_path);
|
bool is_scene_open(const String &p_path);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user