private void SEARCH_COUNT_BUTTON_Click(object sender, EventArgs e) { Dictionary <uint, FETextDecode.huffman_count_st> dic = new Dictionary <uint, FETextDecode.huffman_count_st>(); //初期値を入れる. uint addr = (uint)InputFormRef.BaseAddress; int limitsize = (int)InputFormRef.DataCount; for (int i = 0; i < limitsize; i++) { FETextDecode.huffman_count_st st = new FETextDecode.huffman_count_st(); st.code_number = i; dic[Program.ROM.u16(addr)] = st; addr += InputFormRef.BlockSize; } //テキスト探索. FETextDecode textdecoder = new FETextDecode(); List <U.AddrResult> list = TextForm.MakeItemList(); for (int i = 0; i < list.Count; i++) { uint textaddr = Program.ROM.p32(list[i].addr); textdecoder.huffman_count(textaddr, ref dic); } SEARCH_COUNT_LIST.Items.Clear(); uint minimaumCount = (uint)SEARCH_COUNT.Value; foreach (var pair in dic) { if (pair.Key == 0) { continue; } if (pair.Value.count > minimaumCount) { continue; } string line = pair.Value.code_number.ToString(); line = line + "," + U.ConvertUnitToMojiChar((uint)pair.Key); line = line + "," + pair.Value.count.ToString(); for (int n = 0; n < pair.Value.unsing_text_addr.Count; n++) { for (int i = 0; i < list.Count; i++) { uint textaddr = Program.ROM.p32(list[i].addr); if (pair.Value.unsing_text_addr[n] == textaddr) { line = line + "," + i.ToString("X"); break; } } } SEARCH_COUNT_LIST.Items.Add(line); } }
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); } }
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); } } } } }