예제 #1
0
        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();
        }
예제 #2
0
        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();
        }
예제 #3
0
        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));
                }
        }
예제 #4
0
 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);
 }
예제 #5
0
 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;
     }
 }
예제 #6
0
 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);
 }
예제 #7
0
 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);
 }
예제 #8
0
 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);
 }
예제 #9
0
        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);
            }
        }
예제 #10
0
        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();
            }
        }
예제 #11
0
        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();
            }
        }
예제 #12
0
        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);
        }
예제 #13
0
        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;
            }
        }
예제 #14
0
        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);
            }
        }
예제 #15
0
        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);
            }
        }
예제 #16
0
 public UiWpdTableLeaf(string name, WpdEntry entry, WpdArchiveListing listing)
     : base(name, UiNodeType.FileTableLeaf)
 {
     Entry = entry;
     Listing = listing;
 }
예제 #17
0
 public UiWpdLeafsAccessor(WpdArchiveListing listing, bool? conversion, params WpdEntry[] leafs)
 {
     _listing = listing;
     _leafs = leafs;
     _conversion = conversion;
 }
예제 #18
0
 public void Show(WpdArchiveListing listing, WpdEntry entry)
 {
     Visibility = Visibility.Visible;
     Texture = GLTextureReader.ReadFromWpd(listing, entry);
 }
예제 #19
0
 public UiWpdLeafsAccessor(WpdArchiveListing listing, bool?conversion, params WpdEntry[] leafs)
 {
     _listing    = listing;
     _leafs      = leafs;
     _conversion = conversion;
 }
예제 #20
0
 public UiWpdTableLeaf(string name, WpdEntry entry, WpdArchiveListing listing)
     : base(name, UiNodeType.FileTableLeaf)
 {
     Entry   = entry;
     Listing = listing;
 }
예제 #21
0
 public void Show(WpdArchiveListing listing, WpdEntry entry)
 {
     Visibility = Visibility.Visible;
     Texture    = DxTextureReader.ReadFromWpd(listing, entry);
 }