Beispiel #1
0
        void WriteText(uint id, string text, Undo.UndoData undodata)
        {
            //無効なID
            if (id <= 0)
            {
                return;
            }
            //最後の改行の削除.
            if (text.Length < 2)
            {
                return;
            }
            string writetext = U.substr(text, 0, text.Length - 2);

            writetext = TextForm.ConvertFEditorToEscape(writetext);

            if (id < this.MaxTextCount)
            {
                WriteTextUnHffman(id, writetext, undodata);
            }
            else if (U.isSafetyPointer(id))
            {
                WriteCString(id, writetext, undodata);
            }
            else
            {
                Log.Error("不明な文字列", id.ToString(), writetext);
                return;
            }
        }
        private void WriteButton_Click(object sender, EventArgs e)
        {
            if (this.SelectFontBitmapByte == null || this.SelectFontBitmapByte.Length != 64)
            {
                return;
            }


            string undo_name = "FONT " + this.SearchChar.Text;

            PatchUtil.PRIORITY_CODE priorityCode = PatchUtil.SearchPriorityCode();
            string target = this.SearchChar.Text;

            target = TextForm.ConvertFEditorToEscape(target);
            uint search_char = U.ConvertMojiCharToUnitFast(target, priorityCode);

            uint fontlist_pointer = GetFontPointer(this.FontType.SelectedIndex == 0);

            uint prevaddr;
            uint fontaddr = FindFontData(fontlist_pointer, search_char, out prevaddr, priorityCode);

            if (fontaddr == U.NOT_FOUND)
            {     //末尾に追加.
                if (prevaddr == U.NOT_FOUND)
                { //このフォントはルールにより登録できない.日本語フォントで 0x100以下とか.
                    return;
                }
                byte[] newFontData = MakeNewFontData(search_char
                                                     , (uint)this.FontWidth.Value
                                                     , this.SelectFontBitmapByte
                                                     , Program.ROM
                                                     , priorityCode
                                                     );

                Undo.UndoData undodata = Program.Undo.NewUndoData(undo_name);

                uint newaddr = InputFormRef.AppendBinaryData(newFontData, undodata);
                if (newaddr == U.NOT_FOUND)
                {//エラー
                    return;
                }

                //ひとつ前のフォントリストのポインタを、現在追加した最後尾にすげかえる.
                Program.ROM.write_u32(prevaddr + 0, U.toPointer(newaddr), undodata);
                fontaddr = newaddr;
            }
            else
            {//更新
                Program.Undo.Push(undo_name, fontaddr, 8 + 64);
                Program.ROM.write_u8(fontaddr + 5, (uint)this.FontWidth.Value);
                Program.ROM.write_range(fontaddr + 8, this.SelectFontBitmapByte); //64バイト書き込み
            }
            this.Address.Value = U.toPointer(fontaddr);
            InputFormRef.ShowWriteNotifyAnimation(this, fontaddr);
        }
Beispiel #3
0
        void WriteText(uint id, string text, Undo.UndoData undodata)
        {
            //無効なID
            if (id <= 0)
            {
                return;
            }

            //最後の改行の削除.
            if (text.Length < 2)
            {
                return;
            }
            string writetext = U.substr(text, 0, text.Length - 2);

            writetext = TextForm.ConvertFEditorToEscape(writetext);

            if (id < this.MaxTextCount)
            {
                TextForm.WriteText(this.TextBaseAddress
                                   , this.MaxTextCount
                                   , id
                                   , writetext
                                   , undodata);
                return;
            }
            if (!U.isSafetyPointer(id))
            {
                Log.Error("不明な文字列", id.ToString(), text);
                return;
            }
            uint p_text_pointer = U.toOffset(id);
            uint text_pointer   = Program.ROM.u32(p_text_pointer);

            if (!U.isSafetyPointer(text_pointer))
            {
                Log.Error("ポインタではありません", id.ToString(), text);
                return;
            }
            uint new_textpointer = CStringForm.WriteCString(text_pointer, writetext, undodata);

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

            Program.ROM.write_p32(p_text_pointer, new_textpointer, undodata);
        }
        static void AppendDicTextID(Dictionary <string, string> transDic, uint id, string text)
        {
            if (id <= 0)
            {
                return;
            }
            string to_string = U.substr(text, 0, text.Length - 2);

            to_string = TextForm.ConvertFEditorToEscape(to_string);

            FETextDecode decode      = new FETextDecode();
            string       from_string = decode.Decode(id);

            from_string = from_string.ToUpper();

            transDic[from_string] = to_string;
            transDic[U.ToHexString(id) + "|" + from_string] = to_string;
        }
Beispiel #5
0
        private void ExportButton_Click(object sender, EventArgs e)
        {
            if (this.SearchChar.Text.Length <= 0)
            {
                return;
            }
            string target = this.SearchChar.Text;

            target = TextForm.ConvertFEditorToEscape(target);

            PatchUtil.PRIORITY_CODE priorityCode = PatchUtil.SearchPriorityCode();
            if (this.FontType.SelectedIndex == 0)
            {
                //アイテム
                Bitmap bitmap = FontForm.DrawFont(target, true, priorityCode);
                ImageFormRef.ExportImage(this, bitmap, InputFormRef.MakeSaveImageFilename(this, "Item_" + this.SearchChar.Text), 8);
            }
            else
            {
                //セリフ
                Bitmap bitmap = FontForm.DrawFont(target, false, priorityCode);
                ImageFormRef.ExportImage(this, bitmap, InputFormRef.MakeSaveImageFilename(this, "Serif_" + this.SearchChar.Text), 8);
            }
        }
Beispiel #6
0
        //検索して表示
        private void SearchButton_Click(object sender, EventArgs e)
        {
            string target = this.SearchChar.Text;

            target = TextForm.ConvertFEditorToEscape(target);

            PatchUtil.PRIORITY_CODE priorityCode = PatchUtil.SearchPriorityCode();
            uint search_char = U.ConvertMojiCharToUnitFast(target, priorityCode);

            uint fontlist_pointer = GetFontPointer(this.FontType.SelectedIndex == 0);

            uint fontaddr = FindFontData(fontlist_pointer, search_char, priorityCode);

            if (fontaddr == U.NOT_FOUND)
            {
                U.ForceUpdate(this.FontWidth, 0);
                this.SelectFontBitmapByte = null;
                this.Address.Value        = 0;

                R.ShowWarning(R._("フォント:{0} が見つかりませんでした。"), this.SearchChar.Text);
            }
            else
            {
                int width;
                this.SelectFontBitmapByte = ReadFontData(fontaddr, out width);
                this.Address.Value        = U.toPointer(fontaddr);

                if (width >= 30)
                {//たまにでかい値が来る時があるらしい.
                    width = 30;
                }
                U.ForceUpdate(this.FontWidth, width);
            }

            DrawFonts();
        }
Beispiel #7
0
        //フォントの描画
        void DrawFonts()
        {
            if (SearchChar.Text.Length <= 0)
            {
                return;
            }
            string target = this.SearchChar.Text;

            target = TextForm.ConvertFEditorToEscape(target);

            Bitmap fontSampleBitmap;

            uint  fontlist_pointer = GetFontPointer(this.FontType.SelectedIndex == 0);
            Color bgcolor          = GetFontColor(this.FontType.SelectedIndex == 0);

            fontSampleBitmap = ImageUtil.Blank(FontPictureBox.Width, FontPictureBox.Height);

            PatchUtil.PRIORITY_CODE priorityCode = PatchUtil.SearchPriorityCode();

            int drawwidth = 0;

            for (int i = 0; i < this.FontSample.Text.Length; i++)
            {
                uint search_char;
                if (this.FontSample.Text[i] == '@')
                {
                    search_char = U.ConvertMojiCharToUnitFast(target, priorityCode);
                }
                else
                {
                    search_char = U.ConvertMojiCharToUnitFast(this.FontSample.Text.Substring(i, 1), priorityCode);
                }
                uint fontaddr = FindFontData(fontlist_pointer, search_char, priorityCode);
                if (fontaddr == U.NOT_FOUND)
                {
                    continue;
                }
                int    width;
                byte[] fontbyte;
                if (this.FontSample.Text[i] == '@')
                {
                    width    = (int)this.FontWidth.Value;
                    fontbyte = this.SelectFontBitmapByte;
                }
                else
                {
                    fontbyte = ReadFontData(fontaddr, out width);
                }

                if (width <= 0 || fontbyte == null)
                {
                    continue;
                }
                Bitmap bitmap = ImageUtil.ByteToImage4(16, 16, fontbyte, 0, bgcolor);

                fontSampleBitmap.Palette = bitmap.Palette;
                ImageUtil.BitBlt(fontSampleBitmap, drawwidth, 0, width, 16, bitmap, 0, 0);
                drawwidth += width;
            }
            FontPictureBox.Image = U.Zoom(fontSampleBitmap, ZoomComboBox.SelectedIndex);
        }