Skip to content
Merged
Show file tree
Hide file tree
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
20 changes: 13 additions & 7 deletions editor/docks/filesystem_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,6 @@ void FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory

// Create all items for the files in the subdirectory.
if (display_mode == DISPLAY_MODE_TREE_ONLY) {
const String main_scene = ResourceUID::ensure_path(GLOBAL_GET("application/run/main_scene"));

// Build the list of the files to display.
List<FileInfo> file_list;
for (int i = 0; i < p_dir->get_file_count(); i++) {
Expand Down Expand Up @@ -337,7 +335,7 @@ void FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory
file_item->select(0);
file_item->set_as_cursor(0);
}
if (main_scene == file_metadata) {
if (main_scene_path == file_metadata) {
file_item->set_custom_color(0, get_theme_color(SNAME("accent_color"), EditorStringName(Editor)));
}
EditorResourcePreview::get_singleton()->queue_resource_preview(file_metadata, callable_mp(this, &FileSystemDock::_tree_thumbnail_done).bind(tree_update_id, file_item->get_instance_id()));
Expand Down Expand Up @@ -1132,7 +1130,6 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
sort_file_info_list(file_list, file_sort);

// Fills the ItemList control node from the FileInfos.
const String main_scene = ResourceUID::ensure_path(GLOBAL_GET("application/run/main_scene"));
for (FileInfo &E : file_list) {
FileInfo *finfo = &(E);
String fname = finfo->name;
Expand Down Expand Up @@ -1166,7 +1163,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
files->set_item_metadata(item_index, fpath);
}

if (fpath == main_scene) {
if (fpath == main_scene_path) {
files->set_item_custom_fg_color(item_index, get_theme_color(SNAME("accent_color"), EditorStringName(Editor)));
}

Expand Down Expand Up @@ -2397,7 +2394,8 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
case FILE_MENU_MAIN_SCENE: {
// Set as main scene with selected scene file.
if (p_selected.size() == 1) {
ProjectSettings::get_singleton()->set("application/run/main_scene", ResourceUID::path_to_uid(p_selected[0]));
main_scene_path = ResourceUID::path_to_uid(p_selected[0]);
ProjectSettings::get_singleton()->set("application/run/main_scene", main_scene_path);
ProjectSettings::get_singleton()->save();
_update_tree(get_uncollapsed_paths());
_update_file_list(true);
Expand Down Expand Up @@ -3330,7 +3328,7 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, const Vect
if (filenames.size() == 1) {
p_popup->add_icon_item(get_editor_theme_icon(SNAME("Load")), TTRC("Open Scene"), FILE_MENU_OPEN);
p_popup->add_icon_item(get_editor_theme_icon(SNAME("CreateNewSceneFrom")), TTRC("New Inherited Scene"), FILE_MENU_INHERIT);
if (ResourceUID::ensure_path(GLOBAL_GET("application/run/main_scene")) != filenames[0]) {
if (main_scene_path != filenames[0]) {
p_popup->add_icon_item(get_editor_theme_icon(SNAME("PlayScene")), TTRC("Set as Main Scene"), FILE_MENU_MAIN_SCENE);
}
} else {
Expand Down Expand Up @@ -4013,6 +4011,12 @@ void FileSystemDock::_feature_profile_changed() {

void FileSystemDock::_project_settings_changed() {
assigned_folder_colors = ProjectSettings::get_singleton()->get_setting("file_customization/folder_colors");

const String &current_main_scene_path = ResourceUID::ensure_path(GLOBAL_GET("application/run/main_scene"));
if (main_scene_path != current_main_scene_path) {
main_scene_path = current_main_scene_path;
update_all();
}
}

void FileSystemDock::set_file_sort(FileSortOption p_file_sort) {
Expand Down Expand Up @@ -4479,6 +4483,8 @@ FileSystemDock::FileSystemDock() {
file_list_display_mode = FILE_LIST_DISPLAY_THUMBNAILS;

ProjectSettings::get_singleton()->connect("settings_changed", callable_mp(this, &FileSystemDock::_project_settings_changed));
main_scene_path = ResourceUID::ensure_path(GLOBAL_GET("application/run/main_scene"));

add_resource_tooltip_plugin(memnew(EditorTextureTooltipPlugin));
add_resource_tooltip_plugin(memnew(EditorAudioStreamTooltipPlugin));
}
Expand Down
1 change: 1 addition & 0 deletions editor/docks/filesystem_dock.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ class FileSystemDock : public EditorDock {

String current_path = "res://";
String select_after_scan;
String main_scene_path;

bool updating_tree = false;
int tree_update_id;
Expand Down