Exemplo n.º 1
0
        public void UpdateFile(DataFileInfo file)
        {
            if(file.ExtensionInfo.Extension != ".fx")
                return;

            _shaderFiles[file.FullPath] = file;
            Invalidate();
        }
Exemplo n.º 2
0
        public void DeleteFile(DataFileInfo file)
        {
            if (file.ExtensionInfo.Extension != ".fx")
                return;

            _shaderFiles.Remove(file.FullPath);
            Invalidate();
        }
Exemplo n.º 3
0
        public void UpdateFile(DataFileInfo info)
        {
            if(info.ExtensionInfo.Extension != ".fx")
                return;

            _filesToProcess.Add(info);

            Invalidate();
        }
Exemplo n.º 4
0
        public void UpdateFile(DataFileInfo info)
        {
            if(info.ExtensionInfo.Method == null)
                return;

            var folderInfo = GetFolderInfo(info);
            folderInfo.Files.Add(info);

            Invalidate();
        }
Exemplo n.º 5
0
        public void DeleteFile(DataFileInfo info)
        {
            if (info.ExtensionInfo.Method == null || !_folders.ContainsKey(info.ParentName))
                return;

            var folderInfo = _folders[info.ParentName];
            folderInfo.Files.Remove(info);

            Invalidate();
        }
Exemplo n.º 6
0
        public CGEngine(string dataRootDir)
        {
            _dataRootDir = dataRootDir.TrimEnd(Path.PathSeparator);

            _extensions = new Dictionary<string, ExtensionInfo>();
            _excludedPaths = new List<string>();
            _excludedExtensionsInPath = new Dictionary<string, List<string>>();
            _handlers = new List<IDataHandler>();

            _nullDataInfo = new DataFileInfo(new ExtensionInfo("", "", "", false), "", "", "", "");
        }
Exemplo n.º 7
0
        public void DeleteFile(DataFileInfo info)
        {
            if (info.ExtensionInfo.Extension != ".fx")
                return;

            var mgfxoFilePath = GetMgfxoFilePath(info);
            try
            {
                File.Delete(mgfxoFilePath);
            }
            catch (IOException ex)
            {
                Trace.TraceError(ex.Message);
            }
        }
Exemplo n.º 8
0
 public ShaderDefinition(DataFileInfo file, string name, string description, List<ShaderParam> shaderParams)
 {
     File = file;
     Description = description;
     Params = shaderParams;
     Name = name;
 }
Exemplo n.º 9
0
        private ShaderDefinition ParseFile(DataFileInfo file)
        {
            var lines = File.ReadAllLines(file.FullPath);
            var shaderParams = new List<ShaderParam>();
            var i = -1;
            bool inFunctionBody = false;

            foreach (var line in lines)
            {
                i++;

                if (line.Contains("{"))
                    inFunctionBody = true;
                if (line.Contains("}"))
                    inFunctionBody = false;

                if(inFunctionBody)
                    continue;

                foreach (var shaderParamType in _shaderParamTypes)
                {
                    string paramName;
                    if (IsParamDeclaration(line, shaderParamType, out paramName))
                    {
                        shaderParams.Add(CreateParam(paramName, lines, i, shaderParamType));
                    }
                }
            }

            var shaderName = file.PropertyName.Replace(file.ExtensionInfo.Extension, "");
            var exitCondition = new Func<string, int, bool>((line, index) => index == lines.Length - 1);
            var description = GetValue("description", lines, 0, 1, exitCondition);

            var shaderDef = new ShaderDefinition(file, shaderName, description, shaderParams);
            return shaderDef;
        }
Exemplo n.º 10
0
        private bool GetInfos(string filePath, out DataFileInfo infos)
        {
            infos = _nullDataInfo;

            // get extension infos

            var extension = Path.GetExtension(filePath);
            if (extension == null)
                return false;

            if (!_extensions.ContainsKey(extension))
                return false;

            var extensionInfo = _extensions[extension];

            // get property name

            var propName = Path.GetFileName(filePath);
            if (propName == null)
                return false;

            propName = GetPropName(propName);

            // get relative path

            var relativePath = filePath.Replace(_dataRootDir + @"\", "");

            // get parent folder name

            var parent = Path.GetDirectoryName(filePath);
            if (parent == null)
                return false;

            parent = parent.Replace(_dataRootDir + @"\", "");

            // verify exclusions

            if (_excludedPaths.Any(relativePath.StartsWith))
            {
                return false;
            }

            List<string> exclusions;
            if (_excludedExtensionsInPath.TryGetValue(parent, out exclusions))
            {
                if (exclusions.Contains(extension))
                    return false;
            }

            infos = new DataFileInfo(extensionInfo, filePath, relativePath, parent, propName);

            return true;
        }
Exemplo n.º 11
0
 private string GetMgfxoFilePath(DataFileInfo info)
 {
     return _location + @"\Content\" + info.RelativePath.Replace(".fx", ".mgfxo");
 }
Exemplo n.º 12
0
        private FolderInfo GetFolderInfo(DataFileInfo info)
        {
            if (_folders.ContainsKey(info.ParentName))
                return _folders[info.ParentName];
            else
            {
                // make new folder info
                var folder = new FolderInfo(info.ParentName);
                _folders[info.ParentName] = folder;

                if (info.ParentName.Contains("\\"))
                {
                    // add folder to its parent subfolder
                    var folderParentName = info.ParentName.Substring(0, info.ParentName.LastIndexOf("\\", System.StringComparison.Ordinal));
                    if (_folders.ContainsKey(folderParentName))
                    {
                        var parent = _folders[folderParentName];
                        parent.SubFolder.Add(folder);
                    }
                }

                return folder;
            }
        }