private void ReadFontIndices(ImgbArchiveAccessor accessor, out WpdArchiveListing listing, out WpdEntry[] textureEntries, out WpdEntry[] fontEntries, out string[] names) { listing = WpdArchiveListingReader.Read(accessor); List <WpdEntry> textures = new List <WpdEntry>(4); List <WpdEntry> fonts = new List <WpdEntry>(4); foreach (WpdEntry entry in listing) { const string prefix = "wfnt"; if (!entry.NameWithoutExtension.StartsWith(prefix)) { continue; } switch (entry.Extension) { case "txbh": textures.Add(entry); break; case "wfl": fonts.Add(entry); break; } } names = SortAndExcludeNotPaired(textures, fonts); fontEntries = fonts.ToArray(); textureEntries = textures.ToArray(); }
private void Inject(WpdArchiveListing listing, WpdEntry[] fontEntries, WflContent[] fontContent) { UiInjectionManager manager = new UiInjectionManager(); using (MemoryInjectionSource source = new MemoryInjectionSource()) { String injectionRoot = Path.Combine(source.ProvideRootDirectory(), listing.ExtractionSubpath); for (int i = 0; i < fontEntries.Length; i++) { WpdEntry entry = fontEntries[i]; WflContent content = fontContent[i]; String injectionPath = Path.Combine(injectionRoot, entry.Name); MemoryStream stream = new MemoryStream(1024); source.RegisterStream(injectionPath, stream); WflFileWriter writer = new WflFileWriter(stream); writer.Write(content); stream.SetPosition(0); } UiWpdInjector injector = new UiWpdInjector(listing, fontEntries, false, source); injector.Inject(manager); } manager.WriteListings(); }
public static DxTexture ReadFromWpd(WpdArchiveListing listing, WpdEntry entry) { using (Stream headers = listing.Accessor.ExtractHeaders()) using (Stream content = listing.Accessor.ExtractContent()) { headers.SetPosition(entry.Offset); GtexData gtex; SectionHeader sectionHeader = headers.ReadContent <SectionHeader>(); switch (sectionHeader.Type) { case SectionType.Txb: gtex = ReadGtexFromTxb(headers); break; case SectionType.Vtex: gtex = ReadGtexFromVtex(headers); break; default: throw new NotImplementedException(); } return(LoadFromStream(gtex, content)); } }
public UiWpdExtractor(WpdArchiveListing listing, WpdEntry[] leafs, bool?conversion, IUiExtractionTarget target) { _listing = listing; _leafs = leafs; _conversion = conversion; _target = target; _extractors = ProvideExtractors(conversion); _headers = new Lazy <Stream>(AcquireHeaders); _content = new Lazy <Stream>(AcquireContent); }
public WpdArchiveListing Read() { using (Stream input = _accessor.ExtractHeaders()) { WpdHeader header = input.ReadContent<WpdHeader>(); WpdArchiveListing result = new WpdArchiveListing(_accessor, header.Count); result.AddRange(header.Entries); return result; } }
public UiWpdExtractor(WpdArchiveListing listing, WpdEntry[] leafs, bool? conversion, IUiExtractionTarget target) { _listing = listing; _leafs = leafs; _conversion = conversion; _target = target; _extractors = ProvideExtractors(conversion); _headers = new Lazy<Stream>(AcquireHeaders); _content = new Lazy<Stream>(AcquireContent); }
public UiWpdInjector(WpdArchiveListing listing, WpdEntry[] leafs, bool?conversion, IUiInjectionSource source) { _listing = listing; _leafs = leafs; _source = source; _conversion = conversion; _injectors = ProvideInjectors(); _headers = new Lazy <Stream>(AcquireHeaders); _content = new Lazy <Stream>(AcquireContent); }
public UiWpdInjector(WpdArchiveListing listing, WpdEntry[] leafs, bool? conversion, IUiInjectionSource source) { _listing = listing; _leafs = leafs; _source = source; _conversion = conversion; _injectors = ProvideInjectors(); _headers = new Lazy<Stream>(AcquireHeaders); _content = new Lazy<Stream>(AcquireContent); }
private void ReadXgrContent(ImgbArchiveAccessor accessor, out WpdArchiveListing listing, out WpdEntry[] fontEntries, out WflContent[] fontContent, out TextureSection[] textureHeaders, out string[] names) { using (Stream indices = accessor.ExtractHeaders()) { WpdEntry[] textureEntries; ReadFontIndices(accessor, out listing, out textureEntries, out fontEntries, out names); fontContent = ReadFontContent(indices, fontEntries); textureHeaders = ReadTextureHeaders(indices, textureEntries); } }
public static void InjectSingle(WpdArchiveListing listing, WpdEntry entry, MemoryStream output) { using (MemoryInjectionSource source = new MemoryInjectionSource()) { source.RegisterStream(String.Empty, output); UiWpdInjector injector = new UiWpdInjector(listing, new[] { entry }, false, source); UiInjectionManager manager = new UiInjectionManager(); injector.Inject(manager); manager.WriteListings(); } }
public static void InjectSingle(WpdArchiveListing listing, WpdEntry entry, MemoryStream output) { using (MemoryInjectionSource source = new MemoryInjectionSource()) { source.RegisterStream(String.Empty, output); UiWpdInjector injector = new UiWpdInjector(listing, new[] {entry}, false, source); UiInjectionManager manager = new UiInjectionManager(); injector.Inject(manager); manager.WriteListings(); } }
private UiNode[] ExpandWpdChilds() { ImgbArchiveAccessor imgbAccessor = new ImgbArchiveAccessor(_listing, _indices, _binary); WpdArchiveListing wpdListing = WpdArchiveListingReader.Read(imgbAccessor); UiNode[] result = new UiNode[wpdListing.Count]; for (int i = 0; i < result.Length; i++) { WpdEntry xgrEntry = wpdListing[i]; result[i] = new UiWpdTableLeaf(xgrEntry.Name, xgrEntry, wpdListing) { Parent = this }; } return(result); }
private void OnWpdLeafSelected(UiWpdTableLeaf wpdLeaf) { WpdEntry entry = wpdLeaf.Entry; WpdArchiveListing listing = wpdLeaf.Listing; switch (entry.Extension) { case "txbh": case "vtex": _textureViewer.Show(listing, entry); break; case "ykd": _ykd.Show(listing, entry); break; } }
public static GLTexture ReadFromWpd(WpdArchiveListing listing, WpdEntry entry) { using (Stream headers = listing.Accessor.ExtractHeaders()) using (Stream content = listing.Accessor.ExtractContent()) { headers.SetPosition(entry.Offset); GtexData gtex; SectionHeader sectionHeader = headers.ReadContent<SectionHeader>(); switch (sectionHeader.Type) { case SectionType.Txb: gtex = ReadGtexFromTxb(headers); break; case SectionType.Vtex: gtex = ReadGtexFromVtex(headers); break; default: throw new NotImplementedException(); } if (gtex.Header.LayerCount == 0) return null; int offset = 0; byte[] rawData = new byte[gtex.MipMapData.Sum(d => d.Length)]; foreach (GtexMipMapLocation mimMap in gtex.MipMapData) { using (StreamSegment textureInput = new StreamSegment(content, mimMap.Offset, mimMap.Length, FileAccess.Read)) { textureInput.EnsureRead(rawData, offset, mimMap.Length); offset += mimMap.Length; } } using (GLService.AcquireContext()) return ImageDDS.LoadFromStream(rawData, gtex); } }
public static DxTexture ReadFromWpd(WpdArchiveListing listing, WpdEntry entry) { using (Stream headers = listing.Accessor.ExtractHeaders()) using (Stream content = listing.Accessor.ExtractContent()) { headers.SetPosition(entry.Offset); GtexData gtex; SectionHeader sectionHeader = headers.ReadContent<SectionHeader>(); switch (sectionHeader.Type) { case SectionType.Txb: gtex = ReadGtexFromTxb(headers); break; case SectionType.Vtex: gtex = ReadGtexFromVtex(headers); break; default: throw new NotImplementedException(); } return LoadFromStream(gtex, content); } }
public UiWpdTableLeaf(string name, WpdEntry entry, WpdArchiveListing listing) : base(name, UiNodeType.FileTableLeaf) { Entry = entry; Listing = listing; }
public UiWpdLeafsAccessor(WpdArchiveListing listing, bool? conversion, params WpdEntry[] leafs) { _listing = listing; _leafs = leafs; _conversion = conversion; }
public void Show(WpdArchiveListing listing, WpdEntry entry) { Visibility = Visibility.Visible; Texture = GLTextureReader.ReadFromWpd(listing, entry); }
public UiWpdLeafsAccessor(WpdArchiveListing listing, bool?conversion, params WpdEntry[] leafs) { _listing = listing; _leafs = leafs; _conversion = conversion; }
public void Show(WpdArchiveListing listing, WpdEntry entry) { Visibility = Visibility.Visible; Texture = DxTextureReader.ReadFromWpd(listing, entry); }