/// <summary> /// Gets the offset to the message relative to the start of the file /// </summary> public string GetMessageOffset(ushort id, Rom.Language language) { id = (Dialogs[language].ContainsKey(id)) ? id : (ushort)1; TextboxMessage mesg = Dialogs[language][id]; return($"{mesg.StartOffset:X6}:{mesg.EndOffset:X6}"); }
private string GetMessage(TextboxMessage textboxMessage, Rom.Language language) { Dialog dialog; byte[] data; using (BinaryReader message_data_static = new BinaryReader(rom.Files.GetMessageFile(language))) { message_data_static.BaseStream.Position = textboxMessage.StartOffset; data = message_data_static.ReadBytes((int)textboxMessage.Length); } if (language == Rom.Language.Japanese) { dialog = JpnEscapeCustomCodes(data); } else { dialog = NesEscapeCustomCodes(data); } var settings = new DialogWriterSettings(language, DialogWriterSettings.OutputType.Textbox); return(dialog.Print(settings)); }
private void LoadTextTable(BinaryReader file, Rom.Language lang) { List <TextboxMessage> messages = new List <TextboxMessage>(); Dictionary <ushort, TextboxMessage> TextBank = new Dictionary <ushort, TextboxMessage>(); InitializeTextBank(TextBank, file); Dialogs.Add(lang, TextBank); }
/// <summary> /// Returns a message_data_static file (the game's text dialog) for a specific language /// </summary> /// <param name="language"></param> /// <returns></returns> public RomFile GetMessageFile(Rom.Language language) { switch (language) { case Rom.Language.Japanese: return(GetFile(ORom.FileList.jpn_message_data_static)); case Rom.Language.English: return(GetFile(ORom.FileList.nes_message_data_static)); case Rom.Language.German: return(GetFile(ORom.FileList.ger_message_data_static)); case Rom.Language.French: return(GetFile(ORom.FileList.fra_message_data_static)); default: throw new NotImplementedException(); } }
private void inputButton_Click(object sender, EventArgs e) { Rom.Language language = Rom.Language.Japanese; if (ushort.TryParse(inputTextBox.Text, System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.InvariantCulture, out ushort id) && g != null) { outRichTextBox.Clear(); outRichTextBox.AppendText(g.GetMessageOffset(id, language)); outRichTextBox.AppendText(Environment.NewLine); outRichTextBox.AppendText(g.GetMessage(id, language)); outRichTextBox.AppendText(Environment.NewLine); } }
public static void SetLanguage(Stream rom, Rom.Language language) { long pos = rom.Position; rom.Position = 0x3E; byte chr = language switch { Rom.Language.Japanese => 0x4A, Rom.Language.English => 0x45, _ => throw new NotImplementedException(), }; rom.WriteByte(chr); rom.Position = pos; }
/// <summary> /// Returns the raw data for a single message as a list of integers /// </summary> /// <param name="id">message id</param> /// <param name="language">language</param> /// <returns>the message data as a list of integers</returns> public List <int> GetMessageData(ushort id, Rom.Language language) { TextboxMessage mesg = Dialogs[language][id]; List <int> result = new List <int>(); using (BinaryReader message_data_static = new BinaryReader(rom.Files.GetMessageFile(language))) { message_data_static.BaseStream.Position = mesg.StartOffset; for (int i = 0; i < (mesg.EndOffset - mesg.StartOffset) / 4; i++) { result.Add(message_data_static.ReadBigInt32()); } } return(result); }
public static void SetLanguage(Stream rom, Rom.Language language) { long pos = rom.Position; byte chr; rom.Position = 0x3E; switch (language) { case Rom.Language.Japanese: chr = 0x4A; break; case Rom.Language.English: chr = 0x45; break; default: throw new NotImplementedException(); } rom.WriteByte(chr); rom.Position = pos; }
public DialogWriterSettings(Rom.Language lang, OutputType style, bool verbose = true) { Language = lang; OutputStyle = style; VerboseMode = verbose; }
public IEnumerable <ushort> GetMessageEnumerator(Rom.Language lang) { return(Dialogs[lang].Keys.AsEnumerable()); }
private void LoadTextTable_Pal2(BinaryReader code, Dictionary <ushort, TextboxMessage> nes_message, Rom.Language language) { uint current, next; Dictionary <ushort, TextboxMessage> TextBank = new Dictionary <ushort, TextboxMessage>(); next = code.ReadBigUInt32() & 0xFFFFFF; var nes_message_query = from x in nes_message.Values orderby x.Id ascending select x; foreach (TextboxMessage item in nes_message_query) { current = next; next = code.ReadBigUInt32(); if ((next & 0xFFFFFF) == 0) { break; } TextBank.Add(item.Id, new TextboxMessage(item.Message, current, next)); } Dialogs.Add(language, TextBank); }
public string GetMessage(ushort id, Rom.Language language) { id = (Dialogs[language].ContainsKey(id)) ? id : (ushort)1; return(GetMessage(Dialogs[language][id], language)); }