Ejemplo n.º 1
0
        private FXProject CreateProject(string filename)
        {
            FXProject project;

            if (!FProjects.TryGetValue(filename, out project))
            {
                project = new FXProject(filename, new Uri(filename), FHDEHost.ExePath);
                if (FSolution.Projects.CanAdd(project))
                {
                    FSolution.Projects.Add(project);
                    //effects are actually being compiled by vvvv when nodeinfo is update
                    //so we need to intervere with the doCompile
                    project.DoCompileEvent += project_DoCompileEvent;
                    //in turn not longer needs the following:
                    //project.ProjectCompiledSuccessfully += project_ProjectCompiledSuccessfully;
                }
                else
                {
                    // Project was renamed
                    project = FSolution.Projects[project.Name] as FXProject;
                }

                FProjects[filename] = project;
            }

            return(project);
        }
Ejemplo n.º 2
0
        private INodeInfo LoadNodeInfoFromEffect(string filename, FXProject project)
        {
            var nodeInfo = FNodeInfoFactory.CreateNodeInfo(
                Path.GetFileNameWithoutExtension(filename),
                this.NodeCategory,this.NodeVersion,
                filename,
                true);

            nodeInfo.BeginUpdate();
            nodeInfo.Type = NodeType.Dynamic;
            nodeInfo.Factory = this;
            nodeInfo.UserData = project;

            try
            {
                // Create an instance of StreamReader to read from a file.
                // The using statement also closes the StreamReader.
                using (StreamReader sr = new StreamReader(filename))
                {
                    string line;
                    string author = @"//@author:";
                    string desc = @"//@help:";
                    string tags = @"//@tags:";
                    string credits = @"//@credits:";

                    // Parse lines from the file until the end of
                    // the file is reached.
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (line.StartsWith(author))
                            nodeInfo.Author = line.Replace(author, "").Trim();

                        else if (line.StartsWith(desc))
                            nodeInfo.Help = line.Replace(desc, "").Trim();

                        else if (line.StartsWith(tags))
                            nodeInfo.Tags = line.Replace(tags, "").Trim();

                        else if (line.StartsWith(credits))
                            nodeInfo.Credits = line.Replace(credits, "").Trim();
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(LogType.Error, "Effect does not contain detailed info");
                Logger.Log(ex);
            }

            try
            {
                nodeInfo.CommitUpdate();
            }
            catch { }

            return nodeInfo;
        }
Ejemplo n.º 3
0
        private FXProject CreateProject(string filename)
        {
            FXProject project;

            if (!FProjects.TryGetValue(filename, out project))
            {
                var isDX9 = true;

                // check if file exists before attempt to open it - can happen because of a node info added
                // event triggered by nodelist.xml file.
                if (File.Exists(filename))
                {
                    //check if this is a dx11 effect in that it does not contain "technique10 " or "technique11 "
                    using (var sr = new StreamReader(filename))
                    {
                        var code = sr.ReadToEnd();
                        //remove comments: between (* and *)
                        code = Regex.Replace(code, @"/\*.*?\*/", "", RegexOptions.Singleline);
                        //remove comments: from // to lineend
                        code = Regex.Replace(code, @"//.*?\n", "", RegexOptions.Singleline);

                        //if the rest of the code contains "technique10 " or "technique11 " this must be a dx11 effect
                        if (code.Contains("technique10 ") || code.Contains("technique11 "))
                        {
                            isDX9 = false;
                        }
                    }
                }

                if (isDX9)
                {
                    // This is the single include path also used internally by vvvv.exe
                    var includePath = Path.Combine(FHDEHost.ExePath, "lib", "nodes");
                    project = new FXProject(filename, includePath);
                    if (FSolution.Projects.CanAdd(project))
                    {
                        FSolution.Projects.Add(project);
                        //effects are actually being compiled by vvvv when nodeinfo is update
                        //so we need to intervere with the doCompile
                        project.DoCompileEvent += project_DoCompileEvent;
                        //in turn not longer needs the following:
                        //project.ProjectCompiledSuccessfully += project_ProjectCompiledSuccessfully;
                    }
                    else
                    {
                        // Project was renamed
                        project = FSolution.Projects[project.Name] as FXProject;
                    }

                    FProjects[filename] = project;
                }
            }

            return(project);
        }
        private void ParseErrors(string e, FXProject project, DX11Effect shader)
        {
            string filePath        = project.LocalPath;
            var    compilerResults = ShaderCompilerErrorParser.ParseCompilerResult(e, project.LocalPath, filePath);

            //Add some extra error from reflection
            if (shader.IsCompiled)
            {
                compilerResults.Errors.AddRange(this.VerifyShader(project.LocalPath, shader).ToArray());
            }

            project.CompilerResults = compilerResults;
        }
Ejemplo n.º 5
0
        private FXProject CreateProject(string filename)
        {
            FXProject project;

            if (!FProjects.TryGetValue(filename, out project))
            {
                var isDX9 = true;
                //check if this is a dx9 effect in that it does not contain "technique10" or "technique11"
                using (StreamReader sr = new StreamReader(filename))
                {
                    string line;
                    var    t10 = "technique10";
                    var    t11 = "technique11";

                    // Parse lines from the file until the end of
                    // the file is reached.
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (line.Contains(t10) || line.Contains(t11))
                        {
                            isDX9 = false;
                            break;
                        }
                    }
                }

                if (isDX9)
                {
                    project = new FXProject(filename, FHDEHost.ExePath);
                    if (FSolution.Projects.CanAdd(project))
                    {
                        FSolution.Projects.Add(project);
                        //effects are actually being compiled by vvvv when nodeinfo is update
                        //so we need to intervere with the doCompile
                        project.DoCompileEvent += project_DoCompileEvent;
                        //in turn not longer needs the following:
                        //project.ProjectCompiledSuccessfully += project_ProjectCompiledSuccessfully;
                    }
                    else
                    {
                        // Project was renamed
                        project = FSolution.Projects[project.Name] as FXProject;
                    }

                    FProjects[filename] = project;
                }
            }

            return(project);
        }
        private FXProject CreateProject(string filename)
        {
            FXProject project;

            if (!FProjects.TryGetValue(filename, out project))
            {
                var isDX11 = true;

                //check if this is a dx11 effect in that it does not contain "technique "

                /*using (var sr = new StreamReader(filename))
                 * {
                 *      string line;
                 *      var t9 = "technique ";
                 *
                 *  // Parse lines from the file until the end of
                 *  // the file is reached.
                 *  while ((line = sr.ReadLine()) != null)
                 *  {
                 *      if (line.Contains(t9))
                 *      {
                 *              isDX11 = false;
                 *              break;
                 *      }
                 *  }
                 * }*/

                if (isDX11)
                {
                    project = new FXProject(filename, FHDEHost.ExePath);
                    if (FSolution.Projects.CanAdd(project))
                    {
                        FSolution.Projects.Add(project);
                    }
                    else
                    {
                        // Project was renamed
                        project = FSolution.Projects[project.Name] as FXProject;
                    }

                    project.DoCompileEvent += project_DoCompileEvent;

                    FProjects[filename] = project;
                }
            }

            return(project);
        }
        private FXProject CreateProject(string filename)
        {
            FXProject project;

            if (!FProjects.TryGetValue(filename, out project))
            {
                var isDX11 = false;

                //check if this is a dx11 effect in that it does contain either "technique10 " or "technique11 "
                using (var sr = new StreamReader(filename))
                {
                    var code = sr.ReadToEnd();
                    //remove comments: from // to lineend
                    code = Regex.Replace(code, @"//.*?\n", "", RegexOptions.Singleline);
                    //remove comments: between (* and *)
                    code = Regex.Replace(code, @"/\*.*?\*/", "", RegexOptions.Singleline);
                    //if the code contains now contains "technique10 " or "technique11 " this must be a dx11 effect
                    if (code.Contains("technique10 ") || code.Contains("technique11 "))
                    {
                        isDX11 = true;
                    }
                }

                if (isDX11)
                {
                    project = new FXProject(filename, FHDEHost.ExePath);
                    if (FSolution.Projects.CanAdd(project))
                    {
                        FSolution.Projects.Add(project);
                    }
                    else
                    {
                        // Project was renamed
                        project = FSolution.Projects[project.Name] as FXProject;
                    }

                    project.DoCompileEvent += project_DoCompileEvent;

                    FProjects[filename] = project;
                }
            }

            return(project);
        }
Ejemplo n.º 8
0
        private FXProject CreateProject(string filename)
        {
            FXProject project;

            if (!FProjects.TryGetValue(filename, out project))
            {
                var isValid = false;

                //do some kind of validation here
                using (var sr = new StreamReader(filename))
                {
                    var code = sr.ReadToEnd();
                    code = Regex.Replace(code, @"//.*?\n", "", RegexOptions.Singleline);
                    code = Regex.Replace(code, @"/\*.*?\*/", "", RegexOptions.Singleline);

                    if (code.Contains("#pragma mirage"))
                    {
                        isValid = true;
                    }
                }

                if (isValid)
                {
                    project = new FXProject(filename, FHDEHost.ExePath);
                    if (FSolution.Projects.CanAdd(project))
                    {
                        FSolution.Projects.Add(project);
                    }
                    else
                    {
                        // Project was renamed
                        project = FSolution.Projects[project.Name] as FXProject;
                    }

                    project.DoCompileEvent += project_DoCompileEvent;

                    FProjects[filename] = project;
                }
            }

            return(project);
        }
        private void ParseErrors(string e, FXProject project, DX11Effect shader)
        {
            var compilerResults = new CompilerResults(null);
            //now parse errors to CompilerResults
            //split errorstring linewise
            var errorlines = e.Split(new char[1] {
                '\n'
            });

            foreach (var line in errorlines)
            {
                string filePath  = project.LocalPath;
                string eCoords   = string.Empty;
                int    eLine     = 0;
                int    eChar     = 0;
                string eNumber   = string.Empty;
                string eText     = string.Empty;
                bool   isWarning = false;

                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }

                //split the line at ": "
                //which results in 3 or 4 lines:
                //[0] filename (line, character)
                //[1] error/warning code
                //[2] (optional) erroneous character
                //[3] error description
                var eItems = line.Split(new string[1] {
                    ": "
                }, StringSplitOptions.None);

                //extract line/char substring
                int start = eItems[0].LastIndexOf('(');
                int end   = eItems[0].LastIndexOf(')');

                if (start > 0)
                {
                    string relativePath = eItems[0].Substring(0, start);

                    //if this is a path to an include..
                    if (relativePath != Path.Combine(FHDEHost.ExePath, "memory"))
                    {
                        // we need to guess here. shader compiler outputs relative paths.
                        // we don't know if the include was "local" or <global>

                        filePath = Path.Combine(Path.GetDirectoryName(project.LocalPath), relativePath);
                        if (!File.Exists(filePath))
                        {
                            string fileName = Path.GetFileName(relativePath);

                            foreach (var reference in project.References)
                            {
                                var referenceFileName = Path.GetFileName((reference as FXReference).ReferencedDocument.LocalPath);
                                if (referenceFileName.ToLower() == fileName.ToLower())
                                {
                                    filePath = reference.AssemblyLocation;
                                }
                            }
                        }
                    }
                }

                if (start > -1 && end > 0)
                {
                    eCoords = eItems[0].Substring(start + 1, end - start - 1);
                    var eLineChar = eCoords.Split(new char[1] {
                        ','
                    });
                    eLine = Convert.ToInt32(eLineChar[0]);
                    eChar = Convert.ToInt32(eLineChar[1]);

                    if (eItems[1].StartsWith("warning"))
                    {
                        isWarning = true;
                        eNumber   = eItems[1].Substring(8, 5);
                    }
                    else
                    {
                        eNumber = eItems[1].Substring(6, 5);
                    }

                    if (eItems.Length == 2)
                    {
                        isWarning = false;
                        eNumber   = "-1";
                        eText     = eItems[1];
                    }
                    else
                    {
                        eText = eItems[2];
                        if (eItems.Length > 3)
                        {
                            eText += ": " + eItems[3];
                        }
                    }
                }
                else
                {
                    eText = line;
                }

                var error = new CompilerError(filePath, eLine, eChar, eNumber, eText);
                error.IsWarning = isWarning;
                compilerResults.Errors.Add(error);
            }

            //Add some extra error from reflection
            if (shader.IsCompiled)
            {
                compilerResults.Errors.AddRange(this.VerifyShader(project.LocalPath, shader).ToArray());
            }

            project.CompilerResults = compilerResults;
        }
Ejemplo n.º 10
0
 public FXProjectViewProvider(FXProject project, ModelMapper mapper)
     : base(project, mapper)
 {
     mapper.RegisterMapping <IEditableIDList <IReference>, INamed, FXReferenceListNameProvider>();
 }
Ejemplo n.º 11
0
 public FXProjectMenuProvider(FXProject project, ILogger logger)
 {
     FProject = project;
     FLogger  = logger;
 }