Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
        private void dataGridView_DoubleClick(object sender, EventArgs e)
        {
            int index = dataGridView.CurrentCell.RowIndex;

            if (index >= 0)
            {
                // TAHを取得する.
                ArcsTahEntry tah = TDCGExplorer.TDCGExplorer.ArcsDB.GetTah(missings[index].id);
                TDCGExplorer.TDCGExplorer.SelectArcsTreeNode(Path.Combine(TDCGExplorer.TDCGExplorer.SystemDB.arcs_path, tah.path));
            }
        }
Exemplo n.º 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)
            {
            }
        }
Exemplo n.º 6
0
        private void toolStripMenuItemEditTah_Click(object sender, EventArgs e)
        {
            if (TDCGExplorer.TDCGExplorer.BusyTest() == true)
            {
                return;
            }

            ArcsCollisionRecord col  = collisionEntry.entries[0];
            ArcsDatabase        db   = TDCGExplorer.TDCGExplorer.ArcsDB;
            ArcsTahEntry        from = db.GetTah(col.fromTahID);

            LBFileTahUtl.OpenTahEditor(new GenericArcsTahInfo(from));
        }
Exemplo n.º 7
0
        public static void ArcsDumpDirEntries(string dir, ArcsDatabase db)
        {
            bool skipflag = false;

            string[] shortnames = dir.Split('\\');
            foreach (string shortname in shortnames)
            {
                if (shortname[0] == '!')
                {
                    skipflag = true;
                }
            }
            if (skipflag)
            {
                return;           // !で始まるディレクトリはスキップ
            }
            string[] tah_files = Directory.GetFiles(dir, "*.TAH");
            foreach (string file in tah_files)
            {
                // 既にdb上にエントリがあるか調べる.
                //string tahid = db.GetTahID(file.Substring(arcspath.Length + 1));
                ArcsTahEntry tah = db.GetTah(file.Substring(arcspath.Length + 1));
                if (tah != null)
                {
                    // 日付が一致するか?
                    DateTime datetime = File.GetLastWriteTime(file);
                    if (tah.datetime.ToString() == datetime.ToString())
                    {
                        // 該当するエントリの存在フラグを立てる.
                        TDCGExplorer.SetToolTips("Update " + Path.GetFileName(file));
                        db.UpdateTahExistUp(tah.id);
                        continue;
                    }
                    else
                    {
                        // dbから一旦削除する.
                        db.DeleteTah(tah.id);
                    }
                }
                TDCGExplorer.LastAccessFile = file;
                using (FileStream source = File.OpenRead(file))
                {
                    ArcsDumpTAHEntries(source, db, file);
                }
            }
            string[] entries = Directory.GetDirectories(dir);
            foreach (string entry in entries)
            {
                ArcsDumpDirEntries(entry, db);
            }
        }
Exemplo n.º 8
0
        // TAHからファイルを読み取る.
        private byte[] getTahFile(string file)
        {
            TDCGExplorer.ArcsDatabase arcDB = TDCGExplorer.TDCGExplorer.ArcsDB;
            string filename = file.ToLower();

            byte[] filedata = null;

            List <ArcsTahFilesEntry> tahs = arcDB.GetTahFilesEntry(TDCGExplorer.TAHUtil.CalcHash(filename));

            foreach (ArcsTahFilesEntry tahfile in tahs)
            {
                if (tahfile.path.ToLower() == filename)
                {
                    ArcsTahEntry arcs = arcDB.GetTah(tahfile.tahid);
                    using (Stream file_stream = File.OpenRead(Path.Combine(TDCGExplorer.TDCGExplorer.SystemDB.arcs_path, arcs.path)))
                    {
                        TAHFile tah = new TAHFile(file_stream);
                        try
                        {
                            tah.LoadEntries();
                            foreach (TAHEntry ent in tah.EntrySet.Entries)
                            {
                                if (ent.FileName != null && ent.FileName.ToLower() == filename)
                                {
                                    filedata = TAHUtil.ReadEntryData(tah.Reader, ent);
                                    break;
                                }
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                    break;
                }
            }
            return(filedata);
        }
Exemplo n.º 9
0
        public static void ArcsDumpTAHEntries(Stream source, ArcsDatabase db, string tahname)
        {
            try
            {
                TDCGExplorer.SetToolTips("Processing " + Path.GetFileName(tahname));
                using (TAHFile tah = new TAHFile(source))
                {
                    try
                    {
                        tah.LoadEntries();
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine("Error: " + ex);
                        return;
                    }

                    DateTime datetime = File.GetLastWriteTime(tahname);

                    ArcsTahEntry entry = new ArcsTahEntry();
                    entry.path      = tahname.Substring(arcspath.Length + 1);
                    entry.shortname = Path.GetFileName(tahname).ToLower();
                    entry.version   = (int)tah.Header.Version;
                    entry.id        = 0;
                    entry.exist     = 1;
                    entry.datetime  = datetime;

                    entry.id = db.SetTahEntry(entry);
                    ArcsDumpTahFilesEntries(db, entry, tah);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error: " + ex);
                return;
            }
        }
Exemplo n.º 10
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)
                {
                }
            }
        }
Exemplo n.º 11
0
 public GenericArcsTahInfo(ArcsTahEntry entry)
 {
     tahEntry = entry;
 }
Exemplo n.º 12
0
 public LbFileItem(ArcsTahEntry argentry)
 {
     entry = argentry;
 }
Exemplo n.º 13
0
        public void Run()
        {
            TDCGExplorer.TDCGExplorer.IncBusy();
            ArcsDatabase arcDB = TDCGExplorer.TDCGExplorer.ArcsDB;
            // TAHを列挙する.
            List <ArcsTahEntry> tahs = arcDB.GetTahs();

            foreach (ArcsTahEntry tah in tahs)
            {
                TDCGExplorer.TDCGExplorer.SetToolTips("検索中:" + tah.shortname);
                if (HasString(tah.path, keyword))
                {
                    FindEntryInformation entry = new FindEntryInformation();
                    entry.category = 0; // arcs
                    entry.path     = String.Copy(tah.path);
                    entry.file     = Path.GetFileName(tah.path);
                    control.asyncDisplayFromArcs(entry);
                }
            }

            if (flagtahlevelsearch)
            {
                List <ArcsTahFilesEntry> files = arcDB.GetTahFilesPathHasString(keyword);
                foreach (ArcsTahFilesEntry file in files)
                {
                    ArcsTahEntry         tah   = arcDB.GetTah(file.tahid);
                    FindEntryInformation entry = new FindEntryInformation();
                    entry.category = 0; // arcs
                    entry.path     = String.Copy(tah.path);
                    entry.file     = String.Copy(file.GetDisplayPath());
                    control.asyncDisplayFromArcs(entry);
                }
            }

            if (flagzipsearch)
            {
                List <ArcsZipArcEntry> zips = arcDB.GetZips();
                foreach (ArcsZipArcEntry zip in zips)
                {
                    TDCGExplorer.TDCGExplorer.SetToolTips(TextResource.Searching + ":" + zip.GetDisplayPath());
                    if (HasString(zip.GetDisplayPath(), keyword))
                    {
                        FindEntryInformation entry = new FindEntryInformation();
                        entry.category = 1; //zips
                        entry.path     = String.Copy(Path.GetDirectoryName(zip.path) + "\\" + zip.GetDisplayPath());
                        entry.file     = zip.GetDisplayPath();
                        control.asyncDisplayFromArcs(entry);
                    }
                }
                //  LIKE文で総当たりする.
                List <ArcsZipTahEntry> ziptahs = arcDB.GetZipTahsHasString(keyword);
                foreach (ArcsZipTahEntry tah in ziptahs)
                {
                    ArcsZipArcEntry      subzip = arcDB.GetZip(tah.zipid);
                    FindEntryInformation entry  = new FindEntryInformation();
                    entry.category = 1; //zips
                    entry.path     = String.Copy(Path.GetDirectoryName(subzip.path) + "\\" + subzip.GetDisplayPath());
                    entry.file     = tah.shortname;
                    control.asyncDisplayFromArcs(entry);
                }
            }

            if (flagzipsearch && flagtahlevelsearch)
            {
                List <ArcsTahFilesEntry> files = arcDB.GetTahFilesPathHasString(keyword);
                foreach (ArcsTahFilesEntry file in files)
                {
                    ArcsZipTahEntry      tah   = arcDB.GetZipTah(file.tahid);
                    ArcsZipArcEntry      zip   = arcDB.GetZip(tah.zipid);
                    FindEntryInformation entry = new FindEntryInformation();
                    entry.category = 1; //zips
                    entry.path     = String.Copy(zip.path + "\\" + zip.GetDisplayPath());
                    entry.file     = String.Copy(file.GetDisplayPath());
                    control.asyncDisplayFromArcs(entry);
                }
            }

            // TBN辞書をセットして終了
            TDCGExplorer.TDCGExplorer.SetToolTips(TextResource.SearchComplete);
            TDCGExplorer.TDCGExplorer.DecBusy();
        }