private static FFTText GetText(Stream iso, Context context, XmlNode doc, BytesFromIso reader, GenericCharMap charmap, BackgroundWorker worker) { IDictionary <Guid, ISerializableFile> files = GetFiles(iso, context, doc, reader, charmap, worker); if (files == null || worker.CancellationPending) { return(null); } var quickEditLookup = GetQuickEditLookup(doc.SelectSingleNode("//QuickEdit"), worker); var quickEdit = new QuickEdit(context, files, quickEditLookup); if (quickEdit == null || worker.CancellationPending) { return(null); } return(new FFTText(context, files, quickEdit)); }
public static FFTText GetFilesXml(XmlNode doc, BackgroundWorker worker, Set <Guid> guidsToLoadFromIso, Stream iso) { Context context = (Context)Enum.Parse(typeof(Context), doc.SelectSingleNode("/FFTText/@context").InnerText); //XmlNode layoutDoc = context == Context.US_PSP ? Resources.PSP : Resources.PSX; XmlNode layoutDoc = context == Context.US_PSP ? Settings.PSPText : Settings.PSXText; GenericCharMap charmap = (context == Context.US_PSP) ? (GenericCharMap)TextUtilities.PSPMap : (GenericCharMap)TextUtilities.PSXMap; Dictionary <Guid, ISerializableFile> result = new Dictionary <Guid, ISerializableFile>(); foreach (XmlNode fileNode in doc.SelectNodes("//File")) { string guidText = fileNode.SelectSingleNode("Guid").InnerText; Guid guid = new Guid(guidText); if (worker.CancellationPending) { return(null); } FileInfo fi = GetFileInfo(context, layoutDoc.SelectSingleNode(string.Format("//Files/*[Guid='{0}']", guidText))); string fileComment = GetFileComment(doc.SelectSingleNode(string.Format("//FFTText/*[Guid='{0}']", guidText))); if (worker.CancellationPending) { return(null); } XmlNode sectionsNode = fileNode.SelectSingleNode("Sections"); result.Add( guid, AbstractFile.ConstructFile(fi.FileType, charmap, fi, GetStrings(sectionsNode), fileComment, GetSectionComments(sectionsNode))); if (worker.CancellationPending) { return(null); } } if (guidsToLoadFromIso != null && guidsToLoadFromIso.Count > 0 && iso != null) { FFTText tempText = null; if (context == Context.US_PSP) { tempText = GetPspText(iso, worker); } else if (context == Context.US_PSX) { tempText = GetPsxText(iso, worker); } Set <IFile> isoFiles = new Set <IFile>( tempText.Files.FindAll(f => f is ISerializableFile).FindAll(g => guidsToLoadFromIso.Contains((g as ISerializableFile).Layout.Guid))); isoFiles.ForEach(f => result.Add((f as ISerializableFile).Layout.Guid, f as ISerializableFile)); } XmlNode quickEditNode = layoutDoc.SelectSingleNode("//QuickEdit"); Set <Guid> guids = GetGuidsNeededForQuickEdit(quickEditNode); QuickEdit quickEdit = null; if (guids.TrueForAll(g => result.ContainsKey(g))) { quickEdit = new QuickEdit(context, result, GetQuickEditLookup(layoutDoc.SelectSingleNode("//QuickEdit"), worker)); if (quickEdit == null || worker.CancellationPending) { return(null); } } return(new FFTText(context, result, quickEdit)); }
private static IDictionary <Guid, ISerializableFile> GetFiles(Stream iso, Context context, XmlNode layoutDoc, BytesFromIso reader, GenericCharMap charmap, BackgroundWorker worker) { Dictionary <Guid, ISerializableFile> files = new Dictionary <Guid, ISerializableFile>(); foreach (XmlNode node in layoutDoc.SelectNodes("//Files/*")) { if (worker.CancellationPending) { return(null); } FileInfo fi = GetFileInfo(context, node); if (worker.CancellationPending) { return(null); } IList <byte> bytes = reader(iso, fi.PrimaryFile.Key, fi.PrimaryFile.Value, fi.Size); if (worker.CancellationPending) { return(null); } switch (fi.FileType) { case FileType.CompressedFile: files.Add(fi.Guid, new SectionedFile(charmap, fi, bytes, string.Empty, new string[fi.SectionNames.Count], true)); break; case FileType.SectionedFile: files.Add(fi.Guid, new SectionedFile(charmap, fi, bytes, string.Empty, new string[fi.SectionNames.Count])); break; case FileType.CompressibleOneShotFile: files.Add(fi.Guid, new CompressibleOneShotFile(charmap, fi, bytes, string.Empty, new string[fi.SectionNames.Count])); break; case FileType.OneShotFile: case FileType.PartitionedFile: files.Add(fi.Guid, new PartitionedFile(charmap, fi, bytes, string.Empty, new string[fi.SectionNames.Count])); break; } if (worker.CancellationPending) { return(null); } } return(new ReadOnlyDictionary <Guid, ISerializableFile>(files)); }
public static FFTText GetPsxText(Stream iso, GenericCharMap charmap, BackgroundWorker worker) { //return GetText(iso, Context.US_PSX, Resources.PSX, BytesFromPsxIso, charmap, worker); return(GetText(iso, Context.US_PSX, Settings.PSXText, BytesFromPsxIso, charmap, worker)); }
public SectionedFile(GenericCharMap map, FFTPatcher.TextEditor.FFTTextFactory.FileInfo layout, IList <byte> bytes, string fileComments, IList <string> sectionComments) : this(map, layout, bytes, fileComments, sectionComments, false) { }
public SectionedFile(GenericCharMap map, FFTTextFactory.FileInfo layout, IList <IList <string> > strings, string fileComments, IList <string> sectionComments, bool compressed) : base(map, layout, strings, fileComments, sectionComments, compressed) { }
public SectionedFile(GenericCharMap map, FFTTextFactory.FileInfo layout, IList <IList <string> > strings, string fileComments, IList <string> sectionComments) : this(map, layout, strings, fileComments, sectionComments, false) { }
public CompressibleOneShotFile(GenericCharMap map, FFTTextFactory.FileInfo layout, IList <IList <string> > strings) : base(map, layout, strings, true) { }
private IList <PatchedByteArray> GetCharMapPatches(Stream iso, Context context, GenericCharMap baseCharmap, IDictionary <byte, string> dteInfo) { if (context == Context.US_PSX) { return(GetPsxCharMapPatches(iso, baseCharmap, dteInfo)); } else if (context == Context.US_PSP) { return(GetPspCharMapPatches(iso, baseCharmap, dteInfo)); } else { return(new PatchedByteArray[0]); } }