Skip to content

Commit

Permalink
Merge pull request #86171 from YuriSizov/editor-what-colors-what-sounds
Browse files Browse the repository at this point in the history
Fix various issues with the folder color lookup
  • Loading branch information
YuriSizov committed Dec 14, 2023
2 parents c357976 + efa8c46 commit f8a2a91
Showing 1 changed file with 9 additions and 2 deletions.
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

0 comments on commit f8a2a91

Please sign in to comment.