private TreeNode AddEntryNode(RpfEntry entry, TreeNode node) { string text = entry.Path.Substring(entry.File.Path.Length + 1); //includes \ on the end TreeNode cnode = (node != null) ? node.Nodes.Add(text) : MainTreeView.Nodes.Add(text); cnode.Tag = entry; return(cnode); }
public static byte[] SaveResourceAsBytes(RpfEntry RPFFile) { RpfFileEntry InternalFile = (RpfFileEntry)RPFFile; byte[] data = InternalFile.Parent.File.ExtractFile(InternalFile); RpfResourceFileEntry rrfe = InternalFile as RpfResourceFileEntry; if (rrfe != null) { data = ResourceBuilder.Compress(data); data = ResourceBuilder.AddResourceHeader(rrfe, data); } return(data); }
public bool LoadFile <T>(T file, RpfEntry e) where T : class, PackedFile { byte[] data = null; RpfFileEntry entry = e as RpfFileEntry; if (entry != null) { data = entry.File.ExtractFile(entry); } if (data != null) { file.Load(data, entry); return(true); } return(false); }
public T GetFile <T>(RpfEntry e) where T : class, PackedFile, new() { T file = null; byte[] data = null; RpfFileEntry entry = e as RpfFileEntry; if (entry != null) { data = entry.File.ExtractFile(entry); } if (data != null) { file = new T(); file.Load(data, entry); } return(file); }
private void SaveTexture(Texture tex, RpfEntry entry, string folder) { //DirectXTex byte[] dds = DDSIO.GetDDSFile(tex); string bpath = folder + "\\" + entry.Name + "_" + tex.Name; string fpath = bpath + ".dds"; int c = 1; while (File.Exists(fpath)) { fpath = bpath + "_Copy" + c.ToString() + ".dds"; c++; } File.WriteAllBytes(fpath, dds); }
private void MainTreeView_AfterSelect(object sender, TreeViewEventArgs e) { if (e.Node == null) { return; } if (!e.Node.IsSelected) { return; //only do this for selected node } if (MainTreeView.SelectedNode == null) { return; } SelectedEntry = MainTreeView.SelectedNode.Tag as RpfEntry; SelectedOffset = -1; SelectedLength = 0; SelectFile(); }
private void SelectFile(RpfEntry entry, int offset, int length) { RpfSelectedEntry = entry; RpfSelectedOffset = offset; RpfSelectedLength = length; RpfFileEntry rfe = entry as RpfFileEntry; if (rfe == null) { RpfDirectoryEntry rde = entry as RpfDirectoryEntry; if (rde != null) { FileInfoLabel.Text = rde.Path + " (Directory)"; DataTextBox.Text = "[Please select a data file]"; } else { FileInfoLabel.Text = "[Nothing selected]"; DataTextBox.Text = "[Please select a search result]"; } return; } Cursor = Cursors.WaitCursor; string typestr = "Resource"; if (rfe is RpfBinaryFileEntry) { typestr = "Binary"; } byte[] data = rfe.File.ExtractFile(rfe); int datalen = (data != null) ? data.Length : 0; FileInfoLabel.Text = rfe.Path + " (" + typestr + " file) - " + TextUtil.GetBytesReadable(datalen); if (ShowLargeFileContentsCheckBox.Checked || (datalen < 524287)) //512K { DisplayFileContentsText(rfe, data, length, offset); } else { DataTextBox.Text = "[Filesize >512KB. Select the Show large files option to view its contents]"; } //bool istexdict = false; //if (rfe.NameLower.EndsWith(".ymap")) //{ // YmapFile ymap = new YmapFile(rfe); // ymap.Load(data, rfe); // DetailsPropertyGrid.SelectedObject = ymap; //} //else if (rfe.NameLower.EndsWith(".ytyp")) //{ // YtypFile ytyp = new YtypFile(); // ytyp.Load(data, rfe); // DetailsPropertyGrid.SelectedObject = ytyp; //} //else if (rfe.NameLower.EndsWith(".ymf")) //{ // YmfFile ymf = new YmfFile(); // ymf.Load(data, rfe); // DetailsPropertyGrid.SelectedObject = ymf; //} //else if (rfe.NameLower.EndsWith(".ymt")) //{ // YmtFile ymt = new YmtFile(); // ymt.Load(data, rfe); // DetailsPropertyGrid.SelectedObject = ymt; //} //else if (rfe.NameLower.EndsWith(".ybn")) //{ // YbnFile ybn = new YbnFile(); // ybn.Load(data, rfe); // DetailsPropertyGrid.SelectedObject = ybn; //} //else if (rfe.NameLower.EndsWith(".fxc")) //{ // FxcFile fxc = new FxcFile(); // fxc.Load(data, rfe); // DetailsPropertyGrid.SelectedObject = fxc; //} //else if (rfe.NameLower.EndsWith(".yft")) //{ // YftFile yft = new YftFile(); // yft.Load(data, rfe); // DetailsPropertyGrid.SelectedObject = yft; // if ((yft.Fragment != null) && (yft.Fragment.Drawable != null) && (yft.Fragment.Drawable.ShaderGroup != null) && (yft.Fragment.Drawable.ShaderGroup.TextureDictionary != null)) // { // ShowTextures(yft.Fragment.Drawable.ShaderGroup.TextureDictionary); // istexdict = true; // } //} //else if (rfe.NameLower.EndsWith(".ydr")) //{ // YdrFile ydr = new YdrFile(); // ydr.Load(data, rfe); // DetailsPropertyGrid.SelectedObject = ydr; // if ((ydr.Drawable != null) && (ydr.Drawable.ShaderGroup != null) && (ydr.Drawable.ShaderGroup.TextureDictionary != null)) // { // ShowTextures(ydr.Drawable.ShaderGroup.TextureDictionary); // istexdict = true; // } //} //else if (rfe.NameLower.EndsWith(".ydd")) //{ // YddFile ydd = new YddFile(); // ydd.Load(data, rfe); // DetailsPropertyGrid.SelectedObject = ydd; // //todo: show embedded texdicts in ydd's? is this possible? //} //else if (rfe.NameLower.EndsWith(".ytd")) //{ // YtdFile ytd = new YtdFile(); // ytd.Load(data, rfe); // DetailsPropertyGrid.SelectedObject = ytd; // ShowTextures(ytd.TextureDict); // istexdict = true; //} //else if (rfe.NameLower.EndsWith(".ycd")) //{ // YcdFile ycd = new YcdFile(); // ycd.Load(data, rfe); // DetailsPropertyGrid.SelectedObject = ycd; //} //else if (rfe.NameLower.EndsWith(".ynd")) //{ // YndFile ynd = new YndFile(); // ynd.Load(data, rfe); // DetailsPropertyGrid.SelectedObject = ynd; //} //else if (rfe.NameLower.EndsWith(".ynv")) //{ // YnvFile ynv = new YnvFile(); // ynv.Load(data, rfe); // DetailsPropertyGrid.SelectedObject = ynv; //} //else if (rfe.NameLower.EndsWith("_cache_y.dat")) //{ // CacheDatFile cdf = new CacheDatFile(); // cdf.Load(data, rfe); // DetailsPropertyGrid.SelectedObject = cdf; //} //else if (rfe.NameLower.EndsWith(".rel")) //{ // RelFile rel = new RelFile(rfe); // rel.Load(data, rfe); // DetailsPropertyGrid.SelectedObject = rel; //} //else if (rfe.NameLower.EndsWith(".gxt2")) //{ // Gxt2File gxt2 = new Gxt2File(); // gxt2.Load(data, rfe); // DetailsPropertyGrid.SelectedObject = gxt2; //} //else if (rfe.NameLower.EndsWith(".pso")) //{ // JPsoFile pso = new JPsoFile(); // pso.Load(data, rfe); // DetailsPropertyGrid.SelectedObject = pso; //} //else //{ // DetailsPropertyGrid.SelectedObject = null; //} //if (!istexdict) //{ // ShowTextures(null); //} Cursor = Cursors.Default; }