Browse Source

Update resource file project settings on rename

Benjamin 7 years ago
parent
commit
4cd69e91fc
4 changed files with 23 additions and 0 deletions
  1. 4 0
      core/project_settings.cpp
  2. 1 0
      core/project_settings.h
  3. 17 0
      editor/filesystem_dock.cpp
  4. 1 0
      editor/filesystem_dock.h

+ 4 - 0
core/project_settings.cpp

@@ -870,6 +870,10 @@ void ProjectSettings::set_custom_property_info(const String &p_prop, const Prope
 	custom_prop_info[p_prop].name = p_prop;
 	custom_prop_info[p_prop].name = p_prop;
 }
 }
 
 
+const Map<StringName, PropertyInfo> &ProjectSettings::get_custom_property_info() const {
+	return custom_prop_info;
+}
+
 void ProjectSettings::set_disable_feature_overrides(bool p_disable) {
 void ProjectSettings::set_disable_feature_overrides(bool p_disable) {
 
 
 	disable_feature_overrides = p_disable;
 	disable_feature_overrides = p_disable;

+ 1 - 0
core/project_settings.h

@@ -137,6 +137,7 @@ public:
 	Error save_custom(const String &p_path = "", const CustomMap &p_custom = CustomMap(), const Vector<String> &p_custom_features = Vector<String>(), bool p_merge_with_current = true);
 	Error save_custom(const String &p_path = "", const CustomMap &p_custom = CustomMap(), const Vector<String> &p_custom_features = Vector<String>(), bool p_merge_with_current = true);
 	Error save();
 	Error save();
 	void set_custom_property_info(const String &p_prop, const PropertyInfo &p_info);
 	void set_custom_property_info(const String &p_prop, const PropertyInfo &p_info);
+	const Map<StringName, PropertyInfo> &get_custom_property_info() const;
 
 
 	Vector<String> get_optimizer_presets() const;
 	Vector<String> get_optimizer_presets() const;
 
 

+ 17 - 0
editor/filesystem_dock.cpp

@@ -920,6 +920,21 @@ void FileSystemDock::_update_dependencies_after_move(const Map<String, String> &
 	}
 	}
 }
 }
 
 
+void FileSystemDock::_update_project_settings_after_move(const Map<String, String> &p_renames) const {
+
+	// Find all project settings of type FILE and replace them if needed
+	const Map<StringName, PropertyInfo> prop_info = ProjectSettings::get_singleton()->get_custom_property_info();
+	for (const Map<StringName, PropertyInfo>::Element *E = prop_info.front(); E; E = E->next()) {
+		if (E->get().hint == PROPERTY_HINT_FILE) {
+			String old_path = GLOBAL_GET(E->key());
+			if (p_renames.has(old_path)) {
+				ProjectSettings::get_singleton()->set_setting(E->key(), p_renames[old_path]);
+			}
+		};
+	}
+	ProjectSettings::get_singleton()->save();
+}
+
 void FileSystemDock::_update_favorite_dirs_list_after_move(const Map<String, String> &p_renames) const {
 void FileSystemDock::_update_favorite_dirs_list_after_move(const Map<String, String> &p_renames) const {
 
 
 	Vector<String> favorite_dirs = EditorSettings::get_singleton()->get_favorite_dirs();
 	Vector<String> favorite_dirs = EditorSettings::get_singleton()->get_favorite_dirs();
@@ -1002,6 +1017,7 @@ void FileSystemDock::_rename_operation_confirm() {
 	_try_move_item(to_rename, new_path, file_renames, folder_renames);
 	_try_move_item(to_rename, new_path, file_renames, folder_renames);
 	_update_dependencies_after_move(file_renames);
 	_update_dependencies_after_move(file_renames);
 	_update_resource_paths_after_move(file_renames);
 	_update_resource_paths_after_move(file_renames);
+	_update_project_settings_after_move(file_renames);
 	_update_favorite_dirs_list_after_move(folder_renames);
 	_update_favorite_dirs_list_after_move(folder_renames);
 
 
 	//Rescan everything
 	//Rescan everything
@@ -1061,6 +1077,7 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path) {
 	if (is_moved) {
 	if (is_moved) {
 		_update_dependencies_after_move(file_renames);
 		_update_dependencies_after_move(file_renames);
 		_update_resource_paths_after_move(file_renames);
 		_update_resource_paths_after_move(file_renames);
+		_update_project_settings_after_move(file_renames);
 		_update_favorite_dirs_list_after_move(folder_renames);
 		_update_favorite_dirs_list_after_move(folder_renames);
 
 
 		print_line("call rescan!");
 		print_line("call rescan!");

+ 1 - 0
editor/filesystem_dock.h

@@ -186,6 +186,7 @@ private:
 	void _update_dependencies_after_move(const Map<String, String> &p_renames) const;
 	void _update_dependencies_after_move(const Map<String, String> &p_renames) const;
 	void _update_resource_paths_after_move(const Map<String, String> &p_renames) const;
 	void _update_resource_paths_after_move(const Map<String, String> &p_renames) const;
 	void _update_favorite_dirs_list_after_move(const Map<String, String> &p_renames) const;
 	void _update_favorite_dirs_list_after_move(const Map<String, String> &p_renames) const;
+	void _update_project_settings_after_move(const Map<String, String> &p_renames) const;
 
 
 	void _make_dir_confirm();
 	void _make_dir_confirm();
 	void _rename_operation_confirm();
 	void _rename_operation_confirm();