示例#1
0
        public CollisionTahPageControl(CollisionItem argCollisionEntry)
        {
            InitializeComponent();
            collisionEntry = argCollisionEntry;
            Text           = Path.GetFileName(collisionEntry.tah.path);

            TDCGExplorer.TDCGExplorer.SetToolTips(Text);

            DataTable data = new DataTable();

            data.Columns.Add(TextResource.CollisionFrom, Type.GetType("System.String"));
            data.Columns.Add(TextResource.CollisionTo, Type.GetType("System.String"));
            data.Columns.Add(TextResource.CollisionedTAH, Type.GetType("System.String"));
            foreach (ArcsCollisionRecord col in collisionEntry.entries)
            {
                ArcsDatabase db = TDCGExplorer.TDCGExplorer.ArcsDB;
                // 衝突した先のtahを取得する.
                ArcsTahEntry to = db.GetTah(col.toTahID);
                // 既に同じ名前で追加していないか調べる.
                ArcsTahFilesEntry fromfile = db.GetTahFilesEntry(col.fromFilesID);
                ArcsTahFilesEntry tofile   = db.GetTahFilesEntry(col.toFilesID);
                DataRow           row      = data.NewRow();
                string[]          content  = { fromfile.GetDisplayPath(), tofile.GetDisplayPath().ToLower(), to.shortname };
                row.ItemArray = content;
                data.Rows.Add(row);
            }
            dataGridView.DataSource            = data;
            dataGridView.AutoSizeColumnsMode   = DataGridViewAutoSizeColumnsMode.AllCells;
            dataGridView.ReadOnly              = true;
            dataGridView.AllowUserToAddRows    = false;
            dataGridView.AllowUserToDeleteRows = false;

            selectIndex(0);
        }
示例#2
0
        private string FindFromArcsTahs(string filename, int id)
        {
            string retval = "";

            List <ArcsTahFilesEntry> files = TDCGExplorer.TDCGExplorer.ArcsDB.GetTahFilesEntry(TAHUtil.CalcHash("script/" + filename + ".tbn"));

            if (files.Count > 0)
            {
                ArcsTahFilesEntry file = null;
                ArcsTahEntry      tah  = null;
                int pastVersion        = -1;
                foreach (ArcsTahFilesEntry subfile in files)
                {
                    ArcsTahEntry subtah = TDCGExplorer.TDCGExplorer.ArcsDB.GetTah(subfile.tahid);
                    if (subtah.version > pastVersion)
                    {
                        file        = subfile;
                        tah         = subtah;
                        pastVersion = subtah.version;
                    }
                }
                if (tah != null)
                {
                    retval = tah.path;
                    LoadTso(new GenericArcsTahInfo(tah), file, id);
                }
            }
            //TDCGExplorer.TDCGExplorer.FigureLoad = true;
            return(retval);
        }
示例#3
0
        private string FindFromZipTahs(string filename, int id)
        {
            string retval = "";

            List <ArcsTahFilesEntry> files = TDCGExplorer.TDCGExplorer.ArcsDB.GetZipTahFilesEntries(TAHUtil.CalcHash("script/" + filename + ".tbn"));

            if (files.Count > 0)
            {
                ArcsTahFilesEntry file = null;
                ArcsZipTahEntry   tah  = null;
                int pastVersion        = -1;
                foreach (ArcsTahFilesEntry subfile in files)
                {
                    ArcsZipTahEntry subtah = TDCGExplorer.TDCGExplorer.ArcsDB.GetZipTah(subfile.tahid);
                    if (subtah.version > pastVersion)
                    {
                        file        = subfile;
                        tah         = subtah;
                        pastVersion = subtah.version;
                    }
                }
                if (tah != null)
                {
                    ArcsZipArcEntry zip = TDCGExplorer.TDCGExplorer.ArcsDB.GetZip(tah.zipid);
                    if (zip != null)
                    {
                        retval = Path.GetDirectoryName(zip.path) + "\\" + zip.GetDisplayPath() + "\\" + tah.path;
                        LoadTso(new GenericZipsTahInfo(tah), file, id);
                    }
                }
            }
            return(retval);
        }
示例#4
0
        public static void ArcsDumpTahFilesEntries(ArcsDatabase db, ArcsTahEntry entry, TAHFile tah)
        {
            string source   = Path.Combine(TDCGExplorer.SystemDB.arcs_path, entry.path);
            int    tahentry = 0;

            foreach (TAHEntry ent in tah.EntrySet.Entries)
            {
                if (ent.FileName == null)
                {
                    TDCGExplorer.SetToolTips("Dump " + ent.Hash.ToString("x8") + " file");
                }
                else
                {
                    TDCGExplorer.SetToolTips("Dump " + ent.FileName + " file");
                }
                ArcsTahFilesEntry fileentry = new ArcsTahFilesEntry();
                fileentry.id       = 0;
                fileentry.tahid    = entry.id;
                fileentry.tahentry = tahentry++;
                fileentry.path     = ent.FileName;
                if (entry.path == null)
                {
                    entry.path = "";
                }
                fileentry.hash   = (int)ent.Hash;
                fileentry.length = (int)ent.Length;
                db.SetTahFilesPath(fileentry);
            }
        }
示例#5
0
        private void selectIndex(int index)
        {
            ArcsCollisionRecord col = collisionEntry.entries[index];

            ArcsDatabase db = TDCGExplorer.TDCGExplorer.ArcsDB;
            // 衝突した先のtahを取得する.
            ArcsTahEntry from = db.GetTah(col.fromTahID);
            ArcsTahEntry to   = db.GetTah(col.toTahID);
            // 既に同じ名前で追加していないか調べる.
            ArcsTahFilesEntry fromfile = db.GetTahFilesEntry(col.fromFilesID);
            ArcsTahFilesEntry tofile   = db.GetTahFilesEntry(col.toFilesID);

            string text =
                @"<p>" +
                @"<h2> " + TextResource.CollisionHTML_CollisionFrom + " : " + from.shortname + "</h2>" +
                @"<adress>" + TextResource.Directory + " : " + Path.GetDirectoryName(from.path) + "</adress>" +
                @"<h3> " + TextResource.CollisionHTML_CollisionTo + " : " + to.shortname + "</h3>" +
                @"<adress>" + TextResource.Directory + " : " + Path.GetDirectoryName(to.path) + "</adress>" +
                @"<pre>" + fromfile.GetDisplayPath().ToLower() + " --> " + tofile.GetDisplayPath().ToLower() + "</pre>" +
                @"<pre>" + TextResource.HashCode + " : " + tofile.hash.ToString("x8") + "</pre>";

            webBrowser.DocumentText = text;

            try
            {
                string filename = fromfile.GetDisplayPath().ToLower();
                if (Path.GetExtension(filename) == ".tso")
                {
                    // TSOを表示する.
                    using (GenericTAHStream tahstream = new GenericTAHStream(new GenericArcsTahInfo(from), fromfile))
                    {
                        Cursor.Current = Cursors.WaitCursor;
                        TDCGExplorer.TDCGExplorer.MainFormWindow.makeTSOViwer();
                        TDCGExplorer.TDCGExplorer.MainFormWindow.clearTSOViewer();
                        TDCGExplorer.TDCGExplorer.MainFormWindow.Viewer.LoadTSOFile(tahstream.stream);
                        if (TDCGExplorer.TDCGExplorer.SystemDB.loadinitialpose)
                        {
                            TDCGExplorer.TDCGExplorer.MainFormWindow.doInitialTmoLoad();                                                    // 初期tmoを読み込む.
                        }
                        // カメラをセンター位置に.
                        TSOCameraAutoCenter camera = new TSOCameraAutoCenter(TDCGExplorer.TDCGExplorer.MainFormWindow.Viewer);
                        camera.UpdateCenterPosition(fromfile.path.ToUpper());
                        // 次回カメラが必ずリセットされる様にする.
                        TDCGExplorer.TDCGExplorer.MainFormWindow.setNeedCameraReset();
                        Cursor.Current = Cursors.Default;
                        //TDCGExplorer.TDCGExplorer.FigureLoad = false;
                    }
                }
            }
            catch (Exception)
            {
            }
        }
示例#6
0
 public LoadTsoInfo(GenericTahInfo itinfo, ArcsTahFilesEntry itfile, int itid)
 {
     info = itinfo;
     file = itfile;
     id   = itid;
 }
示例#7
0
        private void assembleTsoData()
        {
            foreach (LoadTsoInfo tsoload in loadtsoinfo)
            {
                GenericTahInfo    info = tsoload.info;
                ArcsTahFilesEntry file = tsoload.file;
                int id = tsoload.id;
                try
                {
                    // tso名を取得する.
                    string tsoname;
                    using (GenericTAHStream tahstream = new GenericTAHStream(info, file))
                    {
                        using (MemoryStream memorystream = new MemoryStream())
                        {
                            ZipFileUtil.CopyStream(tahstream.stream, memorystream);
                            tsoname = TDCGTbnUtil.GetTsoName(memorystream.ToArray());
                        }
                    }

                    GenericTahInfo    tsoinfo = null;
                    ArcsTahFilesEntry tso     = null;
                    if (info.zipid < 0)
                    {// Arcsの場合
                        int                      pastVersion = -1;
                        ArcsTahEntry             tahinfo     = null;
                        List <ArcsTahFilesEntry> tsos        = TDCGExplorer.TDCGExplorer.ArcsDB.GetTahFilesEntry(TAHUtil.CalcHash(tsoname));
                        foreach (ArcsTahFilesEntry subfile in tsos)
                        {
                            ArcsTahEntry subtah = TDCGExplorer.TDCGExplorer.ArcsDB.GetTah(subfile.tahid);
                            if (subtah.version > pastVersion)
                            {
                                tso         = subfile;
                                tahinfo     = subtah;
                                pastVersion = subtah.version;
                            }
                        }
                        tsoinfo = new GenericArcsTahInfo(tahinfo);
                    }
                    else
                    {// zipの場合
                        int                      pastVersion = -1;
                        ArcsZipTahEntry          tahinfo     = null;
                        List <ArcsTahFilesEntry> tsos        = TDCGExplorer.TDCGExplorer.ArcsDB.GetZipTahFilesEntries(TAHUtil.CalcHash(tsoname));
                        foreach (ArcsTahFilesEntry subfile in tsos)
                        {
                            ArcsZipTahEntry subtah = TDCGExplorer.TDCGExplorer.ArcsDB.GetZipTah(subfile.tahid);
                            if (subtah.version > pastVersion)
                            {
                                tso         = subfile;
                                tahinfo     = subtah;
                                pastVersion = subtah.version;
                            }
                        }
                        tsoinfo = new GenericZipsTahInfo(tahinfo);
                    }
                    if (tsoinfo != null && tso != null)
                    {
                        // TSOを読み込む
                        using (GenericTAHStream tahstream = new GenericTAHStream(tsoinfo, tso))
                        {
                            using (MemoryStream memorystream = new MemoryStream())
                            {
                                ZipFileUtil.CopyStream(tahstream.stream, memorystream);
                                PNGTsoData tsodata = new PNGTsoData();
                                tsodata.tsoID   = (uint)id;
                                tsodata.tsodata = memorystream.ToArray();
                                tsoDataList.Add(tsodata);
                            }
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
        }
示例#8
0
        private void LoadTso(GenericTahInfo info, ArcsTahFilesEntry file, int id)
        {
            LoadTsoInfo tsoinfo = new LoadTsoInfo(info, file, id);

            loadtsoinfo.Add(tsoinfo);
        }
示例#9
0
        public static void DumpArcEntries(ArcsDatabase db, string source_file, IArchive arc, int id)
        {
            try
            {
                TDCGExplorer.LastAccessFile = source_file;
                arc.Open(source_file);

                foreach (IArchiveEntry entry in arc)
                {
                    // ディレクトリのみの場合はスキップする.
                    if (entry.IsDirectory == true)
                    {
                        continue;
                    }

                    // TAHファイルなら詳細をダンプする.
                    if (Path.GetExtension(entry.FileName) == ".tah")
                    {
                        using (MemoryStream ms = new MemoryStream((int)entry.Size))
                        {
                            arc.Extract(entry, ms);
                            ms.Seek(0, SeekOrigin.Begin);

                            using (TAHFile tah = new TAHFile(ms))
                            {
                                try
                                {
                                    tah.LoadEntries();
                                }
                                catch (Exception ex)
                                {
                                    Debug.WriteLine("Error: " + ex);
                                    continue;
                                }

                                ArcsZipTahEntry ziptahentry = new ArcsZipTahEntry();
                                ziptahentry.id        = 0;
                                ziptahentry.path      = entry.FileName;
                                ziptahentry.shortname = Path.GetFileName(entry.FileName).ToLower();
                                ziptahentry.version   = (int)tah.Header.Version;
                                ziptahentry.zipid     = id;
                                int tahid = db.SetZipTahEntry(ziptahentry);

                                int tahentry = 0;
                                foreach (TAHEntry ent in tah.EntrySet.Entries)
                                {
                                    if (ent.FileName == null)
                                    {
                                        TDCGExplorer.SetToolTips("Dump " + ent.Hash.ToString("x8") + " file");
                                    }
                                    else
                                    {
                                        TDCGExplorer.SetToolTips("Dump " + Path.GetFileName(ent.FileName) + " file");
                                    }
                                    ArcsTahFilesEntry fileentry = new ArcsTahFilesEntry();
                                    fileentry.id       = 0;
                                    fileentry.tahid    = tahid;
                                    fileentry.tahentry = tahentry++;
                                    fileentry.path     = ent.FileName;
                                    if (fileentry.path == null)
                                    {
                                        fileentry.path = "";
                                    }
                                    //fileentry.md5sum = "";
                                    fileentry.hash   = (int)ent.Hash;
                                    fileentry.length = (int)ent.Length;
                                    db.SetZipTahFilesPath(fileentry);
                                }
                            }
                        }
                    }
                    else
                    {
                        // tahファイル以外はファイル名のみ情報を格納する.
                        ArcsZipTahEntry ziptahentry = new ArcsZipTahEntry();
                        ziptahentry.id      = 0;
                        ziptahentry.path    = entry.FileName;
                        ziptahentry.version = 0;
                        ziptahentry.zipid   = id;
                        int tahid = db.SetZipTahEntry(ziptahentry);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error: " + ex);
                return;
            }
        }
示例#10
0
        public GenericTAHStream(GenericTahInfo info, ArcsTahFilesEntry tsoInfo)
        {
            // zipファイルの中か?
            if (info.zipid != -1)
            {
                ArcsZipArcEntry zip     = TDCGExplorer.ArcsDB.GetZip(info.zipid);
                string          zippath = Path.Combine(TDCGExplorer.SystemDB.zips_path, zip.path);
                switch (Path.GetExtension(zip.path).ToLower())
                {
                case ".zip":
                    archive = new ZipArchive();
                    break;

                case ".lzh":
                    archive = new LzhArchive();
                    break;

                case ".rar":
                    archive = new RarArchive();
                    break;

                default:
                    archive = new DirectAccessArchive();
                    break;
                }
                TDCGExplorer.LastAccessFile = zippath;
                archive.Open(zippath);
                if (archive == null)
                {
                    throw new Exception(TextResource.ArchiveIsNull);
                }

                //
                foreach (IArchiveEntry entry in archive)
                {
                    // ディレクトリのみの場合はスキップする.
                    if (entry.IsDirectory == true)
                    {
                        continue;
                    }
                    // マッチするファイルを見つけた.
                    if (entry.FileName == info.path)
                    {
                        ms = new MemoryStream((int)entry.Size);

                        archive.Extract(entry, ms);
                        ms.Seek(0, SeekOrigin.Begin);
                        tah = new TAHFile(ms);
                        tah.LoadEntries();
                        if (tsoInfo == null)
                        {
                            return;
                        }
                        int tahentry = 0;
                        foreach (TAHEntry ent in tah.EntrySet.Entries)
                        {
                            // 該当ファイルを見つけた.
                            if (tahentry == tsoInfo.tahentry)
                            {
                                byte[] data = TAHUtil.ReadEntryData(tah.Reader, ent);
                                //
                                Cursor.Current = Cursors.WaitCursor;
                                ims            = new MemoryStream(data);
                                return;
                            }
                            tahentry++;
                        }
                    }
                }
            }
            else
            {
                string source = Path.Combine(TDCGExplorer.SystemDB.arcs_path, info.path);
                tah = new TAHFile(source);
                tah.LoadEntries();
                if (tsoInfo == null)
                {
                    return;
                }
                int tahentry = 0;
                foreach (TAHEntry ent in tah.EntrySet.Entries)
                {
                    // 該当ファイルを見つけた.
                    if (tahentry == tsoInfo.tahentry)
                    {
                        byte[] data = TAHUtil.ReadEntryData(tah.Reader, ent);
                        //
                        ims = new MemoryStream(data);
                        return;
                    }
                    tahentry++;
                }
            }
            throw new Exception("TAH内のファイルが見つかりません");
        }