Skip to content

Commit 82f8838

Browse files
committed
Merge pull request godotengine#110307 from KoBeWi/dialog_yellowlabelizer
Improve dependency editor warning
2 parents 94df7a1 + 19a4476 commit 82f8838

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

editor/file_system/dependency_editor.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "core/io/file_access.h"
3535
#include "core/io/resource_loader.h"
3636
#include "editor/editor_node.h"
37+
#include "editor/editor_string_names.h"
3738
#include "editor/file_system/editor_file_system.h"
3839
#include "editor/gui/editor_file_dialog.h"
3940
#include "editor/settings/editor_settings.h"
@@ -164,6 +165,12 @@ void DependencyEditor::_update_file() {
164165
EditorFileSystem::get_singleton()->update_file(editing);
165166
}
166167

168+
void DependencyEditor::_notification(int p_what) {
169+
if (p_what == NOTIFICATION_THEME_CHANGED) {
170+
warning_label->add_theme_color_override(SceneStringName(font_color), get_theme_color("warning_color", EditorStringName(Editor)));
171+
}
172+
}
173+
167174
void DependencyEditor::_update_list() {
168175
List<String> deps;
169176
ResourceLoader::get_dependencies(editing, &deps, true);
@@ -229,13 +236,17 @@ void DependencyEditor::edit(const String &p_path) {
229236
set_title(TTR("Dependencies For:") + " " + p_path.get_file());
230237

231238
_update_list();
232-
popup_centered_ratio(0.4);
233239

234240
if (EditorNode::get_singleton()->is_scene_open(p_path)) {
235-
EditorNode::get_singleton()->show_warning(vformat(TTR("Scene '%s' is currently being edited.\nChanges will only take effect when reloaded."), p_path.get_file()));
241+
warning_label->show();
242+
warning_label->set_text(vformat(TTR("Scene \"%s\" is currently being edited. Changes will only take effect when reloaded."), p_path.get_file()));
236243
} else if (ResourceCache::has(p_path)) {
237-
EditorNode::get_singleton()->show_warning(vformat(TTR("Resource '%s' is in use.\nChanges will only take effect when reloaded."), p_path.get_file()));
244+
warning_label->show();
245+
warning_label->set_text(vformat(TTR("Resource \"%s\" is in use. Changes will only take effect when reloaded."), p_path.get_file()));
246+
} else {
247+
warning_label->hide();
238248
}
249+
popup_centered_ratio(0.4);
239250
}
240251

241252
DependencyEditor::DependencyEditor() {
@@ -274,6 +285,10 @@ DependencyEditor::DependencyEditor() {
274285
mc->add_child(tree);
275286
vb->add_child(mc);
276287

288+
warning_label = memnew(Label);
289+
warning_label->set_autowrap_mode(TextServer::AUTOWRAP_WORD);
290+
vb->add_child(warning_label);
291+
277292
set_title(TTR("Dependency Editor"));
278293
search = memnew(EditorFileDialog);
279294
search->connect("file_selected", callable_mp(this, &DependencyEditor::_searched));

editor/file_system/dependency_editor.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class DependencyEditor : public AcceptDialog {
4343

4444
Tree *tree = nullptr;
4545
Button *fixdeps = nullptr;
46+
Label *warning_label = nullptr;
4647

4748
EditorFileDialog *search = nullptr;
4849

@@ -59,6 +60,9 @@ class DependencyEditor : public AcceptDialog {
5960

6061
void _update_file();
6162

63+
protected:
64+
void _notification(int p_what);
65+
6266
public:
6367
void edit(const String &p_path);
6468
DependencyEditor();

0 commit comments

Comments
 (0)