Пример #1
0
        public static EffectListEntry InsertEFL(TreeView tree, ArcEntryWrapper node, string filename, Type filetype = null)
        {
            EffectListEntry effectList = new EffectListEntry();

            InsertEntry(tree, node, filename, effectList);

            //Decompression Time.
            effectList.UncompressedData = ZlibStream.UncompressBuffer(effectList.CompressedData);

            try
            {
                using (BinaryReader bnr = new BinaryReader(File.OpenRead(filename)))
                {
                    BuildEffectListEntry(bnr, effectList);
                }
            }
            catch (Exception ex)
            {
                using (StreamWriter sw = File.AppendText("Log.txt"))
                {
                    sw.WriteLine("Caught an exception using the BinaryReader. Here's the details:\n" + ex);
                }
            }

            return(effectList);
        }
Пример #2
0
        public static EffectListEntry BuildEffectListEntry(BinaryReader bnr, EffectListEntry eflentry)
        {
            //Specific file type work goes here!
            int ID = 0;

            //Header Stuff.
            eflentry.Magic       = ByteUtilitarian.BytesToString(bnr.ReadBytes(4), eflentry.Magic);
            eflentry.Version     = bnr.ReadInt32();
            eflentry.FileSize    = bnr.ReadInt32();
            eflentry.FPS         = Convert.ToInt32(bnr.ReadSingle());
            eflentry.EntryCountA = bnr.ReadInt16();
            eflentry.EntryCountB = bnr.ReadInt16();
            eflentry.CountXor    = bnr.ReadInt32();
            eflentry.Unknown18   = bnr.ReadInt32();
            eflentry.Unknown1C   = bnr.ReadInt32();
            eflentry.Buffer10    = bnr.ReadInt32();
            eflentry.Buffer11    = bnr.ReadInt32();
            eflentry.Buffer12    = bnr.ReadInt32();
            eflentry.Buffer13    = bnr.ReadInt32();

            eflentry.Effects = new List <EffectNode>();
            int PrevOffset = Convert.ToInt32(bnr.BaseStream.Position);
            int Iterator   = 0;

            try
            {
                for (int i = 0; i < eflentry.EntryCountA; i++)
                {
                    EffectNode fx = new EffectNode();
                    fx = EffectNode.BuildEffect(fx, i, bnr, eflentry, PrevOffset);
                    eflentry.Effects.Add(fx);
                    ID++;
                    PrevOffset = PrevOffset + 4;
                    bnr.BaseStream.Position = PrevOffset;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("The efl at index: " + ID + " inside the file\n" + eflentry.TrueName + " threw out an error.\nAs long as you do not modify the named file you should be able to save changes made to other files inside this arc and the file will not be modified.", "Uh-Oh");
            }


            return(eflentry);
        }
Пример #3
0
        public static EffectListEntry ReplaceEFL(TreeView tree, ArcEntryWrapper node, string filename, Type filetype = null)
        {
            EffectListEntry eflentry = new EffectListEntry();
            EffectListEntry oldentry = new EffectListEntry();

            tree.BeginUpdate();

            ReplaceEntry(tree, node, filename, eflentry, oldentry);

            //Type Specific Work Here.
            using (MemoryStream LmtStream = new MemoryStream(eflentry.UncompressedData))
            {
                using (BinaryReader bnr = new BinaryReader(LmtStream))
                {
                    BuildEffectListEntry(bnr, eflentry);
                }
            }

            return(node.entryfile as EffectListEntry);
        }
Пример #4
0
        public static EffectListEntry FillEFLEntry(string filename, List <string> subnames, TreeView tree, BinaryReader br, int c, int ID, Type filetype = null)
        {
            EffectListEntry effectList = new EffectListEntry();
            List <byte>     BTemp      = new List <byte>();

            FillEntry(filename, subnames, tree, br, c, ID, effectList, filetype);

            //Decompression Time.
            effectList.UncompressedData = ZlibStream.UncompressBuffer(effectList.CompressedData);

            //Type Specific Work Here.
            using (MemoryStream LmtStream = new MemoryStream(effectList.UncompressedData))
            {
                using (BinaryReader bnr = new BinaryReader(LmtStream))
                {
                    BuildEffectListEntry(bnr, effectList);
                }
            }

            return(effectList);
        }
Пример #5
0
        public static EffectListEntry FillEFLEntry(string filename, List <string> subnames, TreeView tree, BinaryReader br, int c, int ID, Type filetype = null)
        {
            EffectListEntry effectList = new EffectListEntry();

            //This block gets the name of the entry.
            effectList.OffsetTemp = c;
            effectList.EntryID    = ID;
            List <byte> BTemp = new List <byte>();

            br.BaseStream.Position = effectList.OffsetTemp;
            BTemp.AddRange(br.ReadBytes(64));
            BTemp.RemoveAll(ByteUtilitarian.IsZeroByte);

            if (SBname == null)
            {
                SBname = new StringBuilder();
            }
            else
            {
                SBname.Clear();
            }

            string        Tempname;
            ASCIIEncoding ascii = new ASCIIEncoding();

            Tempname = ascii.GetString(BTemp.ToArray());

            //Compressed Data size.
            BTemp = new List <byte>();
            c     = c + 68;
            br.BaseStream.Position = c;
            BTemp.AddRange(br.ReadBytes(4));
            effectList.CSize = BitConverter.ToInt32(BTemp.ToArray(), 0);

            //Uncompressed Data size.
            BTemp = new List <byte>();
            c     = c + 4;
            br.BaseStream.Position = c;
            BTemp.AddRange(br.ReadBytes(4));
            BTemp.Reverse();
            string TempStr = "";

            TempStr = ByteUtilitarian.BytesToStringL2(BTemp, TempStr);
            BigInteger BN1, BN2, DIFF;

            BN2              = BigInteger.Parse("40000000", NumberStyles.HexNumber);
            BN1              = BigInteger.Parse(TempStr, NumberStyles.HexNumber);
            DIFF             = BN1 - BN2;
            effectList.DSize = (int)DIFF;

            //Data Offset.
            BTemp = new List <byte>();
            c     = c + 4;
            br.BaseStream.Position = c;
            BTemp.AddRange(br.ReadBytes(4));
            effectList.AOffset = BitConverter.ToInt32(BTemp.ToArray(), 0);

            //Compressed Data.
            BTemp = new List <byte>();
            c     = effectList.AOffset;
            br.BaseStream.Position = c;
            BTemp.AddRange(br.ReadBytes(effectList.CSize));
            effectList.CompressedData = BTemp.ToArray();


            //Namestuff.
            effectList.EntryName = Tempname;

            //Ensures existing subdirectories are cleared so the directories for files are displayed correctly.
            if (subnames != null)
            {
                if (subnames.Count > 0)
                {
                    subnames.Clear();
                }
            }

            //Gets the filename without subdirectories.
            if (effectList.EntryName.Contains("\\"))
            {
                string[] splstr = effectList.EntryName.Split('\\');

                //foreach (string v in splstr)
                for (int v = 0; v < (splstr.Length - 1); v++)
                {
                    if (!subnames.Contains(splstr[v]))
                    {
                        subnames.Add(splstr[v]);
                    }
                }


                effectList.TrueName = effectList.EntryName.Substring(effectList.EntryName.IndexOf("\\") + 1);
                Array.Clear(splstr, 0, splstr.Length);

                while (effectList.TrueName.Contains("\\"))
                {
                    effectList.TrueName = effectList.TrueName.Substring(effectList.TrueName.IndexOf("\\") + 1);
                }
            }
            else
            {
                effectList.TrueName = effectList.EntryName;
            }

            effectList._FileName = effectList.TrueName;

            effectList.EntryDirs   = subnames.ToArray();
            effectList.FileExt     = ".efl";
            effectList.EntryName   = effectList.EntryName + effectList.FileExt;
            effectList._FileName   = effectList.TrueName;
            effectList._FileType   = effectList.FileExt;
            effectList._FileLength = effectList.DSize;

            //Decompression Time.
            effectList.UncompressedData = ZlibStream.UncompressBuffer(effectList.CompressedData);

            //Specific file type work goes here!

            //Header is 30 bytes. What info is in there?
            byte[] MTemp = new byte[4];
            string STemp = " ";

            Array.Copy(effectList.UncompressedData, 0, MTemp, 0, 4);
            effectList.Magic = ByteUtilitarian.BytesToString(MTemp, effectList.Magic);

            //These values at 0x04 seem identical based on what I've seen so far.
            //string SCTemp = " ";
            Array.Copy(effectList.UncompressedData, 4, MTemp, 0, 4);
            effectList.Magic = ByteUtilitarian.BytesToString(MTemp, effectList.WeirdConstant);

            //Gets the Data Size.
            Array.Copy(effectList.UncompressedData, 8, MTemp, 0, 4);
            Array.Reverse(MTemp);
            STemp = ByteUtilitarian.BytesToString(MTemp, STemp);
            int ECTemp = Convert.ToInt32(STemp, 16);

            effectList.DataSize = ECTemp;

            //These values at 0x0C also seem identical based on what I've seen so far.
            Array.Copy(effectList.UncompressedData, 4, MTemp, 0, 4);
            effectList.Magic = ByteUtilitarian.BytesToString(MTemp, effectList.OtherWeirdConstant);

            byte[] TwoTemp = new byte[2];
            Array.Copy(effectList.UncompressedData, 16, TwoTemp, 0, 2);
            Array.Reverse(TwoTemp);
            effectList.SomeEntryCount = BitConverter.ToInt32(TwoTemp, 0);

            Array.Copy(effectList.UncompressedData, 18, TwoTemp, 0, 2);
            Array.Reverse(TwoTemp);
            effectList.OtherEntryCount = BitConverter.ToInt32(TwoTemp, 0);

            return(effectList);
        }