protected void FixXObject(Hashtable namemap, Hashtable refmap, string grphash) { //set list of critical types uint[] types = new uint[] { Data.MetaData.REF_FILE }; SimPe.Plugin.RefFile fl = new RefFile(); //now fix the texture References in those Resources foreach (uint t in types) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(t); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { fl.ProcessData(pfd, package); foreach (SimPe.Packages.PackedFileDescriptor rfi in fl.Items) { string name = this.BuildRefString(rfi); SimPe.Interfaces.Files.IPackedFileDescriptor npfd = (SimPe.Interfaces.Files.IPackedFileDescriptor)refmap[name]; if (npfd != null) { rfi.Group = npfd.Group; rfi.LongInstance = npfd.LongInstance; } } fl.SynchronizeUserData(); } } }
/// <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 RefFileItem(Interfaces.Files.IPackedFileDescriptor pfd, RefFile parent) { this.parent = parent; this.Group = pfd.Group; this.Type = pfd.Type; this.SubType = pfd.SubType; this.Instance = pfd.Instance; }
/// <summary> /// Is called by SimPe (through the Wrapper) when the Panel is going to be displayed, so /// you should updatet the Data displayed by the Panel with the Attributes stored in the /// passed Wrapper. /// </summary> /// <param name="wrapper">The Attributes of this Wrapper have to be displayed</param> public void UpdateGUI(IFileWrapper wrapper) { FileTable.FileIndex.Load(); form.wrapper = (IFileWrapperSaveExtension)wrapper; RefFile mywrapper = (RefFile)wrapper; form.llcommit.Enabled = false; form.lldelete.Enabled = false; form.btup.Enabled = false; form.btdown.Enabled = false; form.miRem.Enabled = false; form.lblist.Items.Clear(); foreach (Interfaces.Files.IPackedFileDescriptor pfd in mywrapper.Items) { form.lblist.Items.Add(pfd); } }
private void CommitAll(object sender, System.EventArgs e) { try { RefFile wrp = (RefFile)wrapper; Interfaces.Files.IPackedFileDescriptor[] pfds = new Interfaces.Files.IPackedFileDescriptor[lblist.Items.Count]; for (int i = 0; i < pfds.Length; i++) { pfds[i] = (Interfaces.Files.IPackedFileDescriptor)lblist.Items[i]; } wrp.Items = pfds; wrapper.SynchronizeUserData(); MessageBox.Show(Localization.Manager.GetString("commited")); } catch (Exception ex) { Helper.ExceptionMessage(Localization.Manager.GetString("errwritingfile"), ex); } }
private void ChooseFile(object sender, System.EventArgs e) { try { RefFile wrp = (RefFile)wrapper; //FileSelect fs = new FileSelect(wrp.Provider); Interfaces.Files.IPackedFileDescriptor pfd = FileSelect.Execute(); if (pfd != null) { tbtype.Tag = true; this.tbgroup.Text = "0x" + Helper.HexString(pfd.Group); this.tbinstance.Text = "0x" + Helper.HexString(pfd.Instance); this.tbsubtype.Text = "0x" + Helper.HexString(pfd.SubType); this.tbtype.Text = "0x" + Helper.HexString(pfd.Type); tbtype.Tag = null; this.AutoChange(sender, e); } } catch (Exception) {} finally { tbtype.Tag = null; } }
/// <summary> /// Change the SkinTone of a Sim /// </summary> /// <param name="skin">the new skintone</param> /// param name="skinfiles">a Hashtable listing al Proerty Sets for each available skintone (key=skintone string, value= ArrayList of Cpf Objects)</param> /// <returns>the new Package for the patient Sim</returns> public SimPe.Packages.GeneratableFile CloneSkinTone(string skin, Hashtable skinfiles) { SimPe.Packages.GeneratableFile ret = SimPe.Packages.GeneratableFile.LoadFromFile((string)null); string pskin = GetSkintone(this.patient); ArrayList list = new ArrayList(); list.Add((uint)0xE86B1EEF); //make sure the compressed Directory won't be copied! foreach (Interfaces.Files.IPackedFileDescriptor pfd in patient.Index) { if (!list.Contains(pfd.Type)) { Interfaces.Files.IPackedFile fl = patient.Read(pfd); Interfaces.Files.IPackedFileDescriptor newpfd = ret.NewDescriptor(pfd.Type, pfd.SubType, pfd.Group, pfd.Instance); newpfd.UserData = fl.UncompressedData; ret.Add(newpfd); switch (newpfd.Type) { case (uint)0xAC598EAC: //AGED { SimPe.PackedFiles.Wrapper.Cpf cpf = new Cpf(); cpf.ProcessData(newpfd, ret); cpf.GetSaveItem("skincolor").StringValue = skin; cpf.SynchronizeUserData(); break; } case Data.MetaData.GZPS: { SimPe.PackedFiles.Wrapper.Cpf cpf = new Cpf(); cpf.ProcessData(newpfd, ret); cpf.GetSaveItem("skintone").StringValue = skin; cpf.SynchronizeUserData(); break; } case Data.MetaData.TXMT: { SimPe.Plugin.Rcol rcol = new GenericRcol(null, false); rcol.ProcessData(newpfd, ret); MaterialDefinition txmt = (MaterialDefinition)rcol.Blocks[0]; txmt.FindProperty("cafSkinTone").Value = skin; rcol.SynchronizeUserData(); break; } } } } //Update DNA File Interfaces.Files.IPackedFileDescriptor dna = ngbh.FindFile(0xEBFEE33F, 0, Data.MetaData.LOCAL_GROUP, spatient.Instance); if (dna != null) { SimPe.PackedFiles.Wrapper.Cpf cpf = new Cpf(); cpf.ProcessData(dna, ngbh); cpf.GetSaveItem("2").StringValue = skin; cpf.GetSaveItem("6").StringValue = skin; cpf.SynchronizeUserData(); } //Update 3IDR Files SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = ret.FindFiles(0xAC506764); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.Plugin.RefFile reffile = new RefFile(); reffile.ProcessData(pfd, ret); UpdateSkintone(reffile, skin, skinfiles); } //Update TXMT Files for the Face pfds = ret.FindFiles(Data.MetaData.TXMT); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.Plugin.Rcol rcol = new GenericRcol(null, false); rcol.ProcessData(pfd, ret); MaterialDefinition md = (MaterialDefinition)rcol.Blocks[0]; this.UpdateSkintone(md, skin, skinfiles); rcol.SynchronizeUserData(); } return(ret); }
private void SelectFile(object sender, System.EventArgs e) { llcommit.Enabled = false; lldelete.Enabled = false; btup.Enabled = false; btdown.Enabled = false; miAdd.Enabled = false; miRem.Enabled = lldelete.Enabled; if (lblist.SelectedIndex < 0) { return; } llcommit.Enabled = true; lldelete.Enabled = true; btup.Enabled = true; btdown.Enabled = true; miAdd.Enabled = true; miRem.Enabled = lldelete.Enabled; if (tbtype.Tag != null) { return; } try { tbtype.Tag = true; Interfaces.Files.IPackedFileDescriptor pfd = (Interfaces.Files.IPackedFileDescriptor)lblist.Items[lblist.SelectedIndex]; this.tbgroup.Text = "0x" + Helper.HexString(pfd.Group); this.tbinstance.Text = "0x" + Helper.HexString(pfd.Instance); this.tbsubtype.Text = "0x" + Helper.HexString(pfd.SubType); this.tbtype.Text = "0x" + Helper.HexString(pfd.Type); //get Texture if (pfd.GetType() == typeof(RefFileItem)) { RefFile wrp = (RefFile)wrapper; SkinChain sc = ((RefFileItem)pfd).Skin; SimPe.Plugin.GenericRcol txtr = null; if (sc != null) { txtr = sc.TXTR; } //show the Image if (txtr == null) { pb.Image = null; } else { MipMap mm = ((ImageData)txtr.Blocks[0]).GetLargestTexture(pb.Size); if (mm != null) { pb.Image = mm.Texture; } else { pb.Image = null; } } } else { pb.Image = null; } } catch (Exception ex) { Helper.ExceptionMessage(Localization.Manager.GetString("errconvert"), ex); } finally { tbtype.Tag = null; } }
public RefFileItem(RefFile parent) { this.parent = parent; }