Exemple #1
0
        public static void ExportFont(Stream stream, string outputFile)
        {
            var reader = new BINAReader(stream);

            reader.ReadHeader();

            var sig = reader.ReadSignature(8);

            if (sig != "KFCS1000")
            {
                throw new InvalidSignatureException("KFCS1000", sig);
            }

            var fontName = reader.GetString();

            reader.JumpAhead(4);
            reader.JumpAhead(0x10);
            var length = reader.ReadInt64();
            var fntSig = reader.ReadSignature();

            outputFile = fntSig == "OTTO" ? Path.ChangeExtension(outputFile, ".otf")
                : Path.ChangeExtension(outputFile, ".ttf");
            var data = reader.ReadBytes((int)length - 4);

            using (var fntStream = File.Create(outputFile))
            {
                fntStream.Write(Encoding.Default.GetBytes(fntSig), 0, 4);
                fntStream.Write(data, 0, data.Length);
            }
        }
Exemple #2
0
 // Constructors
 public EffectData(BINAReader reader)
 {
     EffectName = reader.GetString();
     reader.JumpAhead(12);
     LinkMotionStop = reader.ReadBoolean();
     reader.JumpAhead(7);
 }
Exemple #3
0
            // Methods
            public void Read(BINAReader reader)
            {
                // Read the data
                uint lineType = reader.ReadUInt32();
                uint padding1 = reader.ReadUInt32();

                ulong nameOffset = reader.ReadUInt64();
                ulong padding2   = reader.ReadUInt64();

                UnknownFloat1 = reader.ReadSingle();
                byte firstCharacter  = reader.ReadByte();
                byte firstAnim       = reader.ReadByte();
                byte secondCharacter = reader.ReadByte();
                byte secondAnim      = reader.ReadByte();

                TalkingCharacter = reader.ReadUInt64();

                // Parse it
                if (nameOffset != 0)
                {
                    Name = reader.GetString((uint)nameOffset + reader.Offset);
                }

                LineType            = (LineTypes)lineType;
                FirstCharacter      = (CharacterTypes)firstCharacter;
                FirstCharAnimation  = (AnimationTypes)firstAnim;
                SecondCharacter     = (CharacterTypes)secondCharacter;
                SecondCharAnimation = (AnimationTypes)secondAnim;
            }
Exemple #4
0
        // Methods
        public override void Load(Stream fileStream)
        {
            var reader = new BINAReader(fileStream);

            Header      = reader.ReadHeader();
            IsBigEndian = reader.IsBigEndian;

            System.Console.WriteLine(reader.BaseStream.Position);
            RangeIn       = reader.ReadSingle(); // Unused
            RangeDistance = reader.ReadSingle(); // Unused

            ModelName = reader.GetString();
            reader.JumpAhead(12);

            SkeletonName = reader.GetString();
            reader.JumpAhead(12);

            BoundingShape = (BoundingShapes)reader.ReadUInt32();

            BoundingSize = reader.ReadVector3();

            MeshName = reader.GetString();
            reader.JumpAhead(20);

            ShapeOffset = reader.ReadVector3();
            reader.JumpAhead(4);
            ShapeSizeOffset = reader.ReadSingle();

            RigidBodyType     = (RigidBodyTypes)reader.ReadByte();
            RigidBodyMaterial = (RigidBodyMaterials)reader.ReadByte();
            reader.JumpAhead(2);

            _PhysicsParam = new PhysicsParam(reader);

            ContactDamageType = (ContactDamageTypes)reader.ReadByte();
            RideOnDamage      = reader.ReadBoolean();
            AerialBounce      = reader.ReadBoolean();

            reader.JumpAhead(9);

            // ReactionData
            for (uint i = 0; i < ReactionDataCount; i++)
            {
                _ReactionData[i] = new ReactionData(reader);
            }
        }
Exemple #5
0
            // Methods
            public void Read(BINAReader reader, bool readStageID = false)
            {
                // Stage Index
                StageIndex = reader.ReadByte();
                byte unknown2 = reader.ReadByte();
                byte unknown3 = reader.ReadByte();
                byte unknown4 = reader.ReadByte();

                // Time Bonus
                TimeBasis = reader.ReadUInt32();
                TimeDown  = reader.ReadUInt32();

                // Miss Bonuses
                NoMissBonus       = reader.ReadUInt32();
                OneMissBonus      = reader.ReadUInt32();
                TwoMissBonus      = reader.ReadUInt32();
                ThreeMissBonus    = reader.ReadUInt32();
                FourMissBonus     = reader.ReadUInt32();
                FivePlusMissBonus = reader.ReadUInt32();

                // Rank Scores
                SRankScore = reader.ReadUInt32();
                ARankScore = reader.ReadUInt32();
                BRankScore = reader.ReadUInt32();

                uint CRankScore = reader.ReadUInt32(); // Not really used
                uint DRankScore = reader.ReadUInt32(); // Unused

                // Stage ID
                stageIDOffset = reader.ReadUInt64();
                ulong unknown5 = reader.ReadUInt64();

                if (readStageID)
                {
                    StageID = reader.GetString((uint)stageIDOffset);
                }

                // Padding/Unknown Value Checks
                if (unknown2 != 0)
                {
                    Console.WriteLine($"WARNING: Unknown2 != 0! ({unknown2})");
                }

                if (unknown3 != 0)
                {
                    Console.WriteLine($"WARNING: Unknown3 != 0! ({unknown3})");
                }

                if (unknown4 != 0)
                {
                    Console.WriteLine($"WARNING: Unknown4 != 0! ({unknown4})");
                }

                if (unknown5 != 0)
                {
                    Console.WriteLine($"WARNING: Unknown5 != 0! ({unknown5})");
                }
            }
Exemple #6
0
                // Constructors
                public MotionData(BINAReader reader)
                {
                    MotionName = reader.GetString();
                    reader.JumpAhead(12);

                    SyncFrame    = reader.ReadBoolean();
                    StopEndFrame = reader.ReadBoolean();
                    reader.JumpAhead(6);
                }
Exemple #7
0
                // Constructors
                public KillData(BINAReader reader)
                {
                    KillType = (KillTypes)reader.ReadUInt32();

                    KillTime        = reader.ReadSingle();
                    BreakMotionName = reader.GetString();
                    reader.JumpAhead(12);

                    _DebrisData = new DebrisData(reader);
                    reader.JumpAhead(4);
                }
            // Methods
            public void Read(BINAReader reader)
            {
                ulong nameOffset  = reader.ReadUInt64();
                ulong padding1    = reader.ReadUInt64();
                ulong startOffset = reader.ReadUInt64();
                ulong padding2    = reader.ReadUInt64();
                ulong endOffset   = reader.ReadUInt64();
                ulong padding3    = reader.ReadUInt64();

                // Read strings
                if (nameOffset != 0)
                {
                    Name = reader.GetString((uint)nameOffset + reader.Offset);
                }

                if (startOffset != 0)
                {
                    StageStartCaptionParam = reader.GetString((uint)startOffset + reader.Offset);
                }

                if (endOffset != 0)
                {
                    StageEndCaptionParam = reader.GetString((uint)endOffset + reader.Offset);
                }

                // Padding Checks
                if (padding1 != 0)
                {
                    Console.WriteLine("WARNING: Padding1 != 0! ({0:X})", padding1);
                }

                if (padding2 != 0)
                {
                    Console.WriteLine("WARNING: Padding2 != 0! ({0:X})", padding2);
                }

                if (padding3 != 0)
                {
                    Console.WriteLine("WARNING: Padding3 != 0! ({0:X})", padding3);
                }
            }
Exemple #9
0
                // Constructors
                public MirageAnimData(BINAReader reader)
                {
                    TextureSrtAnimName0 = reader.GetString();
                    reader.JumpAhead(12);
                    TextureSrtAnimName1 = reader.GetString();
                    reader.JumpAhead(12);
                    TextureSrtAnimName2 = reader.GetString();
                    reader.JumpAhead(12);

                    TexturePatAnimName0 = reader.GetString();
                    reader.JumpAhead(12);
                    TexturePatAnimName1 = reader.GetString();
                    reader.JumpAhead(12);
                    TexturePatAnimName2 = reader.GetString();
                    reader.JumpAhead(12);

                    MaterialAnimName0 = reader.GetString();
                    reader.JumpAhead(12);
                    MaterialAnimName1 = reader.GetString();
                    reader.JumpAhead(12);
                    MaterialAnimName2 = reader.GetString();
                    reader.JumpAhead(12);
                }
Exemple #10
0
            public void Read(BINAReader reader, bool readChildIndices = true)
            {
                long nameOffset            = reader.ReadInt64();
                long dataOffset            = reader.ReadInt64();
                long childIndexTableOffset = reader.ReadInt64();

                ParentIndex = reader.ReadInt32();
                Index       = reader.ReadInt32();
                DataIndex   = reader.ReadInt32();

                ushort childCount   = reader.ReadUInt16();
                bool   hasData      = reader.ReadBoolean();
                byte   fullPathSize = reader.ReadByte(); // Not counting this node in

                // Read name
                if (nameOffset != 0)
                {
                    Name = reader.GetString((uint)nameOffset);
                }

                // (MINOR HACK) Store data offset in Data
                // to be read later, avoiding some Seeks
                if (hasData && dataOffset != 0)
                {
                    Data = dataOffset;
                }

                // Read Child Indices
                if (!readChildIndices)
                {
                    return;
                }

                long curPos = reader.BaseStream.Position;

                reader.JumpTo(childIndexTableOffset);
                ChildIndices.Capacity = childCount;

                for (int i = 0; i < childCount; ++i)
                {
                    ChildIndices.Add(reader.ReadInt32());
                }

                reader.JumpTo(curPos);
            }
Exemple #11
0
 // Constructors
 public SoundData(BINAReader reader)
 {
     CueName = reader.GetString();
     reader.JumpAhead(12);
 }
Exemple #12
0
        // Methods
        public override void Load(Stream fileStream)
        {
            // Header
            var reader = new BINAReader(fileStream);

            Header      = reader.ReadHeader();
            IsBigEndian = reader.IsBigEndian;

            uint gismOffset = reader.ReadUInt32();

            UnknownBoolean1 = reader.ReadUInt32(); // TODO: Find out what this is.
            uint gismoCount = reader.ReadUInt32();

            Gismos = new LWGismo[gismoCount];

            // Containers
            uint containerOffset = reader.ReadUInt32();

            reader.JumpTo(containerOffset, false);

            for (uint i = 0; i < gismoCount; ++i)
            {
                var gismo = new LWGismo();

                // Container 1
                uint fileNameOffset    = reader.ReadUInt32();
                uint fileNameOffset2   = reader.ReadUInt32(); // TODO: Find out what this is for.
                uint unknownNameOffset = reader.ReadUInt32();
                gismo.Unknown1 = reader.ReadUInt32();

                gismo.Unknown2    = reader.ReadSingle();
                gismo.Unknown3    = reader.ReadSingle();
                gismo.DoesAnimate = (reader.ReadUInt32() == 1);
                uint havokOffset = reader.ReadUInt32();

                gismo.UnknownBoolean1 = (reader.ReadUInt32() == 1);
                uint containerTwoOffset = reader.ReadUInt32();

                if (fileNameOffset != fileNameOffset2)
                {
                    Console.WriteLine(
                        "WARNING: fileNameOffset != fileNameOffset2 ({0} vs. {1})",
                        fileNameOffset, fileNameOffset2);
                }

                long curPos = reader.BaseStream.Position;
                gismo.FileName = reader.GetString(fileNameOffset, true);

                // Havok Array
                reader.JumpTo(havokOffset, false);
                uint unknown10 = reader.ReadUInt32();

                if (unknown10 != 0)
                {
                    Console.WriteLine("WARNING: Unknown10 != 0 ({0})!", unknown10);
                }

                gismo.HavokName = reader.GetString();

                // Container 2
                reader.JumpTo(containerTwoOffset, false);

                gismo.UnknownBoolean2 = (reader.ReadUInt32() == 1);
                gismo.UnknownBoolean3 = (reader.ReadUInt32() == 1);

                gismo.Unknown5 = reader.ReadSingle();
                gismo.Unknown6 = reader.ReadSingle();
                gismo.Unknown7 = reader.ReadSingle();

                gismo.Unknown8       = reader.ReadSingle();
                gismo.RotationAmount = reader.ReadSingle();
                gismo.Unknown9       = reader.ReadSingle();

                reader.BaseStream.Position = curPos;
                Gismos[i] = gismo;
            }
        }