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

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

            string filehint = this.AddressList.Text;

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

                    ToolAnimationCreatorForm f = (ToolAnimationCreatorForm)InputFormRef.JumpFormLow <ToolAnimationCreatorForm>();
                    f.Init(ToolAnimationCreatorUserControl.AnimationTypeEnum.MagicAnime_CSACreator
                           , ID, filehint, filename);
                    f.Show();
                }
        }
        void DrawSelectedAnime()
        {
            string log;

            X_B_ANIME_PIC2.Image = ImageUtilMagicCSACreator.Draw((uint)ShowFrameUpDown.Value, (uint)P0.Value, (uint)P4.Value, (uint)P12.Value, out log);
            BinInfo.Text         = log;
        }
        //全データの取得
        public static void MakeAllDataLength(List <Address> list, bool isPointerOnly)
        {
            string       name;
            InputFormRef InputFormRef;
            uint         baseaddr, dimaddr, no_dimaddr;

            if (ImageUtilMagic.SearchMagicSystem(out baseaddr, out dimaddr, out no_dimaddr) != ImageUtilMagic.magic_system_enum.CSA_CREATOR)
            {
                return;
            }

            {
                uint spellDataCount = ImageUtilMagicFEditor.SpellDataCount();
                uint csaSpellTable  = ImageUtilMagic.GetCSASpellTableAddr();
                if (csaSpellTable == U.NOT_FOUND)
                {
                    return;
                }
                uint csaSpellTablePointer = ImageUtilMagic.GetCSASpellTablePointer();

                Dictionary <uint, string> effectDic = new Dictionary <uint, string>();
                InputFormRef = Init(null, dimaddr, no_dimaddr, spellDataCount, csaSpellTable, effectDic);

                name = "Magic";
                FEBuilderGBA.Address.AddAddress(list
                                                , InputFormRef
                                                , name, new uint[] { 0 }
                                                );

                //追加魔法テーブル(結構無駄な構造ですが、仕方ない)
                FEBuilderGBA.Address.AddAddress(list
                                                , csaSpellTable
                                                , InputFormRef.DataCount * 4 * 5
                                                , csaSpellTablePointer
                                                , "Magic_Append_SpellTable"
                                                , FEBuilderGBA.Address.DataTypeEnum.MAGIC_APPEND_SPELLTABLE
                                                );

                uint addr = InputFormRef.BaseAddress;
                for (int i = 0; i < InputFormRef.DataCount; i++, addr += InputFormRef.BlockSize)
                {
                    uint baseaddress = Program.ROM.p32(Program.ROM.RomInfo.magic_effect_pointer);
                    uint csaaddress  = (uint)(csaSpellTable + (20 * i));

                    uint dataaddr = Program.ROM.p32(addr);
                    if (dataaddr == 0)
                    {
                        continue;
                    }
                    if (
                        dataaddr == dimaddr ||
                        dataaddr == no_dimaddr)
                    {
                        name = "Magic:" + U.To0xHexString(i);
                        ImageUtilMagicCSACreator.RecycleOldAnime(ref list, name, isPointerOnly, csaaddress);
                    }
                }
            }
        }
        private void MagicAnimeExportButton_Click(object sender, EventArgs e)
        {
            string title  = R._("保存するファイル名を選択してください");
            string filter = R._("魔法アニメ コメントあり|*.txt|魔法アニメ コメントなし|*.txt|アニメGIF|*.gif|Dump All|*.txt|All files|*");

            SaveFileDialog save = new SaveFileDialog();

            save.Title        = title;
            save.Filter       = filter;
            save.AddExtension = true;
            Program.LastSelectedFilename.Load(this, "", save, "magic_" + this.AddressList.Text.Trim());

            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);

            if (save.FilterIndex == 2)
            {//コメントなし
                bool enableComment = false;
                ImageUtilMagicCSACreator.Export(enableComment, filename, (uint)P0.Value, (uint)P4.Value, (uint)P12.Value);
            }
            else if (save.FilterIndex == 3)
            {//GIF
                ImageUtilMagicCSACreator.ExportGif(filename, (uint)P0.Value, (uint)P4.Value, (uint)P12.Value);
            }
            else if (save.FilterIndex == 4)
            {//All
                bool enableComment = false;
                ImageUtilMagicCSACreator.Export(enableComment, filename, (uint)P0.Value, (uint)P4.Value, (uint)P12.Value);
                filename = U.ChangeExtFilename(filename, ".gif");
                ImageUtilMagicCSACreator.ExportGif(filename, (uint)P0.Value, (uint)P4.Value, (uint)P12.Value);
            }
            else
            {//コメントあり
                bool enableComment = true;
                ImageUtilMagicCSACreator.Export(enableComment, filename, (uint)P0.Value, (uint)P4.Value, (uint)P12.Value);
            }

            //エクスプローラで選択しよう
            U.SelectFileByExplorer(filename);
        }
        //変更するアニメデータから、他のアニメーションでも使っているものを除外する
        public static void SubConfilctArea(RecycleAddress ra, uint Now_baseaddress)
        {
            InputFormRef InputFormRef;
            uint         baseaddr, dimaddr, no_dimaddr;

            if (ImageUtilMagic.SearchMagicSystem(out baseaddr, out dimaddr, out no_dimaddr) != ImageUtilMagic.magic_system_enum.CSA_CREATOR)
            {
                return;
            }

            {
                uint spellDataCount = ImageUtilMagicFEditor.SpellDataCount();
                uint csaSpellTable  = ImageUtilMagic.GetCSASpellTableAddr();
                if (csaSpellTable == U.NOT_FOUND)
                {
                    return;
                }
                Dictionary <uint, string> effectDic = new Dictionary <uint, string>();
                InputFormRef = Init(null, dimaddr, no_dimaddr, spellDataCount, csaSpellTable, effectDic);

                uint addr = InputFormRef.BaseAddress;
                for (int i = 0; i < InputFormRef.DataCount; i++, addr += InputFormRef.BlockSize)
                {
                    uint baseaddress = Program.ROM.p32(Program.ROM.RomInfo.magic_effect_pointer);
                    uint csaaddress  = (uint)(csaSpellTable + (20 * i));

                    uint dataaddr = Program.ROM.p32(addr);
                    if (dataaddr == 0)
                    {
                        continue;
                    }
                    if (csaaddress == Now_baseaddress)
                    {
                        continue;
                    }

                    if (
                        dataaddr == dimaddr ||
                        dataaddr == no_dimaddr)
                    {
                        List <Address> list = new List <Address>();
                        ImageUtilMagicCSACreator.RecycleOldAnime(ref list, "", false, csaaddress);
                        ra.SubRecycle(list);
                    }
                }
            }
        }
        public string MagicAnimeImportDirect(uint id, string filename)
        {
            if (InputFormRef.IsPleaseWaitDialog(this))
            {//2重割り込み禁止
                return(R._("現在他の処理中です"));
            }

            if (id <= 0)
            {
                return(R._("指定されたID({0})は存在しません。", U.To0xHexString(id)));
            }

            uint magic_baseaddress = InputFormRef.SelectToAddr(AddressList, (int)id - 1);

            if (magic_baseaddress == U.NOT_FOUND)
            {
                return(R._("指定されたID({0})は存在しません。", U.To0xHexString(id)));
            }

            string error = "";

            //少し時間がかかるので、しばらくお待ちください表示.
            using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this))
            {
                string ext = U.GetFilenameExt(filename);
                error = ImageUtilMagicCSACreator.Import(filename, magic_baseaddress);
            }

            if (error != "")
            {
                return(error);
            }

            if (DimComboBox.SelectedIndex >= 2)
            {//EMPTYになっている場合は、dim_pcを選択.
                DimComboBox.SelectedIndex = 0;
                WriteDim();
            }

            U.ReSelectList(AddressList);
            InputFormRef.ShowWriteNotifyAnimation(this, magic_baseaddress);

            return("");
        }
        //エラー検出
        public static void MakeCheckError(List <FELint.ErrorSt> errors)
        {
            string       name;
            InputFormRef InputFormRef;
            uint         baseaddr, dimaddr, no_dimaddr;

            if (ImageUtilMagic.SearchMagicSystem(out baseaddr, out dimaddr, out no_dimaddr) != ImageUtilMagic.magic_system_enum.CSA_CREATOR)
            {
                return;
            }

            {
                uint spellDataCount = ImageUtilMagicFEditor.SpellDataCount();
                uint csaSpellTable  = ImageUtilMagic.GetCSASpellTableAddr();
                if (csaSpellTable == U.NOT_FOUND)
                {
                    return;
                }
                Dictionary <uint, string> effectDic = new Dictionary <uint, string>();
                InputFormRef = Init(null, dimaddr, no_dimaddr, spellDataCount, csaSpellTable, effectDic);

                uint addr = InputFormRef.BaseAddress;
                for (int i = 0; i < InputFormRef.DataCount; i++, addr += InputFormRef.BlockSize)
                {
                    uint baseaddress = Program.ROM.p32(Program.ROM.RomInfo.magic_effect_pointer);
                    uint csaaddress  = (uint)(csaSpellTable + (20 * i));

                    uint dataaddr = Program.ROM.p32(addr);
                    if (dataaddr == 0)
                    {
                        continue;
                    }
                    if (
                        dataaddr == dimaddr ||
                        dataaddr == no_dimaddr)
                    {
                        name = "Magic:" + U.To0xHexString(i);
                        ImageUtilMagicCSACreator.MakeCheckError(ref errors, name, csaaddress, (uint)i);
                    }
                }
            }
        }
Esempio n. 8
0
 void DrawSelectedAnime()
 {
     X_B_ANIME_PIC2.Image = ImageUtilMagicCSACreator.Draw((uint)ShowFrameUpDown.Value, (uint)P0.Value, (uint)P4.Value, (uint)P12.Value);
 }