private void Select(object sender, System.Windows.Forms.TreeViewEventArgs e) { pb.Image = null; button1.Enabled = false; lbname.Text = ""; last = null; if (e == null) { return; } if (e.Node == null) { return; } if (e.Node.Tag == null) { return; } button1.Enabled = true; last = e.Node; SkinChain sc = new SkinChain((SimPe.PackedFiles.Wrapper.Cpf)e.Node.Tag); GenericRcol rcol = sc.TXTR; if (rcol != null) { ImageData id = (ImageData)rcol.Blocks[0]; MipMap mm = id.GetLargestTexture(pb.Size); if (mm != null) { pb.Image = ImageLoader.Preview(mm.Texture, pb.Size); } } lbname.Text = "Name: " + Helper.lbr + sc.Name + Helper.lbr + Helper.lbr; lbname.Text += "Category: " + Helper.lbr + sc.CategoryNames + Helper.lbr + Helper.lbr; lbname.Text += "Age: " + Helper.lbr + sc.AgeNames + Helper.lbr + Helper.lbr; lbname.Text += "Override: " + Helper.lbr + sc.Cpf.GetSaveItem("override0subset").StringValue + Helper.lbr + Helper.lbr; lbname.Text += "Group: " + Helper.lbr + Helper.HexString(sc.Cpf.FileDescriptor.Group) + Helper.lbr + Helper.lbr; }
/// <summary> /// Updates the SkinTone References in the 3IDR Files /// </summary> /// <param name="md">The Metreial Definition</param> /// <param name="skinfiles">a Hashtable listing al Proerty Sets for each available skintone (key=skintone string, value= ArrayList of Cpf Objects)</param> /// <param name="sourceskin">the hash for the source skin</param> /// <param name="targetskin">the hash for the target skin</param> void UpdateSkintone(MaterialDefinition md, string targetskin, Hashtable skinfiles) { uint age = (uint)Data.MetaData.AgeTranslation((Data.MetaData.LifeSections)spatient.CharacterDescription.Age); try { age = (uint)Math.Pow(2, Convert.ToInt32(md.FindProperty("paramAge").Value)); } catch {} try { patientgender = Convert.ToUInt32(md.FindProperty("paramGender").Value); } catch {} if (skinfiles[targetskin] == null) { return; } foreach (Cpf newcpf in (ArrayList)skinfiles[targetskin]) { if (newcpf.GetSaveItem("override0subset").StringValue.Trim().ToLower() == "face") { if ((newcpf.GetSaveItem("age").UIntegerValue & age) == age) { if ((newcpf.GetSaveItem("gender").UIntegerValue & patientgender) == patientgender) { SimPe.Plugin.SkinChain sc = new SkinChain(newcpf); Interfaces.Files.IPackedFileDescriptor[] pfds = newcpf.Package.FindFile(0xAC506764, newcpf.FileDescriptor.SubType, newcpf.FileDescriptor.Instance); Rcol txmt = sc.TXMT; Rcol txtr = sc.TXTR; if (txtr != null && txmt != null) { string txmtname = txmt.FileName.Trim(); if (txmtname.ToLower().EndsWith("_txmt")) { txmtname = txmtname.Substring(0, txmtname.Length - 5); } string basename = txtr.FileName.Trim(); if (basename.ToLower().EndsWith("_txtr")) { basename = basename.Substring(0, basename.Length - 5); } if (txmtname.IndexOf("#") == 0) { txmtname = "_" + txmtname; } int count = 0; try { count = Convert.ToInt32(md.FindProperty("numTexturesToComposite").Value); } catch {} if (count > 0) { md.FindProperty("baseTexture0").Value = basename; md.FindProperty("stdMatBaseTextureName").Value = basename; for (int i = 1; i < count; i++) { string name = md.FindProperty("baseTexture" + i.ToString()).Value.Trim(); if (!name.ToLower().EndsWith("_txtr")) { name += "_txtr"; } name = this.FindTxtrName(name); if (i != 0) { txmtname += "_"; } txmtname += name; } md.FindProperty("compositeBaseTextureName").Value = txmtname; string[] list = new string[1]; list[0] = txmtname; md.Listing = list; } } } } } } }
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; } }