Пример #1
0
 private void button4_Click(object sender, EventArgs e)
 {
     if (lbFiles.SelectedIndex != -1)
     {
         FatRecord rec = selectedLodFile[lbFiles.SelectedItem.ToString()];
         if (rec.Extension == "TXT" || rec.Extension == "ZBK")
         {
             rtbMain.Text = Encoding.Default.GetString(rec.GetRawData());
         }
         else if (rec.Extension == "PCX")
         {
             bmp = rec.GetBitmap();
             Invalidate();
         }
         else if (rec.Extension == "DEF")
         {
             def = rec.GetDefFile();
             bmp = def.GetSprite(0, 0);
             lbDecomposed.Items.Clear();
             for (int i = 0; i < def.BlockCount; i++)
             {
                 lbDecomposed.Items.AddRange(def.headers[i].Names);
             }
         }
     }
 }
        public void LoadData(Heroes3Master master)
        {
            Master = master;

            OriginalData = new List <FatRecord>();
            foreach (var name in FileEntriesToBackups)
            {
                string backupName = GetBackupFileName(name);

                FatRecord temp     = master.ResolveWith(backupName, false);
                FatRecord original = master.ResolveWith(name);

                if (temp == null || temp.Parent != original.Parent)
                {
                    List <string> list;
                    if (!master.NameToFileMap.TryGetValue(backupName.ToLower(), out list))
                    {
                        list = new List <string>();
                        master.NameToFileMap[backupName.ToLower()] = list;
                    }

                    list.Add(original.Parent.Name.ToLower());
                    temp = original.Clone(backupName);
                    temp.Parent.AddNewRecord(temp);
                }

                OriginalData.Add(temp);
            }
        }
        public static void LoadFromMaster(Heroes3Master master)
        {
            FatRecord un32, un44;


            un32    = master.ResolveWith(BackupManager.GetBackupFileName(Speciality.IMG_FNAME_SMALL)) ?? master.ResolveWith(Speciality.IMG_FNAME_SMALL);
            un44    = master.ResolveWith(BackupManager.GetBackupFileName(Speciality.IMG_FNAME)) ?? master.ResolveWith(Speciality.IMG_FNAME);
            h_specs = master.ResolveWith(BackupManager.GetBackupFileName(HeroesManager.H_SPECS)) ?? master.ResolveWith(HeroesManager.H_SPECS);

            spec_rows = Encoding.Default.GetString(h_specs.GetRawData()).Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

            LoadOriginalSpecs(Properties.Resources.allspecs, 0);
            LoadDefsUncompressed(un32.GetRawData(), un44.GetRawData());
        }
Пример #4
0
        public List <FatRecord> Filter(string extension)
        {
            if (extension[0] == '.')
            {
                extension = extension.Substring(1);
            }
            if (extension == "*")
            {
                return(FilesTable.ToList());
            }
            string local = FatRecord.ToggleCase(extension);

            return(FilesTable.Where(fat => fat.Extension == local).ToList());
        }
Пример #5
0
        public DefFile(FatRecord parent, byte[] block)
        {
            Parent = parent;

            ID         = BitConverter.ToInt32(block, 0);
            Width      = BitConverter.ToInt32(block, 4);
            Height     = BitConverter.ToInt32(block, 8);
            BlockCount = BitConverter.ToInt32(block, 12);
            bytes      = block;
            headers    = new List <SpriteBlockHeader>(BlockCount);
            int off = 0;

            for (int i = 0; i < BlockCount; i++)
            {
                headers.Add(new SpriteBlockHeader(block, BLOCK_HEADER_OFFSET + off));
                off += headers.Last().HeaderLength;
            }
            LoadPalette();
        }
Пример #6
0
        public void AddNewRecord(FatRecord record)
        {
            record.Parent = this;

            int index = IndexOf(record.FileName);

            if (index >= 0)
            {
                return;
            }

            if (string.Compare(record.FileName, FilesTable.Last().FileName) == 1)
            {
                FilesTable.Add(record);
            }
            else
            {
                FilesTable.Insert(~index, record);
            }
            FileCount++;
        }