Example #1
0
        public void XMLReader()
        {
            DEX    = new EXP[0];
            Header = new KKtMain.Header();

            KKtXml Xml = new KKtXml();

            Xml.OpenXml(filepath + ".xml", true);
            Xml.Compact = true;
            int i = 0;

            foreach (XElement DEX_ in Xml.doc.Elements("DEX"))
            {
                foreach (XAttribute Entry in DEX_.Attributes())
                {
                    if (Entry.Name == "Format")
                    {
                        Enum.TryParse(Entry.Value, out Header.Format);
                    }
                    else if (Entry.Name == "Length")
                    {
                        DEX = new EXP[int.Parse(Entry.Value)];
                    }
                }
                foreach (XElement EXP in DEX_.Elements())
                {
                    if (EXP.Name != "EXP")
                    {
                        continue;
                    }

                    DEX[i] = new EXP {
                        Main = new List <EXPElement>(), Eyes = new List <EXPElement>()
                    };
                    foreach (XAttribute Entry in EXP.Attributes())
                    {
                        if (Entry.Name == "Name")
                        {
                            DEX[i].Name = Entry.Value;
                        }
                    }
                    foreach (XElement EXPElement in EXP.Elements())
                    {
                        if (EXPElement.Name == "Main" || EXPElement.Name == "Eyes")
                        {
                            foreach (XElement Element in EXPElement.Elements())
                            {
                                if (Element.Name != "Element")
                                {
                                    continue;
                                }

                                EXPElement element = new EXPElement();
                                foreach (XAttribute Entry in Element.Attributes())
                                {
                                    if (Entry.Name == "Frame")
                                    {
                                        element.Frame = KKtMain.ToDouble(Entry.Value);
                                    }
                                    if (Entry.Name == "Both")
                                    {
                                        element.Both = ushort.Parse(Entry.Value);
                                    }
                                    if (Entry.Name == "ID")
                                    {
                                        element.ID = ushort.Parse(Entry.Value);
                                    }
                                    if (Entry.Name == "Value")
                                    {
                                        element.Value = KKtMain.ToDouble(Entry.Value);
                                    }
                                    if (Entry.Name == "Trans")
                                    {
                                        element.Trans = KKtMain.ToDouble(Entry.Value);
                                    }
                                }
                                if (EXPElement.Name == "Main")
                                {
                                    DEX[i].Main.Add(element);
                                }
                                else if (EXPElement.Name == "Eyes")
                                {
                                    DEX[i].Eyes.Add(element);
                                }
                            }
                        }
                    }
                    i++;
                }
            }
        }
Example #2
0
        public int DEXReader()
        {
            KKtIO reader = KKtIO.OpenReader(filepath + ext);

            Header = new KKtMain.Header();

            Header.Format    = KKtMain.Format.F;
            Header.Signature = reader.ReadInt32();
            if (Header.Signature == 0x43505845)
            {
                Header = reader.ReadHeader(true);
            }
            if (Header.Signature != 0x64)
            {
                return(0);
            }

            Offset = reader.Position - 0x4;
            DEX    = new EXP[reader.ReadInt32()];
            int DEXOffset = reader.ReadInt32();

            if (reader.ReadInt32() == 0x00)
            {
                Header.Format = KKtMain.Format.X;
            }

            reader.Seek(DEXOffset + Offset, 0);
            for (int i0 = 0; i0 < DEX.Length; i0++)
            {
                DEX[i0] = new EXP {
                    Main = new List <EXPElement>(), Eyes = new List <EXPElement>()
                }
            }
            ;

            for (int i0 = 0; i0 < DEX.Length; i0++)
            {
                DEX[i0].MainOffset = reader.ReadInt32();
                if (Header.Format == KKtMain.Format.X)
                {
                    reader.ReadInt32();
                }
                DEX[i0].EyesOffset = reader.ReadInt32();
                if (Header.Format == KKtMain.Format.X)
                {
                    reader.ReadInt32();
                }
            }
            for (int i0 = 0; i0 < DEX.Length; i0++)
            {
                DEX[i0].NameOffset = reader.ReadInt32();
                if (Header.Format == KKtMain.Format.X)
                {
                    reader.ReadInt32();
                }
            }

            for (int i0 = 0; i0 < DEX.Length; i0++)
            {
                EXPElement element = new EXPElement();
                reader.Seek(DEX[i0].MainOffset + Offset, 0);
                while (true)
                {
                    element.Frame = reader.ReadSingle();
                    element.Both  = reader.ReadUInt16();
                    element.ID    = reader.ReadUInt16();
                    element.Value = reader.ReadSingle();
                    element.Trans = reader.ReadSingle();
                    DEX[i0].Main.Add(element);

                    if (element.Frame == 999999 || element.Both == 0xFFFF)
                    {
                        break;
                    }
                }

                reader.Seek(DEX[i0].EyesOffset + Offset, 0);
                while (true)
                {
                    element.Frame = reader.ReadSingle();
                    element.Both  = reader.ReadUInt16();
                    element.ID    = reader.ReadUInt16();
                    element.Value = reader.ReadSingle();
                    element.Trans = reader.ReadSingle();
                    DEX[i0].Eyes.Add(element);

                    if (element.Frame == 999999 || element.Both == 0xFFFF)
                    {
                        break;
                    }
                }

                reader.Seek(DEX[i0].NameOffset + Offset, 0);
                DEX[i0].Name = KKtText.ToUTF8(reader.NullTerminated());
            }

            reader.Close();
            return(1);
        }
Example #3
0
        public int STRReader()
        {
            KKtIO reader = KKtIO.OpenReader(filepath + ext);

            reader.Format    = KKtMain.Format.F;
            Header.Signature = reader.ReadInt32();
            if (Header.Signature == 0x41525453)
            {
                Header          = reader.ReadHeader(true);
                STR             = new List <String>();
                POF             = KKtMain.AddPOF(Header);
                reader.Position = Header.Lenght;

                Count  = reader.ReadInt32Endian();
                Offset = reader.ReadInt32Endian();
                if (Offset == 0)
                {
                    Offset         = Count;
                    OffsetX        = reader.ReadInt64();
                    Count          = reader.ReadInt64();
                    reader.XOffset = Header.Lenght;
                    reader.Format  = KKtMain.Format.X;
                }
                reader.LongPosition = reader.IsX ? Offset + reader.XOffset : Offset;

                for (int i = 0; i < Count; i++)
                {
                    String Str = new String
                    {
                        StrOffset = reader.GetOffset(ref POF).ReadInt32Endian(),
                        ID        = reader.ReadInt32Endian()
                    };
                    if (reader.IsX)
                    {
                        Str.StrOffset += (int)OffsetX;
                    }
                    STR.Add(Str);
                }
                for (int i = 0; i < Count; i++)
                {
                    reader.LongPosition = STR[i].StrOffset + (reader.IsX ? reader.XOffset : 0);
                    STR[i] = new String {
                        ID = STR[i].ID, Str = KKtText.
                                              ToUTF8(reader.NullTerminated()), StrOffset = STR[i].StrOffset
                    };
                }
                reader.Seek(POF.Offset, 0);
                reader.ReadPOF(ref POF);
            }
            else
            {
                reader.Seek(-4, (SeekOrigin)1);
                int i = 0;
                STR = new List <String>();
                while (reader.LongPosition > 0 && reader.LongPosition < reader.LongLength)
                {
                    int a = reader.ReadInt32();
                    if (a != 0)
                    {
                        reader.Seek(-4, (SeekOrigin)1);
                        STR.Add(new String {
                            Str = KKtText.ToUTF8(reader.NullTerminated()), ID = i
                        });
                        i++;
                    }
                    else
                    {
                        break;
                    }
                }
                Count = STR.Count;
            }

            reader.Close();
            return(1);
        }