Пример #1
0
        /// <summary>
        /// Add the MATD referenced by the passed MMAT
        /// </summary>
        /// <param name="mmat">A valid MMAT file</param>
        protected void AddMATD(SimPe.PackedFiles.Wrapper.Cpf mmat)
        {
            SimPe.Packages.File pkg  = SimPe.Packages.File.LoadFromFile(System.IO.Path.Combine(PathProvider.Global.GetExpansion(Expansions.BaseGame).InstallFolder, "TSData\\Res\\Sims3D\\Objects02.package"));
            ArrayList           list = new ArrayList();
            string flname            = Hashes.StripHashFromName(mmat.GetSaveItem("name").StringValue) + "_txmt";

            Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFile(flname, 0x49596978);

            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                SimPe.Plugin.Rcol matd = new GenericRcol(null, false);
                matd.ProcessData(pfd, pkg);

                if (matd.FileName.Trim().ToLower() == flname.Trim().ToLower())
                {
                    matd.SynchronizeUserData();
                    if (package.FindFile(matd.FileDescriptor) == null)
                    {
                        package.Add(matd.FileDescriptor);
                    }
                }
            }

            //pkg.Reader.Close();
        }
Пример #2
0
        private bool FindInField(SimPe.PackedFiles.Wrapper.Cpf cpf, bool found, string fldname)
        {
            string n = cpf.GetSaveItem(fldname).StringValue.ToLower();

            if (compareType == CompareType.Equal)
            {
                found = n == name;
            }
            else if (compareType == CompareType.Start)
            {
                found = n.StartsWith(name);
            }
            else if (compareType == CompareType.End)
            {
                found = n.EndsWith(name);
            }
            else if (compareType == CompareType.Contain)
            {
                found = n.IndexOf(name) > -1;
            }
            else if (compareType == CompareType.RegExp && reg != null)
            {
                found = reg.IsMatch(n);
            }
            return(found);
        }
Пример #3
0
        /// <summary>
        /// Chnages materialStateFlags and objectStateIndex according to the MaTD Reference Name
        /// </summary>
        /// <param name="mmat">The MMAT File to change the values in</param>
        public static void FixMMAT(SimPe.PackedFiles.Wrapper.Cpf mmat)
        {
            string name = mmat.GetSaveItem("name").StringValue;

            if (name.EndsWith("_clean"))
            {
                mmat.GetSaveItem("materialStateFlags").UIntegerValue = 0;
                mmat.GetSaveItem("objectStateIndex").IntegerValue    = 0;
            }
            else if (name.EndsWith("_dirty"))
            {
                mmat.GetSaveItem("materialStateFlags").UIntegerValue = 2;
                mmat.GetSaveItem("objectStateIndex").IntegerValue    = 1;
            }
            else if (name.EndsWith("_lit"))
            {
                mmat.GetSaveItem("materialStateFlags").UIntegerValue = 1;
                mmat.GetSaveItem("objectStateIndex").IntegerValue    = 3;
            }
            else if (name.EndsWith("_unlit"))
            {
                mmat.GetSaveItem("materialStateFlags").UIntegerValue = 0;
                mmat.GetSaveItem("objectStateIndex").IntegerValue    = 4;
            }
            else if (name.EndsWith("_on"))
            {
                mmat.GetSaveItem("materialStateFlags").UIntegerValue = 2;
                mmat.GetSaveItem("objectStateIndex").IntegerValue    = 6;
            }
            else if (name.EndsWith("_off"))
            {
                mmat.GetSaveItem("materialStateFlags").UIntegerValue = 0;
                mmat.GetSaveItem("objectStateIndex").IntegerValue    = 5;
            }
        }
Пример #4
0
        internal CpfListItem(SimPe.PackedFiles.Wrapper.Cpf cpf) : base(cpf)
        {
            this.cpf = cpf;
            name     = Localization.Manager.GetString("Unknown");
            category = 0;
            if (cpf != null)
            {
                foreach (SimPe.PackedFiles.Wrapper.CpfItem citem in cpf.Items)
                {
                    if (citem.Name.ToLower() == "name")
                    {
                        name = citem.StringValue;
                    }
                }
                foreach (SimPe.PackedFiles.Wrapper.CpfItem citem in cpf.Items)
                {
                    if (citem.Name.ToLower() == "category")
                    {
                        category = citem.UIntegerValue;
                    }
                }
            }

            name = name.Replace("CASIE_", "");
        }
Пример #5
0
        void FixCpfProperties(SimPe.PackedFiles.Wrapper.Cpf cpf, string[] props, Hashtable namemap, string prefix, string sufix)
        {
            foreach (string p in props)
            {
                SimPe.PackedFiles.Wrapper.CpfItem item = cpf.GetItem(p);
                if (item == null)
                {
                    continue;
                }

                string name = Hashes.StripHashFromName(item.StringValue.Trim().ToLower());
                if (!name.EndsWith(sufix))
                {
                    name += sufix;
                }
                string newname = (string)namemap[name];

                if (newname != null)
                {
                    if (newname.EndsWith(sufix))
                    {
                        newname = newname.Substring(0, newname.Length - sufix.Length);
                    }
                    item.StringValue = prefix + newname;
                }
            }
        }
Пример #6
0
        public override void SetFromObjectCacheItem(SimPe.Cache.ObjectCacheItem oci)
        {
            ClearScreen();
            if (oci == null)
            {
                objd = null;
                return;
            }

            //Original Implementation
            if (oci.Class == SimPe.Cache.ObjectClass.Object)
            {
                cpf = null;
                base.SetFromObjectCacheItem(oci);
                return;
            }


            objd = null;
            cpf  = null;
            if (oci.Tag != null)
            {
                if (oci.Tag is SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem)
                {
                    cpf = new SimPe.PackedFiles.Wrapper.Cpf();
                    cpf.ProcessData((SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem)oci.Tag);
                }
            }


            UpdateXObjScreen(null, false);
            nfo.Image = oci.Thumbnail;
            nfo.Name  = oci.Name;
        }
Пример #7
0
        public override void SetFromPackage(SimPe.Interfaces.Files.IPackageFile pkg)
        {
            if (pkg == null)
            {
                objd = null;
                ClearScreen();
                return;
            }

            //this is a regular Object?
            if (pkg.FindFiles(Data.MetaData.OBJD_FILE).Length > 0)
            {
                cpf = null;
                base.SetFromPackage(pkg);
                return;
            }

            objd = null;



            foreach (uint t in xtypes)
            {
                SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(t);
                if (pfds.Length > 0)
                {
                    cpf = new SimPe.PackedFiles.Wrapper.Cpf();
                    cpf.ProcessData(pfds[0], pkg);
                    break;
                }
            }

            UpdateXObjScreen();
        }
Пример #8
0
        AbstractWrapper findInPackage(String pkg, uint Filetype, IPackedFileDescriptor pfd)
        {
            IPackageFile p = SimPe.Packages.File.LoadFromFile(pkg);

            if (p == null)
            {
                return(null);
            }

            IPackedFileDescriptor pt = p.FindFile(Filetype, pfd.SubType, pfd.Group, pfd.Instance);

            if (pt == null)
            {
                return(null);
            }

            AbstractWrapper tgt;

            if (Filetype == SimPe.Data.MetaData.REF_FILE)
            {
                tgt = new SimPe.Plugin.RefFile();
            }
            else
            {
                tgt = new SimPe.PackedFiles.Wrapper.Cpf();
            }
            tgt.ProcessData(pt, p);
            return(tgt);
        }
Пример #9
0
        public static Image GetXThumbnail(SimPe.PackedFiles.Wrapper.Cpf cpf)
        {
            if (xthumbs == null)
            {
                xthumbs = SimPe.Packages.File.LoadFromFile(System.IO.Path.Combine(PathProvider.SimSavegameFolder, "Thumbnails\\BuildModeThumbnails.package"));
            }

            SimPe.Packages.File      tmbs = xthumbs;
            Data.XObjFunctionSubSort fss  = GetFunctionSort(cpf);

            uint inst = cpf.GetSaveItem("guid").UIntegerValue;
            uint grp  = cpf.FileDescriptor.Group;

            if (cpf.GetItem("thumbnailinstanceid") != null)
            {
                inst = cpf.GetSaveItem("thumbnailinstanceid").UIntegerValue;
                grp  = cpf.GetSaveItem("thumbnailgroupid").UIntegerValue;
            }


            //get Thumbnail Type
            uint[] types = new uint[] { 0x8C311262, 0x8C31125E }; //floors, walls
            if (fss == Data.XObjFunctionSubSort.Roof)
            {
                types = new uint[] { 0xCC489E46 }
            }
            ;
            else if (fss == Data.XObjFunctionSubSort.Fence_Rail || fss == Data.XObjFunctionSubSort.Fence_Halfwall)
            {
                types = new uint[] { 0xCC30CDF8 }
            }
            ;
            else if (fss == Data.XObjFunctionSubSort.Roof)
            {
                types = new uint[] { 0xCC489E46 }
            }
            ;
            else if (fss == Data.XObjFunctionSubSort.Terrain)
            {
                types = new uint[] { 0xEC3126C4 };
                if (cpf.GetItem("texturetname") != null)
                {
                    inst = Hashes.GetCrc32(Hashes.StripHashFromName(cpf.GetItem("texturetname").StringValue.Trim().ToLower()));
                }
            }
            else if (cpf.FileDescriptor.Type == Data.MetaData.XNGB)
            {
                types = new uint[] { 0x4D533EDD };
                if (nthumbs == null)
                {
                    nthumbs = SimPe.Packages.File.LoadFromFile(System.IO.Path.Combine(PathProvider.SimSavegameFolder, "Thumbnails\\CANHObjectsThumbnails.package"));
                }
                tmbs = nthumbs;
            }


            return(GetThumbnail(cpf.GetSaveItem("name").StringValue, types, grp, inst, tmbs));
            //tmbs = null;
        }
Пример #10
0
 /// <summary>
 /// adds the passed value if it doesn't already exist
 /// </summary>
 /// <param name="val">The value to add</param>
 public bool AddMMAT(SimPe.PackedFiles.Wrapper.Cpf mmat)
 {
     if (this.AddObjectStateIndex(mmat.GetItem("objectStateIndex").UIntegerValue))
     {
         mmats = (SimPe.PackedFiles.Wrapper.Cpf[])Helper.Add(mmats, mmat);
         return(true);
     }
     return(false);
 }
Пример #11
0
        public void ExecuteEventHandler(object sender, SimPe.Events.ResourceEventArgs e)
        {
            if (!RealChangeEnabledStateEventHandler(null, e))
            {
                System.Windows.Forms.MessageBox.Show(Localization.GetString("This is not an appropriate context in which to use this tool"),
                                                     Localization.GetString(this.ToString()));
                return;
            }

            if (Message.Show(SimPe.Localization.GetString("Fix_Fence_Warning"), SimPe.Localization.GetString("Warning"), System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
            {
                return;
            }



            try
            {
                SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = e.LoadedPackage.Package.FindFiles(Data.MetaData.XFNC);
                foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                {
                    SimPe.PackedFiles.Wrapper.Cpf cpf = new SimPe.PackedFiles.Wrapper.Cpf();
                    cpf.ProcessData(pfd, e.LoadedPackage.Package);

                    uint guid = cpf.GetSaveItem("guid").UIntegerValue;
                    //load the Descriptor for the String Resource
                    SimPe.Interfaces.Files.IPackedFileDescriptor p = e.LoadedPackage.Package.FindFile(
                        cpf.GetSaveItem("stringsetrestypeid").UIntegerValue,
                        0,
                        cpf.GetSaveItem("stringsetgroupid").UIntegerValue,
                        cpf.GetSaveItem("stringsetid").UIntegerValue
                        );

                    //change the Properties
                    cpf.GetSaveItem("resourcegroupid").UIntegerValue  = 0x4c8cc5c0;
                    cpf.GetSaveItem("resourceid").UIntegerValue       = guid;
                    cpf.GetSaveItem("stringsetgroupid").UIntegerValue = guid;

                    cpf.SynchronizeUserData(true, true);

                    //change the Descriptor for the XML
                    cpf.FileDescriptor.Instance = guid;
                    cpf.FileDescriptor.Group    = 0x4c8cc5c0;

                    //change the descriptor for the CTSS
                    if (p != null)
                    {
                        p.Group = guid;
                    }
                }
            }
            catch (Exception ex)
            {
                Helper.ExceptionMessage(ex);
            }
        }
Пример #12
0
        public ColorOptionsItem(SimPe.PackedFiles.Wrapper.Cpf mmat)
        {
            this.MMAT = mmat;

            Subset  = mmat.GetSaveItem("subsetName").StringValue.Trim().ToLower();
            Family  = mmat.GetSaveItem("family").StringValue.Trim().ToLower();
            Guid    = mmat.GetSaveItem("objectGUID").UIntegerValue;
            Default = mmat.GetSaveItem("defaultMaterial").BooleanValue;
            matd    = null;
        }
Пример #13
0
        SimPe.PackedFiles.Wrapper.CpfItem FixCpfProperties(SimPe.PackedFiles.Wrapper.Cpf cpf, string prop, uint val)
        {
            SimPe.PackedFiles.Wrapper.CpfItem item = cpf.GetItem(prop);
            if (item == null)
            {
                return(null);
            }

            item.UIntegerValue = val;
            return(item);
        }
Пример #14
0
        private List <AbstractWrapper[]> findFragKeys()
        {
            List <AbstractWrapper[]> fragKeys = new List <AbstractWrapper[]>();

            foreach (String pkg in fragkeys)
            {
                IPackageFile p = SimPe.Packages.File.LoadFromFile(pkg);
                if (p == null)
                {
                    continue;
                }

                IPackedFileDescriptor[] apfd = p.FindFiles(0x0C560F39 /*BINX*/);
                SimPe.Wait.SubStart(apfd.Length);
                foreach (IPackedFileDescriptor bx in apfd)
                {
                    try
                    {
                        // is there a paired 3idr?
                        IPackedFileDescriptor pfd = p.FindFile(SimPe.Data.MetaData.REF_FILE /*3IDR*/, bx.SubType, bx.Group, bx.Instance);
                        if (pfd == null)
                        {
                            continue;
                        }

                        // load the pair
                        SimPe.Plugin.RefFile fk3idr = new SimPe.Plugin.RefFile();
                        fk3idr.ProcessData(pfd, p);
                        SimPe.PackedFiles.Wrapper.Cpf fkCpf = new SimPe.PackedFiles.Wrapper.Cpf();
                        fkCpf.ProcessData(bx, p);

                        // does the pair point to the object we're working on?
                        SimPe.PackedFiles.Wrapper.CpfItem objKeyIdx = fkCpf.GetItem("objectidx");
                        if (objKeyIdx == null || objKeyIdx.Datatype != SimPe.Data.MetaData.DataTypes.dtUInteger)
                        {
                            continue;
                        }
                        if (!fk3idr.Items[objKeyIdx.UIntegerValue].Equals(objKeyCPF))
                        {
                            continue;
                        }

                        // success - save the fragkey
                        fragKeys.Add(new AbstractWrapper[] { fkCpf, fk3idr });
                    }
                    finally
                    {
                        SimPe.Wait.Progress++;
                    }
                }
                SimPe.Wait.SubStop();
            }
            return(fragKeys);
        }
Пример #15
0
        /// <summary>
        /// Add Resources referenced from XML Files
        /// </summary>
        /// <param name="names"></param>
        public void AddFromXml(SimPe.Interfaces.Files.IPackageFile pkg)
        {
            SimPe.Interfaces.Files.IPackedFileDescriptor[] index = (SimPe.Interfaces.Files.IPackedFileDescriptor[])pkg.Index.Clone();
            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in index)
            {
                SimPe.PackedFiles.Wrapper.Cpf cpf = new SimPe.PackedFiles.Wrapper.Cpf();
                if (!cpf.CanHandleType(pfd.Type))
                {
                    continue;
                }

                cpf.ProcessData(pfd, pkg);

                //xobj
                AddFromXml(cpf.GetItem("material"), "_txmt", Data.MetaData.TXMT);

                //hood object
                if (pfd.Type == Data.MetaData.XNGB)
                {
                    AddFromXml(cpf.GetItem("modelname"), "_cres", Data.MetaData.CRES);
                }

                //fences
                AddFromXml(cpf.GetItem("diagrail"), "_cres", Data.MetaData.CRES);
                AddFromXml(cpf.GetItem("post"), "_cres", Data.MetaData.CRES);
                AddFromXml(cpf.GetItem("rail"), "_cres", Data.MetaData.CRES);
                AddFromXml(cpf.GetItem("diagrail"), "_txmt", Data.MetaData.TXMT);
                AddFromXml(cpf.GetItem("post"), "_txmt", Data.MetaData.TXMT);
                AddFromXml(cpf.GetItem("rail"), "_txmt", Data.MetaData.TXMT);

                //terrain
                AddFromXml(cpf.GetItem("texturetname"), "_txtr", Data.MetaData.TXTR);
                AddFromXml(cpf.GetItem("texturetname"), "_detail_txtr", Data.MetaData.TXTR);
                AddFromXml(cpf.GetItem("texturetname"), "-bump_txtr", Data.MetaData.TXTR);

                //roof
                AddFromXml(cpf.GetItem("textureedges"), "_txtr", Data.MetaData.TXTR);
                AddFromXml(cpf.GetItem("texturetop"), "_txtr", Data.MetaData.TXTR);
                AddFromXml(cpf.GetItem("texturetopbump"), "_txtr", Data.MetaData.TXTR);
                AddFromXml(cpf.GetItem("texturetrim"), "_txtr", Data.MetaData.TXTR);
                AddFromXml(cpf.GetItem("textureunder"), "_txtr", Data.MetaData.TXTR);

                SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] items =
                    FileTable.FileIndex.FindFile(
                        cpf.GetSaveItem("stringsetrestypeid").UIntegerValue,
                        cpf.GetSaveItem("stringsetgroupid").UIntegerValue,
                        cpf.GetSaveItem("stringsetid").UIntegerValue,
                        null
                        );
                AddFromXml(items);
            }
        }
Пример #16
0
        /// <summary>
        /// Return all Modelnames that can be found in this package
        /// </summary>
        /// <param name="pkg">The Package you want to scan</param>
        /// <returns>a list of Modelnames</returns>
        public static string[] FindModelNames(SimPe.Interfaces.Files.IPackageFile pkg)
        {
            ArrayList names = new ArrayList();

            Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFile(Data.MetaData.STRING_FILE, 0, 0x85);
            if (pfds.Length > 0)
            {
                foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                {
                    SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                    str.ProcessData(pfd, pkg);

                    foreach (SimPe.PackedFiles.Wrapper.StrToken item in str.Items)
                    {
                        string mname = Hashes.StripHashFromName(item.Title.Trim().ToLower());
                        if (!mname.EndsWith("_cres"))
                        {
                            mname += "_cres";
                        }
                        if ((mname != "") && (!names.Contains(mname)))
                        {
                            names.Add(mname);
                        }
                    }
                }
            }

            pfds = pkg.FindFiles(Data.MetaData.MMAT);
            if (pfds.Length > 0)
            {
                foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                {
                    SimPe.PackedFiles.Wrapper.Cpf cpf = new SimPe.PackedFiles.Wrapper.Cpf();
                    cpf.ProcessData(pfd, pkg);

                    string mname = Hashes.StripHashFromName(cpf.GetSaveItem("modelName").StringValue.Trim().ToLower());
                    if (!mname.EndsWith("_cres"))
                    {
                        mname += "_cres";
                    }
                    if ((mname != "") && (!names.Contains(mname)))
                    {
                        names.Add(mname);
                    }
                }
            }

            string[] ret = new string[names.Count];
            names.CopyTo(ret);

            return(ret);
        }
Пример #17
0
        /// <summary>
        /// Changes all guids (ignore the current GUID)
        /// </summary>
        /// <param name="newguid">The new GUID</param>
        public void FixGuids(uint newguid)
        {
            Interfaces.Files.IPackedFileDescriptor[] mpfds = package.FindFiles(Data.MetaData.MMAT);

            foreach (Interfaces.Files.IPackedFileDescriptor pfd in mpfds)
            {
                SimPe.PackedFiles.Wrapper.Cpf mmat = new SimPe.PackedFiles.Wrapper.Cpf();
                mmat.ProcessData(pfd, package);

                mmat.GetSaveItem("objectGUID").UIntegerValue = newguid;
                mmat.SynchronizeUserData();
            }
        }
Пример #18
0
        void FixCpfProperties(SimPe.PackedFiles.Wrapper.Cpf cpf, string[] props, uint val)
        {
            foreach (string p in props)
            {
                SimPe.PackedFiles.Wrapper.CpfItem item = cpf.GetItem(p);
                if (item == null)
                {
                    continue;
                }

                item.UIntegerValue = val;
            }
        }
Пример #19
0
        protected void FixSkin(Hashtable namemap, Hashtable refmap, string grphash)
        {
            SimPe.PackedFiles.Wrapper.Cpf cpf = new SimPe.PackedFiles.Wrapper.Cpf();
            Random rnd = new Random();

            //set list of critical types
            uint[]   types          = new uint[] { Data.MetaData.XOBJ, Data.MetaData.XFLR, Data.MetaData.XFNC, Data.MetaData.XROF, Data.MetaData.XNGB };
            string[] txtr_props     = new string[] { "textureedges", "texturetop", "texturetopbump", "texturetrim", "textureunder", "texturetname", "texturetname" };
            string[] txmt_props     = new string[] { "material", "diagrail", "post", "rail" };
            string[] cres_props     = new string[] { "diagrail", "post", "rail" };
            string[] cres_props_ngb = new string[] { "modelname" };
            string[] groups         = new string[] { "stringsetgroupid", "resourcegroupid" };
            string[] set_to_guid    = new string[] {};          //"thumbnailinstanceid"

            //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)
                {
                    cpf.ProcessData(pfd, package);
                    uint guid = (uint)rnd.Next();

                    string pfx = grphash; if (t == Data.MetaData.XFNC)
                    {
                        pfx = "";
                    }

                    FixCpfProperties(cpf, txtr_props, namemap, pfx, "_txtr");
                    FixCpfProperties(cpf, txmt_props, namemap, pfx, "_txmt");
                    FixCpfProperties(cpf, cres_props, namemap, pfx, "_cres");
                    if (pfd.Type == Data.MetaData.XNGB)
                    {
                        FixCpfProperties(cpf, cres_props_ngb, namemap, pfx, "_cres");
                    }

                    FixCpfProperties(cpf, groups, Data.MetaData.LOCAL_GROUP);
                    FixCpfProperties(cpf, set_to_guid, guid);
#if DEBUG
                    FixCpfProperties(cpf, "guid", (uint)((guid & 0x00fffffe) | 0xfb000001));
#else
                    FixCpfProperties(cpf, "guid", (uint)((guid & 0xfffffffe) | 0x00000001));
#endif

                    cpf.SynchronizeUserData();
                }
            }
        }
Пример #20
0
        protected void LoadSkinFormPackage(SimPe.Interfaces.Files.IPackageFile package)
        {
            Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(0xEBCF3E27);

            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                try
                {
                    SimPe.PackedFiles.Wrapper.Cpf cpf = new SimPe.PackedFiles.Wrapper.Cpf();
                    cpf.ProcessData(pfd, package);
                    sets.Add(cpf);
                }
                catch (Exception) {}
            }
        }
Пример #21
0
 /// <summary>
 /// Load all MATDs referenced by the passed MMATs
 /// </summary>
 /// <param name="pfds">List of MMAT Descriptors from the current Package</param>
 protected void LoadReferencedMATDs(Interfaces.Files.IPackedFileDescriptor[] pfds)
 {
     //WaitingScreen.Wait();
     if (WaitingScreen.Running)
     {
         WaitingScreen.UpdateMessage("Loading Material Overrides");
     }
     foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
     {
         SimPe.PackedFiles.Wrapper.Cpf mmat = new SimPe.PackedFiles.Wrapper.Cpf();
         mmat.ProcessData(pfd, package);
         AddMATD(mmat);
     }
     //WaitingScreen.Stop();
 }
Пример #22
0
        void AddToMMAT(SimPe.Events.ResourceContainer rc)
        {
            SimPe.PackedFiles.Wrapper.Cpf mmat = new SimPe.PackedFiles.Wrapper.Cpf();
            mmat.ProcessData(rc.Resource);
            RemoveFromMMAT(mmat);

            if (mmat.GetItem("copyright") == null)
            {
                SimPe.PackedFiles.Wrapper.CpfItem item = new SimPe.PackedFiles.Wrapper.CpfItem();
                item.Name  = "copyright";
                mmat.Items = (SimPe.PackedFiles.Wrapper.CpfItem[])Helper.Add(mmat.Items, item);
            }

            mmat.GetItem("copyright").StringValue = form.tbMMAT.Text;
            mmat.SynchronizeUserData(true, true);
        }
Пример #23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ocpf">The MMAT or Property Set describing the Model</param>
        /// <returns>The Texture or null</returns>
        public object FindTxtrName(object ocpf)
        {
            SimPe.PackedFiles.Wrapper.Cpf     cpf  = (SimPe.PackedFiles.Wrapper.Cpf)ocpf;
            SimPe.PackedFiles.Wrapper.CpfItem item = cpf.GetSaveItem("name");

            if (cpf.Package != BasePackage)
            {
                string name = FindTxtrName(cpf.FileDescriptor);
                return(FindUserTxtr(name));
            }
            else
            {
                string name = FindTxtrName(item.StringValue + "_txmt");
                return(FindTxtr(name));
            }
        }
Пример #24
0
        protected SimPe.Interfaces.Files.IPackedFileDescriptor DoExecute()
        {
            lbname.Text     = "";
            ok              = false;
            last            = null;
            button1.Enabled = false;
            this.ShowDialog();

            if ((ok) && (last != null))
            {
                SimPe.PackedFiles.Wrapper.Cpf cpf = (SimPe.PackedFiles.Wrapper.Cpf)last.Tag;
                return(cpf.FileDescriptor);
            }

            return(null);
        }
Пример #25
0
        //static Ambertation.Panel3D p3d;
        public static void Execute(SimPe.PackedFiles.Wrapper.Cpf cmmat, SimPe.Interfaces.Files.IPackageFile package)
        {
            if (!(cmmat is MmatWrapper))
            {
                return;
            }

            MmatWrapper mmat = cmmat as MmatWrapper;

            try
            {
                PreviewForm f = new PreviewForm();
                SimPe.Interfaces.Scenegraph.IScenegraphFileIndex fii;
                f.scene = BuildScene(out fii, mmat, package);
                fii.Clear();
                if (f.scene == null)
                {
                    return;
                }
                f.dx.Reset();
                f.dx.ResetDefaultViewport();
                f.ShowDialog();
                f.dx.Meshes.Clear(true);
            }
            catch (System.IO.FileNotFoundException)
            {
                Wait.Stop();
                if (MessageBox.Show("The Microsoft Managed DirectX Extensions were not found on your System. Without them, the Preview is not available.\n\nYou can install them manually, by extracting the content of the DirectX\\ManagedDX.CAB on your Sims 2 Installation CD #1. If you double click on the extracted msi File, all needed Files will be installed.\n\nYou can also let SimPE install it automatically. SimPE will download the needed Files (3.5MB) from the SimPE Homepage and install them. Do you want SimPE to download and install the Files?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    if (WebUpdate.InstallMDX())
                    {
                        MessageBox.Show("Managed DirectX Extension were installed succesfully!");
                    }
                }

                return;
            }
            catch (Exception ex)
            {
                Wait.Stop();
                Helper.ExceptionMessage(ex);
            }
            finally
            {
            }
        }
Пример #26
0
        public override void SearchPackage(SimPe.Interfaces.Files.IPackageFile pkg, SimPe.Interfaces.Files.IPackedFileDescriptor pfd)
        {
            if (type != 0)
            {
                if (pfd.Type != type)
                {
                    return;
                }
            }
            else
            {
                if (pfd.Type != Data.MetaData.GZPS && pfd.Type != Data.MetaData.MMAT)
                {
                    return;
                }
            }

            SimPe.PackedFiles.Wrapper.Cpf cpf = new SimPe.PackedFiles.Wrapper.Cpf();
            cpf.ProcessData(pfd, pkg);


            bool found = false;

            if (field != "")
            {
                found = FindInField(cpf, found, field);
            }
            else
            {
                foreach (SimPe.PackedFiles.Wrapper.CpfItem item in cpf.Items)
                {
                    found = FindInField(cpf, found, item.Name);
                    if (found)
                    {
                        break;
                    }
                }
            }

            //we have a match, so add the result item
            if (found)
            {
                ResultGui.AddResult(pkg, pfd);
            }
        }
Пример #27
0
        protected void GetCpf(SimPe.Interfaces.Files.IPackageFile pkg)
        {
            foreach (uint t in xtypes)
            {
                SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(t);
                foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                {
                    cpf = new SimPe.PackedFiles.Wrapper.Cpf();
                    cpf.ProcessData(pfd, pkg);

                    SimPe.PackedFiles.Wrapper.CpfItem item = cpf.GetItem("guid");
                    if (item != null)
                    {
                        nfo.AddGuid(item.UIntegerValue);
                    }
                }
            }
        }
Пример #28
0
        public override void SetFromObjectCacheItem(SimPe.Cache.ObjectCacheItem oci)
        {
            if (oci == null)
            {
                objd = null;
                ClearScreen();
                return;
            }

            //Original Implementation
            if (oci.Class == SimPe.Cache.ObjectClass.Object)
            {
                cpf = null;
                base.SetFromObjectCacheItem(oci);
                return;
            }


            objd = null;
            cpf  = null;
            if (oci.Tag != null)
            {
                if (oci.Tag is SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem)
                {
                    cpf = new SimPe.PackedFiles.Wrapper.Cpf();
                    cpf.ProcessData((SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem)oci.Tag);
                }
            }


            UpdateXObjScreen();
            if (pb.Image == null)
            {
                if (oci.Thumbnail == null)
                {
                    pb.Image = defimg;
                }
                else
                {
                    pb.Image = GenerateImage(pb.Size, oci.Thumbnail, true);
                }
            }
            lbName.Text = oci.Name;
        }
Пример #29
0
        /// <summary>
        /// Create a new Instance and load the main Template Files
        /// </summary>
        /// <param name="package"></param>
        public PhotoStudioTemplate(Interfaces.Files.IPackageFile package)
        {
            this.package = package;

            Interfaces.Files.IPackedFileDescriptor pfd = package.FindFile(0xEBCF3E27, 0xffffffff, 0xffffffff, 0xffffffff);
            pset = new SimPe.PackedFiles.Wrapper.Cpf();
            ctss = null;
            if (pfd != null)
            {
                pset.ProcessData(pfd, package);

                pfd = package.FindFile(Data.MetaData.CTSS_FILE, 0xffffffff, 0xffffffff, pset.GetSaveItem("description").UIntegerValue);
                if (pfd != null)
                {
                    ctss = new SimPe.PackedFiles.Wrapper.Str();
                    ctss.ProcessData(pfd, package);
                }
            }
        }
Пример #30
0
        protected static void UpdateDescription(OWCloneSettings cs, SimPe.Packages.GeneratableFile package)
        {
            //change the price in the OBJd
            SimPe.PackedFiles.Wrapper.ExtObjd obj = new SimPe.PackedFiles.Wrapper.ExtObjd();
            SimPe.PackedFiles.Wrapper.Str     str = new SimPe.PackedFiles.Wrapper.Str();
            SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(Data.MetaData.OBJD_FILE);
            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                obj.ProcessData(pfd, package);

                SimPe.Interfaces.Files.IPackedFileDescriptor spfd = UpdateDescription(cs, package, obj);

                if (spfd != null)
                {
                    str.ProcessData(spfd, package);
                    UpdateDescription(cs, str);
                }
            }

            //change Price, Title, Desc in the XObj Files
            uint[] types = new uint[] { Data.MetaData.XFNC, Data.MetaData.XROF, Data.MetaData.XFLR, Data.MetaData.XOBJ };
            SimPe.PackedFiles.Wrapper.Cpf cpf = new SimPe.PackedFiles.Wrapper.Cpf();
            foreach (uint t in types)
            {
                pfds = package.FindFiles(t);
                foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                {
                    cpf.ProcessData(pfd, package);
                    SimPe.Interfaces.Files.IPackedFileDescriptor spfd = UpdateDescription(cs, package, cpf);

                    if (spfd != null)
                    {
                        str.ProcessData(spfd, package);
                        UpdateDescription(cs, str);
                    }
                }
            }

            if (package.FileName != null)
            {
                package.Save();
            }
        }