예제 #1
0
        private void X_N_JumpEditor_Click(object sender, EventArgs e)
        {
            if (InputFormRef.IsPleaseWaitDialog(this))
            {//2重割り込み禁止
                return;
            }

            uint battleanime_baseaddress = InputFormRef.SelectToAddr(N_AddressList);

            if (battleanime_baseaddress == U.NOT_FOUND)
            {
                return;
            }
            uint sectionData    = (uint)N_P12.Value;
            uint frameData      = (uint)N_P16.Value;
            uint rightToLeftOAM = (uint)N_P20.Value;
            uint leftToRightOAM = (uint)N_P24.Value;
            uint palettes       = (uint)N_P28.Value;

            uint ID = (uint)N_AddressList.SelectedIndex + 1;

            string filehint = GetBattleAnimeHint(ID);

            if (filehint == "")
            {//不明な場合、 FE7にある個別バトルにも問い合わせる
                filehint = UnitCustomBattleAnimeForm.GetBattleAnimeHint((uint)N_AddressList.SelectedIndex + 1);
            }
            filehint = N_AddressList.Text + " " + filehint;
            int palette_count = ImageUtilOAM.CalcMaxPaletteCount(sectionData, frameData, rightToLeftOAM, palettes);

            //少し時間がかかるので、しばらくお待ちください表示.
            using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this))
                //テンポラリディレクトリを利用する
                using (U.MakeTempDirectory tempdir = new U.MakeTempDirectory())
                {
                    string filename = Path.Combine(tempdir.Dir, "anime.txt");
                    ImageUtilOAM.ExportBattleAnime("", false, filename
                                                   , sectionData, frameData, rightToLeftOAM, palettes, palette_count);
                    if (!File.Exists(filename))
                    {
                        R.ShowStopError("アニメーションエディタを表示するために、アニメーションをエクスポートしようとしましたが、アニメをファイルにエクスポートできませんでした。\r\n\r\nファイル:{0}", filename);
                        return;
                    }
                    byte[] paletteBIN = LZ77.decompress(Program.ROM.Data, U.toOffset(palettes));

                    ToolAnimationCreatorForm f = (ToolAnimationCreatorForm)InputFormRef.JumpFormLow <ToolAnimationCreatorForm>();
                    f.Init(ToolAnimationCreatorUserControl.AnimationTypeEnum.BattleAnime
                           , ID, filehint, filename, paletteBIN);
                    f.Show();
                    f.Focus();
                }
        }
        private void BattleAnimeExportButton_Click(object sender, EventArgs e)
        {
            uint battleanime_baseaddress = InputFormRef.SelectToAddr(N_AddressList);

            if (battleanime_baseaddress == U.NOT_FOUND)
            {
                return;
            }

            string title  = R._("保存するファイル名を選択してください");
            string filter = R._("FEditorシリアライズ形式|*.bin|バトルアニメ コメントあり|*.txt|バトルアニメ コメントなし|*.txt|アニメGIF|*.gif|Dump All|*.bin|All files|*");

            SaveFileDialog save = new SaveFileDialog();

            save.Title  = title;
            save.Filter = filter;
            Program.LastSelectedFilename.Load(this, "", save, N_L_0_SPLITSTRING_7.Text);

            DialogResult dr = save.ShowDialog();

            if (dr != DialogResult.OK)
            {
                return;
            }
            if (save.FileNames.Length <= 0 || !U.CanWriteFileRetry(save.FileNames[0]))
            {
                return;
            }
            string filename = save.FileNames[0];

            Program.LastSelectedFilename.Save(this, "", save);

            uint sectionData    = (uint)N_P12.Value;
            uint frameData      = (uint)N_P16.Value;
            uint rightToLeftOAM = (uint)N_P20.Value;
            uint leftToRightOAM = (uint)N_P24.Value;
            uint palettes       = (uint)N_P28.Value;

            string filehint = GetBattleAnimeHint((uint)N_AddressList.SelectedIndex + 1);

            if (filehint == "")
            {//不明な場合、 FE7にある個別バトルにも問い合わせる
                filehint = UnitCustomBattleAnimeForm.GetBattleAnimeHint((uint)N_AddressList.SelectedIndex + 1);
            }
            filehint = N_AddressList.Text + " " + filehint;
            int palette_count = ImageUtilOAM.CalcMaxPaletteCount(sectionData, frameData, rightToLeftOAM, palettes);

            string ext = U.GetFilenameExt(save.FileName);

            if (save.FilterIndex == 5)
            {
                {
                    string name            = U.ChangeExtFilename(filename, ".gif");
                    uint   showSectionData = U.atoh(ShowSectionCombo.Text) - 1;
                    ImageUtilOAM.ExportBattleAnimeGIF(name, showSectionData
                                                      , sectionData, frameData, rightToLeftOAM, palettes, palette_count);
                }
                {
                    string name = U.ChangeExtFilename(filename, ".bin");
                    ImageUtilOAM.ExportBattleAnimeOnFEditorSerialize(name, battleanime_baseaddress
                                                                     , sectionData, frameData, rightToLeftOAM, leftToRightOAM, palettes, palette_count);
                }
                {
                    string name          = U.ChangeExtFilename(filename, ".txt");
                    bool   enableComment = false;
                    ImageUtilOAM.ExportBattleAnime(filehint, enableComment, name
                                                   , sectionData, frameData, rightToLeftOAM, palettes, palette_count);
                }
            }
            else if (save.FilterIndex == 4 || ext == ".GIF")
            {
                uint showSectionData = U.atoh(ShowSectionCombo.Text) - 1;
                ImageUtilOAM.ExportBattleAnimeGIF(filename, showSectionData
                                                  , sectionData, frameData, rightToLeftOAM, palettes, palette_count);
            }
            else if (save.FilterIndex == 0 || ext == ".BIN")
            {
                ImageUtilOAM.ExportBattleAnimeOnFEditorSerialize(filename, battleanime_baseaddress
                                                                 , sectionData, frameData, rightToLeftOAM, leftToRightOAM, palettes, palette_count);
            }
            else
            {
                bool enableComment = true;
                if (save.FilterIndex == 3)
                {
                    enableComment = false;
                }
                ImageUtilOAM.ExportBattleAnime(filehint, enableComment, filename
                                               , sectionData, frameData, rightToLeftOAM, palettes, palette_count);
            }

            //エクスプローラで選択しよう
            U.SelectFileByExplorer(filename);
        }