示例#1
0
        private void savePccToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (pcc == null)
            {
                return;
            }
            SaveFileDialog d = new SaveFileDialog();

            d.Filter = "ME1 Package File|*." + pcc.pccFileName.Split('.')[pcc.pccFileName.Split('.').Length - 1];
            if (d.ShowDialog() == DialogResult.OK)
            {
                pcc.SaveToFile(d.FileName);
                MessageBox.Show("Done");
            }
        }
示例#2
0
        private void savePccToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (pcc == null)
            {
                return;
            }
            SaveFileDialog d = new SaveFileDialog();

            d.Filter = "ME1 Package File|*." + pcc.pccFileName.Split('.')[pcc.pccFileName.Split('.').Length - 1];
            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                pcc.SaveToFile(d.FileName);
                //if (MessageBox.Show("Do you want to update TOC.bin?", "ME3Explorer", MessageBoxButtons.YesNo) == DialogResult.Yes)
                //{
                //    TOCUpdater.TOCUpdater tc = new TOCUpdater.TOCUpdater();
                //    tc.MdiParent = this.ParentForm;
                //    tc.Show();
                //    tc.EasyUpdate();
                //    tc.Close();
                //}
            }
        }
示例#3
0
        public void replaceTlkwithFile(PCCObject pcc, int Index)
        {
            BitConverter.IsLittleEndian = true;

            /* converts Huffmann Tree to binary form */
            byte[] treeBuffer = ConvertHuffmanTreeToBuffer();

            List <EncodedString> encodedStrings = new List <EncodedString>();
            int i = 0;

            foreach (var entry in _inputData)
            {
                if (entry.Flags == 0)
                {
                    if (entry.StringID > 0)
                    {
                        entry.index = -1;
                    }
                    else
                    {
                        entry.index = 0;
                    }
                }
                else
                {
                    entry.index = i;
                    i++;
                    List <BitArray> binaryData   = new List <BitArray>();
                    int             binaryLength = 0;
                    /* for every character in a string, put it's binary code into data array */
                    foreach (char c in entry.data)
                    {
                        binaryData.Add(_huffmanCodes[c]);
                        binaryLength += _huffmanCodes[c].Count;
                    }
                    byte[] buffer = BitArrayListToByteArray(binaryData, binaryLength);
                    encodedStrings.Add(new EncodedString(entry.data.Length, buffer.Length, buffer));
                }
            }

            /* get properties from object we're replacing*/
            byte[] properties = pcc.Exports[Index].Data.Take(40).ToArray();

            MemoryStream m = new MemoryStream();

            /* writing properties */
            m.Write(properties, 0, 40);
            m.Seek(0x1C, SeekOrigin.Begin);
            m.Write(BitConverter.GetBytes(_inputData.Count), 0, 4);
            m.Seek(0, SeekOrigin.End);

            /* writing entries */
            m.Write(BitConverter.GetBytes(_inputData.Count), 0, 4);
            foreach (TLKEntry entry in _inputData)
            {
                m.Write(BitConverter.GetBytes(entry.StringID), 0, 4);
                m.Write(BitConverter.GetBytes(entry.Flags), 0, 4);
                m.Write(BitConverter.GetBytes(entry.index), 0, 4);
            }

            /* writing HuffmanTree */
            m.Write(treeBuffer, 0, treeBuffer.Length);

            /* writing data */
            m.Write(BitConverter.GetBytes(encodedStrings.Count), 0, 4);
            foreach (EncodedString enc in encodedStrings)
            {
                m.Write(BitConverter.GetBytes(enc.stringLength), 0, 4);
                m.Write(BitConverter.GetBytes(enc.encodedLength), 0, 4);
                m.Write(enc.binaryData, 0, enc.encodedLength);
            }

            byte[] buff = m.ToArray();
            pcc.Exports[Index].Data = buff;
            pcc.SaveToFile(pcc.pccFileName);
        }