private void treeView5_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode t = treeView5.SelectedNode;

            if (t == null || t.Nodes.Count != 0)
            {
                return;
            }
            string path = t.Text;

            while (t.Parent.Text != "Textures")
            {
                t    = t.Parent;
                path = t.Text + "/" + path;
            }
            listBox2.Items.Clear();
            ttprevlist = new List <DBAccess.TextureInformation>();
            int    count   = 0;
            string DAIpath = GlobalStuff.FindSetting("gamepath");

            foreach (DBAccess.TextureInformation tmp in ttlist)
            {
                if (tmp.name == path)
                {
                    ttprevlist.Add(tmp);
                    DBAccess.BundleInformation buni = DBAccess.GetBundleInformationByIndex(tmp.bundleIndex);
                    listBox2.Items.Add((count++) + " : " + buni.filepath.Substring(DAIpath.Length, buni.filepath.Length - DAIpath.Length) + " -> " + buni.bundlepath);
                }
            }
            if (listBox2.Items.Count > 0)
            {
                listBox2.SelectedIndex = 0;
            }
        }
示例#2
0
        private void createSingleModToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int n = listBox1.SelectedIndex;

            if (n == -1)
            {
                return;
            }
            MessageBox.Show("Please select replacement texture (same size)");
            OpenFileDialog d = new OpenFileDialog();

            d.Filter = "*.dds|*.dds";
            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                byte[] data = File.ReadAllBytes(d.FileName);
                MessageBox.Show("Please select mod save location");
                SaveFileDialog d2 = new SaveFileDialog();
                d2.Filter = "*.DAIMWV|*.DAIMWV";
                if (d2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    Mod mod = new Mod();
                    mod.jobs = new List <Mod.ModJob>();
                    Mod.ModJob mj = new Mod.ModJob();
                    mj.type        = 0;
                    mj.bundlePaths = new List <string>();
                    mj.tocPaths    = new List <string>();
                    int plen = GlobalStuff.FindSetting("gamepath").Length;
                    DBAccess.BundleInformation  buni = bil[n];
                    DBAccess.TextureInformation ti   = new DBAccess.TextureInformation();
                    foreach (DBAccess.TextureInformation t in til)
                    {
                        if (t.bundleIndex == buni.index)
                        {
                            ti = t;
                        }
                    }
                    DBAccess.TOCInformation toci = DBAccess.GetTocInformationByIndex(buni.tocIndex);
                    mj.respath = ti.name;
                    mj.bundlePaths.Add(buni.bundlepath);
                    mj.tocPaths.Add(toci.path.Substring(plen, toci.path.Length - plen));
                    MemoryStream m = new MemoryStream();
                    m.Write(data, 0x80, data.Length - 0x80);
                    mj.data = m.ToArray();
                    mod.jobs.Add(mj);
                    mod.Save(d2.FileName);
                    MessageBox.Show("Done.");
                }
            }
        }
示例#3
0
        private void listBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            rtb3.Text = "";
            int n = listBox3.SelectedIndex;

            if (n == -1)
            {
                return;
            }
            DBAccess.ChunkInformation  ci = cl[n];
            DBAccess.BundleInformation bi = DBAccess.GetBundleInformationByIndex(ci.bundleIndex);
            DBAccess.TOCInformation    ti = DBAccess.GetTocInformationByIndex(bi.tocIndex);
            rtb3.AppendText("Bundle Path : " + bi.bundlepath + "\n");
            rtb3.AppendText("TOC Path    : " + ti.path + "\n");
            rtb3.AppendText("In CAS      : " + ti.incas + "\n");
            rtb3.AppendText("SHA1        : " + Helpers.ByteArrayToHexString(ci.sha1) + "\n");
        }
示例#4
0
 private void RefreshPreview()
 {
     try
     {
         int n = listBox2.SelectedIndex;
         if (n == -1)
         {
             return;
         }
         status.Text = "Getting header infos from db...";
         Application.DoEvents();
         DBAccess.RESInformation    ti   = ttprevlist[n];
         DBAccess.BundleInformation buni = DBAccess.GetBundleInformationById(ti.bundlepath)[0];
         DBAccess.TOCInformation    toci = DBAccess.GetTocInformationByIndex(buni.tocIndex);
         byte[] resdata = new byte[0];
         if (toci.incas)
         {
             status.Text = "Getting header data from sha1...";
             Application.DoEvents();
             resdata = SHA1Access.GetDataBySha1(Helpers.HexStringToByteArray(ti.sha1));
         }
         else
         {
             status.Text = "Getting header data from binary bundle...";
             Application.DoEvents();
             TOCFile      toc        = new TOCFile(toci.path);
             byte[]       bundledata = toc.ExportBundleDataByPath(buni.bundlepath);
             BinaryBundle b          = new BinaryBundle(new MemoryStream(bundledata));
             foreach (BinaryBundle.ResEntry res in b.ResList)
             {
                 if (res._name == ti.resname)
                 {
                     resdata = res._data;
                     break;
                 }
             }
         }
         hb2.ByteProvider = new DynamicByteProvider(resdata);
         status.Text      = "Ready";
     }
     catch (Exception ex)
     {
         status.Text = "General error, after state '" + status.Text + "' : " + ex.Message;
     }
 }
        private void treeView3_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode t = treeView3.SelectedNode;

            if (t == null || t.Nodes == null || t.Nodes.Count != 0)
            {
                return;
            }
            string path = Helpers.GetPathFromNode(t, "/");

            for (int i = 0; i < tblist.Count; i++)
            {
                if (path.Contains(tblist[i].bundlepath))
                {
                    DBAccess.BundleInformation bi = tblist[i];
                    if (bi.isbase)
                    {
                        return;
                    }
                    TOCFile toc  = new TOCFile(bi.filepath);
                    byte[]  data = toc.ExportBundleDataByPath(bi.bundlepath);
                    Bundle  b    = null;
                    if (bi.incas)
                    {
                        List <BJSON.Entry> tmp = new List <BJSON.Entry>();
                        BJSON.ReadEntries(new MemoryStream(data), tmp);
                        b = Bundle.Create(tmp[0]);
                    }
                    else
                    {
                        b = Bundle.Create(data, true);
                    }
                    if (b == null)
                    {
                        return;
                    }
                    if (b.ebx == null)
                    {
                        b.ebx = new List <Bundle.ebxtype>();
                    }
                    if (b.res == null)
                    {
                        b.res = new List <Bundle.restype>();
                    }
                    if (b.chunk == null)
                    {
                        b.chunk = new List <Bundle.chunktype>();
                    }
                    int           total = b.ebx.Count + b.res.Count + b.chunk.Count;
                    StringBuilder sb    = new StringBuilder();
                    sb.AppendFormat("Total count : {0}\n", total);
                    sb.AppendFormat("EBX count   : {0}\n", b.ebx.Count);
                    sb.AppendFormat("RES count   : {0}\n", b.res.Count);
                    sb.AppendFormat("CHUNK count : {0}\n", b.chunk.Count);
                    rtb1.Text = sb.ToString();
                    DBAccess.BundleInformation[] dupBun = DBAccess.GetBundleInformationById(bi.bundlepath);
                    listBox3.Items.Clear();
                    int count = 0;
                    int l     = GlobalStuff.FindSetting("gamepath").Length;
                    foreach (DBAccess.BundleInformation dup in dupBun)
                    {
                        DBAccess.TOCInformation ti = DBAccess.GetTocInformationByIndex(dup.tocIndex);
                        listBox3.Items.Add((count++) + " : " + ti.path.Substring(l, ti.path.Length - l) + " -> Delta:" + dup.isdelta + " Base:" + dup.isbase);
                    }
                }
            }
        }
示例#6
0
 private void RefreshPreview()
 {
     try
     {
         int n = listBox2.SelectedIndex;
         if (n == -1)
         {
             return;
         }
         status.Text = "Getting header infos from db...";
         Application.DoEvents();
         DBAccess.RESInformation    ti   = ttprevlist[n];
         DBAccess.BundleInformation buni = DBAccess.GetBundleInformationById(ti.bundlepath)[0];
         DBAccess.TOCInformation    toci = DBAccess.GetTocInformationByIndex(buni.tocIndex);
         BinaryBundle b       = new BinaryBundle();
         byte[]       resdata = new byte[0];
         if (toci.incas)
         {
             status.Text = "Getting header data from sha1...";
             Application.DoEvents();
             resdata = SHA1Access.GetDataBySha1(Helpers.HexStringToByteArray(ti.sha1));
         }
         else
         {
             status.Text = "Getting header data from binary bundle...";
             Application.DoEvents();
             TOCFile toc        = new TOCFile(toci.path);
             byte[]  bundledata = toc.ExportBundleDataByPath(buni.bundlepath);
             b = new BinaryBundle(new MemoryStream(bundledata));
             foreach (BinaryBundle.ResEntry res in b.ResList)
             {
                 if (res._name == ti.resname)
                 {
                     resdata = res._data;
                     break;
                 }
             }
         }
         hb2.ByteProvider = new DynamicByteProvider(resdata);
         Mesh mesh = new Mesh(new MemoryStream(resdata));
         foreach (Mesh.MeshLOD lod in mesh.header.LODs)
         {
             byte[] id   = lod.ChunkID;
             byte[] data = new byte[0];
             if (toci.incas)
             {
                 DBAccess.ChunkInformation ci = DBAccess.GetChunkInformationById(id);
                 if (ci.sha1 == null)
                 {
                     continue;
                 }
                 data = SHA1Access.GetDataBySha1(ci.sha1);
             }
             else
             {
                 byte t = id[0];
                 id[0] = id[3];
                 id[3] = t;
                 t     = id[1];
                 id[1] = id[2];
                 id[2] = t;
                 t     = id[6];
                 id[6] = id[7];
                 id[7] = t;
                 t     = id[4];
                 id[4] = id[5];
                 id[5] = t;
                 foreach (BinaryBundle.ChunkEntry c in b.ChunkList)
                 {
                     if (Helpers.ByteArrayCompare(id, c.id))
                     {
                         data = c._data;
                     }
                 }
                 if (data.Length == 0)
                 {
                     DBAccess.ChunkInformation ci = DBAccess.GetChunkInformationById(id);
                     if (ci.sha1 == null)
                     {
                         continue;
                     }
                     data = SHA1Access.GetDataBySha1(ci.sha1);
                 }
             }
             mesh.LoadChunkData(lod, new MemoryStream(data));
         }
         MeshRenderObject mro = new MeshRenderObject(mesh);
         renderer.list.Clear();
         renderer.list.Add(mro);
         renderer.worldoffset = -mro.center;
         renderer.CamDistance = mro.min.Length() + mro.max.Length();
         status.Text          = "Ready";
     }
     catch (Exception ex)
     {
         status.Text = "General error, after state '" + status.Text + "' : " + ex.Message;
     }
 }
示例#7
0
        private void createForAllDupsModToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Please select replacement texture (same size)");
            OpenFileDialog d = new OpenFileDialog();

            d.Filter = "*.dds|*.dds";
            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                byte[] data = File.ReadAllBytes(d.FileName);
                MessageBox.Show("Please select mod save location");
                SaveFileDialog d2 = new SaveFileDialog();
                d2.Filter = "*.DAIMWV|*.DAIMWV";
                if (d2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    Mod mod = new Mod();
                    mod.jobs = new List <Mod.ModJob>();
                    Mod.ModJob mj = new Mod.ModJob();
                    mj.type        = 0;
                    mj.bundlePaths = new List <string>();
                    mj.tocPaths    = new List <string>();
                    int  plen = GlobalStuff.FindSetting("gamepath").Length;
                    bool skip = false;
                    for (int i = 0; i < bil.Length; i++)
                    {
                        DBAccess.BundleInformation  buni = bil[i];
                        DBAccess.TextureInformation ti   = new DBAccess.TextureInformation();
                        foreach (DBAccess.TextureInformation t in til)
                        {
                            if (t.bundleIndex == buni.index)
                            {
                                ti = t;
                            }
                        }
                        DBAccess.TOCInformation toci = DBAccess.GetTocInformationByIndex(buni.tocIndex);
                        mj.respath = ti.name;
                        skip       = false;
                        foreach (string p in mj.bundlePaths)
                        {
                            if (p == buni.bundlepath)
                            {
                                skip = true;
                                break;
                            }
                        }
                        if (!skip)
                        {
                            mj.bundlePaths.Add(buni.bundlepath);
                        }
                        string tpath = toci.path.Substring(plen, toci.path.Length - plen);
                        skip = false;
                        foreach (string p in mj.tocPaths)
                        {
                            if (p == tpath)
                            {
                                skip = true;
                                break;
                            }
                        }
                        if (tpath.ToLower().Contains("\\patch\\"))
                        {
                            skip = true;
                        }
                        if (!skip)
                        {
                            mj.tocPaths.Add(tpath);
                        }
                    }
                    MemoryStream m = new MemoryStream();
                    m.Write(data, 0x80, data.Length - 0x80);
                    mj.data = m.ToArray();
                    mod.jobs.Add(mj);
                    mod.Save(d2.FileName);
                    MessageBox.Show("Done.");
                }
            }
        }
示例#8
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int n = listBox1.SelectedIndex;

            if (n == -1)
            {
                return;
            }
            try
            {
                statustext.Text = "Getting header infos from db...";
                Application.DoEvents();
                hb1.ByteProvider = new DynamicByteProvider(new byte[0]);
                if (File.Exists("tmp\\tmp.dds"))
                {
                    File.Delete("tmp\\tmp.dds");
                }

                DBAccess.BundleInformation  buni = bil[n];
                DBAccess.TextureInformation ti   = new DBAccess.TextureInformation();
                foreach (DBAccess.TextureInformation t in til)
                {
                    if (t.bundleIndex == buni.index)
                    {
                        ti = t;
                    }
                }
                DBAccess.TOCInformation toci = DBAccess.GetTocInformationByIndex(buni.tocIndex);
                byte[] resdata = new byte[0];
                if (toci.incas)
                {
                    statustext.Text = "Getting header data from sha1...";
                    Application.DoEvents();
                    resdata = SHA1Access.GetDataBySha1(ti.sha1);
                }
                else
                {
                    statustext.Text = "Getting header data from binary bundle...";
                    Application.DoEvents();
                    TOCFile      toc        = new TOCFile(toci.path);
                    byte[]       bundledata = toc.ExportBundleDataByPath(buni.bundlepath);
                    BinaryBundle b          = new BinaryBundle(new MemoryStream(bundledata));
                    foreach (BinaryBundle.ResEntry res in b.ResList)
                    {
                        if (res._name == ti.name)
                        {
                            resdata = res._data;
                            break;
                        }
                    }
                }
                hb1.ByteProvider = new DynamicByteProvider(resdata);
                statustext.Text  = "Getting texture infos from db...";
                Application.DoEvents();
                TextureMetaResource       tmr = new TextureMetaResource(resdata);
                DBAccess.ChunkInformation ci  = DBAccess.GetChunkInformationById(tmr.chunkid);
                if (ci.bundleIndex == -1)
                {
                    throw new Exception("no chunk info found in db");
                }
                DBAccess.BundleInformation buni2 = DBAccess.GetBundleInformationByIndex(ci.bundleIndex);
                DBAccess.TOCInformation    toci2 = DBAccess.GetTocInformationByIndex(buni2.tocIndex);
                byte[] texdata = new byte[0];
                if (toci2.incas)
                {
                    statustext.Text = "Getting texture data from sha1...";
                    Application.DoEvents();
                    texdata = SHA1Access.GetDataBySha1(ci.sha1);
                }
                else
                {
                    statustext.Text = "Getting texture data from binary bundle...";
                    Application.DoEvents();
                    TOCFile      toc        = new TOCFile(toci2.path);
                    byte[]       bundledata = toc.ExportBundleDataByPath(buni2.bundlepath);
                    BinaryBundle b          = new BinaryBundle(new MemoryStream(bundledata));
                    foreach (BinaryBundle.ChunkEntry chunk in b.ChunkList)
                    {
                        if (Helpers.MatchByteArray(chunk.id, ci.id))
                        {
                            texdata = chunk._data;
                            break;
                        }
                    }
                }
                hb2.ByteProvider = new DynamicByteProvider(texdata);
                statustext.Text  = "Making Preview...";
                Application.DoEvents();
                MemoryStream m = new MemoryStream();
                tmr.WriteTextureHeader(m);
                m.Write(texdata, 0, texdata.Length);
                if (!Directory.Exists("tmp"))
                {
                    Directory.CreateDirectory("tmp");
                }
                File.WriteAllBytes("tmp\\tmp.dds", m.ToArray());
                try
                {
                    pb1.Image = DevIL.DevIL.LoadBitmap("tmp\\tmp.dds");
                    pb1.BringToFront();
                }
                catch (Exception)
                {
                    statustext.Text = "Error loading dds, after state '" + statustext.Text + "'";
                }
                statustext.Text = "Ready";
            }
            catch (Exception)
            {
                statustext.Text = "General error, after state '" + statustext.Text + "'";
            }
        }