public static void OpenPTPFile(ObjectFile objectFile, string path, PersonaEncoding.PersonaEncoding newEncoding) { if (objectFile.Object is FileStructure.Text.BMD bmd) { if (File.Exists(path)) { FileStructure.Text.PTP PTP = new FileStructure.Text.PTP(File.ReadAllBytes(path)); bmd.Open(PTP, newEncoding); } } }
public static void SavePTPFile(ObjectFile objectFile, string path, PersonaEncoding.PersonaEncoding oldEncoding = null) { if (objectFile.Object is FileStructure.Text.BMD bmd) { FileStructure.Text.PTP PTP = new FileStructure.Text.PTP(bmd); if (oldEncoding != null) { PTP.CopyOld2New(oldEncoding); } File.WriteAllBytes(path, PTP.Get()); } }
public static ObjectFile OpenFile(string name, byte[] data, FileType type) { try { object Obj; if (type == FileType.BIN) { Obj = new FileStructure.Container.BIN(data); } else if (type == FileType.SPR) { Obj = new FileStructure.SPR.SPR(data); } else if (type == FileType.TMX) { Obj = new FileStructure.Graphic.TMX(data); } else if (type == FileType.BF) { Obj = new FileStructure.Container.BF(data, name); } else if (type == FileType.PM1) { Obj = new FileStructure.Container.PM1(data); } else if (type == FileType.BMD) { Obj = new FileStructure.Text.BMD(data); } else if (type == FileType.PTP) { Obj = new FileStructure.Text.PTP(data); } else if (type == FileType.FNT) { Obj = new FileStructure.FNT.FNT(data); } else if (type == FileType.BVP) { Obj = new FileStructure.Container.BVP(name, data); } else if (type == FileType.TBL) { try { Obj = new FileStructure.Container.TBL(data, name); } catch { Obj = new FileStructure.Container.BIN(data); } } else if (type == FileType.FTD) { Obj = new FileStructure.Text.FTD(data); } else if (type == FileType.DDS) { Obj = new FileStructure.Graphic.DDS(data); } else if (type == FileType.SPD) { Obj = new FileStructure.SPR.SPD(data); } else { Obj = new FileStructure.DAT(data); } return(new ObjectFile(name, Obj)); } catch { return(new ObjectFile(name, null)); } }