Beispiel #1
0
        public WorkshopMMAT[] Execute(WorkshopMMAT[] list)
        {
            lb.Items.Clear();
            foreach (WorkshopMMAT s in list)
            {
                lb.Items.Add(s);
            }
            if (lb.Items.Count > 0)
            {
                lb.SelectedIndex = 0;
            }

            this.ShowDialog();

            WorkshopMMAT[] str;
            if (lb.SelectedItems.Count > 0)
            {
                str = new WorkshopMMAT[lb.SelectedItems.Count];
                for (int i = 0; i < lb.SelectedItems.Count; i++)
                {
                    str[i] = (WorkshopMMAT)lb.SelectedItems[i];
                }
            }
            else
            {
                str = new WorkshopMMAT[0];
            }
            return(str);
        }
Beispiel #2
0
        /// <summary>
        /// adds the subsets to the tsDesignMode.. Block and returns a List of all added Subsets
        /// </summary>
        /// <param name="shpes"></param>
        /// <param name="gmnd"></param>
        /// <param name="subsets"></param>
        protected void GetSubsets(SimPe.Plugin.Rcol[] shpes, SimPe.Plugin.Rcol gmnd, ArrayList subsets)
        {
            ArrayList         list         = new ArrayList();
            ArrayList         localsubsets = new ArrayList();
            DataListExtension dle          = new DataListExtension(gmnd);
            uint index = (uint)(gm_pkg.FindFiles(0x4C697E5A).Length + 1);

            foreach (SimPe.Plugin.Rcol shpe in shpes)
            {
                SimPe.Plugin.Shape sh   = (SimPe.Plugin.Shape)shpe.Blocks[0];
                SimPe.Plugin.Rcol  cres = FindResourceNode(shpe);

                foreach (SimPe.Plugin.ShapePart part in sh.Parts)
                {
                    if (subsets.Contains(part.Subset))
                    {
                        continue;
                    }
                    if (localsubsets.Contains(part.Subset))
                    {
                        continue;
                    }

                    //Read the MATD
                    Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFile(part.FileName + "_txmt", 0x49596978);
                    foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                    {
                        SimPe.Plugin.Rcol matd = new GenericRcol(null, false);
                        matd.ProcessData(pfd, package);
                        SimPe.Plugin.MaterialDefinition md = (SimPe.Plugin.MaterialDefinition)matd.Blocks[0];

                        //check that the Material is not transparent
                        if (md.GetProperty("stdMatAlphaBlendMode").Value == "none")
                        {
                            //check that the Material references a texture
                            if (package.FindFile(md.GetProperty("stdMatBaseTextureName").Value + "_txtr", 0x1C4A276C).Length > 0)
                            {
                                localsubsets.Add(part.Subset);

                                SimPe.Plugin.ExtensionItem ei = new ExtensionItem();
                                ei.Name     = part.Subset;
                                ei.Typecode = ExtensionItem.ItemTypes.Array;

                                WorkshopMMAT i   = new WorkshopMMAT(part.Subset);
                                object[]     tag = new object[3];
                                tag[0] = matd;
                                tag[1] = cres.FileName;
                                tag[2] = ei;
                                i.Tag  = tag;

                                //if (md.GetProperty("stdMatAlphaBlendMode").Value!="none") i.AddObjectStateIndex(1);
                                list.Add(i);
                                //dle.Extension.Items = (ExtensionItem[])Helper.Add(dle.Extension.Items, ei);
                                //AddMMAT(matd, part.Type, cres.FileName, index++);
                            }
                        }
                    }
                }
            }

            WorkshopMMAT[] mmats = new WorkshopMMAT[list.Count];
            list.CopyTo(mmats);

            Listing li = new Listing();

            if (mmats.Length > 0)
            {
                mmats = li.Execute(mmats);
            }

            foreach (WorkshopMMAT mmat in mmats)
            {
                subsets.Add(mmat.Subset);
                dle.Extension.Items = (ExtensionItem[])Helper.Add(dle.Extension.Items, (ExtensionItem)mmat.Tag[2]);
                AddMMAT((SimPe.Plugin.Rcol)mmat.Tag[0], mmat.Subset, (string)mmat.Tag[1], index++, false);
            }

            if (dle.Extension.Items.Length > 0)
            {
                AddDesignModeBlock(gmnd, dle);
                gmnd.SynchronizeUserData();
                dn_pkg.Add(gmnd.FileDescriptor);
            }
        }