protected virtual void OnLuaVariableFilterServiceFiltering(object sender, SledLuaVariableFilterService.FilteringEventArgs e) { if (e.NodeType != NodeType) { return; } if (Collection.Count <= 0) { return; } var objects = new List <TType>(); foreach (var list in Collection) { SledDomUtil.GatherAllAs(list.DomNode, objects); } foreach (var luaVar in objects) { e.LuaVarsToFilter.Add(luaVar); } Editor.View = null; }
/// <summary> /// Open the project file and remove any duplicates /// </summary> /// <param name="szAbsPath"></param> public static void CleanupProjectFileDuplicates(string szAbsPath) { if (!File.Exists(szAbsPath)) { return; } if (SledUtil.IsFileReadOnly(szAbsPath)) { return; } try { var schemaLoader = SledServiceInstance.TryGet <SledSharedSchemaLoader>(); if (schemaLoader == null) { return; } var uri = new Uri(szAbsPath); var reader = new SledSpfReader(schemaLoader); var root = reader.Read(uri, false); if (root == null) { return; } var lstProjFiles = new List <SledProjectFilesFileType>(); // Gather up all project files in the project SledDomUtil.GatherAllAs(root, lstProjFiles); if (lstProjFiles.Count <= 1) { return; } var uniquePaths = new Dictionary <string, SledProjectFilesFileType>(StringComparer.CurrentCultureIgnoreCase); var lstDuplicates = new List <SledProjectFilesFileType>(); foreach (var projFile in lstProjFiles) { if (uniquePaths.ContainsKey(projFile.Path)) { lstDuplicates.Add(projFile); } else { uniquePaths.Add(projFile.Path, projFile); } } if (lstDuplicates.Count <= 0) { return; } foreach (var projFile in lstDuplicates) { projFile.DomNode.RemoveFromParent(); } var writer = new SledSpfWriter(schemaLoader.TypeCollection); // Write changes back to disk writer.Write(root, uri, false); } catch (Exception ex) { SledOutDevice.OutLine( SledMessageType.Error, SledUtil.TransSub(Localization.SledProjectFilesErrorRemovingDuplicates, ex.Message, szAbsPath)); } }
/// <summary> /// Try and obtain project information from a project file on disk /// </summary> /// <param name="absPath"></param> /// <param name="name"></param> /// <param name="projectDir"></param> /// <param name="assetDir"></param> /// <param name="guid"></param> /// <param name="files"></param> /// <returns></returns> public static bool TryGetProjectDetails( string absPath, out string name, out string projectDir, out string assetDir, out Guid guid, out List <string> files) { name = null; projectDir = null; assetDir = null; guid = Guid.Empty; files = null; try { // ATF 3's DOM makes this so much easier now! var schemaLoader = SledServiceInstance.TryGet <SledSharedSchemaLoader>(); if (schemaLoader == null) { return(false); } var uri = new Uri(absPath); var reader = new SledSpfReader(schemaLoader); var root = reader.Read(uri, false); if (root == null) { return(false); } var project = root.As <SledProjectFilesType>(); project.Uri = uri; // Pull out project details name = project.Name; guid = project.Guid; assetDir = project.AssetDirectory; projectDir = Path.GetDirectoryName(absPath); var lstProjFiles = new List <SledProjectFilesFileType>(); SledDomUtil.GatherAllAs(root, lstProjFiles); var assetDirTemp = assetDir; files = (from projFile in lstProjFiles let absFilePath = SledUtil.GetAbsolutePath( projFile.Path, assetDirTemp) select absFilePath).ToList(); return(true); } catch (Exception ex) { SledOutDevice.OutLine( SledMessageType.Error, "Exception encountered obtaining project " + "details. Project file: \"{0}\". Exception: {1}", absPath, ex.Message); return(false); } }