예제 #1
0
        public static List <DescList> LoadDescFile(string fileName, IFF_REGION RegionSelected)
        {
            if (!File.Exists(fileName))
            {
                return(new List <DescList>());
            }
            List <DescList> list = new List <DescList>();

            using (BinaryReader reader = new BinaryReader(File.Open(fileName, FileMode.Open, FileAccess.Read), IffFile.GetFileEncodingByRegion(RegionSelected)))
            {
                IffFile file            = new IffFile();
                ushort  numberOfRecords = file.GetNumberOfRecords(reader);
                file.JumpToFirstRecord(reader);
                if (file.CheckMagicNumber(reader))
                {
                    for (int i = 0; i < numberOfRecords; i++)
                    {
                        long     position = reader.BaseStream.Position;
                        DescList item     = new DescList
                        {
                            IdObject = reader.ReadUInt32()
                        };
                        position        += IdObjetlen;
                        item.Description = IffFile.GetFileEncodingByRegion(RegionSelected).GetString(reader.ReadBytes(DescriptionLen));
                        position        += DescriptionLen;
                        list.Add(item);
                    }

                    reader.Close();
                    return(list);
                }
                return(new List <DescList>());
            }
        }
예제 #2
0
        private void openFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog
            {
                Filter = "Pangya IFF Character (Character*.iff)|Character*.iff",
                Title  = "Open IFF Desc"
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                CharacterListing = new List <CharacterStock>();
                using (BinaryReader reader = new BinaryReader(File.Open(dialog.FileName, FileMode.Open, FileAccess.Read), IffFile.GetFileEncodingByRegion(RegionSelected)))
                {
                    IffFile file            = new IffFile();
                    ushort  numberOfRecords = file.GetNumberOfRecords(reader);
                    file.JumpToFirstRecord(reader);
                    if (file.CheckMagicNumber(reader))
                    {
                        for (int i = 0; i < numberOfRecords; i++)
                        {
                            //GetFileEncodingByRegion(RegionSelected).GetString(reader.ReadBytes(XXXXXXXX)); --> exemple for encoding string
                            long position = reader.BaseStream.Position;

                            // added the virtual number
                            CharacterStock item = new CharacterStock
                            {
                                Index = i
                            };

                            //Now laborious work -> Read The file
                            item.Active = reader.ReadUInt32();
                            item.TypeId = reader.ReadUInt32();
                            item.Name   = GetFileEncodingByRegion(RegionSelected).GetString(reader.ReadBytes(40));             // 40 Byte long
                            item.Level  = reader.ReadByte();
                            item.Icon   = GetFileEncodingByRegion(RegionSelected).GetString(reader.ReadBytes(40));             // 40 Byte long
                            //Do a trick for flag for have clean read
                            item.Flag1              = reader.ReadByte();
                            item.Flag2              = reader.ReadByte();
                            item.Flag3              = reader.ReadByte();
                            item.Price              = reader.ReadUInt32();
                            item.DiscountPrice      = reader.ReadUInt32();
                            item.UsedPrice          = reader.ReadUInt32();
                            item.FlagShop           = reader.ReadUInt32();
                            item.Qnt_Tiki_Pts       = reader.ReadUInt32();
                            item.Tiki_Pts           = reader.ReadUInt32();
                            item.Recyling_Pts       = reader.ReadUInt16();
                            item.Bonus_Proba        = reader.ReadUInt16();
                            item.Recyling_Pts2      = reader.ReadUInt16();
                            item.Recyling_Pts3      = reader.ReadUInt16();
                            item.Type_Tiki          = reader.ReadUInt32();
                            item.Tiki_Pang          = reader.ReadUInt32();
                            item.Active_Date        = reader.ReadUInt32();
                            item.Activate_Date      = GetFileEncodingByRegion(RegionSelected).GetString(reader.ReadBytes(16)); // 16 Byte long
                            item.End_Date           = GetFileEncodingByRegion(RegionSelected).GetString(reader.ReadBytes(16)); // 16 Byte long
                            item.Model              = GetFileEncodingByRegion(RegionSelected).GetString(reader.ReadBytes(40)); // 40 Byte long
                            item.Tex_01             = GetFileEncodingByRegion(RegionSelected).GetString(reader.ReadBytes(40)); // 40 Byte long
                            item.Tex_02             = GetFileEncodingByRegion(RegionSelected).GetString(reader.ReadBytes(40)); // 40 Byte long
                            item.Tex_03             = GetFileEncodingByRegion(RegionSelected).GetString(reader.ReadBytes(40)); // 40 Byte long
                            item.Power              = reader.ReadUInt16();
                            item.Control            = reader.ReadUInt16();
                            item.Accuracy           = reader.ReadUInt16();
                            item.Spin               = reader.ReadUInt16();
                            item.Curve              = reader.ReadUInt16();
                            item.PowerSlot          = reader.ReadByte();
                            item.ControlSlot        = reader.ReadByte();
                            item.AccuracySlot       = reader.ReadByte();
                            item.SpinSlot           = reader.ReadByte();
                            item.CurveSlot          = reader.ReadByte();
                            item.Unknow_1           = reader.ReadByte();
                            item.RankS              = reader.ReadUInt32();
                            item.RankS_PowerSlot    = reader.ReadByte();
                            item.RankS_ControlSlot  = reader.ReadByte();
                            item.RankS_AccuracySlot = reader.ReadByte();
                            item.RankS_SpinSlot     = reader.ReadByte();
                            item.RankS_CurveSlot    = reader.ReadByte();
                            item.Additional_Tex     = GetFileEncodingByRegion(RegionSelected).GetString(reader.ReadBytes(40)); // 40 Byte long
                            item.Unknow_3           = GetFileEncodingByRegion(RegionSelected).GetString(reader.ReadBytes(3));  // 3 Byte long

                            //Adding to the list
                            CharacterListing.Add(item);
                        }
                        reader.Close();
                    }
                    UpdateStringList();
                }
            }
        }