protected ArrayList LoadStrLinked(SimPe.Interfaces.Files.IPackageFile pkg, CloneSettings.StrIntsanceAlias instance) { ArrayList list = new ArrayList(); SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFile(Data.MetaData.STRING_FILE, 0, instance.Instance); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(); str.ProcessData(pfd, pkg); foreach (SimPe.PackedFiles.Wrapper.StrToken si in str.Items) { string name = Hashes.StripHashFromName(si.Title).Trim(); if (name == "") { continue; } name += instance.Extension; //Console.WriteLine("Str Linked: "+name); SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii = FileTable.FileIndex.FindFileByName(name, instance.Type, Hashes.GetHashGroupFromName(si.Title, Data.MetaData.GLOBAL_GROUP), true); if (fii != null) { //Console.WriteLine(" --> found"); list.Add(fii); } } } return(list); }
/// <summary> /// Loads Slave TXMTs by name Replacement /// </summary> /// <param name="pkg">the package File with the base TXMTs</param> /// <param name="slaves">The Hashtable holding als Slave Subsets</param> public static void AddSlaveTxmts(SimPe.Interfaces.Files.IPackageFile pkg, Hashtable slaves) { ArrayList files = new ArrayList(); ArrayList items = new ArrayList(); SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(Data.MetaData.TXMT); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { GenericRcol rcol = new GenericRcol(null, false); rcol.ProcessData(pfd, pkg); if (rcol.FileDescriptor.Type == Data.MetaData.TXMT) { AddSlaveTxmts(new ArrayList(), new ArrayList(), files, items, rcol, slaves); } } foreach (GenericRcol rcol in files) { if (pkg.FindFile(rcol.FileDescriptor) == null) { rcol.FileDescriptor = rcol.FileDescriptor.Clone(); rcol.SynchronizeUserData(); pkg.Add(rcol.FileDescriptor); } } }
/// <summary> /// Add Resources referenced from 3IDR Files /// </summary> /// <param name="names"></param> public void AddFrom3IDR(SimPe.Interfaces.Files.IPackageFile pkg) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(Data.MetaData.REF_FILE); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.Plugin.RefFile re = new RefFile(); re.ProcessData(pfd, pkg); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor p in re.Items) { SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFile(p, null); foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in items) { try { SimPe.Plugin.GenericRcol sub = new GenericRcol(null, false); sub.ProcessData(item); LoadReferenced(this.modelnames, this.exclude, files, itemlist, sub, item, true, setup); } catch (Exception ex) { if (Helper.DebugMode) { Helper.ExceptionMessage("", ex); } } } } } }
public Interfaces.Plugin.IToolResult Execute(ref SimPe.Interfaces.Files.IPackedFileDescriptor pfd, ref SimPe.Interfaces.Files.IPackageFile package, Interfaces.IProviderRegistry prov) { this.package = package; lv.ListViewItemSorter = sorter; this.Cursor = Cursors.WaitCursor; SimPe.Plugin.Idno idno = SimPe.Plugin.Idno.FromPackage(package); if (idno != null) { this.lbUbi.Visible = (idno.Type != NeighborhoodType.Normal); } this.pfd = null; lv.Sorting = SortOrder.Ascending; sorter.CurrentColumn = 3; FillList(); this.Cursor = Cursors.Default; RemoteControl.ShowSubForm(this); this.package = null; if (this.pfd != null) { pfd = this.pfd; } return(new Plugin.ToolResult((this.pfd != null), false)); }
public override void SetFromPackage(SimPe.Interfaces.Files.IPackageFile pkg) { if (pkg == null) { objd = null; ClearScreen(); return; } //this is a regular Object? if (pkg.FindFiles(Data.MetaData.OBJD_FILE).Length > 0) { cpf = null; base.SetFromPackage(pkg); return; } objd = null; foreach (uint t in xtypes) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(t); if (pfds.Length > 0) { cpf = new SimPe.PackedFiles.Wrapper.Cpf(); cpf.ProcessData(pfds[0], pkg); break; } } UpdateXObjScreen(); }
void DeleteRelations(uint inst, uint guid, SimPe.Interfaces.Files.IPackageFile pkg, SimPe.PackedFiles.Wrapper.ExtSDesc victim) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(Data.MetaData.SIM_DESCRIPTION_FILE); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { if (pfd.Instance == inst) { continue; } ArrayList list = new ArrayList(); SimPe.PackedFiles.Wrapper.ExtSDesc sdsc = new SimPe.PackedFiles.Wrapper.ExtSDesc(); sdsc.ProcessData(pfd, pkg); foreach (uint i in sdsc.Relations.SimInstances) { if (i != inst) { list.Add((ushort)i); } } if (list.Count < sdsc.Relations.SimInstances.Length) { sdsc.Relations.SimInstances = new ushort[list.Count]; list.CopyTo(sdsc.Relations.SimInstances); sdsc.SynchronizeUserData(); } } }
public virtual bool ChangeEnabledStateEventHandler(object sender, SimPe.Events.ResourceEventArgs e) { SimPe.Interfaces.Files.IPackedFileDescriptor pfd = ExtractFileDescriptor(e); SimPe.Interfaces.Files.IPackageFile pkg = ExtractPackage(e); return IsEnabled(pfd, pkg); }
void DeleteCharacterFile(uint inst, uint guid, SimPe.Interfaces.Files.IPackageFile pkg, SimPe.PackedFiles.Wrapper.ExtSDesc victim) { //do not delete for NPCs if (victim.IsNPC) { return; } if (System.IO.File.Exists(victim.CharacterFileName)) { if (Message.Show("SimPE can now delete the Character File \"" + victim.CharacterFileName + "\" from your System. \n\nShould SimPE delete this File?", "Question", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) { return; } try { SimPe.Packages.StreamItem si = SimPe.Packages.StreamFactory.UseStream(victim.CharacterFileName, System.IO.FileAccess.Read); si.Close(); System.IO.File.Delete(victim.CharacterFileName); /*FileTable.ProviderRegistry.SimNameProvider.BaseFolder = null; * FileTable.ProviderRegistry.SimNameProvider.BaseFolder = System.IO.Path.GetDirectoryName(pkg.SaveFileName);*/ } catch (Exception ex) { Helper.ExceptionMessage(ex); } } }
/// <summary> /// Find the SHPE that is referencing the passed GMND /// </summary> /// <param name="gmnd"></param> /// <param name="flname">null, or the Filename of a package to search in</param> /// <returns>null or the first found shpe</returns> public Rcol FindReferencingSHPE(Rcol gmnd, string flname) { if (gmnd == null) { return(null); } SimPe.Interfaces.Files.IPackageFile lpackage = package; if (flname != null) { lpackage = SimPe.Packages.File.LoadFromFile(flname); } Interfaces.Files.IPackedFileDescriptor[] pfds = lpackage.FindFiles(0xFC6EB1F7); foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds) { Rcol rcol = new GenericRcol(null, false); rcol.ProcessData(pfd, lpackage); Shape shp = (Shape)rcol.Blocks[0]; foreach (ShapeItem i in shp.Items) { if (Hashes.StripHashFromName(i.FileName).Trim().ToLower() == Hashes.StripHashFromName(gmnd.FileName).Trim().ToLower()) { return(rcol); } } } return(null); }
public static SimPe.Cache.ObjectCacheItem ObjectCacheItemFromPackage(SimPe.Interfaces.Files.IPackageFile pkg) { SimPe.Cache.ObjectCacheItem oci = new SimPe.Cache.ObjectCacheItem(); oci.Class = SimPe.Cache.ObjectClass.Object; SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(Data.MetaData.OBJD_FILE); bool first = true; foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFile(pfd, pkg); foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in items) { if (first || item.FileDescriptor.Instance == 0x41A7 || item.FileDescriptor.Instance == 0x41AF) { oci.Tag = item; oci.Useable = false; ObjectConsumer.DoConsume(oci, null, Helper.WindowsRegistry.LanguageCode); first = false; } } } return(oci); }
public TextureLocator(SimPe.Interfaces.Files.IPackageFile package) { this.package = package; fii = SimPe.FileTable.FileIndex.AddNewChild(); //fii.AddIndexFromPackage(package); }
/// <summary> /// Find the GMND that is referencing the passed gmdc /// </summary> /// <param name="gmdc"></param> /// <param name="flname">null, or the Filename of a package to search in</param> /// <returns>null or the found gmnd</returns> public Rcol FindReferencingGMND(Rcol gmdc, string flname) { if (gmdc == null) { return(null); } SimPe.Interfaces.Files.IPackageFile lpackage = package; if (flname != null) { lpackage = SimPe.Packages.File.LoadFromFile(flname); } Interfaces.Files.IPackedFileDescriptor[] pfds = lpackage.FindFiles(0x7BA3838C); foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds) { Rcol rcol = new GenericRcol(null, false); rcol.ProcessData(pfd, lpackage); foreach (Interfaces.Files.IPackedFileDescriptor rpfd in rcol.ReferencedFiles) { if ((gmdc.FileDescriptor.Group == rpfd.Group) && (gmdc.FileDescriptor.Instance == rpfd.Instance) && (gmdc.FileDescriptor.SubType == rpfd.SubType) && (gmdc.FileDescriptor.Type == rpfd.Type)) { return(rcol); } } } return(null); }
internal static void PrepareForClone(SimPe.Interfaces.Files.IPackageFile package, SimPe.Interfaces.IAlias current, out SimPe.Interfaces.IAlias a, out uint localgroup, out SimPe.Interfaces.Files.IPackedFileDescriptor pfd) { FileTable.FileIndex.Load(); a = null; pfd = null; localgroup = Data.MetaData.LOCAL_GROUP; if (package != null) { if (package.FileName != null) { SimPe.Interfaces.Wrapper.IGroupCacheItem gci = SimPe.FileTable.GroupCache.GetItem(package.FileName); if (gci != null) { localgroup = gci.LocalGroup; } } } else { if (current != null) { a = current; pfd = (Interfaces.Files.IPackedFileDescriptor)a.Tag[0]; localgroup = (uint)a.Tag[1]; } } }
/// <summary> /// Show the Graph /// </summary> /// <param name="pkg"></param> /// <param name="fileindex"></param> /// <remarks>Do not run twice</remarks> public void BuildGraph(SimPe.Interfaces.Files.IPackageFile pkg, SimPe.Interfaces.Scenegraph.IScenegraphFileIndex fileindex) { gc.BeginUpdate(); gc.Clear(); gc.SaveBounds = false; gc.AutoSize = true; this.coords.Clear(); this.names.Clear(); if (WaitingScreen.Running) { WaitingScreen.UpdateMessage("Scaning MMAT Tree"); } SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(Data.MetaData.MMAT); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { AddItem(pfd, pkg, null, fileindex); } if (WaitingScreen.Running) { WaitingScreen.UpdateMessage("Scaning CRES Tree"); } pfds = pkg.FindFiles(Data.MetaData.CRES); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { AddItem(pfd, pkg, null, fileindex); } gc.AutoSize = false; gc.SaveBounds = true; gc.EndUpdate(); }
public Interfaces.Plugin.IToolResult ShowDialog(ref SimPe.Interfaces.Files.IPackedFileDescriptor pfd, ref SimPe.Interfaces.Files.IPackageFile package) { if (Helper.StartedGui == Executable.Default) { if (Message.Show(SimPe.Localization.GetString("ObsoleteOW"), SimPe.Localization.GetString("Warning"), System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) { return(new ToolResult(false, false)); } } SimPe.Interfaces.Files.IPackageFile pkg = ws.Execute(prov, package); if (pkg != null) { if (pkg.Reader != null) { if (!pkg.Reader.BaseStream.CanWrite) { new ToolResult(false, false); } } package = pkg; return(new ToolResult(false, true)); } else { return(new ToolResult(false, false)); } }
public static Ambertation.Scenes.Scene BuildScene(MmatWrapper mmat, SimPe.Interfaces.Files.IPackageFile package) { SimPe.Interfaces.Scenegraph.IScenegraphFileIndex fii; Ambertation.Scenes.Scene scn = BuildScene(out fii, mmat, package); fii.Clear(); return(scn); }
public NamedPackedFileDescriptor(SimPe.Interfaces.Files.IPackedFileDescriptor pfd, SimPe.Interfaces.Files.IPackageFile pkg) { this.pfd = pfd; this.pkg = pkg; this.fii = new SimPe.Plugin.FileIndexItem(pfd, pkg); realname = null; }
void DeleteFamMembers(uint inst, uint guid, SimPe.Interfaces.Files.IPackageFile pkg, SimPe.PackedFiles.Wrapper.ExtSDesc victim) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(0x46414D49); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.PackedFiles.Wrapper.Fami f = new SimPe.PackedFiles.Wrapper.Fami(null); f.ProcessData(pfd, pkg); ArrayList list = new ArrayList(); foreach (uint i in f.Members) { if (i != guid) { list.Add(i); } } f.Members = new uint[list.Count]; list.CopyTo(f.Members); f.SynchronizeUserData(); } }
public void Execute(string path, SimPe.Interfaces.Files.IPackageFile package, Interfaces.IProviderRegistry prov, string lable) { this.path = path; this.package = package; this.prov = prov; string name = System.IO.Path.GetFileName(path); if (lable != "") { name = lable + "_" + name; } long grp = PathProvider.Global.SaveGamePathProvidedByGroup(path); if (grp > 1) { name = grp.ToString() + "_" + name; } backuppath = System.IO.Path.Combine(PathProvider.Global.BackupFolder, name); UpdateList(); ShowDialog(); }
/// <summary> /// Update the old Provider Infrastructure /// </summary> public void UpdateProviders() { if (Helper.IsNeighborhoodFile(FileName) && (Helper.WindowsRegistry.LoadMetaInfo)) { SimPe.Interfaces.Files.IPackageFile pkg = Package; try { string mname = Helper.GetMainNeighborhoodFile(pkg.SaveFileName); if (mname != pkg.SaveFileName) { pkg = SimPe.Packages.GeneratableFile.LoadFromFile(mname); } } catch {} FileTable.ProviderRegistry.SimFamilynameProvider.BasePackage = pkg; FileTable.ProviderRegistry.SimDescriptionProvider.BasePackage = pkg; FileTable.ProviderRegistry.SimNameProvider.BaseFolder = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(FileName), "Characters"); FileTable.ProviderRegistry.LotProvider.BaseFolder = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(FileName), "Lots"); } else { FileTable.ProviderRegistry.SimNameProvider.BaseFolder = ""; FileTable.ProviderRegistry.SimFamilynameProvider.BasePackage = null; FileTable.ProviderRegistry.SimDescriptionProvider.BasePackage = null; FileTable.ProviderRegistry.LotProvider.BaseFolder = ""; } }
protected void GetObjd(SimPe.Interfaces.Files.IPackageFile pkg) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(Data.MetaData.OBJD_FILE); if (pfds.Length > 0) { foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.PackedFiles.Wrapper.ExtObjd mobjd = new SimPe.PackedFiles.Wrapper.ExtObjd(); mobjd.ProcessData(pfd, pkg); nfo.AddGuid(mobjd.Guid); if (objd == null) { objd = mobjd; } if (pfds.Length == 1) { break; } if (mobjd.Data.Length > 0xb) { if (mobjd.Data[0xb] == -1) { objd = mobjd; } } } } }
public bool IsEnabled(SimPe.Interfaces.Files.IPackedFileDescriptor pfd, SimPe.Interfaces.Files.IPackageFile package) { if (package == null) { return(false); } return(true); }
internal void SetPackage(SimPe.Interfaces.Files.IPackageFile pkg) { this.op.SetFromPackage(pkg); this.np.SetFromPackage(pkg); op.Visible = op.Loaded; np.Visible = np.Loaded; }
/// <summary> /// Create a new Instance /// </summary> /// <remarks>Same as a call to FileIndex(null)</remarks> public ResourceIndex(SimPe.Interfaces.Files.IPackageFile pkg, bool flat, int capacity) { this.pkg = pkg; pfds = new PackedFileDescriptors(capacity); this.flat = true; higestoffset = 0; LoadIndex(); }
public PackageInfo(SimPe.Interfaces.Files.IPackageFile pkg) { guid = new uint[0]; flname = pkg.SaveFileName; knockout = true; BuildDefaultImage(); Reset(); }
public override void SearchPackage(SimPe.Interfaces.Files.IPackageFile pkg, SimPe.Interfaces.Files.IPackedFileDescriptor pfd) { if (pfd.Type != Data.MetaData.OBJD_FILE) { return; } DoSearchPackage(pkg, pfd); }
public void LoadContent(SimPe.Cache.PackageType type, SimPe.Interfaces.Files.IPackageFile pkg) { nfo = new PackageInfo(pkg); BeforeLoadContent(type, pkg); SetName(pkg); SetImage(pkg); AfterLoadContent(type, pkg); }
public override void SearchPackage(SimPe.Interfaces.Files.IPackageFile pkg, SimPe.Interfaces.Files.IPackedFileDescriptor pfd) { bool found = false; if (type == 0) { foreach (uint tt in SimPe.Data.MetaData.RcolList) { if (tt == pfd.Type) { found = true; break; } } } else { found = type == pfd.Type; } if (!found) { return; } SimPe.Plugin.GenericRcol rcol = new GenericRcol(null, true); rcol.ProcessData(pfd, pkg); found = false; string n = rcol.FileName.Trim().ToLower(); if (compareType == CompareType.Equal) { found = n == name; } else if (compareType == CompareType.Start) { found = n.StartsWith(name); } else if (compareType == CompareType.End) { found = n.EndsWith(name); } else if (compareType == CompareType.Contain) { found = n.IndexOf(name) > -1; } else if (compareType == CompareType.RegExp && reg != null) { found = reg.IsMatch(n); } //we have a match, so add the result item if (found) { ResultGui.AddResult(pkg, pfd); } }
public void LoadContent(SimPe.Cache.PackageType type, SimPe.Interfaces.Files.IPackageFile pkg) { this.flname = pkg.SaveFileName; nfo = new PackageInfo(pkg); nfo.Type = type; OnLoadContent(); this.SetFromPackage(pkg); }
public override void SearchPackage(SimPe.Interfaces.Files.IPackageFile pkg, SimPe.Interfaces.Files.IPackedFileDescriptor pfd) { if ((t.val == pfd.Type || !t.use) && (g.val == pfd.Group || !g.use) && (hi.val == pfd.SubType || !hi.use) && (li.val == pfd.Instance || !li.use)) { ResultGui.AddResult(pkg, pfd); } }