private ResourcePage LoadPage(StructureValueCollection values, int index, ThirdGenCacheFileReference[] externalFiles)
        {
            var result = new ResourcePage();

            result.Index             = index;
            result.Salt              = (ushort)values.GetInteger("salt");
            result.Flags             = (byte)values.GetInteger("flags");
            result.CompressionMethod = ((int)values.GetInteger("compression codec index") != -1)
                                ? ResourcePageCompression.Deflate
                                : ResourcePageCompression.None; // FIXME: hax/laziness
            var externalFile = (int)values.GetInteger("shared cache file index");

            result.FilePath         = (externalFile != -1) ? externalFiles[externalFile].Path : null;
            result.Unknown1         = (int)values.GetIntegerOrDefault("unknown 1", 0);
            result.Offset           = (int)values.GetInteger("compressed block offset");
            result.CompressedSize   = (int)values.GetInteger("compressed block size");
            result.UncompressedSize = (int)values.GetInteger("uncompressed block size");
            result.Checksum         = values.GetInteger("checksum");
            result.Hash1            = values.GetRaw("hash 1");
            result.Hash2            = values.GetRaw("hash 2");
            result.Hash3            = values.GetRaw("hash 3");
            result.Unknown2         = (int)values.GetIntegerOrDefault("unknown 2", 0);
            result.Unknown3         = (int)values.GetIntegerOrDefault("unknown 3", 0);
            return(result);
        }
Пример #2
0
        private static ResourcePage ReadResourcePage(IReader reader, byte version)
        {
            if (version > 1)
            {
                throw new InvalidOperationException("Unrecognized \"rspg\" block version");
            }

            var page = new ResourcePage();

            page.Index = reader.ReadInt32();
            if (version > 0)
            {
                page.Salt = reader.ReadUInt16();
            }
            page.Flags    = reader.ReadByte();
            page.FilePath = reader.ReadAscii();
            if (page.FilePath.Length == 0)
            {
                page.FilePath = null;
            }
            page.Offset            = reader.ReadInt32();
            page.UncompressedSize  = reader.ReadInt32();
            page.CompressionMethod = (ResourcePageCompression)reader.ReadByte();
            page.CompressedSize    = reader.ReadInt32();
            page.Checksum          = reader.ReadUInt32();
            page.Hash1             = ReadByteArray(reader);
            page.Hash2             = ReadByteArray(reader);
            page.Hash3             = ReadByteArray(reader);
            page.Unknown1          = reader.ReadInt32();
            page.AssetCount        = reader.ReadInt32();
            page.Unknown2          = reader.ReadInt32();
            return(page);
        }
Пример #3
0
        public int InjectResourcePage(ResourcePage page, IReader reader)
        {
            if (_resources == null)
            {
                return(-1);
            }
            if (page == null)
            {
                throw new ArgumentNullException("page is null");
            }

            // Don't inject the page if it's already been injected
            int newIndex;

            if (_pageIndices.TryGetValue(page, out newIndex))
            {
                return(newIndex);
            }

            // Add the page and associate its new index with it
            newIndex   = _resources.Pages.Count;
            page.Index = newIndex;             // haxhaxhax
            LoadResourceTable(reader);
            _resources.Pages.Add(page);
            _pageIndices[page] = newIndex;
            return(newIndex);
        }
Пример #4
0
        public void AllSectionsButtonClick_IsResourcePageOpen()
        {
            TopBarPanel topBarPanel = homePage.OpenTopBarPanel();

            ResourcePage resourcePage = topBarPanel.AllSectionsButtonClick();

            AllureLifecycle.Instance.Verify.That("Portal sections displayed", () => resourcePage.IsPortalSectionsDisplayed(), Is.True);
        }
        public void AllSectionsButtonClick_IsResourcePageOpen()
        {
            TopBarPanel topBarPanel = homePage.OpenTopBarPanel();

            ResourcePage resourcePage = topBarPanel.AllSectionsButtonClick();

            Assert.IsTrue(resourcePage.IsPortalSectionsDisplayed());
        }
Пример #6
0
 public SpringCMSteps(ScenarioContext context)
 {
     _context      = context;
     _launcher     = new SpringCMLauncher();
     _webDriver    = _launcher.GetWebDriverObject(testSetting.BrowserName);
     _homePage     = new HomePage(_webDriver);
     _demoPage     = new DemoPage(_webDriver);
     _resourcePage = new ResourcePage(_webDriver);
 }
        public void LogoClick_IsHomePageOpen()
        {
            TopBarPanel topBarPanel = homePage.OpenTopBarPanel();

            ResourcePage resourcePage = topBarPanel.AllSectionsButtonClick();

            HomePage pageHome = resourcePage.LogoClick();

            Assert.IsTrue(pageHome.IsNewsBlockDisplayed());
        }
        public void LogoClick_IsHomePageOpen()
        {
            TopBarPanel topBarPanel = homePage.OpenTopBarPanel();

            ResourcePage resourcePage = topBarPanel.AllSectionsButtonClick();

            HomePage pageHome = resourcePage.LogoClick();

            AllureLifecycle.Instance.Verify.That("News block displayed", () => pageHome.IsNewsBlockDisplayed(), Is.True);
        }
Пример #9
0
        public int InjectExtractedResourcePage(ResourcePage resourcePage, ExtractedPage extractedPage, IStream stream)
        {
            if (extractedPage == null)
            {
                throw new ArgumentNullException("extractedPage");
            }

            var injector  = new ResourcePageInjector(_cacheFile);
            var rawOffset = injector.InjectPage(stream, resourcePage, extractedPage.ExtractedPageData);

            _extractedResourcePages[extractedPage] = extractedPage.ResourcePageIndex;

            return(rawOffset);
        }
Пример #10
0
        public int InjectResourcePage(ResourcePage page, IStream stream)
        {
            if (_resources == null)
            {
                return(-1);
            }
            if (page == null)
            {
                throw new ArgumentNullException("page is null");
            }

            // Don't inject the page if it's already been injected
            int newIndex;

            if (_pageIndices.TryGetValue(page, out newIndex))
            {
                return(newIndex);
            }

            // Add the page and associate its new index with it
            var extractedRaw = _container.FindExtractedResourcePage(page.Index);

            newIndex   = _resources.Pages.Count;
            page.Index = newIndex;             // haxhaxhax, oh aaron
            LoadResourceTable(stream);

            // Inject?
            if (_injectRaw && extractedRaw != null)
            {
                if (_findExistingPages && page.FilePath != null &&
                    (page.FilePath.Contains("mainmenu") || page.FilePath.Contains("shared") ||
                     ((page.FilePath.Contains("campaign") && (_cacheFile.Type == CacheFileType.SinglePlayer)))))
                {
                    // Nothing!
                }
                else
                {
                    var rawOffset = InjectExtractedResourcePage(page, extractedRaw, stream);
                    page.Offset   = rawOffset;
                    page.FilePath = null;
                }
            }

            _resources.Pages.Add(page);
            _pageIndices[page] = newIndex;
            return(newIndex);
        }
Пример #11
0
    void Awake()
    {
        IsQstUps   = new bool[4];
        IsQstDowns = new bool[4];
        for (int i = 0; i < 4; i++)
        {
            IsQstUps[i]   = false;
            IsQstDowns[i] = false;
        }

        PageTypes    = new PageType[6];
        PageTypes[0] = new CharacterPage();
        PageTypes[1] = new WeaponPage();
        PageTypes[2] = new ResourcePage();
        PageTypes[3] = new StagePage();
        PageTypes[4] = new ItemPage();
        PageTypes[5] = new DataPage();
        Page         = PageTypes[0];
    }
        private StructureValueCollection SerializePage(ResourcePage page, ThirdGenCacheFileReference[] externalFiles)
        {
            var result = new StructureValueCollection();

            result.SetInteger("salt", page.Salt);
            result.SetInteger("flags", page.Flags);
            result.SetInteger("compression codec index",
                              (page.CompressionMethod != ResourcePageCompression.None) ? 0 : 0xFFFFFFFF);
            result.SetInteger("shared cache file index",
                              (page.FilePath != null) ? (uint)FindExternalFile(externalFiles, page.FilePath) : 0xFFFFFFFF);
            result.SetInteger("unknown 1", (uint)page.Unknown1);
            result.SetInteger("compressed block offset", (uint)page.Offset);
            result.SetInteger("compressed block size", (uint)page.CompressedSize);
            result.SetInteger("uncompressed block size", (uint)page.UncompressedSize);
            result.SetInteger("checksum", page.Checksum);
            result.SetRaw("hash 1", page.Hash1);
            result.SetRaw("hash 2", page.Hash2);
            result.SetRaw("hash 3", page.Hash3);
            result.SetInteger("unknown 2", (uint)page.Unknown2);
            result.SetInteger("unknown 3", (uint)page.Unknown3);
            return(result);
        }
Пример #13
0
        public int InjectResourcePage(ResourcePage page, IStream stream)
        {
            if (_resources == null)
            {
                return(-1);
            }
            if (page == null)
            {
                throw new ArgumentNullException("page is null");
            }

            // Don't inject the page if it's already been injected
            int newIndex;

            if (_pageIndices.TryGetValue(page, out newIndex))
            {
                return(newIndex);
            }

            // Add the page and associate its new index with it
            var extractedRaw = _container.FindExtractedResourcePage(page.Index);

            newIndex   = _resources.Pages.Count;
            page.Index = newIndex;             // haxhaxhax, oh aaron
            LoadResourceTable(stream);

            // Inject?
            if (extractedRaw != null)
            {
                var rawOffset = InjectExtractedResourcePage(page, extractedRaw, stream);
                page.Offset   = rawOffset;
                page.FilePath = null;
            }

            _resources.Pages.Add(page);
            _pageIndices[page] = newIndex;
            return(newIndex);
        }
Пример #14
0
        public void BVT_S02_TC09_CanLoadResourcePageImages()
        {
            foreach (MenuItemOfResource item in Enum.GetValues(typeof(MenuItemOfResource)))
            {
                ResourcePage page;
                switch (item)
                {
                case (MenuItemOfResource.AppRegistrationTool):
                case (MenuItemOfResource.APISandbox):
                case (MenuItemOfResource.MiniLabs):
                    break;

                case (MenuItemOfResource.Training):
                    Browser.SetWaitTime(TimeSpan.FromSeconds(30));
                    Pages.Navigation.Select("Resources", item.ToString());
                    //Browser.Wait(TimeSpan.FromSeconds(20));
                    page = new ResourcePage();
                    foreach (ResourcePageImages image in Enum.GetValues(typeof(ResourcePageImages)))
                    {
                        Assert.IsTrue(page.CanLoadImage(image), string.Format("The images in resource page {0} is not loaded currectly.", item.ToString()));
                    }
                    Browser.SetWaitTime(TimeSpan.FromSeconds(Utility.DefaultWaitTime));
                    break;

                default:
                    Pages.Navigation.Select("Resources", item.ToString());
                    //Browser.Wait(TimeSpan.FromSeconds(20));
                    page = new ResourcePage();
                    foreach (ResourcePageImages image in Enum.GetValues(typeof(ResourcePageImages)))
                    {
                        Assert.IsTrue(page.CanLoadImage(image), string.Format("The images in resource page {0} is not loaded currectly.", item.ToString()));
                    }
                    break;
                }
            }
        }
        private byte[] ReadResourcePageData(BlamCacheFile cacheFile, ResourcePage page)
        {
            BlamCacheFile cache         = cacheFile;
            string        cacheFilePath = "";
            bool          cleanup       = false;

            if (page.FilePath != null)
            {
                cacheFilePath = Util.VisualStudioProvider.TryGetSolutionDirectoryInfo().FullName + "\\" + page.FilePath;
                cleanup       = true;
                cache         = new BlamCacheFile(cacheFilePath);
            }

            byte[] decompressed = new byte[page.UncompressedSize];
            cacheFile.Reader.SeekTo(page.Offset);

            byte[] compressed = cacheFile.Reader.ReadBlock(page.CompressedSize);

            if (page.CompressionMethod == ResourcePageCompression.None)
            {
                decompressed = compressed;
            }
            else if (page.CompressionMethod == ResourcePageCompression.Deflate)
            {
                using (DeflateStream stream = new DeflateStream(new MemoryStream(compressed), CompressionMode.Decompress))
                    stream.Read(decompressed, 0, BitConverter.ToInt32(BitConverter.GetBytes(page.UncompressedSize), 0));
            }


            if (cleanup)
            {
                cache.Dispose();
            }

            return(decompressed);
        }
Пример #16
0
        public App()
        {
            InitializeComponent();

            MainPage = new ResourcePage();
        }
Пример #17
0
 public ResourceSubjectsPageSteps(ResourceSubjectsPage resourceSubjectsPage, ResourcePage resourcePage)
 {
     this.resourceSubjectsPage = resourceSubjectsPage;
     this.resourcePage         = resourcePage;
 }
Пример #18
0
		/// <summary>
		/// Reads the resource data for a sound from a stream and passes it back into the ISound.
		/// </summary>
		/// <param name="reader">The stream to read the sound data from.</param>
		/// <param name="sound">The sound's metadata.</param>
		/// <param name="resourceCacheFolder"> </param>
		/// <param name="buildInfo">Information about the cache file's target engine.</param>
		/// <param name="cacheFile"> </param>
		/// <param name="resourcePages"> </param>
		public static void ReadSoundData(IReader reader, ISound sound, ICacheFile cacheFile, ResourcePage[] resourcePages,
			string resourceCacheFolder, EngineDescription buildInfo)
		{
			// TODO: me
		}
Пример #19
0
 /// <summary>
 ///     Adds information about a resource page to the container.
 /// </summary>
 /// <param name="page">The page to add.</param>
 public void AddResourcePage(ResourcePage page)
 {
     _pagesByIndex[page.Index] = page;
 }
 public ResourcePageSteps(ResourcePage resourcePage, ResourcePageContext context)
 {
     this.resourcePage = resourcePage;
     this.context      = context;
 }
 public NewResourcePageSteps(ResourcePage resourcePage, ResourceSubjectsPage resourceSubjectsPage, ResourcePageContext context)
 {
     this.resourcePage         = resourcePage;
     this.resourceSubjectsPage = resourceSubjectsPage;
     this.context = context;
 }
Пример #22
0
        private byte[] ReadPageData(ResourceData resource, ResourcePage page)
        {
            string cacheFilePath;

            var cache = Cache;

            if (page.SharedCacheIndex != -1)
            {
                cacheFilePath = ResourceLayoutTable.SharedFiles[page.SharedCacheIndex].MapPath;
                var pathComponent = cacheFilePath.Split('\\');
                cacheFilePath = pathComponent[pathComponent.Length - 1];
                cacheFilePath = Path.Combine(Cache.Directory.FullName, cacheFilePath);

                if (cacheFilePath != Cache.CacheFile.FullName)
                {
                    if (Cache.SharedCacheFiles.ContainsKey(cacheFilePath))
                    {
                        cache = Cache.SharedCacheFiles[cacheFilePath];
                    }
                    else
                    {
                        var newCache = new FileInfo(cacheFilePath);
                        using (var newCacheStream = newCache.OpenRead())
                            using (var newCacheReader = new EndianReader(newCacheStream))
                            {
                                var newMapFile = new MapFile();
                                newMapFile.Read(newCacheReader);
                                cache = Cache.SharedCacheFiles[cacheFilePath] = new GameCacheGen3(newMapFile, newCache);
                            }
                    }
                }
            }

            var decompressed = new byte[page.UncompressedBlockSize];

            using (var cacheStream = cache.OpenCacheRead())
                using (var reader = new EndianReader(cacheStream, EndianFormat.BigEndian))
                {
                    var sectionTable = cache.BaseMapFile.Header.SectionTable;
                    var blockOffset  = sectionTable.GetOffset(CacheFileSectionType.ResourceSection, page.BlockAddress);

                    reader.SeekTo(blockOffset);
                    var compressed = reader.ReadBytes(BitConverter.ToInt32(BitConverter.GetBytes(page.CompressedBlockSize), 0));

                    if (resource.ResourceTypeIndex != -1 && GetResourceTypeName(resource) == "sound_resource_definition")
                    {
                        return(compressed);
                    }

                    if (page.CompressionCodecIndex == -1)
                    {
                        reader.BaseStream.Read(decompressed, 0, BitConverter.ToInt32(BitConverter.GetBytes(page.UncompressedBlockSize), 0));
                    }
                    else
                    {
                        using (var readerDeflate = new DeflateStream(new MemoryStream(compressed), CompressionMode.Decompress))
                            readerDeflate.Read(decompressed, 0, BitConverter.ToInt32(BitConverter.GetBytes(page.UncompressedBlockSize), 0));
                    }
                }

            return(decompressed);
        }