Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        //翻訳用のよくあるテキスト集の作成.
        public static Dictionary <string, string> LoadTranslateDic(string from, string to, string rom_from, string rom_to)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();

            ROM    rom_f = new ROM();
            string version;

            if (!rom_f.Load(rom_from, out version))
            {
                return(dic);
            }

            ROM rom_t = new ROM();

            if (!rom_t.Load(rom_to, out version))
            {
                return(dic);
            }

            if (rom_f.RomInfo.version() != rom_t.RomInfo.version())
            {
                return(dic);
            }

            SystemTextEncoder from_tbl, to_tbl;
            int  from_n;
            bool trimEnd1F = true;

            if (from == "ja")
            {
                from_n   = 0;
                from_tbl = new SystemTextEncoder(OptionForm.textencoding_enum.Shift_JIS, rom_f);
            }
            else if (from == "en")
            {
                from_n = 1;
                if (rom_f.RomInfo.version() == 6)
                {
                    from_tbl = new SystemTextEncoder(OptionForm.textencoding_enum.EN_TBL, rom_f);
                }
                else
                {
                    from_tbl = new SystemTextEncoder(OptionForm.textencoding_enum.Shift_JIS, rom_f);
                }
                trimEnd1F = false;
            }
            else if (from == "zh" || from == "zh-CN")
            {
                from_n   = 0;
                from_tbl = new SystemTextEncoder(OptionForm.textencoding_enum.ZH_TBL, rom_f);
            }
            else if (from == "ko" || from == "ko-KR")
            {
                from_n   = 0;
                from_tbl = new SystemTextEncoder(OptionForm.textencoding_enum.KO_TBL, rom_f);
            }
            else
            {//fromが対応外.
                return(dic);
            }

            int to_n;

            if (to == "ja")
            {
                to_n   = 0;
                to_tbl = new SystemTextEncoder(OptionForm.textencoding_enum.Shift_JIS, rom_t);
            }
            else if (to == "en")
            {
                to_n = 1;
                if (rom_t.RomInfo.version() == 6)
                {
                    to_tbl = new SystemTextEncoder(OptionForm.textencoding_enum.EN_TBL, rom_t);
                }
                else
                {
                    to_tbl = new SystemTextEncoder(OptionForm.textencoding_enum.Shift_JIS, rom_t);
                }
            }
            else if (to == "zh" || to == "zh-CN")
            {
                to_n   = 0;
                to_tbl = new SystemTextEncoder(OptionForm.textencoding_enum.ZH_TBL, rom_t);
            }
            else if (to == "ko" || to == "ko-KR")
            {
                to_n   = 0;
                to_tbl = new SystemTextEncoder(OptionForm.textencoding_enum.KO_TBL, rom_t);
            }
            else
            {//toが対応外.
                return(dic);
            }

            //FE8は、日本語版と英語版で顔画像の並びが違うので補正するかどうかのチェック
            FE8FaceCode48Fix fe8faceCode48Fix = is_FE8FaceCode48Fix(rom_f, rom_t);

            string filename = U.ConfigDataFilename("translate_textid_", rom_f);

            string[]     lines        = File.ReadAllLines(filename);
            FETextDecode from_decoder = new FETextDecode(rom_f, from_tbl);
            FETextDecode to_decoder   = new FETextDecode(rom_t, to_tbl);

            for (int i = 0; i < lines.Length; i++)
            {
                if (U.IsComment(lines[i]))
                {
                    continue;
                }
                string   line = U.ClipComment(lines[i]);
                string[] sp   = line.Split('\t');
                if (sp.Length < 2)
                {
                    continue;
                }
                string from_string, to_string;
                uint   from_key         = U.atoh(sp[from_n]);
                uint   orignal_from_key = from_key;
                if (from_key <= 0)
                {
                    continue;
                }
                if (U.isSafetyPointer(from_key, rom_f))
                {//ポインタの場合、実アドレスを求める.
                    from_key = rom_f.u32(U.toOffset(from_key));
                    if (!U.isSafetyPointer(from_key, rom_f))
                    {
                        continue;
                    }
                }
                from_string = from_decoder.Decode(from_key);
                from_string = from_string.ToUpper();

                uint to_key            = U.atoh(sp[to_n]);
                int  change_string_pos = sp[to_n].IndexOf('|');
                if (change_string_pos < 0)
                {
                    if (to_key <= 0)
                    {
                        dic[U.ToHexString(orignal_from_key) + "#NOTFOUND#" + from_string] = "";
                        continue;
                    }
                    if (U.isSafetyPointer(to_key, rom_t))
                    {//ポインタの場合、実アドレスを求める.
                        to_key = rom_t.u32(U.toOffset(to_key));
                        if (!U.isSafetyPointer(to_key, rom_t))
                        {
                            dic[U.ToHexString(orignal_from_key) + "#NOTFOUND#" + from_string] = "";
                            continue;
                        }
                    }
                    to_string = to_decoder.Decode(to_key);
                }
                else
                {//長さ当の問題で置換できないものは、代替えテキストを入れます.
                    to_string = sp[to_n].Substring(change_string_pos + 1);
                }

                //FE8顔画像の修正.
                if (fe8faceCode48Fix != FE8FaceCode48Fix.NONE)
                {
                    to_string = FE8SkipFace48(to_string, fe8faceCode48Fix);
                }

                if (trimEnd1F)
                {
                    //末尾の001Fを消す
                    to_string = Trim001F(to_string);
                }

                dic[from_string] = to_string;
                dic[U.ToHexString(orignal_from_key) + "|" + from_string] = to_string;
            }

            return(dic);
        }
Esempio n. 3
0
        public void ImportFont(Form self, string FontROMTextBox, bool FontAutoGenelateCheckBox, Font ttf)
        {
            string filename = FontROMTextBox;

            this.YourROM = new ROM();

            this.ProcessedFont      = new Dictionary <string, bool>();
            this.MyselfPriorityCode = PatchUtil.SearchPriorityCode();

            string version;

            if (this.YourROM.Load(filename, out version))
            {//フォントを取るようのROM
                this.YourPriorityCode = PatchUtil.SearchPriorityCode(this.YourROM);
            }
            else
            {
                this.YourROM = null;
            }

            if (FontAutoGenelateCheckBox)
            {//自動生成する
                this.UseAutoGenFont = ttf;
            }
            else
            {//自動生成しない
                this.UseAutoGenFont = null;
            }
            FETextDecode decode = new FETextDecode();


            //少し時間がかかるので、しばらくお待ちください表示.
            using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(self))
            {
                this.UndoData = Program.Undo.NewUndoData("FONT Import");

                //文字列からフォントを探索
                {
                    List <U.AddrResult> list = TextForm.MakeItemList();
                    for (int i = 0; i < list.Count; i++)
                    {
                        string text = decode.Decode((uint)i);
                        pleaseWait.DoEvents("String:" + U.To0xHexString((uint)i));

                        FontImporter(text);
                    }
                }
                //メニュー1
                if (Program.ROM.RomInfo.is_multibyte())
                {
                    List <U.AddrResult> menuDefineList = MenuDefinitionForm.MakeListAll();
                    for (int n = 0; n < menuDefineList.Count; n++)
                    {
                        if (!U.isSafetyOffset(menuDefineList[n].addr + 8))
                        {
                            continue;
                        }
                        uint p = menuDefineList[n].addr + 8;
                        if (!U.isSafetyOffset(Program.ROM.p32(p)))
                        {
                            continue;
                        }
                        List <U.AddrResult> list = MenuCommandForm.MakeListPointer(p);
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (!U.isSafetyOffset(list[i].addr))
                            {
                                continue;
                            }
                            uint   textid = Program.ROM.u32(list[i].addr + 0);
                            string str    = FETextDecode.Direct(textid);

                            pleaseWait.DoEvents("Menu:" + U.To0xHexString(textid));
                            FontImporter(str);
                        }
                    }
                }

                //地形
                if (Program.ROM.RomInfo.is_multibyte())
                {
                    List <U.AddrResult> list = MapTerrainNameForm.MakeList();
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (!U.isSafetyOffset(list[i].addr))
                        {
                            continue;
                        }
                        uint   textid = Program.ROM.u32(list[i].addr + 0);
                        string str    = FETextDecode.Direct(textid);

                        pleaseWait.DoEvents("Terrain:" + U.To0xHexString(textid));
                        FontImporter(str);
                    }
                }

                //サウンドルーム
                //FE7のサウンドルームは、日本語直地
                if (Program.ROM.RomInfo.is_multibyte() && Program.ROM.RomInfo.version() == 7)
                {
                    List <U.AddrResult> list = SoundRoomForm.MakeList();
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (!U.isSafetyOffset(list[i].addr))
                        {
                            continue;
                        }
                        uint   textid = Program.ROM.u32(list[i].addr + 12);
                        string str    = FETextDecode.Direct(textid);

                        pleaseWait.DoEvents("SoundRoom:" + U.To0xHexString(textid));
                        FontImporter(str);
                    }
                }
                //その他文字列
                {
                    List <U.AddrResult> list = OtherTextForm.MakeList();
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (!U.isSafetyOffset(list[i].addr))
                        {
                            continue;
                        }

                        uint   p_str = Program.ROM.p32(list[i].addr);
                        string str   = Program.ROM.getString(p_str);

                        pleaseWait.DoEvents("Other:" + U.To0xHexString(p_str));
                        FontImporter(str);
                    }
                }

                Program.Undo.Push(this.UndoData);
            }
        }
Esempio n. 4
0
        //ワンライナー
        public static String Direct(uint id)
        {
            FETextDecode d = new FETextDecode();

            return(d.Decode(id));
        }
Esempio n. 5
0
        public void ExportallText(Form self
                                  , string writeTextFileName
                                  , string tralnslate_from, string tralnslate_to
                                  , string rom_from, string rom_to
                                  , bool isModifiedTextOnly
                                  , bool isOneLiner
                                  )
        {
            //少し時間がかかるので、しばらくお待ちください表示.
            using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(self))
            {
                FETextDecode decode = new FETextDecode();

                Dictionary <string, string> transDic = TranslateTextUtil.MakeFixedDic(tralnslate_from, tralnslate_to, rom_from, rom_to);
                if (ExportFilterArray != null)
                {
                    using (StreamWriter writer = new StreamWriter(writeTextFileName))
                    {
                        List <U.AddrResult> list = TextForm.MakeItemList();
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (!ExportFilterArray.ContainsKey(i))
                            {
                                continue;
                            }
                            string text = decode.Decode((uint)i);

                            pleaseWait.DoEvents("Text:" + U.To0xHexString((uint)i));
                            ExportText(writer, (uint)i, text, tralnslate_from, tralnslate_to, transDic, isModifiedTextOnly, isOneLiner);
                        }
                    }
                    return;
                }

                using (StreamWriter writer = new StreamWriter(writeTextFileName))
                {
                    //テキスト
                    {
                        List <U.AddrResult> list = TextForm.MakeItemList();
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (ExportFilterArray != null && ExportFilterArray[i] != false)
                            {
                                continue;
                            }
                            string text = decode.Decode((uint)i);

                            pleaseWait.DoEvents("Text:" + U.To0xHexString((uint)i));
                            ExportText(writer, (uint)i, text, tralnslate_from, tralnslate_to, transDic, isModifiedTextOnly, isOneLiner);
                        }
                    }

                    //メニュー1
                    if (Program.ROM.RomInfo.is_multibyte)
                    {
                        List <U.AddrResult> menuDefineList = MenuDefinitionForm.MakeListAll();
                        for (int n = 0; n < menuDefineList.Count; n++)
                        {
                            if (!U.isSafetyOffset(menuDefineList[n].addr + 8))
                            {
                                continue;
                            }
                            uint p = menuDefineList[n].addr + 8;
                            if (!U.isSafetyOffset(Program.ROM.p32(p)))
                            {
                                continue;
                            }
                            List <U.AddrResult> list = MenuCommandForm.MakeListPointer(p);
                            for (int i = 0; i < list.Count; i++)
                            {
                                if (!U.isSafetyOffset(list[i].addr))
                                {
                                    continue;
                                }
                                uint   text_pointer = list[i].addr + 0;
                                uint   textid       = Program.ROM.u32(text_pointer);
                                string str          = FETextDecode.Direct(textid);
                                if (str.Trim() == "")
                                {
                                    continue;
                                }

                                pleaseWait.DoEvents("Menu:" + U.To0xHexString(textid));
                                ExportText(writer, U.toPointer(text_pointer), str, tralnslate_from, tralnslate_to, transDic, isModifiedTextOnly, isOneLiner);
                            }
                        }
                    }

                    //地形
                    if (Program.ROM.RomInfo.is_multibyte)
                    {
                        List <U.AddrResult> list = MapTerrainNameForm.MakeList();
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (!U.isSafetyOffset(list[i].addr))
                            {
                                continue;
                            }
                            uint   text_pointer = list[i].addr + 0;
                            uint   textid       = Program.ROM.u32(text_pointer);
                            string str          = FETextDecode.Direct(textid);
                            if (str.Trim() == "")
                            {
                                continue;
                            }

                            pleaseWait.DoEvents("Terrain:" + U.To0xHexString(textid));
                            ExportText(writer, U.toPointer(text_pointer), str, tralnslate_from, tralnslate_to, transDic, isModifiedTextOnly, isOneLiner);
                        }
                    }

                    //サウンドルーム
                    //FE7のサウンドルームは、日本語直地
                    if (Program.ROM.RomInfo.is_multibyte && Program.ROM.RomInfo.version == 7)
                    {
                        List <U.AddrResult> list = SoundRoomForm.MakeList();
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (!U.isSafetyOffset(list[i].addr))
                            {
                                continue;
                            }
                            uint   text_pointer = list[i].addr + 12;
                            uint   textid       = Program.ROM.u32(text_pointer);
                            string str          = FETextDecode.Direct(textid);
                            if (str.Trim() == "")
                            {
                                continue;
                            }

                            pleaseWait.DoEvents("SoundRoom:" + U.To0xHexString(textid));
                            ExportText(writer, U.toPointer(text_pointer), str, tralnslate_from, tralnslate_to, transDic, isModifiedTextOnly, isOneLiner);
                        }
                    }
                    //その他文字列
                    {
                        List <U.AddrResult> list = OtherTextForm.MakeList();
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (!U.isSafetyOffset(list[i].addr))
                            {
                                continue;
                            }
                            uint   text_pointer = list[i].addr + 0;
                            uint   p_str        = Program.ROM.p32(text_pointer);
                            string str          = Program.ROM.getString(p_str);
                            if (str.Trim() == "")
                            {
                                continue;
                            }

                            pleaseWait.DoEvents("Other:" + U.To0xHexString(p_str));
                            ExportText(writer, U.toPointer(text_pointer), str, tralnslate_from, tralnslate_to, transDic, isModifiedTextOnly, isOneLiner);
                        }
                    }
                }
            }
        }