Пример #1
0
        static void GenerateKeywordPragmaStrings(
            string keywordReferenceName,
            KeywordDefinition keywordDefinition,
            KeywordScope keywordScope,
            KeywordShaderStage keywordStages,
            string keywordVariantsString,
            Action <string> PragmaStringAction)
        {
            string definitionString = keywordDefinition.ToDeclarationString();
            string scopeString      = keywordScope.ToDeclarationSuffix();

            // check the active shader stages
            if ((keywordStages == KeywordShaderStage.All) || (keywordStages == 0))  // 0 is a default, so assume that means ALL
            {
                PragmaStringAction($"#pragma {definitionString}{scopeString} {keywordVariantsString}");
            }
            else
            {
                // have to process each stage separately
                for (int shaderStage = (int)KeywordShaderStage.Vertex; shaderStage <= (int)keywordStages; shaderStage = shaderStage * 2)
                {
                    if (((int)keywordStages & shaderStage) != 0)
                    {
                        var keywordStage = (KeywordShaderStage)shaderStage;
                        var stageString  = keywordStage.ToKeywordStagesString();
                        PragmaStringAction($"#pragma {definitionString}{scopeString}{stageString} {keywordVariantsString}");
                    }
                }
            }
        }
Пример #2
0
        // GET: Keywords/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var keyword = await _context.Keywords.FindAsync(id);

            if (keyword == null)
            {
                return(NotFound());
            }

            ViewData["KeywordDefinitionId"] = new SelectList(_context.KeywordDefinitions, "KeywordDefinitionId", "KeywordDefinitionName", keyword.KeywordDefinitionId);

            KeywordDefinition keywordDef = _dataDictionaryRepository.GetDefinitionById(keyword.KeywordDefinitionId);

            if (keywordDef != null)
            {
                var keywordViewModel = new KeywordViewModel(keyword, keywordDef);
                return(View(keywordViewModel));
            }
            else
            {
                return(View(keyword));
            }
        }
Пример #3
0
        // GET: Keywords/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var keyword = await _context.Keywords
                          .Include(k => k.KeywordDefinition)
                          .FirstOrDefaultAsync(m => m.KeywordId == id);

            if (keyword == null)
            {
                return(NotFound());
            }

            KeywordDefinition keywordDef = _dataDictionaryRepository.GetDefinitionById(keyword.KeywordDefinitionId);

            if (keywordDef != null)
            {
                var keywordViewModel = new KeywordViewModel(keyword, keywordDef);
                return(View(keywordViewModel));
            }
            else
            {
                return(View(keyword));
            }
        }
Пример #4
0
 public static void GenerateBooleanKeywordPragmaStrings(
     string keywordReferenceName,
     KeywordDefinition keywordDefinition,
     KeywordScope keywordScope,
     KeywordShaderStage keywordStages,
     Action <string> pragmaStringAction)
 {
     if (keywordDefinition != KeywordDefinition.Predefined)
     {
         string variantsString = $"_ {keywordReferenceName}";
         GenerateKeywordPragmaStrings(keywordReferenceName, keywordDefinition, keywordScope, keywordStages, variantsString, pragmaStringAction);
     }
 }
Пример #5
0
        public static string ToDeclarationString(this KeywordDefinition keywordDefinition)
        {
            switch (keywordDefinition)
            {
            case KeywordDefinition.MultiCompile:
                return("multi_compile");

            case KeywordDefinition.ShaderFeature:
                return("shader_feature");

            default:
                return(string.Empty);
            }
        }
Пример #6
0
 public static void GenerateEnumKeywordPragmaStrings(
     string keywordReferenceName,
     KeywordDefinition keywordDefinition,
     KeywordScope keywordScope,
     KeywordShaderStage keywordStages,
     IEnumerable <KeywordEntry> keywordEntries,
     Action <string> pragmaStringAction)
 {
     if (keywordDefinition != KeywordDefinition.Predefined)
     {
         var    entryStrings   = keywordEntries.Select(x => $"{keywordReferenceName}_{x.referenceName}");
         string variantsString = string.Join(" ", entryStrings);
         GenerateKeywordPragmaStrings(keywordReferenceName, keywordDefinition, keywordScope, keywordStages, variantsString, pragmaStringAction);
     }
 }
        public async Task <IActionResult> Create([Bind("KeywordDefinitionId,KeywordDefinitionName,ApplicationId,ApplicationName,Field1Description,Field2Description,Field3Description,Field4Description,Field5Description,Field6Description,Field7Description,Field8Description,Field9Description,Field10Description,Field11Description,Field12Description,Field13Description,Field14Description,Field15Description,Field16Description,Field17Description,Field18Description,Field19Description,Field20Description,Field21Description,Field22Description,Field23Description,Field24Description,Field25Description")] KeywordDefinition keywordDefinition)
        {
            if (ModelState.IsValid)
            {
                _context.Add(keywordDefinition);
                await _context.SaveChangesAsync();

                var thisApp = _dataDictionaryRepository.GetApplicationById(keywordDefinition.ApplicationId);
                if (thisApp != null)
                {
                    keywordDefinition.ApplicationName = thisApp.ApplicationName;
                    _context.SaveChanges();
                }

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ApplicationId"] = new SelectList(_context.Applications, "ApplicationId", "ApplicationName", keywordDefinition.ApplicationId);
            return(View(keywordDefinition));
        }
        public async Task <IActionResult> Edit(int id, [Bind("KeywordDefinitionId,KeywordDefinitionName,ApplicationId,ApplicationName,Field1Description,Field2Description,Field3Description,Field4Description,Field5Description,Field6Description,Field7Description,Field8Description,Field9Description,Field10Description,Field11Description,Field12Description,Field13Description,Field14Description,Field15Description,Field16Description,Field17Description,Field18Description,Field19Description,Field20Description,Field21Description,Field22Description,Field23Description,Field24Description,Field25Description")] KeywordDefinition keywordDefinition)
        {
            if (id != keywordDefinition.KeywordDefinitionId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(keywordDefinition);
                    await _context.SaveChangesAsync();

                    var thisApp = _dataDictionaryRepository.GetApplicationById(keywordDefinition.ApplicationId);
                    if (thisApp != null)
                    {
                        keywordDefinition.ApplicationName = thisApp.ApplicationName;
                        _context.SaveChanges();
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!KeywordDefinitionExists(keywordDefinition.KeywordDefinitionId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ApplicationId"] = new SelectList(_context.Applications, "ApplicationId", "ApplicationName", keywordDefinition.ApplicationId);
            return(View(keywordDefinition));
        }
Пример #9
0
        public List <string> PopulateKeywordDescriptions(KeywordDefinition theDef)
        {
            List <string> DescriptionList = new List <string>();

            if (theDef.Field1Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field1Description);
            }

            if (theDef.Field2Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field2Description);
            }

            if (theDef.Field3Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field3Description);
            }

            if (theDef.Field4Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field4Description);
            }

            if (theDef.Field5Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field5Description);
            }

            if (theDef.Field6Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field6Description);
            }

            if (theDef.Field7Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field7Description);
            }

            if (theDef.Field8Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field8Description);
            }

            if (theDef.Field9Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field9Description);
            }

            if (theDef.Field10Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field10Description);
            }

            if (theDef.Field11Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field11Description);
            }

            if (theDef.Field12Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field12Description);
            }

            if (theDef.Field13Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field13Description);
            }

            if (theDef.Field14Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field14Description);
            }

            if (theDef.Field15Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field15Description);
            }

            if (theDef.Field16Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field16Description);
            }

            if (theDef.Field17Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field17Description);
            }

            if (theDef.Field18Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field18Description);
            }

            if (theDef.Field19Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field19Description);
            }

            if (theDef.Field20Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field20Description);
            }

            if (theDef.Field21Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field21Description);
            }

            if (theDef.Field22Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field22Description);
            }

            if (theDef.Field23Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field23Description);
            }

            if (theDef.Field24Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field24Description);
            }

            if (theDef.Field25Description == null)
            {
                DescriptionList.Add("This field is not used");
            }
            else
            {
                DescriptionList.Add(item: theDef.Field25Description);
            }


            return(DescriptionList);
        }
Пример #10
0
        /* Function: Load
         * Loads the information in <Comments.nd> into a <Config> object, returning whether it was successful.  If it was not
         * config will be null.
         */
        public bool Load(Path filename, out Config config)
        {
            BinaryFile file = new BinaryFile();

            try
            {
                if (file.OpenForReading(filename, "2.2") == false)
                {
                    config = null;
                    return(false);
                }
                else
                {
                    config = new Config();

                    // [String: Tag Name]
                    // [Int32: ID]
                    // ...
                    // [String: null]

                    string tagName = file.ReadString();

                    while (tagName != null)
                    {
                        Tag tag = new Tag(tagName);
                        tag.ID = file.ReadInt32();
                        config.AddTag(tag);

                        tagName = file.ReadString();
                    }


                    // [String: Comment Type Name]
                    // [Int32: ID]
                    // [String: Display Name]
                    // [String: Plural Display Name]
                    // [String: Simple Identifier]
                    // [Byte: Scope]
                    // [Byte: Flags]
                    // ...
                    // [String: null]

                    string commentTypeName = file.ReadString();

                    while (commentTypeName != null)
                    {
                        CommentType commentType = new CommentType(commentTypeName);

                        commentType.ID                = file.ReadInt32();
                        commentType.DisplayName       = file.ReadString();
                        commentType.PluralDisplayName = file.ReadString();
                        commentType.SimpleIdentifier  = file.ReadString();

                        // We don't have to validate the scope and flag values because they're only used to compare to the text file
                        // versions, which are validated.  If these are invalid they'll just show up as changed.

                        commentType.Scope = (CommentType.ScopeValue)file.ReadByte();
                        commentType.Flags = (CommentType.FlagValue)file.ReadByte();

                        config.AddCommentType(commentType);

                        commentTypeName = file.ReadString();
                    }


                    // [String: Keyword]
                    // [Byte: Plural (0 or 1)]
                    // [Int32: Comment Type ID]
                    // [Int32: Language ID or 0 if agnostic]
                    // ...
                    // [String: null]

                    string keywordName = file.ReadString();

                    while (keywordName != null)
                    {
                        var keywordDefinition = new KeywordDefinition(keywordName);

                        keywordDefinition.Plural        = (file.ReadByte() != 0);
                        keywordDefinition.CommentTypeID = file.ReadInt32();

                        int languageID = file.ReadInt32();
                        if (languageID != 0)
                        {
                            keywordDefinition.LanguageID = languageID;
                        }

                        config.AddKeywordDefinition(keywordDefinition);

                        keywordName = file.ReadString();
                    }
                }
            }
            catch
            {
                config = null;
                return(false);
            }
            finally
            {
                file.Close();
            }

            return(true);
        }