private static void DumpSharedResources(string mapPath, EngineDatabase db) { ICacheFile cacheFile; ResourceTable resources; using (var reader = new EndianReader(File.OpenRead(mapPath), Endian.BigEndian)) { cacheFile = CacheFileLoader.LoadCacheFile(reader, db); resources = cacheFile.Resources.LoadResourceTable(reader); } using (var output = new StreamWriter(Path.ChangeExtension(mapPath, ".txt"))) { output.WriteLine("Shared resources referenced by {0}:", Path.GetFileName(mapPath)); output.WriteLine(); output.WriteLine("Rsrc Datum Map File Class Tag"); output.WriteLine("---------- -------- ----- ---"); foreach (Resource resource in resources.Resources.Where(r => r.Location != null && r.ParentTag != null)) { // If either page has a null file path, then it's shared ResourcePointer loc = resource.Location; string primaryFile = (loc.PrimaryPage != null) ? loc.PrimaryPage.FilePath : null; string secondaryFile = (loc.SecondaryPage != null) ? loc.SecondaryPage.FilePath : null; if (primaryFile != null || secondaryFile != null) { string className = CharConstant.ToString(resource.ParentTag.Class.Magic); string name = cacheFile.FileNames.GetTagName(resource.ParentTag) ?? resource.ParentTag.Index.ToString(); string fileName = primaryFile ?? secondaryFile; fileName = fileName.Substring(fileName.IndexOf('\\') + 1); output.WriteLine("{0} {1, -12} {2} {3}", resource.Index, fileName, className, name); } } } }
private ResourcePointer LoadPointer(StructureValueCollection values, IList <ResourcePage> pages, IList <ResourceSize> sizes) { var result = new ResourcePointer(); var primaryPage = (int)values.GetInteger("primary page index"); result.PrimaryPage = (primaryPage != -1) ? pages[primaryPage] : null; result.PrimaryOffset = (int)values.GetInteger("primary offset"); var primarySize = (int)values.GetInteger("primary size index"); result.PrimarySize = (primarySize != -1) ? sizes[primarySize] : null; var secondaryPage = (int)values.GetInteger("secondary page index"); result.SecondaryPage = (secondaryPage != -1) ? pages[secondaryPage] : null; result.SecondaryOffset = (int)values.GetInteger("secondary offset"); var secondarySize = (int)values.GetInteger("secondary size index"); result.SecondarySize = (secondarySize != -1) ? sizes[secondarySize] : null; if (values.HasInteger("tertiary page index")) { var tertiaryPage = (int)values.GetInteger("tertiary page index"); result.TertiaryPage = (tertiaryPage != -1) ? pages[tertiaryPage] : null; result.TertiaryOffset = (int)values.GetInteger("tertiary offset"); var tertiarySize = (int)values.GetInteger("tertiary size index"); result.TertiarySize = (tertiarySize != -1) ? sizes[tertiarySize] : null; } return(result); }
/// <summary> /// Initializes a new instance of the <see cref="ExtractedResourcePointer" /> class. /// </summary> /// <param name="basePointer">The original location information for the resource.</param> public ExtractedResourcePointer(ResourcePointer basePointer) { OriginalPrimaryPageIndex = (basePointer.PrimaryPage != null) ? basePointer.PrimaryPage.Index : -1; PrimaryOffset = basePointer.PrimaryOffset; PrimaryUnknown = basePointer.PrimaryUnknown; OriginalSecondaryPageIndex = (basePointer.SecondaryPage != null) ? basePointer.SecondaryPage.Index : -1; SecondaryOffset = basePointer.SecondaryOffset; SecondaryUnknown = basePointer.SecondaryUnknown; }
public TreeNodeLocalizeResource(ResourcePointer owner, CultureInfo culture) { _pointer = owner; _culture = culture; Text = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0} [{1}]", _culture.NativeName, _culture.Name); ImageIndex = TreeViewObjectExplorer.GetLangaugeImageByName(_culture.Name); SelectedImageIndex = ImageIndex; }
public TreeNodeLocalizeResource(ResourcePointer owner, string culture) { _pointer = owner; _name = culture; if (string.CompareOrdinal("zh", _name) == 0) { _culture = CultureInfo.GetCultureInfo("zh-CHT"); Text = "中文 zh"; ImageIndex = TreeViewObjectExplorer.GetLangaugeImageByName(_name); SelectedImageIndex = ImageIndex; } }
private StructureValueCollection SerializePointer(ResourcePointer pointer) { var result = new StructureValueCollection(); result.SetInteger("primary page index", (pointer.PrimaryPage != null) ? (uint)pointer.PrimaryPage.Index : 0xFFFFFFFF); result.SetInteger("primary offset", (uint)pointer.PrimaryOffset); result.SetInteger("primary unknown", (uint)pointer.PrimaryUnknown); result.SetInteger("secondary page index", (pointer.SecondaryPage != null) ? (uint)pointer.SecondaryPage.Index : 0xFFFFFFFF); result.SetInteger("secondary offset", (uint)pointer.SecondaryOffset); result.SetInteger("secondary unknown", (uint)pointer.SecondaryUnknown); return(result); }
/// <summary> /// Initializes a new instance of the <see cref="ExtractedResourcePointer" /> class. /// </summary> /// <param name="basePointer">The original location information for the resource.</param> public ExtractedResourcePointer(ResourcePointer basePointer) { OriginalPrimaryPageIndex = (basePointer.PrimaryPage != null) ? basePointer.PrimaryPage.Index : -1; PrimaryOffset = basePointer.PrimaryOffset; PrimarySize = basePointer.PrimarySize; OriginalSecondaryPageIndex = (basePointer.SecondaryPage != null) ? basePointer.SecondaryPage.Index : -1; SecondaryOffset = basePointer.SecondaryOffset; SecondarySize = basePointer.SecondarySize; OriginalTertiaryPageIndex = (basePointer.TertiaryPage != null) ? basePointer.TertiaryPage.Index : -1; TertiaryOffset = basePointer.TertiaryOffset; TertiarySize = basePointer.TertiarySize; }
private ResourcePointer LoadPointer(StructureValueCollection values, IList <ResourcePage> pages) { var result = new ResourcePointer(); var primaryPage = (int)values.GetInteger("primary page index"); result.PrimaryPage = (primaryPage != -1) ? pages[primaryPage] : null; result.PrimaryOffset = (int)values.GetInteger("primary offset"); result.PrimaryUnknown = (int)values.GetInteger("primary unknown"); var secondaryPage = (int)values.GetInteger("secondary page index"); result.SecondaryPage = (secondaryPage != -1) ? pages[secondaryPage] : null; result.SecondaryOffset = (int)values.GetInteger("secondary offset"); result.SecondaryUnknown = (int)values.GetInteger("secondary unknown"); return(result); }
public void SetResourcePointer(ResourcePointer pointer, int index = 0) { switch (index) { case 0: LOD1TextureDataOffset = pointer; break; case 1: LOD2TextureDataOffset = pointer; break; case 2: LOD3TextureDataOffset = pointer; break; } }
private StructureValueCollection SerializePointer(ResourcePointer pointer) { var result = new StructureValueCollection(); result.SetInteger("primary page index", (pointer.PrimaryPage != null) ? (uint)pointer.PrimaryPage.Index : 0xFFFFFFFF); result.SetInteger("primary offset", (uint)pointer.PrimaryOffset); result.SetInteger("primary size index", (pointer.PrimarySize != null) ? (uint)pointer.PrimarySize.Index : 0xFFFFFFFF); result.SetInteger("secondary page index", (pointer.SecondaryPage != null) ? (uint)pointer.SecondaryPage.Index : 0xFFFFFFFF); result.SetInteger("secondary offset", (uint)pointer.SecondaryOffset); result.SetInteger("secondary size index", (pointer.SecondarySize != null) ? (uint)pointer.SecondarySize.Index : 0xFFFFFFFF); if (_buildInfo.HeaderSize == 0x1E000) { result.SetInteger("tertiary page index", (pointer.TertiaryPage != null) ? (uint)pointer.TertiaryPage.Index : 0xFFFFFFFF); result.SetInteger("tertiary offset", (uint)pointer.TertiaryOffset); result.SetInteger("tertiary size index", (pointer.TertiarySize != null) ? (uint)pointer.TertiarySize.Index : 0xFFFFFFFF); } return(result); }
public void SetResourcePointer(ResourcePointer pointer, int index = 0) { GeometryBlockInfo.BlockOffset = pointer; }
public void SetResourcePointer(ResourcePointer pointer, int index = 0) { FileOffset = pointer; }
private void CopyLocalResource(Stream outputStream, IResourceBlock resourceBlock, ResourcePointer address, int length, int index = 0) { // the resource has already been copied if (address < GetFilePosition( )) { // if this is true then we've already handled this resource so use the // new address ResourcePointer newAddress; if (ShiftData.TryGetValue(address, out newAddress)) { resourceBlock.SetResourcePointer(newAddress, index); return; } // has the resource already been copied? Has it been moved? // well, shit. System.Diagnostics.Debug.WriteLineIf(address < GetFilePosition( ), "Warning: address < GetFilePosition()"); this.Seek(address); } // this is not strictly an error but it should be treated as such if (address > GetFilePosition( )) { System.Diagnostics.Debug.WriteLineIf(address > GetFilePosition( ), "Warning: address > GetFilePosition()"); this.Seek(address); } System.Diagnostics.Debug.WriteLineIf(address % 512 != 0, "Warning: address % 512 != 0"); if (outputStream.Position % 512 != 0) { System.Diagnostics.Debug.WriteLineIf(outputStream.Position % 512 != 0, "Warning: output address % 512 != 0"); } var position = outputStream.Position; ShiftData[address] = ( int )position; resourceBlock.SetResourcePointer(( int )position, index); var size = Padding.Align(length, 512); this.BufferedCopyBytesTo(size, outputStream); }
public void AfterComposition() { ResourcePointer.FillRepository(_repository); }