protected static IList <MoonfishTagField> GuerillaPreProcessMethod(IList <MoonfishTagField> fields)
        {
            var soundPromotionRuleBlockField = new MoonfishTagField(MoonfishFieldType.FieldBlock,
                                                                    "Sound Promotion Rules");

            soundPromotionRuleBlockField.AssignDefinition(new MoonfishTagDefinition("Sound Promotion Rule Block",
                                                                                    new[]
            {
                new MoonfishTagField(MoonfishFieldType.FieldShortBlockIndex1, "Pitch Ranges"),
                new MoonfishTagField(MoonfishFieldType.FieldShortInteger, "Maximum Playing Count"),
                new MoonfishTagField(MoonfishFieldType.FieldReal,
                                     "Suppression Time Seconds#time from when first permutation plays to when another sound from an equal or lower promotion can play"),
                new MoonfishTagField(MoonfishFieldType.FieldPad, "", 8),
                new MoonfishTagField(MoonfishFieldType.FieldTerminator, "")
            }));
            var soundPromotionRuntimeTimerBlockField = new MoonfishTagField(MoonfishFieldType.FieldBlock,
                                                                            "Sound Promotion Runtime Timers");

            soundPromotionRuntimeTimerBlockField.AssignDefinition(
                new MoonfishTagDefinition("Sound Promotion Runtime Timer Block",
                                          new[]
            {
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, ""),
                new MoonfishTagField(MoonfishFieldType.FieldTerminator, "")
            }
                                          ));
            return(new[]
            {
                soundPromotionRuleBlockField,
                soundPromotionRuntimeTimerBlockField,
                new MoonfishTagField(MoonfishFieldType.FieldPad, "", 12),
                new MoonfishTagField(MoonfishFieldType.FieldTerminator, ""),
            });
        }
Example #2
0
        protected static IList <MoonfishTagField> GuerillaPreProcessMethod(IList <MoonfishTagField> fields)
        {
            var unknownBlock = new MoonfishTagField(MoonfishFieldType.FieldBlock, "Xbox Unknown Animation Block");

            unknownBlock.AssignDefinition(new MoonfishTagDefinition("Moonfish Xbox Animation Unknown Block",
                                                                    new List <MoonfishTagField>
            {
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Unknown1"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Unknown2"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Unknown3"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Unknown4"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Unknown5"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Unknown6")
            }));

            var rawBlock = new MoonfishTagField(MoonfishFieldType.FieldBlock, "Xbox Animation Data Block");

            rawBlock.AssignDefinition(new MoonfishTagDefinition("Moonfish Xbox Animation Raw Block",
                                                                new List <MoonfishTagField>
            {
                new MoonfishTagField(MoonfishFieldType.FieldMoonfishIdent, "Owner Tag"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Block Size"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Block Offset"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Unknown"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Unknown1"),
            }));

            fields.Insert(fields.Count - 1, rawBlock);
            fields.Insert(fields.Count - 1, unknownBlock);
            return(fields);
        }
Example #3
0
        protected static IList <MoonfishTagField> GuerillaPreProcessMethod(IList <MoonfishTagField> fields)
        {
            var soundField = new MoonfishTagField(MoonfishFieldType.FieldPad, "Sound Fields");

            soundField.AssignCount(20);
            fields = new[] { soundField, new MoonfishTagField(MoonfishFieldType.FieldTerminator, ""), };
            return(fields);
        }
        private static string GenerateClassName(GuerillaBlockClassBase parentClass, MoonfishTagField field)
        {
            var nameToken     = new StringBuilder(field.Strings.Name.ToPascalCase().ToAlphaNumericToken());
            var typeToken     = GetTypeToken(field);
            var fieldTypeName = nameToken + typeToken;

            fieldTypeName = parentClass.TokenDictionary.Contains(fieldTypeName)
                ? parentClass.TargetClass.Name.Replace("Block", "") + fieldTypeName
                : fieldTypeName;
            return(parentClass.TokenDictionary.GenerateValidToken(fieldTypeName));
        }
        protected string GenerateFieldName(MoonfishTagField field,
                                           MemberAttributes attributes = MemberAttributes.Public)
        {
            if (field.Type == MoonfishFieldType.FieldTagReference)
            {
                return(GenerateName(attributes, field.Strings.Name, typeof(TagReference).Name()));
            }
            var fieldTypeName = field.Type.ToString();

            return(field.Definition != null
                ? GenerateName(attributes, field.Strings.Name, field.Definition.Name, fieldTypeName)
                : GenerateName(attributes, field.Strings.Name, fieldTypeName));
        }
        private static string GetTypeToken(MoonfishTagField field)
        {
            var typeToken = "";

            switch (field.Type)
            {
            case MoonfishFieldType.FieldCharEnum:
            case MoonfishFieldType.FieldEnum:
            case MoonfishFieldType.FieldLongEnum:
                typeToken = "Enum";
                break;
            }
            return(typeToken);
        }
        protected static IList <MoonfishTagField> GuerillaPreProcessMethod(IList <MoonfishTagField> fields)
        {
            var blockInfoStruct = new MoonfishTagField(MoonfishFieldType.FieldStruct, "StructureBlockInfo");

            blockInfoStruct.AssignDefinition(
                new MoonfishTagStruct(new MoonfishTagDefinition("MoonfishGlobalStructureBlockInfoStructBlock", new[]
            {
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Block Offset"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Block Length"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Block Address"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "")
            })));
            fields.RemoveAt(0);
            fields.Insert(0, blockInfoStruct);

            return(fields);
        }
Example #8
0
        protected static IList <MoonfishTagField> GuerillaPreProcessMethod(IList <MoonfishTagField> fields)
        {
            var field = new MoonfishTagField(MoonfishFieldType.FieldBlock, "Sounds");
            var soundTagReferenceField = new MoonfishTagField(MoonfishFieldType.FieldTagReference, "Sound*");

            soundTagReferenceField.AssignDefinition(new MoonfishTagReferenceDefinition((TagClass)"snd!"));
            field.AssignDefinition(new MoonfishTagDefinition("Moonfish Sound References Block",
                                                             new List <MoonfishTagField>
            {
                soundTagReferenceField
            }));
            fields[8] = field;
            var unicodeStruct = new MoonfishTagField(MoonfishFieldType.FieldStruct, "UnicodeBlockInfo");

            unicodeStruct.AssignDefinition(new MoonfishTagStruct(new MoonfishTagDefinition("MoonfishGlobalUnicodeBlockInfoStructBlock", new[]
            {
                new MoonfishTagField(MoonfishFieldType.FieldPad, "", 8),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "English String Count"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "English String Table Length"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "English String Index Address"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "English String Table Address"),
                new MoonfishTagField(MoonfishFieldType.FieldPad, "", 4),

                new MoonfishTagField(MoonfishFieldType.FieldPad, "", 8),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Japanese String Count"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Japanese String Table Length"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Japanese String Index Address"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Japanese String Table Address"),
                new MoonfishTagField(MoonfishFieldType.FieldPad, "", 4),

                new MoonfishTagField(MoonfishFieldType.FieldPad, "", 8),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Dutch String Count"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Dutch String Table Length"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Dutch String Index Address"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Dutch String Table Address"),
                new MoonfishTagField(MoonfishFieldType.FieldPad, "", 4),

                new MoonfishTagField(MoonfishFieldType.FieldPad, "", 8),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "French String Count"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "French String Table Length"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "French String Index Address"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "French String Table Address"),
                new MoonfishTagField(MoonfishFieldType.FieldPad, "", 4),

                new MoonfishTagField(MoonfishFieldType.FieldPad, "", 8),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Spanish String Count"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Spanish String Table Length"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Spanish String Index Address"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Spanish String Table Address"),
                new MoonfishTagField(MoonfishFieldType.FieldPad, "", 4),

                new MoonfishTagField(MoonfishFieldType.FieldPad, "", 8),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Italian String Count"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Italian String Table Length"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Italian String Index Address"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Italian String Table Address"),
                new MoonfishTagField(MoonfishFieldType.FieldPad, "", 4),

                new MoonfishTagField(MoonfishFieldType.FieldPad, "", 8),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Korean String Count"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Korean String Table Length"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Korean String Index Address"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Korean String Table Address"),
                new MoonfishTagField(MoonfishFieldType.FieldPad, "", 4),

                new MoonfishTagField(MoonfishFieldType.FieldPad, "", 8),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Chinese String Count"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Chinese String Table Length"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Chinese String Index Address"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Chinese String Table Address"),
                new MoonfishTagField(MoonfishFieldType.FieldPad, "", 4),

                new MoonfishTagField(MoonfishFieldType.FieldPad, "", 8),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Portuguese String Count"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Portuguese String Table Length"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Portuguese String Index Address"),
                new MoonfishTagField(MoonfishFieldType.FieldLongInteger, "Portuguese String Table Address"),
                new MoonfishTagField(MoonfishFieldType.FieldPad, "", 4),
            })));
            fields.RemoveAt(fields.Count - 2);
            fields.Insert(fields.Count - 1, unicodeStruct);

            return(fields);
        }
        internal GuerillaEnumBlockClass(GuerillaBlockClassBase parentClass, MoonfishTagField field)
            : base(GenerateClassName(parentClass, field))
        {
            _field = field;
            bool isFlags;

            TargetClass = ConstructCodeTypeDeclaration(field, TargetClass.Name, out isFlags);


            var comments       = PullComments();
            var memberComments = comments.Descriptions.ToList();
            var enumDefinition = (MoonfishTagEnumDefinition)field.Definition;

            //  add a none flag for flag-enums
            if (isFlags)
            {
                TargetClass.Members.Add(new CodeMemberField
                {
                    Name           = "None",
                    InitExpression = new CodePrimitiveExpression(0)
                });
            }

            //  loop through all the enum options and add them
            for (var index = 0; index < enumDefinition.Names.Count; index++)
            {
                var value   = enumDefinition.Names[index];
                var comment = index < memberComments.Count ? memberComments[index] : null;

                if (!value.ToAlphaNumericToken().IsValidIdentifier())
                {
                    Console.WriteLine(@"Skipping enum option: {{{0}}}", value);
                    continue;
                }

                var member = new CodeMemberField
                {
                    Name = GenerateName(MemberAttributes.Public, value)
                };

                //  process comments
                if (comment != null)
                {
                    var lines = comment.Split(new[] { "\n", "\r\n" }, StringSplitOptions.None);
                    member.Comments.Add(new CodeCommentStatement("<summary>", true));
                    foreach (var line in lines)
                    {
                        member.Comments.Add(new CodeCommentStatement(line, true));
                    }
                    member.Comments.Add(new CodeCommentStatement("</summary>", true));
                }
                member.InitExpression = new CodePrimitiveExpression(isFlags ? 1 << index : index);
                TargetClass.Members.Add(member);
            }
            if (comments.HasSummary)
            {
                TargetClass.Comments.AddRange(new[]
                {
                    new CodeCommentStatement("<summary>", true),
                    new CodeCommentStatement(comments.Summary.Trim(), true),
                    new CodeCommentStatement("</summary>", true)
                });
            }
        }
        private static CodeTypeDeclaration ConstructCodeTypeDeclaration(MoonfishTagField field, string fieldTypeName, out bool isFlags)
        {
            CodeTypeDeclaration typeDeclaration;

            switch (field.Type)
            {
            case MoonfishFieldType.FieldByteFlags:
                isFlags         = true;
                typeDeclaration = new CodeTypeDeclaration(fieldTypeName)
                {
                    IsEnum    = true,
                    BaseTypes = { new CodeTypeReference(typeof(byte)) }
                };
                typeDeclaration.CustomAttributes.Add(
                    new CodeAttributeDeclaration(new CodeTypeReference(typeof(FlagsAttribute))));
                break;

            case MoonfishFieldType.FieldWordFlags:
                isFlags         = true;
                typeDeclaration = new CodeTypeDeclaration(fieldTypeName)
                {
                    IsEnum    = true,
                    BaseTypes = { new CodeTypeReference(typeof(short)) }
                };
                typeDeclaration.CustomAttributes.Add(
                    new CodeAttributeDeclaration(new CodeTypeReference(typeof(FlagsAttribute))));
                break;

            case MoonfishFieldType.FieldLongFlags:
                isFlags         = true;
                typeDeclaration = new CodeTypeDeclaration(fieldTypeName)
                {
                    IsEnum    = true,
                    BaseTypes = { new CodeTypeReference(typeof(int)) }
                };
                typeDeclaration.CustomAttributes.Add(
                    new CodeAttributeDeclaration(new CodeTypeReference(typeof(FlagsAttribute))));
                break;

            case MoonfishFieldType.FieldCharEnum:
                isFlags         = false;
                typeDeclaration = new CodeTypeDeclaration(fieldTypeName)
                {
                    IsEnum    = true,
                    BaseTypes = { new CodeTypeReference(typeof(byte)) }
                };
                break;

            case MoonfishFieldType.FieldEnum:
                isFlags         = false;
                typeDeclaration = new CodeTypeDeclaration(fieldTypeName)
                {
                    IsEnum    = true,
                    BaseTypes = { new CodeTypeReference(typeof(short)) }
                };
                break;

            case MoonfishFieldType.FieldLongEnum:
                isFlags         = false;
                typeDeclaration = new CodeTypeDeclaration(fieldTypeName)
                {
                    IsEnum    = true,
                    BaseTypes = { new CodeTypeReference(typeof(int)) }
                };
                break;

            default:
                throw new ArgumentException();
            }
            typeDeclaration.Attributes = MemberAttributes.Public;
            return(typeDeclaration);
        }