public static DialogResult Execute(SimPe.Interfaces.Plugin.AbstractWrapper wrapper, string title) { SaveFileDialog sfd = new SaveFileDialog(); sfd.FileName = wrapper.FileDescriptor.ExportFileName.Replace(" ", "").Replace(":", "_").Replace(@"\", "_"); sfd.Filter = SimPe.ExtensionProvider.BuildFilterString( new SimPe.ExtensionType[] { SimPe.ExtensionType.ExtractedFile, SimPe.ExtensionType.AllFiles } ); sfd.Title = title; DialogResult dr = sfd.ShowDialog(); if (dr != DialogResult.OK) { return(dr); } string path = wrapper.FileDescriptor.Path; string filename = wrapper.FileDescriptor.Filename; try { SimPe.ToolLoaderItemExt.SavePackedFile(sfd.FileName, true, (PackedFileDescriptor)wrapper.FileDescriptor, (GeneratableFile)wrapper.Package); } finally { wrapper.FileDescriptor.Path = path; wrapper.FileDescriptor.Filename = filename; } return(dr); }
public void Create(bool fromCurrent) { guidIndex = new Dictionary <uint, IndexItem>(); pjse.FileTable.Entry[] items = (fromCurrent && pjse.FileTable.GFT.CurrentPackage != null) ? pjse.FileTable.GFT[pjse.FileTable.GFT.CurrentPackage, SimPe.Data.MetaData.OBJD_FILE] : pjse.FileTable.GFT[SimPe.Data.MetaData.OBJD_FILE]; SimPe.Wait.Start(items.Length); try { foreach (pjse.FileTable.Entry item in items) { System.Windows.Forms.Application.DoEvents(); try { SimPe.Interfaces.Plugin.AbstractWrapper wrapper = item.Wrapper; if (wrapper == null) { continue; } IndexItem ii = new IndexItem(); pjse.FileTable.Entry[] globs = pjse.FileTable.GFT[0x474C4F42, item.Group]; ii.semiGlobal = (globs.Length == 0) ? 0 : ((SimPe.Plugin.Glob)globs[0].Wrapper).SemiGlobalGroup; System.IO.BinaryReader reader = wrapper.StoredData; if (reader.BaseStream.Length >= 0x40) // filename length { ii.objdName = SimPe.Helper.ToString(reader.ReadBytes(0x40)).Trim(); ii.objdGroup = wrapper.FileDescriptor.Group; if (reader.BaseStream.Length > 0x52 + 2) // sizeof(ushort) { reader.BaseStream.Seek(0x52, System.IO.SeekOrigin.Begin); ii.objdType = reader.ReadUInt16(); if (reader.BaseStream.Length > 0x5c + 4) // sizeof(uint) { reader.BaseStream.Seek(0x5c, System.IO.SeekOrigin.Begin); UInt32 objdGUID = reader.ReadUInt32(); guidIndex[objdGUID] = ii; } } } } finally { SimPe.Wait.Progress++; } } pjse.FileTable.GFT.OnFiletableRefresh(this, new EventArgs()); } finally { SimPe.Wait.Stop(); } }
public string GetRealName() { if (realname == null) { if (Helper.WindowsRegistry.DecodeFilenamesState) { SimPe.Interfaces.Plugin.Internal.IPackedFileWrapper wrp = FileTable.WrapperRegistry.FindHandler(pfd.Type); if (wrp != null) { lock (wrp) { //System.Diagnostics.Debug.WriteLine("Processing " + pfd.Type.ToString("X")+" "+pfd.Offset.ToString("X")); SimPe.Interfaces.Files.IPackedFileDescriptor bakpfd = null; SimPe.Interfaces.Files.IPackageFile bakpkg = null; if (wrp is SimPe.Interfaces.Plugin.AbstractWrapper) { SimPe.Interfaces.Plugin.AbstractWrapper awrp = (SimPe.Interfaces.Plugin.AbstractWrapper)wrp; if (!awrp.AllowMultipleInstances) { bakpfd = awrp.FileDescriptor; bakpkg = awrp.Package; } awrp.FileDescriptor = pfd; awrp.Package = pkg; } try { realname = wrp.ResourceName; } #if DEBUG catch (Exception ex) { realname = ex.Message; } #else catch { realname = pfd.ToResListString(); } #endif finally { if (bakpfd != null || bakpkg != null) { if (wrp is SimPe.Interfaces.Plugin.AbstractWrapper) { SimPe.Interfaces.Plugin.AbstractWrapper awrp = (SimPe.Interfaces.Plugin.AbstractWrapper)wrp; if (!awrp.AllowMultipleInstances) { awrp.FileDescriptor = bakpfd; awrp.Package = bakpkg; } } } } } //lock } } if (realname == null) { realname = pfd.ToResListString(); } } return(realname); }