Пример #1
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)
                {
                }
            }
        }
Пример #2
0
        private void toolStripMenuItemMakeTah_Click(object sender, EventArgs e)
        {
            if (TDCGExplorer.TDCGExplorer.BusyTest())
            {
                return;
            }

            TAHEditor editor = null;

            try
            {
                SimpleTextDialog dialog = new SimpleTextDialog();
                dialog.Owner      = TDCGExplorer.TDCGExplorer.MainFormWindow;
                dialog.dialogtext = TextResource.SaveTAHFile;
                dialog.labeltext  = TextResource.Filename;
                dialog.textfield  = "dummy.tah";

                if (dialog.ShowDialog() == DialogResult.OK)
                {
#if false
                    // 新規TAHを作成する.
                    string dbfilename  = LBFileTahUtl.GetTahDbPath(dialog.textfield);
                    string tahfilename = Path.GetFileNameWithoutExtension(dialog.textfield);

                    if (File.Exists(dbfilename))
                    {
                        MessageBox.Show("既にデータベースファイルがあります。\n" + dbfilename + "\n削除してから操作してください。", "エラー", MessageBoxButtons.OK);
                        return;
                    }
#endif
                    // 常に新規タブで.
                    editor = new TAHEditor(null);
                    editor.SetInformation(Path.GetFileNameWithoutExtension(dialog.textfield) + ".tah", 1);

                    // baseがないtahを全て反復する.
                    foreach (MissingEntryInformation missing in missings)
                    {
                        try
                        {
                            List <string> tbns = tbnfiles[missing.basetbn];
                            tbns.Sort();                             // 順番を並び替える.
                            string tbnfile = tbns[0];                // 一番若いtbnファイル名を得る.
                            if (tbnfile.StartsWith("script/items/")) // 背景以外のtbnのみ処理する.
                            {
                                // tbnファイルを取得する
                                byte[] tbndata = getTahFile(tbnfile);
                                // data/model/N765BODY_A00.TSO
                                // 012345678901
                                string tsoname = TDCGTbnUtil.GetTsoName(tbndata).Substring(11);
                                string psdpath = "data/icon/items/" + tsoname.Substring(0, 12) + ".psd";
                                // psdファイルを取得する
                                byte[] psddata = getTahFile(psdpath);

                                // 新しい名前を付け替える.
                                //
                                // script/items/N765BODY_A00.tbn
                                // 12345678901234567890123456789
                                string newtbn = tbnfile.Substring(0, 23) + "00.tbn";
                                // data/icon/items/N765BODY_A00.tbn
                                // 12345678901234567890123456789
                                string newpsd = psdpath.Substring(0, 26) + "00.psd";

                                editor.AddItem(newtbn, tbndata);
                                if (psddata != null)
                                {
                                    editor.AddItem(newpsd, psddata);
                                }
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }

                    TDCGExplorer.TDCGExplorer.MainFormWindow.AssignTagPageControl(editor);
                    editor.SelectAll();
                }
            }
            catch (Exception)
            {
                if (editor != null)
                {
                    editor.Dispose();
                }
            }
        }
Пример #3
0
        public TAHPageControl(GenericTahInfo entryinfo, List <ArcsTahFilesEntry> filesentries)
        {
            InitializeComponent();

            info         = entryinfo;
            Text         = info.shortname + " version " + entryinfo.version.ToString();
            filesEntries = filesentries;

            DataTable data = new DataTable();

            data.Columns.Add("ID", Type.GetType("System.String"));
            data.Columns.Add(TextResource.Filename, Type.GetType("System.String"));
            data.Columns.Add(TextResource.FileType, Type.GetType("System.String"));
            data.Columns.Add(TextResource.HashCode, Type.GetType("System.String"));
            data.Columns.Add(TextResource.FileSize, Type.GetType("System.String"));
            data.Columns.Add(TextResource.Category, Type.GetType("System.String"));
            foreach (ArcsTahFilesEntry file in filesentries)
            {
                DataRow  row     = data.NewRow();
                string[] content = { file.tahentry.ToString(), file.GetDisplayPath(), Path.GetExtension(file.path), file.hash.ToString("x8"), file.length.ToString(), TDCGTbnUtil.GetCategoryText(file.GetDisplayPath()) };
                row.ItemArray = content;
                data.Rows.Add(row);
            }
            dataGridView.DataSource = data;

            dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;

            dataGridView.ReadOnly              = true;
            dataGridView.MultiSelect           = false;
            dataGridView.SelectionMode         = DataGridViewSelectionMode.FullRowSelect;
            dataGridView.AllowUserToAddRows    = false;
            dataGridView.AllowUserToDeleteRows = false;

            LoadPsdFile(0);

            TDCGExplorer.TDCGExplorer.SetToolTips(info.shortname + " : " + TextResource.TSOMessage);
        }