コード例 #1
0
        private void saveHexChangesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int n = listBox1.SelectedIndex;

            if (n == -1 || SelectedView != 2 || udk == null)
            {
                return;
            }
            MemoryStream m = new MemoryStream();

            for (int i = 0; i < hb1.ByteProvider.Length; i++)
            {
                m.WriteByte(hb1.ByteProvider.ReadByte(i));
            }
            UDKObject.ExportEntry ent = udk.Exports[n];
            ent.data = m.ToArray();
            if (m.Length != ent.size)
            {
                ent.size      = (int)ent.data.Length;
                ent.IsChanged = true;
            }
            udk.Exports[n] = ent;
        }
コード例 #2
0
ファイル: UDKConverter.cs プロジェクト: Dybuk/ME3Explorer
        public void ConvertPccToUpk(string filename)
        {
            string waitline = "\\-/|";
            int    pos      = 0;
            int    count    = 0;

            BitConverter.IsLittleEndian = true;
            PCCObject pcc         = new PCCObject(filename);
            string    newfilename = Path.GetDirectoryName(filename) + "\\" + Path.GetFileNameWithoutExtension(filename) + ".upk";
            UDKObject udk         = new UDKObject();

            udk.Names       = new List <UDKObject.NameEntry>();
            udk.Imports     = new List <UDKObject.ImportEntry>();
            udk.Exports     = new List <UDKObject.ExportEntry>();
            udk.ExportCount = pcc.Exports.Count;
            udk.ImportCount = pcc.Imports.Count;
            udk.NameCount   = pcc.Names.Count;
            rtb1.Text       = "Convert Names...\n";
            RtbUpd();
            foreach (string s in pcc.Names)
            {
                UDKObject.NameEntry e = new UDKObject.NameEntry();
                e.name  = s;
                e.flags = 0x70010;
                udk.Names.Add(e);
                if ((count++) % 100 == 0)
                {
                    this.Text = "UDK Converter " + waitline[pos++];
                    if (pos == waitline.Length)
                    {
                        pos = 0;
                    }
                }
            }
            rtb1.Text += "Convert Imports...\n";
            RtbUpd();
            foreach (PCCObject.ImportEntry i in pcc.Imports)
            {
                UDKObject.ImportEntry e = new UDKObject.ImportEntry();
                e.raw = i.data;
                udk.Imports.Add(e);
                if ((count++) % 100 == 0)
                {
                    this.Text = "UDK Converter " + waitline[pos++];
                    if (pos == waitline.Length)
                    {
                        pos = 0;
                    }
                }
            }
            rtb1.Text += "Convert Exports...\n";
            RtbUpd();
            foreach (PCCObject.ExportEntry ex in pcc.Exports)
            {
                UDKObject.ExportEntry e = new UDKObject.ExportEntry();
                e.raw  = ex.info;
                e.data = ex.Data;
                udk.Exports.Add(e);
                if ((count++) % 100 == 0)
                {
                    this.Text = "UDK Converter " + waitline[pos++];
                    if (pos == waitline.Length)
                    {
                        pos = 0;
                    }
                }
            }
            rtb1.Text     += "Saving to file...\n";
            this.Text      = "UDK Converter";
            udk._HeaderOff = 0x19;
            udk.Header     = CreateUPKHeader(pcc);
            udk.fz.raw     = new byte[0];
            udk.SaveToFile(newfilename);
            MessageBox.Show("Done.");
        }