Пример #1
0
        private void saveGUIDCacheToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (pcc == null || GUIDs == null)
            {
                return;
            }
            MemoryStream m = new MemoryStream();

            byte[] buff = pcc.Exports[0].Data;
            props = PropertyReader.getPropList(pcc, buff);
            int pos = props[props.Count - 1].offend;

            m.Write(buff, 0, pos);
            m.Write(BitConverter.GetBytes(GUIDs.Count), 0, 4);
            foreach (GuidEntry g in GUIDs)
            {
                m.Write(BitConverter.GetBytes(g.NameIdx), 0, 4);
                m.Write(BitConverter.GetBytes((int)0), 0, 4);
                foreach (byte b in g.GUID)
                {
                    m.WriteByte(b);
                }
            }
            pcc.Exports[0].Data       = m.ToArray();
            pcc.Exports[0].hasChanged = true;
            pcc.altSaveToFile(pcc.pccFileName, true, 30); //weird header!
            MessageBox.Show("Done.");
            RefreshLists();
        }
Пример #2
0
        private void saveChangesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (pcc == null || currentPCC == "")
            {
                return;
            }
            pcc.altSaveToFile(currentPCC, true);
            FileStream fs   = new FileStream(currentPCC, FileMode.Open, FileAccess.Read);
            uint       size = (uint)fs.Length;
            string     name = Path.GetFileName(currentPCC);

            fs.Close();
            TOCeditor tc = new TOCeditor();

            tc.MdiParent = this.ParentForm;
            string tocpath = ME3Directory.tocFile;

            if (File.Exists(tocpath))
            {
                if (!tc.UpdateFile(name, size, tocpath))
                {
                    MessageBox.Show("Didn't found Entry");
                }
            }
            else
            {
                if (!tc.UpdateFile(name, size))
                {
                    MessageBox.Show("Didn't found Entry");
                }
            }
            tc.Close();
            MessageBox.Show("File " + Path.GetFileName(currentPCC) + " saved.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Пример #3
0
        private void saveChangesToolStripMenuItem_Click(object sender, EventArgs ee)
        {
            int count1 = 0xAF;
            int count2 = 0x64;

            BitConverter.IsLittleEndian = true;
            MemoryStream m = new MemoryStream();

            m.Write(pcc.Exports[3].Data, 0, 0xC);
            for (int i = 0; i < count1; i++)
            {
                QMapEntryStruct e = QuestMap.List1[i];
                for (int j = 0; j < 0xC; j++)
                {
                    m.Write(BitConverter.GetBytes(e.Values[j]), 0, 4);
                }
            }
            for (int i = 0; i < count2; i++)
            {
                QMapEntryStruct e = QuestMap.List2[i];
                for (int j = 0; j < 0x8; j++)
                {
                    m.Write(BitConverter.GetBytes(e.Values[j]), 0, 4);
                }
            }
            pcc.Exports[3].Data = m.ToArray();
            pcc.altSaveToFile(pcc.pccFileName, true);
            MessageBox.Show("Done");
        }
Пример #4
0
        private void importFromPSKToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int n = listBox1.SelectedIndex;

            if (n == -1 | pcc == null)
            {
                return;
            }
            if (pcc.Exports[Objects[n].index].ClassName == "StaticMesh")
            {
                OpenFileDialog d = new OpenFileDialog();
                d.Filter = "*.psk|*.psk;*.pskx";
                if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    timer1.Enabled = false;
                    stm.ImportFromPsk(d.FileName);
                    byte[] buff = stm.SerializeToBuffer();
                    int    idx  = Objects[n].index;
                    PCCObject.ExportEntry en = pcc.Exports[idx];
                    en.Data = buff;
                    pcc.altSaveToFile(CurrFile, true);
                    MessageBox.Show("Done.");
                    timer1.Enabled = true;
                }
            }
            if (pcc.Exports[Objects[n].index].ClassName == "SkeletalMesh")
            {
                OpenFileDialog d = new OpenFileDialog();
                d.Filter = "*.psk|*.psk;*.pskx";
                if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    timer1.Enabled = false;
                    rtb1.Visible   = true;
                    skmold.ImportFromPsk(d.FileName, getLOD());
                    byte[] buff = skmold.Serialize();
                    int    idx  = Objects[n].index;
                    PCCObject.ExportEntry en = pcc.Exports[idx];
                    en.Data = buff;
                    pcc.altSaveToFile(CurrFile, true);
                    MessageBox.Show("Done.");
                    rtb1.Visible   = false;
                    timer1.Enabled = true;
                }
            }
        }
Пример #5
0
 private void saveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (pcc == null)
     {
         return;
     }
     pcc.altSaveToFile(pcc.pccFileName, true);
     MessageBox.Show("Done.");
 }
Пример #6
0
        private void savePccToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog d = new SaveFileDialog();

            d.Filter = "*.pcc|*.pcc";
            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                pcc.altSaveToFile(d.FileName, true);
                MessageBox.Show("Done.");
            }
        }
Пример #7
0
        private void importFromWAVToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int n = listBox1.SelectedIndex;

            if (n == -1)
            {
                return;
            }
            int index = ObjectIndexes[n];

            PCCObject.ExportEntry ex = pcc.Exports[index];
            if (ex.ClassName == "WwiseStream")
            {
                OpenFileDialog d = new OpenFileDialog();
                d.Filter = "*.wav|*.wav";
                if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string pathcook = ME3Directory.cookedPath;
                    string pathbio  = Path.GetDirectoryName(Path.GetDirectoryName(pathcook)) + "\\";
                    Status.Text = "Importing...";
                    if (!isDLC)
                    {
                        w.ImportFromFile(d.FileName, pathbio, pathcook);
                    }
                    else
                    {
                        w.ImportFromFile(d.FileName, pathbio, "", false);
                    }
                    byte[] buff = new byte[w.memsize];
                    for (int i = 0; i < w.memsize; i++)
                    {
                        buff[i] = w.memory[i];
                    }
                    ex.Data     = buff;
                    Status.Text = "Saving...";
                    pcc.altSaveToFile(CurrentFile, true);
                    Status.Text = "Ready";
                    MessageBox.Show("Done");
                }
            }
        }
Пример #8
0
        private void savePccToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (pcc == null)
            {
                return;
            }
            SaveFileDialog d = new SaveFileDialog();

            d.Filter = "*.pcc|*.pcc";
            if (d.ShowDialog() == DialogResult.OK)
            {
                pcc.altSaveToFile(d.FileName, true);
                MessageBox.Show("Done");
            }
        }
Пример #9
0
 private void saveChangesToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (pcc != null && CodexMap != null)
     {
         byte[] buff = pcc.Exports[0].Data;
         foreach (EntryStruct entry in CodexMap)
         {
             for (int i = 0; i < 8; i++)
             {
                 byte[] tmp = BitConverter.GetBytes(entry.Values[i]);
                 for (int j = 0; j < 4; j++)
                 {
                     buff[entry.offset + i * 4 + j] = tmp[j];
                 }
             }
         }
         pcc.Exports[0].Data = buff;
         pcc.altSaveToFile(pcc.pccFileName, true);
         MessageBox.Show("Done");
     }
 }
Пример #10
0
        private void savePccToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (pcc == null)
            {
                return;
            }
            SaveFileDialog d = new SaveFileDialog();

            d.Filter = "*.pcc|*.pcc";
            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                pcc.altSaveToFile(d.FileName, true);
                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();
                }
            }
        }
Пример #11
0
        private void savePccFile(string path)
        {
            if (path == null)
            {
                return;
            }

            BitConverter.IsLittleEndian = true;
            if (pcc.bCompressed)
            {
                Print("\nFile is compressed, saving uncompressed...");
                pcc.altSaveToFile(path, true);
                Print("Done.Reloading...");
                pcc = new PCCObject(path);
                Print("Done.");
            }
            Print("\nCreating Header...");
            FileStream fs;

            if (File.Exists(path))
            {
                fs = new FileStream(path, FileMode.Open, FileAccess.Read);
            }
            else
            {
                fs = new FileStream(pcc.pccFileName, FileMode.Open, FileAccess.Read);
            }
            FileStream fsout = new FileStream(path + "_tmp", FileMode.Create, FileAccess.Write);

            fs.Seek(0xC, 0);
            int GroupNameLen = GetInt(fs);

            Print("Group Name Length: " + GroupNameLen);
            int testpos = 0x14 + (-GroupNameLen) * 2;

            fs.Seek(testpos, 0);
            int test = GetInt(fs);

            Print("Test Value: " + test);
            int start;

            if (test == 0)
            {
                start = testpos + 4;
            }
            else
            {
                start = testpos;
            }
            int end = start + 0x6C;

            Print("Start Position: 0x" + start.ToString("X8"));
            Print("End Position: 0x" + end.ToString("X8"));
            Print("Writing Header...");
            fs.Seek(0, 0);
            byte[] buff = new byte[end];
            fs.Read(buff, 0, end);
            fsout.Write(buff, 0, end);
            int pos = end;

            Print("Writing Names...");
            fsout.Seek(pos, 0);
            foreach (string s in pcc.Names)
            {
                pos += WriteName(fsout, s);
            }
            Print("Done. Pos = 0x" + pos.ToString("X8"));
            int NewImportStart = pos;

            Print("Writing Import Table...");
            foreach (PCCObject.ImportEntry i in pcc.Imports)
            {
                fsout.Write(i.data, 0, i.data.Length);
                pos += i.data.Length;
            }
            if (!isExport)
            {
                int len = pcc.Imports[Index].data.Length;
                fsout.Write(pcc.Imports[Index].data, 0, len);
                pos += len;
            }
            Print("Done. Pos = 0x" + pos.ToString("X8"));
            int NewExportStart = pos;

            Print("Writing Export Table...");
            int count = 0;

            foreach (PCCObject.ExportEntry ex in pcc.Exports)
            {
                fsout.Write(ex.info, 0, ex.info.Length);
                pcc.Exports[count++].offset = (uint)pos;
                pos += ex.info.Length;
            }
            if (isExport)
            {
                int len = pcc.Exports[Index].info.Length;
                fsout.Write(pcc.Exports[Index].info, 0, len);
                pos += len;
            }
            Print("Done. Pos = 0x" + pos.ToString("X8"));
            Print("Writing Exports Data...");
            for (int i = 0; i < pcc.Exports.Count; i++)
            {
                pcc.Exports[i].DataOffsetTmp = pos;
                fsout.Write(pcc.Exports[i].Data, 0, pcc.Exports[i].Data.Length);
                pos += pcc.Exports[i].Data.Length;
            }
            if (isExport)
            {
                DynamicByteProvider b = (DynamicByteProvider)hb1.ByteProvider;
                for (int i = 0; i < b.Length; i++)
                {
                    fsout.WriteByte(b.ReadByte(i));
                }
            }
            Print("Fixing Header...");
            if (isExport)
            {
                fsout.Seek(start + 8, 0);
                fsout.Write(BitConverter.GetBytes(pcc.Exports.Count + 1), 0, 4);
            }
            else
            {
                fsout.Seek(start + 16, 0);
                fsout.Write(BitConverter.GetBytes(pcc.Imports.Count + 1), 0, 4);
            }
            fsout.Seek(start, 0);
            fsout.Write(BitConverter.GetBytes(pcc.Names.Count), 0, 4);
            fsout.Write(BitConverter.GetBytes(end), 0, 4);
            fsout.Seek(start + 0xC, 0);
            fsout.Write(BitConverter.GetBytes(NewExportStart), 0, 4);
            fsout.Seek(start + 0x14, 0);
            fsout.Write(BitConverter.GetBytes(NewImportStart), 0, 4);
            int datastart = pcc.Exports[0].DataOffset;

            fsout.Write(BitConverter.GetBytes(datastart), 0, 4); //Fix zero page (start)
            fsout.Write(BitConverter.GetBytes(datastart), 0, 4); //make it zero :P(end)
            Print("Fixing Export Table...");
            for (int i = 0; i < pcc.Exports.Count; i++)
            {
                fsout.Seek(pcc.Exports[i].offset + 0x24, 0);
                fsout.Write(BitConverter.GetBytes(pcc.Exports[i].DataOffsetTmp), 0, 4);
            }
            if (isExport)
            {
                Print("Fixing Clone...");
                int clonestart = (int)pcc.Exports[pcc.Exports.Count - 1].offset + (int)pcc.Exports[pcc.Exports.Count - 1].info.Length;
                fsout.Seek(clonestart, 0);//Class
                if (listBox3.SelectedIndex != -1)
                {
                    fsout.Write(BitConverter.GetBytes(listBox3.SelectedIndex + 1), 0, 4);
                }
                if (listBox4.SelectedIndex != -1)
                {
                    fsout.Write(BitConverter.GetBytes(-listBox4.SelectedIndex - 1), 0, 4);
                }
                if (listBox7.SelectedIndex != -1)
                {
                    fsout.Write(BitConverter.GetBytes(0), 0, 4);
                }
                fsout.Seek(clonestart + 0x8, 0);//Link
                if (listBox5.SelectedIndex != -1)
                {
                    fsout.Write(BitConverter.GetBytes(listBox5.SelectedIndex + 1), 0, 4);
                }
                if (listBox6.SelectedIndex != -1)
                {
                    fsout.Write(BitConverter.GetBytes(-listBox6.SelectedIndex - 1), 0, 4);
                }
                if (listBox8.SelectedIndex != -1)
                {
                    fsout.Write(BitConverter.GetBytes(0), 0, 4);
                }
                fsout.Write(BitConverter.GetBytes(listBox9.SelectedIndex), 0, 4); //Name
                fsout.Seek(clonestart + 0x24, 0);                                 //DataOffset
                fsout.Write(BitConverter.GetBytes(pcc.Exports[pcc.Exports.Count - 1].DataOffsetTmp + pcc.Exports[pcc.Exports.Count - 1].Data.Length), 0, 4);
            }

            fsout.Close();
            fs.Close();
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            File.Move(path + "_tmp", path);
        }
Пример #12
0
        public void Save()
        {
            int tmp1, tmp2, size;

            if (pcc == null)
            {
                return;
            }
            MemoryStream m = new MemoryStream();

            m.Write(BitConverter.GetBytes(Unk1), 0, 4);
            foreach (PropertyReader.Property p in Props)
            {
                switch (pcc.getNameEntry(p.Name))
                {
                case "m_StartingList":
                    m.Write(p.raw, 0, 0x10);
                    m.Write(BitConverter.GetBytes(StartingList.Count * 4 + 4), 0, 4);
                    m.Write(BitConverter.GetBytes((int)0), 0, 4);
                    m.Write(BitConverter.GetBytes(StartingList.Count), 0, 4);
                    foreach (int i in StartingList)
                    {
                        m.Write(BitConverter.GetBytes(i), 0, 4);
                    }
                    break;

                case "m_EntryList":
                    tmp1 = (int)m.Position;
                    m.Write(p.raw, 0, 0x10);
                    m.Write(new byte[8], 0, 8);
                    m.Write(BitConverter.GetBytes(EntryList.Count), 0, 4);
                    size = 4;
                    foreach (EntryListStuct el in EntryList)
                    {
                        size += WriteEntryList(m, el);
                    }
                    tmp2 = (int)m.Position;
                    m.Seek(tmp1 + 0x10, 0);
                    m.Write(BitConverter.GetBytes(size), 0, 4);
                    m.Seek(tmp2, 0);
                    break;

                case "m_ReplyList":
                    tmp1 = (int)m.Position;
                    m.Write(p.raw, 0, 0x10);
                    m.Write(new byte[8], 0, 8);
                    m.Write(BitConverter.GetBytes(ReplyList.Count), 0, 4);
                    size = 4;
                    foreach (ReplyListStruct rp in ReplyList)
                    {
                        size += WriteReplyList(m, rp);
                    }
                    tmp2 = (int)m.Position;
                    m.Seek(tmp1 + 0x10, 0);
                    m.Write(BitConverter.GetBytes(size), 0, 4);
                    m.Seek(tmp2, 0);
                    break;

                case "m_aSpeakerList":
                    m.Write(p.raw, 0, 0x10);
                    m.Write(BitConverter.GetBytes(SpeakerList.Count * 8 + 4), 0, 4);
                    m.Write(BitConverter.GetBytes((int)0), 0, 4);
                    m.Write(BitConverter.GetBytes(SpeakerList.Count), 0, 4);
                    foreach (int i in SpeakerList)
                    {
                        m.Write(BitConverter.GetBytes((long)i), 0, 8);
                    }
                    break;

                case "m_aFemaleFaceSets":
                    m.Write(p.raw, 0, 0x10);
                    m.Write(BitConverter.GetBytes(FemaleFaceSets.Count * 4 + 4), 0, 4);
                    m.Write(BitConverter.GetBytes((int)0), 0, 4);
                    m.Write(BitConverter.GetBytes(FemaleFaceSets.Count), 0, 4);
                    foreach (int i in FemaleFaceSets)
                    {
                        m.Write(BitConverter.GetBytes(i), 0, 4);
                    }
                    break;

                case "m_aMaleFaceSets":
                    m.Write(p.raw, 0, 0x10);
                    m.Write(BitConverter.GetBytes(MaleFaceSets.Count * 4 + 4), 0, 4);
                    m.Write(BitConverter.GetBytes((int)0), 0, 4);
                    m.Write(BitConverter.GetBytes(MaleFaceSets.Count), 0, 4);
                    foreach (int i in MaleFaceSets)
                    {
                        m.Write(BitConverter.GetBytes(i), 0, 4);
                    }
                    break;

                case "m_aStageDirections":
                    tmp1 = (int)m.Position;
                    m.Write(p.raw, 0, 0x10);
                    m.Write(new byte[8], 0, 8);
                    m.Write(BitConverter.GetBytes(StageDirections.Count), 0, 4);
                    size = 4;
                    foreach (StageDirectionStruct sd in StageDirections)
                    {
                        size += WriteStageDirection(m, sd);
                    }
                    tmp2 = (int)m.Position;
                    m.Seek(tmp1 + 0x10, 0);
                    m.Write(BitConverter.GetBytes(size), 0, 4);
                    m.Seek(tmp2, 0);
                    break;

                default:
                    m.Write(p.raw, 0, p.raw.Length);
                    break;
                }
            }
            m.Write(BitConverter.GetBytes((int)0), 0, 4);
            pcc.Exports[MyIndex].Data = m.ToArray();
            pcc.altSaveToFile(pcc.pccFileName, true);
        }