Esempio n. 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>());
            }
        }
Esempio n. 2
0
        public static bool SaveDescFile(string fileName, List <Desc_Editor.DescStock> descriptionList, IFF_REGION RegionSelected)
        {
            BinaryWriter writer;

            writer = new BinaryWriter(File.Open(fileName, FileMode.Create, FileAccess.Write), IffFile.GetFileEncodingByRegion(RegionSelected));


            IffFile file = new IffFile
            {
                ObjectsInFile = ushort.Parse(descriptionList.Count.ToString())
            };

            file.WriteIffFileHeader(writer);
            file.StubRecords(writer, TotalLen, descriptionList.Count);
            file.JumpToFirstRecord(writer);
            foreach (Desc_Editor.DescStock record in descriptionList)
            {
                if (record.ID != 0)
                {
                    long position = writer.BaseStream.Position;
                    writer.Write(record.ID);
                    position += IdObjetlen;
                    if (record.Texte.Length >= DescriptionLen)
                    {
                        record.Texte.Substring(0, DescriptionLen - 1);
                    }
                    writer.Write(record.Texte.ToCharArray());
                    writer.Seek(DescriptionLen - record.Texte.Length, SeekOrigin.Current);
                }
            }
            writer.Close();
            return(true);
        }
Esempio n. 3
0
        private void saveFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog dialog = new SaveFileDialog
            {
                Title  = "Save Language Files",
                Filter = "Pangya Languages (english.dat, thailand.dat)|*.dat"
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                using (BinaryWriter writer = new BinaryWriter(File.Open(dialog.FileName, FileMode.Create, FileAccess.Write), IffFile.GetFileEncodingByRegion(RegionSelected)))
                {
                    foreach (LangStock str in this.languelist)
                    {
                        char[] chars = str.Langue.ToCharArray();
                        writer.Write(chars);
                        writer.Write('\0');
                    }
                }
                MessageBox.Show("The language edited have been saved", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
Esempio n. 4
0
        private void openFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog
            {
                Title  = "Open Language Files",
                Filter = "Pangya Languages (english.dat, thailand.dat)|*.dat"
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                this.languelist = new List <LangStock>();

                using (BinaryReader reader = new BinaryReader(File.Open(dialog.FileName, FileMode.Open, FileAccess.Read), IffFile.GetFileEncodingByRegion(RegionSelected)))
                {
                    int           num     = 0;
                    StringBuilder builder = new StringBuilder();
                    while (reader.BaseStream.Position < reader.BaseStream.Length)
                    {
                        if (reader.PeekChar() != 0)
                        {
                            builder.Append(reader.ReadChar());
                        }
                        else
                        {
                            LangStock item = new LangStock
                            {
                                Langue = builder.ToString(),
                                Index  = num
                            };
                            this.languelist.Add(item);
                            builder = new StringBuilder();
                            reader.BaseStream.Seek(1L, SeekOrigin.Current);
                            num++;
                        }
                    }
                    UpdateStringList();
                }
            }
        }
Esempio n. 5
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();
                }
            }
        }