void SerchCustomFonts(bool isItemFont, uint ignoteEnd, List <Address> list)
        {
            uint topaddress = FontForm.GetFontPointer(isItemFont);

            for (uint moji1 = 0x1f; moji1 <= 0xff; moji1++)
            {
                //リストの元になるポインタへ移動.
                uint fontlist = topaddress + (moji1 << 2) - 0x100;
                if (!U.isSafetyOffset(fontlist))
                {
                    continue;
                }

                uint p = Program.ROM.p32(fontlist);
                if (!U.isSafetyOffset(p))
                {
                    continue;
                }
                uint before_pointer = fontlist;

                //同一ハッシュキーがあるため、リストをたどりながら目的のフォントを探します.
                //struct{
                //    void* next;
                //    byte  moji2
                //    byte  width
                //    byte  nazo1
                //    byte  nazo2
                //} //sizeof()==8
                //+64byte bitmap(4pp)
                while (p > 0)
                {
                    if (p >= ignoteEnd)
                    {
                        uint moji2 = Program.ROM.u8(p + 4);
                        FEBuilderGBA.Address.AddAddress(list
                                                        , p, 8 + 64
                                                        , before_pointer
                                                        , "WipeJP Font"
                                                        , Address.DataTypeEnum.BIN);
                    }

                    uint next = Program.ROM.u32(p);
                    if (next == 0)
                    {//リスト終端.
                        break;
                    }

                    if (!U.isSafetyPointer(next))
                    {//リストが壊れている.
                        break;
                    }

                    before_pointer = p;

                    //次のリストへ進む.
                    p = U.toOffset(next);
                }
            }
        }
Esempio n. 2
0
        private void AddressList_SelectedIndexChanged(object sender, EventArgs e)
        {
            uint addr = InputFormRef.SelectToAddr(this.AddressList);

            PatchUtil.PRIORITY_CODE priorityCode = PatchUtil.SearchPriorityCode();

            //アイテム
            ItemFontPictureBox.Image = FontForm.DrawFont(Program.ROM.u16(addr), true, priorityCode);

            //セリフ
            SerifFontPictureBox.Image = FontForm.DrawFont(Program.ROM.u16(addr), false, priorityCode);
        }
Esempio n. 3
0
 private void ExportButton_Click(object sender, EventArgs e)
 {
     if (this.SearchChar.Text.Length <= 0)
     {
         return;
     }
     PatchUtil.PRIORITY_CODE priorityCode = PatchUtil.SearchPriorityCode();
     if (this.FontType.SelectedIndex == 0)
     {
         //アイテム
         Bitmap bitmap = FontForm.DrawFont(this.SearchChar.Text, true, priorityCode);
         ImageFormRef.ExportImage(this, bitmap, InputFormRef.MakeSaveImageFilename(this, "Item_" + this.SearchChar.Text), 8);
     }
     else
     {
         //セリフ
         Bitmap bitmap = FontForm.DrawFont(this.SearchChar.Text, false, priorityCode);
         ImageFormRef.ExportImage(this, bitmap, InputFormRef.MakeSaveImageFilename(this, "Serif_" + this.SearchChar.Text), 8);
     }
 }
        void WriteBackFontKF(KeepFont kf, RecycleAddress ra)
        {
            uint topaddress = FontForm.GetFontPointer(kf.IsItemFont);

            uint prevaddr;
            uint fontaddr = FontForm.FindFontData(topaddress, kf.MojiCode, out prevaddr, this.PriorityCode);

            if (fontaddr != U.NOT_FOUND)
            {//知ってるらしい
                return;
            }
            if (prevaddr == U.NOT_FOUND)
            {//追加不可能
                return;
            }

            byte[] newFontData = FontForm.MakeNewFontData(kf.MojiCode
                                                          , kf.Width
                                                          , kf.Data
                                                          , Program.ROM
                                                          , this.PriorityCode);

            U.write_u32(newFontData, 0, 0);   //NULL リストの末尾に追加するので.

            uint newaddr = ra.Write(newFontData, this.UndoData);

            if (newaddr == U.NOT_FOUND)
            {//エラー
                return;
            }

            //ひとつ前のフォントリストのポインタを、現在追加した最後尾にすげかえる.
            Program.ROM.write_u32(prevaddr + 0, U.toPointer(newaddr), this.UndoData);

            if (kf.rewitePointer != U.NOT_FOUND)
            {
                Program.ROM.write_u32(kf.rewitePointer, U.toPointer(newaddr), this.UndoData);
            }
        }
        void AddKeepFont(bool isItemFont, uint moji, uint rewitePointer = U.NOT_FOUND)
        {
            uint topaddress = FontForm.GetFontPointer(isItemFont);
            uint prevaddress;
            uint fontaddress = FontForm.FindFontData(topaddress
                                                     , moji
                                                     , out prevaddress
                                                     , PriorityCode);

            if (fontaddress == U.NOT_FOUND)
            {
                return;
            }
            KeepFont kf = new KeepFont();

            kf.IsItemFont    = isItemFont;
            kf.Moji          = "Code" + U.To0xHexString(moji);
            kf.MojiCode      = moji;
            kf.Width         = Program.ROM.u8(fontaddress + 5);
            kf.Data          = Program.ROM.getBinaryData(fontaddress + 8, 64);
            kf.rewitePointer = rewitePointer;
            KeepFontList.Add(kf);
        }
Esempio n. 6
0
        //適度に改行を挿入する
        static string InsertSerifnl(string serif, string to, bool use0003, ref uint ref_addchar)
        {
            if (serif.Trim() == "")
            {
                return("");
            }

            uint[] widths = FontForm.MeasureTextWidthOneLineInts(serif, false);

            //フォントがない場合の幅.
            uint unkownFontSize = FontForm.GetUnkownFontSize(to);
            int  linesCount     = 0;

            string result = "";
            int    starti = 0;
            uint   sum    = ref_addchar;

            for (int i = 0; i < widths.Length; i++)
            {
                uint w = widths[i];
                if (w <= 0)
                {//フォントがないので長さが取れない場合推測する.
                    w = unkownFontSize;
                }
                sum += w + 1;
                if (sum + unkownFontSize < TextForm.MAX_SERIF_WIDTH)
                {
                    continue;
                }

                i = SearchBreakPoint(serif, starti, i - starti, to);

                string a = serif.Substring(starti, i - starti);
                a = a.Trim();
                if (a != "")
                {
                    linesCount++;

                    result += a;
                    if (use0003)
                    {//@0003が使える場合は、 2行枚に @0003 を挟む.
                        if (linesCount % 2 == 0)
                        {
                            result += "@0003";
                        }
                    }
                    result += "\r\n";
                }
                starti = i;
                sum    = 0;
            }

            {
                string a = serif.Substring(starti);
                a = a.Trim();
                if (a != "")
                {
                    result     += a;
                    ref_addchar = sum;
                }
            }
            return(result);
        }
Esempio n. 7
0
        public MainSimpleMenuImageSubForm()
        {
            InitializeComponent();

            ImageBGButton.BackgroundImage = MakeTransparent(Trim(ImageBGForm.DrawBG(0)));

            if (Program.ROM.RomInfo.version() >= 7)
            {
                BigCGButton.BackgroundImage = MakeTransparent(Trim(ImageCGForm.DrawImageByID(0)));
            }
            else
            {
                BigCGButton.Hide();
            }

            ImagePortraitButton.BackgroundImage     = MakeTransparent(ImagePortraitForm.DrawPortraitUnit(2));
            ImageBattleAnimeButton.BackgroundImage  = MakeTransparent(BattleZoom(ImageBattleAnimeForm.DrawBattleAnime(1, ImageBattleAnimeForm.ScaleTrim.SCALE_90)));
            ImageUnitWaitIconButton.BackgroundImage = MakeTransparent(ImageUnitWaitIconFrom.DrawWaitUnitIconBitmap(1, 0, false));
            ImageUnitMoveIconButton.BackgroundImage = MakeTransparent(ImageUnitMoveIconFrom.DrawMoveUnitIconBitmap(3, 0, 0));
            ImageIconButton.BackgroundImage         = MakeTransparent(ImageItemIconForm.DrawIconWhereID(0xB));
            SystemIconButton.BackgroundImage        = MakeTransparent(ImageSystemIconForm.YubiYoko());
            //BattleScreenButton.BackgroundImage = MakeTransparent(ImageSystemIconForm.Allows(8));
            BattleScreenButton.BackgroundImage = MakeTransparent(ImageSystemIconForm.WeaponIcon(0));

            ImageBattleFieldButton.BackgroundImage   = MakeTransparent(ImageBattleBGForm.DrawBG(2));
            ImageBattleTerrainButton.BackgroundImage = MakeTransparent((ImageBattleTerrainForm.Draw(2)));

            if (Program.ROM.RomInfo.version() == 8)
            {
                ImageUnitPaletteButton.BackgroundImage = MakeTransparent(BattleZoom(UnitPaletteForm.DrawSample(2, 3)));
            }
            else
            {//for FE6 , FE7
                ImageUnitPaletteButton.BackgroundImage = MakeTransparent(BattleZoom(ImageBattleAnimeForm.DrawBattleAnime(ImageBattleAnimeForm.GetAnimeIDByClassID(UnitForm.GetClassID(2))
                                                                                                                         , ImageBattleAnimeForm.ScaleTrim.SCALE_90, UnitForm.GetPaletteLowClass(2))));
            }

            WorldMapImageButton.BackgroundImage = MakeTransparent(WorldMapImageForm.DrawWorldMap());

            if (Program.ROM.RomInfo.version() == 7 && Program.ROM.RomInfo.is_multibyte() == false)
            {//英語版FE7は、章タイトルをテキストで保持していて、40260c nazo fontで、描画している.
                ImageChapterTitleButton.Hide();
            }
            else
            {
                ImageChapterTitleButton.BackgroundImage = MakeTransparent(ImageChapterTitleForm.DrawSample(0));
            }


            if (ImageUtilMagic.SearchMagicSystem() != ImageUtilMagic.magic_system_enum.NO)
            {
                ImageMagicButton.BackgroundImage = MakeTransparent(ImageSystemIconForm.WeaponIcon(8 - 3));
            }
            else
            {
                ImageMagicButton.Hide();
            }

            if (Program.ROM.RomInfo.is_multibyte())
            {
                OptionForm.textencoding_enum textencoding = OptionForm.textencoding();
                if (textencoding == OptionForm.textencoding_enum.ZH_TBL)
                {
//                    FontButton.BackgroundImage = MakeTransparent(FontZHForm.DrawFontString("字形", true));
                }
                else
                {
                    FontButton.BackgroundImage = MakeTransparent(FontForm.DrawFontString("フォント", true));
                }
            }
            else
            {
                FontButton.BackgroundImage = MakeTransparent(FontForm.DrawFontString("Font", true));
            }
        }
Esempio n. 8
0
        void FontImporterOne(string one, bool isItemFont)
        {
            uint moji = U.ConvertMojiCharToUnit(one, this.MyselfPriorityCode);

            if (moji < 0x20 || moji == 0x80)
            {//制御文字なので無視
                return;
            }

            uint topaddress_my;
            uint fontaddress_my;
            uint prevaddress_my;

            topaddress_my  = FontForm.GetFontPointer(isItemFont);
            fontaddress_my = FontForm.FindFontData(topaddress_my
                                                   , moji
                                                   , out prevaddress_my
                                                   , this.MyselfPriorityCode);
            if (fontaddress_my != U.NOT_FOUND)
            {//既存ROMに存在している
                return;
            }
            if (prevaddress_my == U.NOT_FOUND)
            {//このフォントはルールにより登録できない.日本語フォントで 0x100以下とか.
                return;
            }

            //既存ROMにはないフォント
            byte[] newFontData = null;
            if (this.YourROM != null)
            {//相手のROMにあるかどうか.
                uint your_moji = U.ConvertMojiCharToUnit(one, this.YourPriorityCode);
                if (your_moji < 0x20)
                {//制御文字なので無視
                    return;
                }

                //相手のROMにはあるかな?
                uint topaddress_your;
                uint fontaddress_your;
                uint prevaddress_your;

                topaddress_your  = FontForm.GetFontPointer(isItemFont, this.YourROM);
                fontaddress_your = FontForm.FindFontData(topaddress_your
                                                         , moji
                                                         , out prevaddress_your
                                                         , this.YourROM
                                                         , this.YourPriorityCode);
                if (fontaddress_your == U.NOT_FOUND)
                {//相手のROMにもない
                    newFontData = null;
                }
                else
                {
                    Log.Notify("Font Porting", one);

                    //fontデータの取得
                    newFontData = this.YourROM.getBinaryData(fontaddress_your, 8 * 64);

                    FontForm.TransportFontStruct(newFontData, moji, this.MyselfPriorityCode, this.YourPriorityCode);
                }
            }

            if (newFontData == null && //存在しないフォントで
                this.UseAutoGenFont != null    //自動生成する場合
                )
            {
                Log.Notify("Font Auto gen", one);

                //自動生成.
                int    font_width;
                Bitmap autogen = ImageUtil.AutoGenerateFont(one
                                                            , this.UseAutoGenFont
                                                            , isItemFont
                                                            , out font_width);
                if (autogen == null)
                {//ない
                    return;
                }
                byte[] fontimage = ImageUtil.Image4ToByte(autogen);

                newFontData = FontForm.MakeNewFontData(moji
                                                       , (uint)font_width
                                                       , fontimage
                                                       , Program.ROM
                                                       , this.MyselfPriorityCode);
            }

            if (newFontData == null)
            {//存在しない
                return;
            }

            U.write_u32(newFontData, 0, 0);   //NULL リストの末尾に追加するので.

            uint newaddr = InputFormRef.AppendBinaryData(newFontData, this.UndoData);

            if (newaddr == U.NOT_FOUND)
            {//エラー
                return;
            }

            //ひとつ前のフォントリストのポインタを、現在追加した最後尾にすげかえる.
            Program.ROM.write_u32(prevaddress_my + 0, U.toPointer(newaddr), this.UndoData);
        }
Esempio n. 9
0
        void AliasFontOne(string one_from, string one_to, bool isItemFont, bool isSquareFont)
        {
            uint moji_from = U.ConvertMojiCharToUnit(one_from, this.MyselfPriorityCode);

            if (moji_from < 0x20 || moji_from == 0x80)
            {//制御文字なので無視
                Debug.Assert(false);
                return;
            }
            uint moji_to = U.ConvertMojiCharToUnit(one_to, this.MyselfPriorityCode);

            if (moji_to < 0x20 || moji_to == 0x80)
            {//制御文字なので無視
                Debug.Assert(false);
                return;
            }

            uint topaddress;
            uint fontaddress_from;
            uint prevaddress_from;

            topaddress       = FontForm.GetFontPointer(isItemFont);
            fontaddress_from = FontForm.FindFontData(topaddress
                                                     , moji_from
                                                     , out prevaddress_from
                                                     , this.MyselfPriorityCode);
            if (fontaddress_from == U.NOT_FOUND)
            {
                Debug.Assert(false);
                return;
            }

            uint fontaddress_to;
            uint prevaddress_to;

            fontaddress_to = FontForm.FindFontData(topaddress
                                                   , moji_to
                                                   , out prevaddress_to
                                                   , this.MyselfPriorityCode);
            if (fontaddress_to == U.NOT_FOUND)
            {                           //ないならコピー
                byte[] bin = Program.ROM.getBinaryData(fontaddress_from, 72);
                U.write_u32(bin, 0, 0); //NULL リストの末尾に追加するので.

                uint moji2 = (moji_to & 0xff);
                U.write_u8(bin, 4, moji2);   //SJIS2バイト目

                uint newaddr = this.Recycle.Write(bin, this.UndoData);
                if (newaddr == U.NOT_FOUND)
                {
                    Debug.Assert(false);
                    return;
                }
                //ひとつ前のフォントリストのポインタを、現在追加した最後尾にすげかえる.
                Program.ROM.write_u32(prevaddress_to + 0, U.toPointer(newaddr), this.UndoData);
            }
            else
            {
                byte[] bin = Program.ROM.getBinaryData(fontaddress_from + 5, 72 - 5);
                Program.ROM.write_range(fontaddress_to + 5, bin, this.UndoData);
            }
        }
Esempio n. 10
0
        void AliasFontOne(string one_from, string one_to, bool isItemFont, bool isSquareFont)
        {
            uint moji_from = U.ConvertMojiCharToUnit(one_from, this.MyselfPriorityCode);

            if (moji_from < 0x20 || moji_from == 0x80)
            {//制御文字なので無視
                return;
            }
            uint moji_to = U.ConvertMojiCharToUnit(one_to, this.MyselfPriorityCode);

            if (moji_to < 0x20 || moji_to == 0x80)
            {//制御文字なので無視
                return;
            }

            uint topaddress;
            uint fontaddress_from;
            uint prevaddress_from;

            topaddress       = FontForm.GetFontPointer(isItemFont);
            fontaddress_from = FontForm.FindFontData(topaddress
                                                     , moji_from
                                                     , out prevaddress_from
                                                     , this.MyselfPriorityCode);
            if (fontaddress_from == U.NOT_FOUND)
            {
                return;
            }

            uint fontaddress_to;
            uint prevaddress_to;

            fontaddress_to = FontForm.FindFontData(topaddress
                                                   , moji_to
                                                   , out prevaddress_to
                                                   , this.MyselfPriorityCode);
            if (fontaddress_to == U.NOT_FOUND)
            {
                uint   font_width  = Program.ROM.u8(fontaddress_from + 5);
                byte[] fontimage   = Program.ROM.getBinaryData(fontaddress_from + 8, 72 - 8);
                byte[] newFontData = FontForm.MakeNewFontData(moji_to
                                                              , font_width
                                                              , fontimage
                                                              , Program.ROM
                                                              , this.MyselfPriorityCode);

                U.write_u32(newFontData, 0, 0);   //NULL リストの末尾に追加するので.

                uint newaddr = this.Recycle.Write(newFontData, this.UndoData);
                if (newaddr == U.NOT_FOUND)
                {//エラー
                    return;
                }
                //ひとつ前のフォントリストのポインタを、現在追加した最後尾にすげかえる.
                Program.ROM.write_u32(prevaddress_to + 0, U.toPointer(newaddr), this.UndoData);
            }
            else
            {
                byte[] bin = Program.ROM.getBinaryData(fontaddress_from + 5, 72 - 5);
                Program.ROM.write_range(fontaddress_to + 5, bin, this.UndoData);
            }
        }