Exemplo n.º 1
0
        /// <summary>
        /// Make sure the correct Face Structure is used (as desribed by Nukael)
        /// </summary>
        /// <remarks>http://www.modthesims2.com/showthread.php?t=56241</remarks>
        /// <param name="pkg">The package with the Face Data</param>
        public void UpdateFaceStructure(SimPe.Packages.GeneratableFile pkg)
        {
            SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds   = pkg.FindFiles((uint)0xCCCEF852);           //LxNR, Face
            SimPe.Interfaces.Files.IPackedFileDescriptor   oldpfd = null;
            SimPe.Interfaces.Files.IPackedFileDescriptor   newpfd = null;

            uint oi = 1;
            uint ni = 2;

            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                if (pfd.Instance <= oi)
                {
                    oldpfd = pfd; oi = pfd.Instance;
                }
                if (pfd.Instance >= ni)
                {
                    newpfd = pfd; ni = pfd.Instance;
                }
            }

            if (oldpfd != null && newpfd != null)
            {
                SimPe.Interfaces.Files.IPackedFile pf = pkg.Read(newpfd);
                oldpfd.UserData = pf.UncompressedData;
                oldpfd.Changed  = true;
            }
        }
Exemplo n.º 2
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();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Clone the Makeup of a Sim
        /// </summary>
        /// <returns>the new Package for the patient Sim</returns>
        /// <param name="eyecolor">true, if you want to alter the eyecolor</param>
        /// <param name="makeups">true, if you want to alter the makeup</param>
        public SimPe.Packages.GeneratableFile CloneMakeup(bool eyecolor, bool makeups)
        {
            SimPe.Packages.GeneratableFile ret = SimPe.Packages.GeneratableFile.LoadFromFile((string)null);

            ArrayList list = new ArrayList();

            list.Add((uint)0xE86B1EEF);             //make sure the compressed Directory won't be copied!
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in patient.Index)
            {
                if (!list.Contains(pfd.Type))
                {
                    Interfaces.Files.IPackedFile fl = patient.Read(pfd);

                    Interfaces.Files.IPackedFileDescriptor newpfd = ret.NewDescriptor(pfd.Type, pfd.SubType, pfd.Group, pfd.Instance);
                    newpfd.UserData = fl.UncompressedData;
                    ret.Add(newpfd);
                }
            }

            //Update TXMT Files for the Face
            SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = ret.FindFiles(Data.MetaData.TXMT);
            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                SimPe.Plugin.Rcol rcol = new GenericRcol(null, false);
                rcol.ProcessData(pfd, ret);

                MaterialDefinition md = (MaterialDefinition)rcol.Blocks[0];
                this.UpdateMakeup(md, eyecolor, makeups);

                rcol.SynchronizeUserData();
            }

            if (eyecolor)
            {
                //Update DNA File
                Interfaces.Files.IPackedFileDescriptor dna  = ngbh.FindFile(0xEBFEE33F, 0, Data.MetaData.LOCAL_GROUP, spatient.Instance);
                Interfaces.Files.IPackedFileDescriptor adna = ngbh.FindFile(0xEBFEE33F, 0, Data.MetaData.LOCAL_GROUP, sarchetype.Instance);
                if ((dna != null) && (adna != null))
                {
                    SimPe.PackedFiles.Wrapper.Cpf cpf = new Cpf();
                    cpf.ProcessData(dna, ngbh);

                    SimPe.PackedFiles.Wrapper.Cpf acpf = new Cpf();
                    acpf.ProcessData(adna, ngbh);
                    cpf.GetSaveItem("3").StringValue = acpf.GetSaveItem("3").StringValue;

                    cpf.SynchronizeUserData();
                }
            }
            return(ret);
        }
Exemplo n.º 4
0
        public Interfaces.Plugin.IToolResult ShowDialog(ref SimPe.Interfaces.Files.IPackedFileDescriptor pfd, ref SimPe.Interfaces.Files.IPackageFile package)
        {
            System.Windows.Forms.DialogResult dr =
                System.Windows.Forms.MessageBox.Show("Using this Tool can serioulsy mess up all of your Neighborhoods. However if some of your Neighborhoods are missing in the Neighborhood Selection of the Game, this Tool might help fixing it.\n\nMake sure you have a Backup of ALL your Neighborhoods befor starting this Tool!\n\nDo you want to start this Tool?", "Confirmation", System.Windows.Forms.MessageBoxButtons.YesNo);


            if (dr == System.Windows.Forms.DialogResult.Yes)
            {
                Wait.SubStop();
                try
                {
                    System.Collections.Hashtable ht = Idno.FindUids(PathProvider.SimSavegameFolder, true);
                    foreach (string file in ht.Keys)
                    {
                        Wait.Message = file;

                        SimPe.Packages.GeneratableFile fl = SimPe.Packages.GeneratableFile.LoadFromFile(file);
                        SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = fl.FindFiles(Data.MetaData.IDNO);
                        foreach (SimPe.Interfaces.Files.IPackedFileDescriptor spfd in pfds)
                        {
                            Idno idno = new Idno();
                            idno.ProcessData(spfd, fl);
                            idno.MakeUnique(ht);

                            idno.SynchronizeUserData();
                        }

                        fl.Save();
                    }
                }
                catch (Exception ex)
                {
                    Helper.ExceptionMessage("", ex);
                }
                finally
                {
                    Wait.SubStop();
                }
            }
            return(new ToolResult(false, false));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Change the SkinTone of a Sim
        /// </summary>
        /// <param name="skin">the new skintone</param>
        /// param name="skinfiles">a Hashtable listing al Proerty Sets for each available skintone (key=skintone string, value= ArrayList of Cpf Objects)</param>
        /// <returns>the new Package for the patient Sim</returns>
        public SimPe.Packages.GeneratableFile CloneSkinTone(string skin, Hashtable skinfiles)
        {
            SimPe.Packages.GeneratableFile ret = SimPe.Packages.GeneratableFile.LoadFromFile((string)null);
            string pskin = GetSkintone(this.patient);

            ArrayList list = new ArrayList();

            list.Add((uint)0xE86B1EEF);             //make sure the compressed Directory won't be copied!
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in patient.Index)
            {
                if (!list.Contains(pfd.Type))
                {
                    Interfaces.Files.IPackedFile fl = patient.Read(pfd);

                    Interfaces.Files.IPackedFileDescriptor newpfd = ret.NewDescriptor(pfd.Type, pfd.SubType, pfd.Group, pfd.Instance);
                    newpfd.UserData = fl.UncompressedData;
                    ret.Add(newpfd);

                    switch (newpfd.Type)
                    {
                    case (uint)0xAC598EAC:                             //AGED
                    {
                        SimPe.PackedFiles.Wrapper.Cpf cpf = new Cpf();
                        cpf.ProcessData(newpfd, ret);
                        cpf.GetSaveItem("skincolor").StringValue = skin;

                        cpf.SynchronizeUserData();
                        break;
                    }

                    case Data.MetaData.GZPS:
                    {
                        SimPe.PackedFiles.Wrapper.Cpf cpf = new Cpf();
                        cpf.ProcessData(newpfd, ret);
                        cpf.GetSaveItem("skintone").StringValue = skin;

                        cpf.SynchronizeUserData();
                        break;
                    }

                    case Data.MetaData.TXMT:
                    {
                        SimPe.Plugin.Rcol rcol = new GenericRcol(null, false);
                        rcol.ProcessData(newpfd, ret);
                        MaterialDefinition txmt = (MaterialDefinition)rcol.Blocks[0];
                        txmt.FindProperty("cafSkinTone").Value = skin;

                        rcol.SynchronizeUserData();
                        break;
                    }
                    }
                }
            }

            //Update DNA File
            Interfaces.Files.IPackedFileDescriptor dna = ngbh.FindFile(0xEBFEE33F, 0, Data.MetaData.LOCAL_GROUP, spatient.Instance);
            if (dna != null)
            {
                SimPe.PackedFiles.Wrapper.Cpf cpf = new Cpf();
                cpf.ProcessData(dna, ngbh);
                cpf.GetSaveItem("2").StringValue = skin;
                cpf.GetSaveItem("6").StringValue = skin;

                cpf.SynchronizeUserData();
            }

            //Update 3IDR Files
            SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = ret.FindFiles(0xAC506764);
            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                SimPe.Plugin.RefFile reffile = new RefFile();
                reffile.ProcessData(pfd, ret);

                UpdateSkintone(reffile, skin, skinfiles);
            }

            //Update TXMT Files for the Face
            pfds = ret.FindFiles(Data.MetaData.TXMT);
            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                SimPe.Plugin.Rcol rcol = new GenericRcol(null, false);
                rcol.ProcessData(pfd, ret);

                MaterialDefinition md = (MaterialDefinition)rcol.Blocks[0];
                this.UpdateSkintone(md, skin, skinfiles);

                rcol.SynchronizeUserData();
            }


            return(ret);
        }
Exemplo n.º 6
0
        public static SimPe.Packages.GeneratableFile Start(SimPe.Packages.GeneratableFile pkg, SimPe.Interfaces.IAlias a, ref Interfaces.Files.IPackedFileDescriptor pfd, uint localgroup, ObjectWorkshopSettings settings, bool containsonlybaseclone)
        {
            SimPe.Packages.GeneratableFile package         = pkg;
            SimPe.Plugin.CloneSettings.BaseResourceType br = SimPe.Plugin.CloneSettings.BaseResourceType.Objd;
            if (pfd != null)
            {
                if (pfd.Type != Data.MetaData.OBJD_FILE)
                {
                    br = SimPe.Plugin.CloneSettings.BaseResourceType.Xml;
                }
            }
            if (settings is OWCloneSettings)
            {
                OWCloneSettings cs = (OWCloneSettings)settings;

                package = RecolorClone(br, package, pfd, localgroup, settings, containsonlybaseclone);


                FixObject fo = new FixObject(package, FixVersion.UniversityReady, settings.RemoveNonDefaultTextReferences);
                System.Collections.Hashtable map = null;

                if (cs.FixResources)
                {
                    map = fo.GetNameMap(true);
                    if (map == null)
                    {
                        return(package);
                    }

                    SaveFileDialog sfd = new SaveFileDialog();
                    sfd.Filter = ExtensionProvider.BuildFilterString(
                        new SimPe.ExtensionType[] {
                        SimPe.ExtensionType.Package,
                        SimPe.ExtensionType.AllFiles
                    }
                        );
                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        WaitingScreen.Wait();
                        try
                        {
                            package.FileName = sfd.FileName;
                            fo.Fix(map, true);

                            if (cs.RemoveUselessResource && br != SimPe.Plugin.CloneSettings.BaseResourceType.Xml)
                            {
                                fo.CleanUp();
                            }
                            package.Save();
                        }
                        finally { WaitingScreen.Stop(); }
                    }
                    else
                    {
                        package = null;
                    }
                }

                if ((cs.CustomGroup) && (package != null))
                {
                    WaitingScreen.Wait();
                    try
                    {
                        fo.FixGroup();
                        if (cs.FixResources)
                        {
                            package.Save();
                        }
                    }
                    finally { WaitingScreen.Stop(); }
                }

                if (cs.ChangeObjectDescription)
                {
                    UpdateDescription(cs, package);
                }

                //select a resource to display in SimPE
                pfd = null;
                if (package != null)
                {
                    SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(Data.MetaData.OBJD_FILE);
                    if (pfds.Length > 0)
                    {
                        pfd = pfds[0];
                    }
                }
            }
            else
            {
                /*if (br == SimPe.Plugin.CloneSettings.BaseResourceType.Xml)
                 *  package = ReColorXObject(br, package, pfd, localgroup, new OWRecolorSettings());
                 * else*/
                package = ReColor(br, package, pfd, localgroup, new OWRecolorSettings(), containsonlybaseclone);

                //select a resource for display in SimPE
                pfd = null;
                if (package != null)
                {
                    SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(Data.MetaData.TXTR);
                    if (pfds.Length > 0)
                    {
                        pfd = pfds[0];
                    }
                }
            }

            settings.SetRemoteResult(false);
            if (settings.OpenWithRemoteControl)
            {
                if (package != null)
                {
                    if (SimPe.RemoteControl.OpenMemoryPackage(package) && pfd != null)
                    {
                        settings.SetRemoteResult(SimPe.RemoteControl.OpenPackedFile(pfd, package));
                    }
                }
            }


            return(package);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Show the Relink Screen
        /// </summary>
        /// <param name="path">The Path where to look for character Files</param>
        /// <param name="wrp">The Sim Description Wrapper</param>
        /// <returns>The new SimID</returns>
        public static uint Execute(SimPe.PackedFiles.Wrapper.SDesc wrp)
        {
            Hashtable     ht  = wrp.nameprovider.StoredData;
            SimRelinkForm srf = new SimRelinkForm();

            WaitingScreen.Wait();
            try
            {
                foreach (SimPe.Data.Alias a in ht.Values)
                {
                    ListViewItem lvi = new ListViewItem(a.Name + " " + (string)a.Tag[2]);
                    lvi.Tag = a;

                    if (a.Tag[1] != null)
                    {
                        lvi.ImageIndex = srf.ilist.Images.Count;
                        Image img = SimPe.Plugin.ImageLoader.Preview((Image)a.Tag[1], srf.ilist.ImageSize);

                        if (wrp.sdescprovider.FindSim(a.Id) != null)
                        {
                            Graphics gr = Graphics.FromImage(img);
                            gr.FillRectangle(new Pen(Color.FromArgb(0x60, Color.Red), 1).Brush, 0, 0, img.Width, img.Height);
                        }

                        srf.ilist.Images.Add(img);
                    }

                    srf.lv.Items.Add(lvi);
                }
                srf.lv.Sort();
                srf.btlink.Enabled = false;
                srf.ok             = false;
            }
            finally { WaitingScreen.Stop(srf); }

            srf.ShowDialog();

            if (srf.ok)
            {
                SimPe.Data.Alias a = (SimPe.Data.Alias)srf.lv.SelectedItems[0].Tag;
                SimPe.Packages.GeneratableFile pkg = SimPe.Packages.GeneratableFile.LoadFromFile((string)a.Tag[0]);

                Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(Data.MetaData.OBJD_FILE);
                if (pfds.Length == 1)
                {
                    SimPe.PackedFiles.Wrapper.Objd objd = new SimPe.PackedFiles.Wrapper.Objd(null);
                    objd.ProcessData(pfds[0], pkg);

                    if (srf.cbfile.Checked)
                    {
                        objd.Guid = wrp.SimId;
                        objd.SynchronizeUserData();
                        pkg.Save();
                    }
                    else
                    {
                        wrp.SimId = objd.Guid;
                    }
                }
            }

            return(wrp.SimId);
        }