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)); } }
private static string LoadLabel(SimPe.Packages.File pk, out NeighborhoodType type) { string name = SimPe.Localization.GetString("Unknown"); type = NeighborhoodType.Unknown; try { SimPe.Interfaces.Files.IPackedFileDescriptor pfd = pk.FindFile(0x43545353, 0, 0xffffffff, 1); if (pfd != null) { SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(); str.ProcessData(pfd, pk); name = str.LanguageItems(new SimPe.PackedFiles.Wrapper.StrLanguage((byte)Data.MetaData.Languages.English))[0].Title; } pfd = pk.FindFile(0xAC8A7A2E, 0, 0xffffffff, 1); if (pfd != null) { SimPe.Plugin.Idno idno = new Idno(); idno.ProcessData(pfd, pk); type = idno.Type; } //pk.Reader.Close(); } finally { //pk.Reader.Close(); } return(name); }
/// <summary> /// Called whenever the Data stored in the Filedescriptor gets changed /// </summary> /// <param name="sender"></param> private void FileDescriptor_ChangedUserData(SimPe.Interfaces.Files.IPackedFileDescriptor sender) { SimPe.Packages.PackedFileDescriptor pfd = (SimPe.Packages.PackedFileDescriptor)sender; TD.SandDock.DockControl doc = this.GetDocument(pfd); if (doc != null) { SimPe.Interfaces.Plugin.IFileWrapper wrapper = (SimPe.Interfaces.Plugin.IFileWrapper)doc.Tag; if (wrapper != null) { if (wrapper.Package != null) { string flname = wrapper.Package.FileName; if (flname == null) { flname = ""; } System.Windows.Forms.DialogResult dr = System.Windows.Forms.DialogResult.Yes; if (!Helper.WindowsRegistry.Silent) { dr = Message.Show(SimPe.Localization.GetString("reschanged").Replace("{name}", doc.Text).Replace("{filename}", flname), SimPe.Localization.GetString("changed?"), System.Windows.Forms.MessageBoxButtons.YesNo); } if (dr == System.Windows.Forms.DialogResult.Yes) { wrapper.Refresh(); } } } } }
protected GenericRcol FindDefiningCRES(SimPe.Interfaces.Files.IPackedFileDescriptor pfd, SimPe.Interfaces.Files.IPackageFile pkg) { GenericRcol rcol = new GenericRcol(); rcol.ProcessData(pfd, pkg); ResourceNode rn = (ResourceNode)rcol.Blocks[0]; foreach (int i in rn.ChildBlocks) { SimPe.Interfaces.Scenegraph.ICresChildren icc = rn.GetBlock(i); if (icc != null) { if (icc.StoredTransformNode != null) { if (icc.StoredTransformNode.ObjectGraphNode.FileName == this.Name) { return(rcol); } } } } return(null); }
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); }
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)); }
/// <summary> /// Constructor /// </summary> public ProcessDeformationsBuilder(Rcol parent) : base(parent) { gb = new GeometryBuilder(null); BlockID = 0x5ce7e026; pfd = new SimPe.Packages.PackedFileDescriptor(); }
/// <summary> /// Make sure the correct Face Structure is used (as desribed by Nukael) /// </summary> /// <remarks>http://www.modthesims2.com/showthread.php?t=56241</remarks> /// <param name="pkg">The package with the Face Data</param> public void UpdateFaceStructure(SimPe.Packages.GeneratableFile pkg) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles((uint)0xCCCEF852); //LxNR, Face SimPe.Interfaces.Files.IPackedFileDescriptor oldpfd = null; SimPe.Interfaces.Files.IPackedFileDescriptor newpfd = null; uint oi = 1; uint ni = 2; foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { if (pfd.Instance <= oi) { oldpfd = pfd; oi = pfd.Instance; } if (pfd.Instance >= ni) { newpfd = pfd; ni = pfd.Instance; } } if (oldpfd != null && newpfd != null) { SimPe.Interfaces.Files.IPackedFile pf = pkg.Read(newpfd); oldpfd.UserData = pf.UncompressedData; oldpfd.Changed = true; } }
protected string[] GetModelnames() { if (objd == null) { return(new string[0]); } if (objd.Package == null) { return(new string[0]); } SimPe.Interfaces.Files.IPackedFileDescriptor pfd = objd.Package.FindFile(Data.MetaData.STRING_FILE, 0, objd.FileDescriptor.Group, 0x85); ArrayList list = new ArrayList(); if (pfd != null) { SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(); str.ProcessData(pfd, objd.Package); SimPe.PackedFiles.Wrapper.StrItemList items = str.LanguageItems(1); for (int i = 1; i < items.Length; i++) { list.Add(items[i].Title); } } string[] refname = new string[list.Count]; list.CopyTo(refname); return(refname); }
public Interfaces.Plugin.IToolResult ShowDialog(ref SimPe.Interfaces.Files.IPackedFileDescriptor pfd, ref SimPe.Interfaces.Files.IPackageFile package) { if (!System.IO.Directory.Exists(PathProvider.Global.NeighborhoodFolder)) { System.Windows.Forms.MessageBox.Show("The Folder " + PathProvider.Global.NeighborhoodFolder + " was not found.\nPlease specify the correct SaveGame Folder in the Options Dialog."); return(new ToolResult(false, false)); } if (package != null) { if (package.HasUserChanges) { if (System.Windows.Forms.MessageBox.Show(Localization.Manager.GetString("unsavedchanges"), Localization.Manager.GetString("savechanges?"), System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) { return(new Plugin.ToolResult(false, false)); } } } NeighborhoodForm nf = new NeighborhoodForm(); nf.Text = Localization.Manager.GetString("neighborhoodbrowser"); Interfaces.Plugin.IToolResult ret = nf.Execute(ref package, prov); if (ret.ChangedPackage) { pfd = null; } return(ret); }
/// <summary> /// Removes an Item from the Table /// </summary> /// <param name="pfd">The item you want to remove</param> internal void RemoveItem(SimPe.Interfaces.Files.IPackedFileDescriptor pfd) { ArrayList list = new ArrayList(); if (!flat) { if (index.ContainsKey(pfd.Type)) { Hashtable groups = (Hashtable)index[pfd.Type]; if (groups.ContainsKey(pfd.Group)) { Hashtable instances = (Hashtable)groups[pfd.Group]; if (instances.ContainsKey(pfd.LongInstance)) { list = (ArrayList)instances[pfd.LongInstance]; list.Remove(pfd); pfds.Remove(pfd); } } } } else { pfds.Remove(pfd); } }
protected SimPe.PackedFiles.Wrapper.ExtSDesc GetDescriptionByInstance(uint inst) { SimPe.PackedFiles.Wrapper.ExtSDesc ret = (SimPe.PackedFiles.Wrapper.ExtSDesc)FileTable.ProviderRegistry.SimDescriptionProvider.FindSim((ushort)inst); return(ret); #if UNREACHABLE if (ret == null) { if (Package == null) { return(null); } if (this.FileDescriptor == null) { return(null); } SimPe.Interfaces.Files.IPackedFileDescriptor pfd = Package.FindFile(Data.MetaData.SIM_DESCRIPTION_FILE, 0, FileDescriptor.Group, inst); if (pfd == null) { return(null); } ret = new SimPe.PackedFiles.Wrapper.ExtSDesc(); ret.ProcessData(pfd, Package); } return(ret); #endif }
internal void RemoveChanged(SimPe.Interfaces.Files.IPackedFileDescriptor pfd) { if (!flat) { foreach (uint type in index.Keys) { Hashtable groups = (Hashtable)index[type]; foreach (uint group in groups.Keys) { Hashtable instances = (Hashtable)groups[group]; foreach (ulong instance in instances.Keys) { PackedFileDescriptors list = (PackedFileDescriptors)instances[instance]; for (int i = list.Count - 1; i >= 0; i--) { if (list[i] == pfd) { RemoveFromList(pfds, list[i]); list.RemoveAt(i); } } } } } } else { RemoveFromList(pfds, pfd); } }
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; }
public Interfaces.Plugin.IToolResult ShowDialog(ref SimPe.Interfaces.Files.IPackedFileDescriptor pfd, ref SimPe.Interfaces.Files.IPackageFile package) { hs = new Hash(); hs.Execute(package); return(new ToolResult(false, false)); }
private bool IsReallyEnabled(SimPe.Interfaces.Files.IPackedFileDescriptor pfd, SimPe.Interfaces.Files.IPackageFile package) { if (System.IO.File.Exists(DefaultCareerFile)) { return(true); } if (package == null) { System.Windows.Forms.MessageBox.Show("You do not have a package open and the Default Career File was not found."); return(false); } Interfaces.Files.IPackedFileDescriptor[] globals = package.FindFiles(Data.MetaData.GLOB_FILE); if (globals.Length == 1) { SimPe.Plugin.Glob glob = new SimPe.Plugin.Glob(); glob.ProcessData(globals[0], package); if (glob.SemiGlobalName == "JobDataGlobals") { return(true); } } System.Windows.Forms.MessageBox.Show("This package does not contain a career."); return(false); }
/// <summary> /// Load availabe lua resources from the FileSystem /// </summary> /// <param name="dir">The directory you want to scan</param> /// <param name="ext">The fiel extension to check</param> /// <param name="global">true, if this is a global LUA</param> /// <remarks>Instance of the loaded resources will be the hash over the FeleName</remarks> static void LoadFromFolder(string dir, string ext, bool global) { if (!System.IO.Directory.Exists(dir)) { return; } string[] fls = System.IO.Directory.GetFiles(dir, "*." + ext); foreach (string fl in fls) { string name = System.IO.Path.GetFileName(fl); System.IO.BinaryWriter bw = new System.IO.BinaryWriter(new System.IO.MemoryStream()); try { bw.Write((int)0); bw.Write((int)name.Length); bw.Write(Helper.ToBytes(name, name.Length)); System.IO.FileStream fs = System.IO.File.Open(fl, System.IO.FileMode.Open); System.IO.BinaryReader br = new System.IO.BinaryReader(fs); try { bw.Write(br.ReadBytes((int)br.BaseStream.Length)); } finally { br.Close(); br = null; fs.Close(); fs.Dispose(); fs = null; } br = new System.IO.BinaryReader(bw.BaseStream); br.BaseStream.Seek(0, System.IO.SeekOrigin.Begin); uint type = SimPe.Data.MetaData.OLUA; if (global) { type = SimPe.Data.MetaData.GLUA; } SimPe.Interfaces.Files.IPackedFileDescriptor pfd = pkg.NewDescriptor( type, Hashes.SubTypeHash(name), SimPe.Data.MetaData.LOCAL_GROUP, Hashes.InstanceHash(name) ); pfd.UserData = br.ReadBytes((int)br.BaseStream.Length); pfd.Changed = false; pkg.Add(pfd); } finally { bw.Close(); } } }
public bool IsEnabled(SimPe.Interfaces.Files.IPackedFileDescriptor pfd, SimPe.Interfaces.Files.IPackageFile package) { if (package == null) { return(false); } return(true); }
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 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 bool IsReallyEnabled(SimPe.Interfaces.Files.IPackedFileDescriptor pfd, SimPe.Interfaces.Files.IPackageFile package) { if (System.IO.File.Exists(ScenegraphHelper.GMND_PACKAGE) && System.IO.File.Exists(ScenegraphHelper.MMAT_PACKAGE)) { return(true); } System.Windows.Forms.MessageBox.Show("The CEP must be installed and has not been found."); return(false); }
/// <summary> /// Create a clone of the Descriptor, so changes won't affect the source Package anymore! /// </summary> /// <param name="item">Clone the Descriptor in this Item</param> public static SimPe.Packages.PackedFileDescriptor Clone(SimPe.Interfaces.Files.IPackedFileDescriptor org) { SimPe.Packages.PackedFileDescriptor pfd = new SimPe.Packages.PackedFileDescriptor(); pfd.Type = org.Type; pfd.Group = org.Group; pfd.LongInstance = org.LongInstance; return(pfd); }
public void ExecuteEventHandler(object sender, SimPe.Events.ResourceEventArgs e) { if (!RealChangeEnabledStateEventHandler(null, e)) { System.Windows.Forms.MessageBox.Show(Localization.GetString("This is not an appropriate context in which to use this tool"), Localization.GetString(this.ToString())); return; } if (Message.Show(SimPe.Localization.GetString("Fix_Fence_Warning"), SimPe.Localization.GetString("Warning"), System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) { return; } try { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = e.LoadedPackage.Package.FindFiles(Data.MetaData.XFNC); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.PackedFiles.Wrapper.Cpf cpf = new SimPe.PackedFiles.Wrapper.Cpf(); cpf.ProcessData(pfd, e.LoadedPackage.Package); uint guid = cpf.GetSaveItem("guid").UIntegerValue; //load the Descriptor for the String Resource SimPe.Interfaces.Files.IPackedFileDescriptor p = e.LoadedPackage.Package.FindFile( cpf.GetSaveItem("stringsetrestypeid").UIntegerValue, 0, cpf.GetSaveItem("stringsetgroupid").UIntegerValue, cpf.GetSaveItem("stringsetid").UIntegerValue ); //change the Properties cpf.GetSaveItem("resourcegroupid").UIntegerValue = 0x4c8cc5c0; cpf.GetSaveItem("resourceid").UIntegerValue = guid; cpf.GetSaveItem("stringsetgroupid").UIntegerValue = guid; cpf.SynchronizeUserData(true, true); //change the Descriptor for the XML cpf.FileDescriptor.Instance = guid; cpf.FileDescriptor.Group = 0x4c8cc5c0; //change the descriptor for the CTSS if (p != null) { p.Group = guid; } } } catch (Exception ex) { Helper.ExceptionMessage(ex); } }
public Interfaces.Plugin.IToolResult ShowDialog(ref SimPe.Interfaces.Files.IPackedFileDescriptor pfd, ref SimPe.Interfaces.Files.IPackageFile package) { if (isg == null) { isg = new ImportSemi(); } isg.Execute(package, this.reg, this.prov); return(new SimPe.Plugin.ToolResult(false, true)); }
private void Open(object sender, System.EventArgs e) { if (lv.SelectedItems.Count < 1) { return; } pfd = (SimPe.Interfaces.Files.IPackedFileDescriptor)((PackedFiles.Wrapper.SDesc)lv.SelectedItems[0].Tag).FileDescriptor; Close(); }
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); } }
public Interfaces.Plugin.IToolResult ShowDialog(ref SimPe.Interfaces.Files.IPackedFileDescriptor pfd, ref SimPe.Interfaces.Files.IPackageFile package) { if (!IsReallyEnabled(pfd, package)) { return(new SimPe.Plugin.ToolResult(false, false)); } CareerEditor careerEditor = new CareerEditor(); return(careerEditor.Execute(ref pfd, ref package, prov)); }
public void AddResult(string group, SimPe.Interfaces.Files.IPackageFile pkg, SimPe.Interfaces.Files.IPackedFileDescriptor pfd) { if (this.InvokeRequired) { this.BeginInvoke(new InvokeAddResult(InvokedAddResult), new object[] { group, pkg, pfd }); } else { InvokedAddResult(group, pkg, pfd); } }
static void LoadModelName(ArrayList list, SimPe.Interfaces.Files.IPackedFileDescriptor pfd, SimPe.Interfaces.Files.IPackageFile pkg) { SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(); str.ProcessData(pfd, pkg); SimPe.PackedFiles.Wrapper.StrItemList items = str.LanguageItems(1); for (int i = 1; i < items.Length; i++) { list.Add(items[i].Title); } str.Dispose(); }
/// <summary> /// /// </summary> /// <param name="cs"></param> /// <param name="cpf"></param> /// <returns>ResourceDescriptor for the references String</returns> protected static SimPe.Interfaces.Files.IPackedFileDescriptor UpdateDescription(OWCloneSettings cs, SimPe.Packages.GeneratableFile package, SimPe.PackedFiles.Wrapper.Cpf cpf) { cpf.GetSaveItem("cost").UIntegerValue = (uint)cs.Price; cpf.GetSaveItem("name").StringValue = cs.Title.Replace("\n", " ").Replace("\t", " ").Replace("\r", " "); cpf.GetSaveItem("description").StringValue = cs.Description.Replace("\n", " ").Replace("\t", " ").Replace("\r", " "); cpf.SynchronizeUserData(); SimPe.Interfaces.Files.IPackedFileDescriptor pfd = package.FindFile(cpf.GetSaveItem("stringsetrestypeid").UIntegerValue, 0, cpf.GetSaveItem("stringsetgroupid").UIntegerValue, cpf.GetSaveItem("stringsetid").UIntegerValue); return(pfd); }