private void TV1_DoubleClick(object sender, EventArgs e) { TreeNode t = TV1.SelectedNode; if (t == null || t.Parent == null) { return; } Println("Loading " + t.Text + " ..."); string DLCName = t.Parent.Text; try { if (DLCName == mainPCCFolder) { currentPCC = ME3Directory.cookedPath + t.Text; pcc = new ME3PCCObject(currentPCC); } else { return; } GeneratePccTree(); } catch (Exception ex) { MessageBox.Show("Error:\n" + ex.Message); } }
public void LoadFile(string s) { try { if (!File.Exists(s)) { return; } pcc = new ME3PCCObject(s); currentPCC = s; GeneratePccTree(); } catch (Exception ex) { MessageBox.Show("Error:\n" + ex.Message); } }
public void LoadPcc(IPCCObject pcc, string path) { switch (pcc.GameVersion) { case 1: pcc = new ME1PCCObject(path); break; case 2: pcc = new ME2PCCObject(path); break; case 3: pcc = new ME3PCCObject(path); break; } }
public ME3Texture2D(ME3PCCObject pccObj, int texIdx) { pccRef = pccObj; // check if texIdx is an Export index and a Texture2D class if (pccObj.isExport(texIdx) && (pccObj.Exports[texIdx].ClassName == className)) { ME3ExportEntry expEntry = pccObj.Exports[texIdx]; properties = new Dictionary <string, PropertyReader.Property>(); byte[] rawData = (byte[])expEntry.Data.Clone(); int propertiesOffset = PropertyReader.detectStart(pccObj, rawData); headerData = new byte[propertiesOffset]; Buffer.BlockCopy(rawData, 0, headerData, 0, propertiesOffset); pccOffset = (uint)expEntry.DataOffset; List <PropertyReader.Property> tempProperties = PropertyReader.getPropList(pccObj, rawData); texName = expEntry.ObjectName; for (int i = 0; i < tempProperties.Count; i++) { PropertyReader.Property property = tempProperties[i]; if (!properties.ContainsKey(pccObj.Names[property.Name])) { properties.Add(pccObj.Names[property.Name], property); } switch (pccObj.Names[property.Name]) { case "Format": texFormat = Textures.Methods.ParseFormat(pccObj.Names[property.Value.IntValue].Substring(3)); break; case "TextureFileCacheName": arcName = pccObj.Names[property.Value.IntValue]; break; case "LODGroup": LODGroup = pccObj.Names[property.Value.IntValue]; break; case "None": dataOffset = (uint)(property.offsetval + property.Size); break; } } // if "None" property isn't found throws an exception if (dataOffset == 0) { throw new Exception("\"None\" property not found"); } else { imageData = new byte[rawData.Length - dataOffset]; Buffer.BlockCopy(rawData, (int)dataOffset, imageData, 0, (int)(rawData.Length - dataOffset)); } } else { throw new Exception("Texture2D " + texIdx + " not found"); } pccExpIdx = texIdx; MemoryStream dataStream = new MemoryStream(imageData); numMipMaps = dataStream.ReadValueU32(); uint count = numMipMaps; privateImageList = new List <ImageInfo>(); while (dataStream.Position < dataStream.Length && count > 0) { ImageInfo imgInfo = new ImageInfo(); imgInfo.storageType = (storage)dataStream.ReadValueS32(); imgInfo.uncSize = dataStream.ReadValueS32(); imgInfo.cprSize = dataStream.ReadValueS32(); imgInfo.offset = dataStream.ReadValueS32(); if (imgInfo.storageType == storage.pccSto) { //imgInfo.offset = (int)(pccOffset + dataOffset); // saving pcc offset as relative to exportdata offset, not absolute imgInfo.offset = (int)dataStream.Position; // saving pcc offset as relative to exportdata offset, not absolute //MessageBox.Show("Pcc class offset: " + pccOffset + "\nimages data offset: " + imgInfo.offset.ToString()); dataStream.Seek(imgInfo.uncSize, SeekOrigin.Current); } imgInfo.imgSize = new ImageSize(dataStream.ReadValueU32(), dataStream.ReadValueU32()); imgList.Add(imgInfo); count--; } // save what remains /*int remainingBytes = (int)(dataStream.Length - dataStream.Position); * footerData = new byte[remainingBytes]; * dataStream.Read(footerData, 0, footerData.Length);*/ }