Exemple #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>());
            }
        }
Exemple #2
0
        private void openFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog
            {
                Filter = "Pangya IFF Desc (Desc*.iff)|Desc*.iff",
                Title  = "Open IFF Desc"
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                DescListing = new List <DescStock>();
                DescListMem = new List <DescList>();
                this.lstStrings.Items.Clear();
                DescListMem = DescList.LoadDescFile(dialog.FileName, RegionSelected);
                int i = 0;
                foreach (DescList record in this.DescListMem)
                {
                    DescStock item = new DescStock
                    {
                        Texte = record.Description.ToString(),
                        ID    = record.IdObject,
                        Index = i
                    };
                    this.DescListing.Add(item);
                    i++;
                }
                UpdateStringList();
            }
        }
Exemple #3
0
        private void saveFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog dialog = new SaveFileDialog
            {
                Title  = "Save Pangya IFF Desc",
                Filter = "Pangya IFF File (*.iff)|*.iff"
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                if (DescList.SaveDescFile(dialog.FileName, this.DescListing, RegionSelected))
                {
                    MessageBox.Show("The Desc IFF have been saved!");
                }
                else
                {
                    MessageBox.Show("Error while writing the file. Please Try Again.");
                }
            }
        }