Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
            }
        }
Ejemplo n.º 7
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();
            }
        }
Ejemplo n.º 8
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();
                }
            }
        }
Ejemplo n.º 9
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) {}
            }
        }
Ejemplo n.º 10
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();
 }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
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);
            }
        }
Ejemplo n.º 13
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);
                    }
                }
            }
        }
Ejemplo n.º 14
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;
        }
Ejemplo n.º 15
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);
                }
            }
        }
Ejemplo n.º 16
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();
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Remove some unreferenced and useless Files
        /// </summary>
        public void CleanUp()
        {
            if (WaitingScreen.Running)
            {
                WaitingScreen.UpdateMessage("Cleaning up");
            }
            Interfaces.Files.IPackedFileDescriptor[] mpfds = package.FindFiles(Data.MetaData.MMAT);             //MMAT
            ArrayList mmats = new ArrayList();

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

                string content = Scenegraph.MmatContent(mmat);

                if (!mmats.Contains(content))
                {
                    string txmtname = (string)Hashes.StripHashFromName(mmat.GetSaveItem("name").StringValue.Trim().ToLower()) + "_txmt";
                    string cresname = (string)Hashes.StripHashFromName(mmat.GetSaveItem("modelName").StringValue.Trim().ToLower());

                    if (package.FindFile(Hashes.StripHashFromName(txmtname), 0x49596978).Length < 0)
                    {
                        pfd.MarkForDelete = true;
                    }
                    if (package.FindFile(Hashes.StripHashFromName(cresname), 0xE519C933).Length < 0)
                    {
                        pfd.MarkForDelete = true;
                    }

                    if (!pfd.MarkForDelete)
                    {
                        mmats.Add(content);
                    }
                }
                else
                {
                    pfd.MarkForDelete = true;
                }
            }
        }
Ejemplo n.º 18
0
        private void makeCpf3idrPair()
        {
            objKeyCPF  = null;
            objKey3IDR = null;
            if (currentPfd == null || currentPackage == null)
            {
                return;
            }

            if (currentPfd.Type == 0x0C1FE246 /*XMOL*/ || currentPfd.Type == 0x2C1FD8A1 /*XTOL*/ || currentPfd.Type == SimPe.Data.MetaData.GZPS)
            {
                AbstractWrapper p3 = findInPackagelist(objkeys, SimPe.Data.MetaData.REF_FILE, currentPfd);
                if (p3 != null)
                {
                    objKeyCPF = new SimPe.PackedFiles.Wrapper.Cpf();
                    objKeyCPF.ProcessData(currentPfd, currentPackage);
                    addFile(p3);
                    objKey3IDR = new SimPe.Plugin.RefFile();
                    objKey3IDR.ProcessData(p3.FileDescriptor, p3.Package);
                }
            }
            else if (currentPfd.Type == SimPe.Data.MetaData.REF_FILE /*3IDR*/)
            {
                foreach (uint t in new uint[] { 0x0C1FE246 /*XMOL*/, 0x2C1FD8A1 /*XTOL*/, SimPe.Data.MetaData.GZPS })
                {
                    AbstractWrapper pc = (SimPe.PackedFiles.Wrapper.Cpf)findInPackagelist(objkeys, t, currentPfd);
                    if (pc != null)
                    {
                        addFile(pc);
                        objKeyCPF = new SimPe.PackedFiles.Wrapper.Cpf();
                        objKeyCPF.ProcessData(pc.FileDescriptor, pc.Package);
                        objKey3IDR = new SimPe.Plugin.RefFile();
                        objKey3IDR.ProcessData(currentPfd, currentPackage);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Changes all guids (Depends on the passed Replacement Map)
        /// </summary>
        /// <param name="guids">List of GuidSet Objects</param>
        public void FixGuids(ArrayList guids)
        {
            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);


                if (guids != null)
                {
                    foreach (GuidSet sget in guids)
                    {
                        if (mmat.GetSaveItem("objectGUID").UIntegerValue == sget.oldguid)
                        {
                            mmat.GetSaveItem("objectGUID").UIntegerValue = sget.guid;
                            mmat.SynchronizeUserData();
                        }
                    }
                }
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Find the Modelname of the Original Object
        /// </summary>
        /// <param name="package">The Package containing the Data</param>
        /// <returns>The Modelname</returns>
        public static string FindMainOldName(SimPe.Interfaces.Files.IPackageFile package)
        {
            Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(Data.MetaData.STRING_FILE);
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                if (pfd.Instance == 0x85)
                {
                    SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                    str.ProcessData(pfd, package);

                    SimPe.PackedFiles.Wrapper.StrItemList sil = str.LanguageItems(1);
                    if (sil.Length > 1)
                    {
                        return(sil[1].Title);
                    }
                    else if (str.Items.Length > 1)
                    {
                        return(str.Items[1].Title);
                    }
                }
            }

            pfds = package.FindFiles(0x4C697E5A);
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                SimPe.PackedFiles.Wrapper.Cpf cpf = new SimPe.PackedFiles.Wrapper.Cpf();
                cpf.ProcessData(pfd, package);

                if (cpf.GetSaveItem("modelName").StringValue.Trim() != "")
                {
                    return(cpf.GetSaveItem("modelName").StringValue.Trim());
                }
            }

            return("SimPE");
        }
Ejemplo n.º 21
0
        private void Main()
        {
            ArrayList al = new ArrayList();

            #region Prompt for mesh name or browse for package and extract names
            GetMeshName  gmn = new GetMeshName();
            DialogResult dr  = gmn.ShowDialog();
            if (dr.Equals(DialogResult.OK))
            {
                if (gmn.MeshName.Length > 0)
                {
                    al.Add(gmn.MeshName);
                }
                else
                {
                    MessageBox.Show(L.Get("noMeshName"), L.Get("pjSME"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else if (dr.Equals(DialogResult.Retry)) // nasty...
            {
                #region Get body mesh package file name and open the package
                String bodyMeshPackage = getFilename();
                if (bodyMeshPackage == null)
                {
                    return;
                }

                IPackageFile p = SimPe.Packages.File.LoadFromFile(bodyMeshPackage);
                if (p == null)
                {
                    return;
                }
                #endregion

                #region Find the Property Set or XML Mesh Overlay
                IPackedFileDescriptor[] pfa = p.FindFiles(SimPe.Data.MetaData.GZPS);
                IPackedFileDescriptor[] pfb = p.FindFiles(0x0C1FE246); // XMOL?
                if ((pfa == null || pfa.Length == 0) && (pfb == null || pfb.Length == 0))
                {
                    MessageBox.Show(L.Get("noGZPSXMOL"),
                                    L.Get("pjSME"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                #endregion

                #region Get the mesh name(s)
                bool prompted = false;
                SimPe.PackedFiles.Wrapper.Cpf cpf = new SimPe.PackedFiles.Wrapper.Cpf();
                for (int i = 0; i < pfa.Length + pfb.Length; i++)
                {
                    if (i < pfa.Length)
                    {
                        cpf.ProcessData(pfa[i], p);
                    }
                    else
                    {
                        cpf.ProcessData(pfb[i - pfa.Length], p);
                    }

                    for (int j = 0; j < cpf.Items.Length; j++)
                    {
                        if (cpf.Items[j].Name.ToLower().Equals("name"))
                        {
                            al.Add(cpf.Items[j].StringValue);
                        }
                        if (al.Count > 1 && !prompted)
                        {
                            if (MessageBox.Show(L.Get("multipleMeshes"),
                                                L.Get("pjSME"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
                                != DialogResult.Yes)
                            {
                                return;
                            }
                            prompted = true;
                        }
                    }
                }
                if (al.Count == 0)
                {
                    MessageBox.Show(L.Get("noMeshPkg"),
                                    L.Get("pjSME"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                #endregion
            }
            else
            {
                return;
            }

            #endregion

            #region For each mesh, find the GMDC, GMND, SHPE and CRES and add them to the current package

            foreach (String m in al)
            {
                String[] ma   = m.Split('_');
                String   mesh = ma[ma[0].Equals("CASIE") ? 1 : 0];
                if (mesh.ToLower().StartsWith("ym"))
                {
                    mesh = "am" + mesh.Substring(2);
                }
                if (mesh.ToLower().StartsWith("yf"))
                {
                    mesh = "af" + mesh.Substring(2);
                }

                bool success = true;
                SimPe.RemoteControl.ApplicationForm.Cursor = Cursors.WaitCursor;
                success = success && findAndAdd(mesh, SimPe.Data.MetaData.GMDC, "Sims03.package");
                success = success && findAndAdd(mesh, SimPe.Data.MetaData.GMND, "Sims04.package");
                success = success && findAndAdd(mesh, SimPe.Data.MetaData.SHPE, "Sims05.package");
                success = success && findAndAdd(mesh, SimPe.Data.MetaData.CRES, "Sims06.package");
                SimPe.RemoteControl.ApplicationForm.Cursor = Cursors.Default;
                if (!success)
                {
                    MessageBox.Show(L.Get("notAllPartsFound") + m,
                                    L.Get("pjSME"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            #endregion
        }
Ejemplo n.º 22
0
        protected override void Unserialize(System.IO.BinaryReader reader)
        {
            items = new List <XWNTItem>();

            #region Un-break Quaxified XWNTs
            // Because Quaxi's CPF wrapper rewrites XML as binary, we handle that case here
            byte[] hdr = reader.ReadBytes(6);
            reader.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);

            bool   isCpf = true;
            byte[] id    = new byte[] { 0xE0, 0x50, 0xE7, 0xCB, 0x02, 0x00, };
            for (int i = 0; i < hdr.Length && isCpf; i++)
            {
                isCpf = hdr[i] == id[i];
            }

            if (isCpf)
            {
                SimPe.PackedFiles.Wrapper.Cpf cpf = new SimPe.PackedFiles.Wrapper.Cpf();
                cpf.ProcessData(this.FileDescriptor, this.Package);
                XWNTWrapper xwnt = new XWNTWrapper();
                foreach (XWNTItem item in xwnt)
                {
                    if (item.Key.StartsWith("<!"))
                    {
                        Add(new XWNTItem(this, item.Key, ""));
                    }
                    else
                    {
                        SimPe.PackedFiles.Wrapper.CpfItem cpfitem = cpf.GetItem(item.Key);
                        if (cpfitem != null)
                        {
                            string value = "";
                            switch (cpfitem.Datatype) // Argh... So broken...
                            {
                            case SimPe.Data.MetaData.DataTypes.dtInteger: value = cpfitem.IntegerValue.ToString(); break;

                            case SimPe.Data.MetaData.DataTypes.dtBoolean: value = cpfitem.BooleanValue.ToString(); break;

                            default: value = cpfitem.StringValue; break;
                            }
                            items.Add(new XWNTItem(this, item.Key, value));
                        }
                        else
                        {
                            items.Add(new XWNTItem(this, item.Key, item.Value));
                        }
                    }
                }
                return;
            }
            #endregion

            XmlReaderSettings xrs = new XmlReaderSettings();
            //xrs.IgnoreComments = true;
            xrs.IgnoreProcessingInstructions = true;
            xrs.IgnoreWhitespace             = true;
            XmlReader xr = XmlReader.Create(reader.BaseStream, xrs);

            if (xr.IsStartElement() && xr.NodeType.Equals(XmlNodeType.Element) && xr.Name.Equals("cGZPropertySetString"))
            {
                setVersion(xr["version"]);
            }
            else
            {
                throw new Exception("Invalid XWNT format");
            }
            xr.Read();

            while (xr.IsStartElement())
            {
                items.Add(new XWNTItem(this, xr));

                if (!xr.IsEmptyElement)
                {
                    xr.ReadEndElement();
                }
                else
                {
                    xr.Skip();
                }
            }
            xr.ReadEndElement();
        }
Ejemplo n.º 23
0
        static void ConsumeFromXobj(SimPe.Cache.ObjectCacheItem oci, Interfaces.Scenegraph.IScenegraphFileIndexItem nrefitem, SimPe.Data.MetaData.Languages deflang)
        {
            SimPe.PackedFiles.Wrapper.Cpf cpf = new SimPe.PackedFiles.Wrapper.Cpf();
            nrefitem.FileDescriptor.UserData = nrefitem.Package.Read(nrefitem.FileDescriptor).UncompressedData;
            cpf.ProcessData(nrefitem);

            oci.FileDescriptor = nrefitem.FileDescriptor;
            oci.LocalGroup     = nrefitem.LocalGroup;
            oci.ObjectType     = SimPe.Data.ObjectTypes.Normal;

            SetFunctionSortForXObj(cpf, oci);

            oci.ObjectFileName = cpf.GetSaveItem("filename").StringValue;
            if (oci.ObjectFileName == "")
            {
                oci.ObjectFileName = cpf.GetSaveItem("name").StringValue;
            }

            oci.Useable = true;
            oci.Class   = SimPe.Cache.ObjectClass.XObject;



            Interfaces.Scenegraph.IScenegraphFileIndexItem[] ctssitems = FileTable.FileIndex.FindFile(cpf.GetSaveItem("stringsetrestypeid").UIntegerValue, cpf.GetSaveItem("stringsetgroupid").UIntegerValue, cpf.GetSaveItem("stringsetid").UIntegerValue, null);             //Data.MetaData.STRING_FILE
            if (ctssitems.Length > 0)
            {
                SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                str.ProcessData(ctssitems[0]);
                SimPe.PackedFiles.Wrapper.StrItemList items = str.LanguageItems(deflang);
                if (items.Length > 0)
                {
                    oci.Name = items[0].Title;
                }
                else
                {
                    items = str.LanguageItems(1);
                    if (items.Length > 0)
                    {
                        oci.Name = items[0].Title;
                    }
                    else
                    {
                        oci.Name = "";
                    }
                }
            }
            else
            {
                oci.Name = "";
            }

            if (oci.Name == "")
            {
                oci.Name = oci.ObjectFileName;
            }

            //now the ModeName File
            if (cpf.GetItem("texturetname") != null)
            {
                oci.ModelName = cpf.GetItem("texturetname").StringValue;
            }
            else if (cpf.GetItem("filename") != null)
            {
                oci.ModelName = cpf.GetItem("filename").StringValue;
            }
            else
            {
                oci.ModelName = cpf.GetSaveItem("material").StringValue;
            }

            //oci.Name = cpf.GetSaveItem("type").StringValue + " - "+ cpf.GetSaveItem("subsort").StringValue;


            if (oci.Thumbnail == null)
            {
                oci.Thumbnail = ObjectPreview.GetXThumbnail(cpf);
            }
            ObjectReader.changedcache = true;
        }
Ejemplo n.º 24
0
        void FillCategoryNodes(Hashtable mmap)
        {
            WaitingScreen.Wait();
            try
            {
                FileTable.FileIndex.Load();
                Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFile(Data.MetaData.GZPS, true);
                foreach (Interfaces.Scenegraph.IScenegraphFileIndexItem item in items)
                {
                    SimPe.PackedFiles.Wrapper.Cpf skin = new SimPe.PackedFiles.Wrapper.Cpf();
                    skin.ProcessData(item);

                    if (skin.GetSaveItem("type").StringValue == "skin")
                    {
                        bool added   = false;
                        uint skinage = skin.GetSaveItem("age").UIntegerValue;
                        uint skincat = skin.GetSaveItem("category").UIntegerValue;
                        if ((skincat & (uint)Data.SkinCategories.Skin) == (uint)Data.SkinCategories.Skin)
                        {
                            skincat = (uint)Data.SkinCategories.Skin;
                        }
                        if (skin.GetSaveItem("override0subset").StringValue.Trim().ToLower().StartsWith("hair"))
                        {
                            skincat = (uint)Data.SkinCategories.Skin;
                        }
                        if (skin.GetSaveItem("override0subset").StringValue.Trim().ToLower().StartsWith("bang"))
                        {
                            skincat = (uint)Data.SkinCategories.Skin;
                        }
                        uint   skinsex = skin.GetSaveItem("gender").UIntegerValue;
                        string name    = skin.GetSaveItem("name").StringValue;
                        foreach (uint age in mmap.Keys)
                        {
                            if ((age & skinage) == age)
                            {
                                Hashtable cats = (Hashtable)mmap[age];
                                foreach (uint cat in cats.Keys)
                                {
                                    if ((cat & skincat) == cat)
                                    {
                                        Hashtable sex = (Hashtable)cats[cat];
                                        foreach (uint g in sex.Keys)
                                        {
                                            if ((g & skinsex) == g)
                                            {
                                                TreeNode parent = (TreeNode)sex[g];
                                                TreeNode node   = new TreeNode(name);
                                                node.Tag = skin;
                                                parent.Nodes.Add(node);

                                                added = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }                         //foreach age

                        if (!added)
                        {
                            TreeNode tn = new TreeNode(name);
                            tn.Tag = skin;
                            tvmale.Nodes.Add(tn);
                            tvfemale.Nodes.Add((TreeNode)tn.Clone());
                        }
                    }
                }
            }
            finally
            {
                WaitingScreen.Stop();
            }
        }
Ejemplo n.º 25
0
        public SimPe.Cache.PackageType GetType(SimPe.Interfaces.Files.IPackageFile pkg)
        {
            SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(Data.MetaData.GZPS);
            if (pfds.Length == 0)
            {
                pfds = pkg.FindFiles(Data.MetaData.XOBJ);                             //Object XML
            }
            if (pfds.Length == 0)
            {
                pfds = pkg.FindFiles(0x2C1FD8A1);                             //TextureOverlay XML
            }
            if (pfds.Length == 0)
            {
                pfds = pkg.FindFiles(0x8C1580B5);                             //Hairtone XML
            }
            if (pfds.Length == 0)
            {
                pfds = pkg.FindFiles(0x0C1FE246);                             //Mesh Overlay XML
            }
            if (pfds.Length == 0)
            {
                pfds = pkg.FindFiles(Data.MetaData.XROF);                             //Object XML
            }
            if (pfds.Length == 0)
            {
                pfds = pkg.FindFiles(Data.MetaData.XFLR);                             //Object XML
            }
            if (pfds.Length == 0)
            {
                pfds = pkg.FindFiles(Data.MetaData.XFNC);                             //Object XML
            }
            if (pfds.Length > 0)
            {
                SimPe.PackedFiles.Wrapper.Cpf cpf = new SimPe.PackedFiles.Wrapper.Cpf();
                cpf.ProcessData(pfds[0], pkg, false);

                string type = cpf.GetSaveItem("type").StringValue.Trim().ToLower();

                switch (type)
                {
                case "wall":
                {
                    return(SimPe.Cache.PackageType.Wallpaper);
                }

                case "terrainpaint":
                {
                    return(SimPe.Cache.PackageType.Terrain);
                }

                case "floor":
                {
                    return(SimPe.Cache.PackageType.Floor);
                }

                case "roof":
                {
                    return(SimPe.Cache.PackageType.Roof);
                }

                case "fence":
                {
                    return(SimPe.Cache.PackageType.Fence);
                }

                case "skin":
                {
                    uint cat = cpf.GetSaveItem("category").UIntegerValue;

                    if ((cat & (uint)Data.SkinCategories.Skin) != 0)
                    {
                        return(SimPe.Cache.PackageType.Skin);
                    }
                    else
                    {
                        return(SimPe.Cache.PackageType.Cloth);
                    }
                }

                case "meshoverlay":
                case "textureoverlay":
                {
                    if (cpf.GetSaveItem("subtype").UIntegerValue == (uint)Data.TextureOverlayTypes.Blush)
                    {
                        return(SimPe.Cache.PackageType.Blush);
                    }
                    if (cpf.GetSaveItem("subtype").UIntegerValue == (uint)Data.TextureOverlayTypes.Eye)
                    {
                        return(SimPe.Cache.PackageType.Eye);
                    }
                    if (cpf.GetSaveItem("subtype").UIntegerValue == (uint)Data.TextureOverlayTypes.EyeBrow)
                    {
                        return(SimPe.Cache.PackageType.EyeBrow);
                    }
                    if (cpf.GetSaveItem("subtype").UIntegerValue == (uint)Data.TextureOverlayTypes.EyeShadow)
                    {
                        return(SimPe.Cache.PackageType.EyeShadow);
                    }
                    if (cpf.GetSaveItem("subtype").UIntegerValue == (uint)Data.TextureOverlayTypes.Glasses)
                    {
                        return(SimPe.Cache.PackageType.Glasses);
                    }
                    if (cpf.GetSaveItem("subtype").UIntegerValue == (uint)Data.TextureOverlayTypes.Lipstick)
                    {
                        return(SimPe.Cache.PackageType.Lipstick);
                    }
                    if (cpf.GetSaveItem("subtype").UIntegerValue == (uint)Data.TextureOverlayTypes.Mask)
                    {
                        return(SimPe.Cache.PackageType.Mask);
                    }
                    if (cpf.GetSaveItem("subtype").UIntegerValue == (uint)Data.TextureOverlayTypes.Beard)
                    {
                        return(SimPe.Cache.PackageType.Beard);
                    }

                    if (type == "meshoverlay")
                    {
                        return(SimPe.Cache.PackageType.Accessory);
                    }
                    return(SimPe.Cache.PackageType.Makeup);
                }

                case "hairtone":
                {
                    return(SimPe.Cache.PackageType.Hair);
                }
                }
            }

            return(SimPe.Cache.PackageType.Unknown);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Add a MMAT to the package
        /// </summary>
        protected SimPe.PackedFiles.Wrapper.Cpf AddMMAT(SimPe.Plugin.Rcol matd, string subset, string cresname, uint instance, bool substate)
        {
            //now add the default MMAT
            System.IO.BinaryReader br = new System.IO.BinaryReader(this.GetType().Assembly.GetManifestResourceStream("SimPe.Plugin.mmat.simpe"));
            SimPe.Packages.PackedFileDescriptor pfd1 = new SimPe.Packages.PackedFileDescriptor();
            pfd1.Group    = 0xffffffff; pfd1.SubType = 0x00000000; pfd1.Instance = instance; pfd1.Type = 0x4C697E5A;          //MMAT
            pfd1.UserData = br.ReadBytes((int)br.BaseStream.Length);

            package.Add(pfd1);
            SimPe.PackedFiles.Wrapper.Cpf mmat = new SimPe.PackedFiles.Wrapper.Cpf();
            mmat.ProcessData(pfd1, package);

            if (!substate)
            {
                mmat.GetSaveItem("family").StringValue = System.Guid.NewGuid().ToString();
            }
            mmat.GetSaveItem("name").StringValue       = matd.FileName.Substring(0, matd.FileName.Length - 5);
            mmat.GetSaveItem("subsetName").StringValue = subset;
            mmat.GetSaveItem("modelName").StringValue  = cresname;

            //Get the GUID
            Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(Data.MetaData.OBJD_FILE);
            mmat.GetSaveItem("objectGUID").UIntegerValue = 0x00000000;
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                SimPe.PackedFiles.Wrapper.Objd objd = new SimPe.PackedFiles.Wrapper.Objd(null);
                objd.ProcessData(pfds[0], package);
                mmat.GetSaveItem("objectGUID").UIntegerValue = objd.SimId;

                if (pfd.Instance == 0x000041A7)
                {
                    break;
                }
            }

            ObjectRecolor.FixMMAT(mmat);
            mmat.SynchronizeUserData();

            gm_pkg.Add(mmat.FileDescriptor);

            //alternate states
            if (!substate)
            {
                string name = mmat.GetSaveItem("name").StringValue;
                pfds = ObjectCloner.FindStateMatchingMatd(name, package);


                if (pfds != null)
                {
                    if (pfds.Length > 0)
                    {
                        SimPe.Plugin.Rcol submatd = new GenericRcol(null, false);
                        submatd.ProcessData(pfds[0], package);

                        SimPe.PackedFiles.Wrapper.Cpf mmat2 = AddMMAT(submatd, subset, cresname, instance, true);
                        mmat2.GetSaveItem("family").StringValue = mmat.GetSaveItem("family").StringValue;
                    }
                }
            }

            return(mmat);
        }