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 various issues with the folder color lookup #86171

Merged
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
11 changes: 9 additions & 2 deletions editor/gui/editor_file_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,19 +769,26 @@ void EditorFileDialog::update_file_name() {

// TODO: Could use a unit test.
Color EditorFileDialog::get_dir_icon_color(const String &p_dir_path) {
if (!FileSystemDock::get_singleton()) { // This dialog can be called from the project manager.
return theme_cache.folder_icon_color;
}

const HashMap<String, Color> &folder_colors = FileSystemDock::get_singleton()->get_folder_colors();
Dictionary assigned_folder_colors = FileSystemDock::get_singleton()->get_assigned_folder_colors();

Color folder_icon_color = theme_cache.folder_icon_color;

// Check for a folder color to inherit (if one is assigned).
String parent_dir = p_dir_path;
while (parent_dir != "res://" && folder_icon_color == theme_cache.folder_icon_color) {
String parent_dir = ProjectSettings::get_singleton()->localize_path(p_dir_path);
while (!parent_dir.is_empty() && parent_dir != "res://") {
if (!parent_dir.ends_with("/")) {
parent_dir += "/";
}
if (assigned_folder_colors.has(parent_dir)) {
folder_icon_color = folder_colors[assigned_folder_colors[parent_dir]];
if (folder_icon_color != theme_cache.folder_icon_color) {
break;
}
}
parent_dir = parent_dir.trim_suffix("/").get_base_dir();
}
Expand Down
Loading