Пример #1
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();
                }
            }
        }
Пример #2
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)
                {
                }
            }
        }