Ejemplo n.º 1
0
        /// <summary>
        /// Adss a DesignMode Block and returns it
        /// </summary>
        /// <param name="gmnd"></param>
        /// <param name="dle"></param>
        protected void AddDesignModeBlock(SimPe.Plugin.Rcol gmnd, DataListExtension dle)
        {
            dle.Extension.VarName = "tsDesignModeEnabled";

            /*IRcolBlock[] newblock = new IRcolBlock[gmnd.Blocks.Length+1];
             * for (int i=0; i<gmnd.Blocks.Length; i++)
             * {
             *      if (i==0) newblock[i] = gmnd.Blocks[i];
             *      else newblock[i+1] = gmnd.Blocks[i];
             * }
             * newblock[1] = dle;
             * gmnd.Blocks = newblock;*/


            SimPe.Plugin.GeometryNode gn = (SimPe.Plugin.GeometryNode)gmnd.Blocks[0];

            ObjectGraphNodeItem item = new ObjectGraphNodeItem();

            item.Enabled   = 0x01;
            item.Dependant = 0x00;
            item.Index     = (uint)gmnd.Blocks.Length;

            gn.ObjectGraphNode.Items = (ObjectGraphNodeItem[])Helper.Add(gn.ObjectGraphNode.Items, item);
            gmnd.Blocks = (IRcolBlock[])Helper.Add(gmnd.Blocks, dle, typeof(IRcolBlock));
        }
Ejemplo n.º 2
0
        private void GrNSettingsChange(object sender, System.EventArgs e)
        {
            if (this.Tag == null)
            {
                return;
            }
            try
            {
                SimPe.Plugin.GeometryNode arb = (SimPe.Plugin.GeometryNode)Tag;

                arb.Version  = Convert.ToUInt32(tb_gn_ver.Text, 16);
                arb.Unknown1 = (short)Convert.ToUInt16(tb_gn_uk1.Text, 16);
                arb.Unknown2 = (short)Convert.ToUInt16(tb_gn_uk2.Text, 16);
                arb.Unknown3 = Convert.ToByte(tb_gn_uk3.Text, 16);

                arb.Changed = true;
            }
            catch (Exception)
            {
                //Helper.ExceptionMessage("", ex);
            }
        }
Ejemplo n.º 3
0
        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();
            }
        }