private void RNItemsDelete(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { if (Tag == null) { return; } if (lb_rn.SelectedIndex < 0) { return; } try { lb_rn.Tag = true; SimPe.Plugin.ResourceNode rn = (SimPe.Plugin.ResourceNode)Tag; ResourceNodeItem b = (ResourceNodeItem)lb_rn.Items[lb_rn.SelectedIndex]; rn.Items = (ResourceNodeItem[])Helper.Delete(rn.Items, b); lb_rn.Items.Remove(b); rn.Changed = true; } catch (Exception ex) { Helper.ExceptionMessage("", ex); } finally { lb_rn.Tag = null; } }
private void RNItemsAdd(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { if (Tag == null) { return; } try { lb_rn.Tag = true; SimPe.Plugin.ResourceNode rn = (SimPe.Plugin.ResourceNode)Tag; ResourceNodeItem b = new ResourceNodeItem(); b.Unknown1 = (short)Convert.ToUInt16(tb_rn_1.Text, 16); b.Unknown2 = (int)Convert.ToUInt32(tb_rn_2.Text, 16); rn.Items = (ResourceNodeItem[])Helper.Add(rn.Items, b); lb_rn.Items.Add(b); rn.Changed = true; } catch (Exception ex) { Helper.ExceptionMessage("", ex); } finally { lb_rn.Tag = null; } }
private void RNChangedItems(object sender, System.EventArgs e) { if (lb_rn.Tag != null) { return; } if (this.lb_rn.SelectedIndex < 0) { return; } try { lb_rn.Tag = true; SimPe.Plugin.ResourceNode rn = (SimPe.Plugin.ResourceNode)Tag; ResourceNodeItem b = (ResourceNodeItem)lb_rn.Items[lb_rn.SelectedIndex]; b.Unknown1 = (short)Convert.ToUInt16(tb_rn_1.Text, 16); b.Unknown2 = (int)Convert.ToUInt32(tb_rn_2.Text, 16); lb_rn.Items[lb_rn.SelectedIndex] = b; rn.Changed = true; } catch (Exception) { //Helper.ExceptionMessage("", ex); } finally { lb_rn.Tag = null; } }
private void RNSelect(object sender, System.EventArgs e) { if (lb_rn.Tag != null) { return; } if (this.lb_rn.SelectedIndex < 0) { return; } try { lb_rn.Tag = true; SimPe.Plugin.ResourceNode rn = (SimPe.Plugin.ResourceNode)Tag; ResourceNodeItem b = (ResourceNodeItem)lb_rn.Items[lb_rn.SelectedIndex]; tb_rn_1.Text = "0x" + Helper.HexString((ushort)b.Unknown1); tb_rn_2.Text = "0x" + Helper.HexString((uint)b.Unknown2); rn.Changed = true; } catch (Exception) { //Helper.ExceptionMessage("", ex); } finally { lb_rn.Tag = null; } }
private void lb_SelectedIndexChanged(object sender, System.EventArgs e) { if (lb.SelectedItem == null) { return; } jointmap.Clear(); ListedMeshBlocks lmb = (ListedMeshBlocks)lb.SelectedItem; if (lmb.CRES == null || lmb.GMDC == null) { return; } SimPe.Plugin.ResourceNode rn = (SimPe.Plugin.ResourceNode)lmb.CRES.Blocks[0]; if (root != null) { root.Dispose(); } root = new Ambertation.Graphics.MeshList(); AddJoint(lmb, rn, root, tv.Nodes); animdata.Clear(); foreach (SimPe.Plugin.Anim.AnimationFrameBlock afb in lmb.ANIMBlock.Part2) { SimPe.Plugin.Anim.AnimationFrameBlock afb2 = afb.CloneBase(true); object o = jointmap[afb.Name]; if (o == null) { continue; } Ambertation.Graphics.MeshBox mb = (Ambertation.Graphics.MeshBox)o; animdata.Add(new AnimationData(afb2, mb, lmb.ANIMBlock.Animation.TotalTime)); } if (inter) { return; } inter = true; //dx.Reset(); dx.ResetViewport(new Microsoft.DirectX.Vector3(-2, -2, -2), new Microsoft.DirectX.Vector3(2, 2, 2)); dx.Render(); inter = false; }
private void RNChangeSettings(object sender, System.EventArgs e) { if (Tag == null) { return; } try { SimPe.Plugin.ResourceNode rn = (SimPe.Plugin.ResourceNode)Tag; rn.Unknown1 = (int)Convert.ToInt32(this.tb_rn_uk1.Text, 16); rn.Unknown2 = (int)Convert.ToInt32(this.tb_rn_uk2.Text, 16); rn.Version = Convert.ToUInt32(tb_rn_ver.Text, 16); rn.Changed = true; } catch (Exception) { //Helper.ExceptionMessage("", ex); } }
void FixFence() { Hashtable shpnamemap = new Hashtable(); GenericRcol rcol = new GenericRcol(); uint[] types = new uint[] { Data.MetaData.SHPE, Data.MetaData.CRES }; //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) { //fix the references to the SHPE Resources, to mirror the fact //that they are in the Global Group now if (t == Data.MetaData.CRES || t == Data.MetaData.GMND) { rcol.ProcessData(pfd, package); string shpname = null; if (t == Data.MetaData.CRES) { SimPe.Plugin.ResourceNode rn = (SimPe.Plugin.ResourceNode)rcol.Blocks[0]; rn.GraphNode.FileName = Hashes.StripHashFromName(rn.GraphNode.FileName); //generate the name for the connected SHPE Resource foreach (SimPe.Interfaces.Scenegraph.IRcolBlock irb in rcol.Blocks) { if (irb is SimPe.Plugin.ShapeRefNode) { ShapeRefNode srn = (ShapeRefNode)irb; shpname = rcol.FileName.Trim().ToLower().Replace("_cres", "").Replace("_", "").Trim(); srn.StoredTransformNode.ObjectGraphNode.FileName = shpname; shpname = rcol.FileName.Replace("_cres", "").Trim() + "_" + shpname + "_shpe"; } } } else if (t == Data.MetaData.GMND) { SimPe.Plugin.GeometryNode gn = (SimPe.Plugin.GeometryNode)rcol.Blocks[0]; gn.ObjectGraphNode.FileName = Hashes.StripHashFromName(gn.ObjectGraphNode.FileName); } foreach (SimPe.Interfaces.Files.IPackedFileDescriptor rpfd in rcol.ReferencedFiles) { //SHPE Resources get a new Name, so fix the Instance of the reference at this point if (rpfd.Type == Data.MetaData.SHPE) { shpnamemap[rpfd.LongInstance] = shpname; rpfd.Instance = Hashes.InstanceHash(shpname); rpfd.SubType = Hashes.SubTypeHash(shpname); } rpfd.Group = Data.MetaData.GLOBAL_GROUP; } rcol.SynchronizeUserData(); } pfd.Group = Data.MetaData.GLOBAL_GROUP; } } //we need some special Adjustments for SHPE Resources, as their name has to match a certain pattern SimPe.Interfaces.Files.IPackedFileDescriptor[] spfds = package.FindFiles(Data.MetaData.SHPE); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in spfds) { if (shpnamemap[pfd.LongInstance] == null) { continue; } rcol.ProcessData(pfd, package); rcol.FileName = (string)shpnamemap[pfd.LongInstance]; rcol.FileDescriptor.Instance = Hashes.InstanceHash(rcol.FileName); rcol.FileDescriptor.SubType = Hashes.SubTypeHash(rcol.FileName); rcol.SynchronizeUserData(); } }