mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Merge pull request #112201 from timothyqiu/update-main-scene
Fix FileSystem item color not updated after changing main scene
This commit is contained in:
commit
dc590a50d3
2 changed files with 14 additions and 7 deletions
|
|
@ -287,8 +287,6 @@ void FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory
|
||||||
|
|
||||||
// Create all items for the files in the subdirectory.
|
// Create all items for the files in the subdirectory.
|
||||||
if (display_mode == DISPLAY_MODE_TREE_ONLY) {
|
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.
|
// Build the list of the files to display.
|
||||||
List<FileInfo> file_list;
|
List<FileInfo> file_list;
|
||||||
for (int i = 0; i < p_dir->get_file_count(); i++) {
|
for (int i = 0; i < p_dir->get_file_count(); i++) {
|
||||||
|
|
@ -337,7 +335,7 @@ void FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory
|
||||||
file_item->select(0);
|
file_item->select(0);
|
||||||
file_item->set_as_cursor(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)));
|
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()));
|
EditorResourcePreview::get_singleton()->queue_resource_preview(file_metadata, callable_mp(this, &FileSystemDock::_tree_thumbnail_done).bind(tree_update_id, file_item->get_instance_id()));
|
||||||
|
|
@ -1132,7 +1130,6 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
|
||||||
sort_file_info_list(file_list, file_sort);
|
sort_file_info_list(file_list, file_sort);
|
||||||
|
|
||||||
// Fills the ItemList control node from the FileInfos.
|
// 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) {
|
for (FileInfo &E : file_list) {
|
||||||
FileInfo *finfo = &(E);
|
FileInfo *finfo = &(E);
|
||||||
String fname = finfo->name;
|
String fname = finfo->name;
|
||||||
|
|
@ -1166,7 +1163,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
|
||||||
files->set_item_metadata(item_index, fpath);
|
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)));
|
files->set_item_custom_fg_color(item_index, get_theme_color(SNAME("accent_color"), EditorStringName(Editor)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2397,7 +2394,8 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
|
||||||
case FILE_MENU_MAIN_SCENE: {
|
case FILE_MENU_MAIN_SCENE: {
|
||||||
// Set as main scene with selected scene file.
|
// Set as main scene with selected scene file.
|
||||||
if (p_selected.size() == 1) {
|
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();
|
ProjectSettings::get_singleton()->save();
|
||||||
_update_tree(get_uncollapsed_paths());
|
_update_tree(get_uncollapsed_paths());
|
||||||
_update_file_list(true);
|
_update_file_list(true);
|
||||||
|
|
@ -3330,7 +3328,7 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, const Vect
|
||||||
if (filenames.size() == 1) {
|
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("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);
|
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);
|
p_popup->add_icon_item(get_editor_theme_icon(SNAME("PlayScene")), TTRC("Set as Main Scene"), FILE_MENU_MAIN_SCENE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -4013,6 +4011,12 @@ void FileSystemDock::_feature_profile_changed() {
|
||||||
|
|
||||||
void FileSystemDock::_project_settings_changed() {
|
void FileSystemDock::_project_settings_changed() {
|
||||||
assigned_folder_colors = ProjectSettings::get_singleton()->get_setting("file_customization/folder_colors");
|
assigned_folder_colors = ProjectSettings::get_singleton()->get_setting("file_customization/folder_colors");
|
||||||
|
|
||||||
|
const String ¤t_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) {
|
void FileSystemDock::set_file_sort(FileSortOption p_file_sort) {
|
||||||
|
|
@ -4479,6 +4483,8 @@ FileSystemDock::FileSystemDock() {
|
||||||
file_list_display_mode = FILE_LIST_DISPLAY_THUMBNAILS;
|
file_list_display_mode = FILE_LIST_DISPLAY_THUMBNAILS;
|
||||||
|
|
||||||
ProjectSettings::get_singleton()->connect("settings_changed", callable_mp(this, &FileSystemDock::_project_settings_changed));
|
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(EditorTextureTooltipPlugin));
|
||||||
add_resource_tooltip_plugin(memnew(EditorAudioStreamTooltipPlugin));
|
add_resource_tooltip_plugin(memnew(EditorAudioStreamTooltipPlugin));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -245,6 +245,7 @@ private:
|
||||||
|
|
||||||
String current_path = "res://";
|
String current_path = "res://";
|
||||||
String select_after_scan;
|
String select_after_scan;
|
||||||
|
String main_scene_path;
|
||||||
|
|
||||||
bool updating_tree = false;
|
bool updating_tree = false;
|
||||||
int tree_update_id;
|
int tree_update_id;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue