示例#1
0
        /// <summary>
        /// Build an override for another Skin
        /// </summary>
        /// <param name="skintone"></param>
        /// <param name="filename"></param>
        /// <param name="addtxtr">true, if you want to replace the default TXTR Files</param>
        /// <param name="addtxmt">true if you want to replace the default TXMT Files</param>
        public void CreateOverride(string skintone, string family, string filename, bool addtxmt, bool addtxtr, bool addref)
        {
            if (selection.Length > 1)
            {
                return;
            }

            SimPe.Packages.GeneratableFile pkg = BuildOverride(selection[0], skintone, family, selection[0].Package, addtxmt, addtxtr, addref);
            pkg.Save(filename);
        }
示例#2
0
        protected static SimPe.Packages.GeneratableFile ReColorXObject(CloneSettings.BaseResourceType br, SimPe.Packages.GeneratableFile pkg, Interfaces.Files.IPackedFileDescriptor pfd, uint localgroup, ObjectWorkshopSettings settings)
        {
            settings.KeepOriginalMesh = true;
            SimPe.Packages.GeneratableFile package = pkg;
            // we need packages in the Gmaes and the Download Folder

            if (((!System.IO.File.Exists(ScenegraphHelper.GMND_PACKAGE)) || (!System.IO.File.Exists(ScenegraphHelper.MMAT_PACKAGE))) && (settings is OWCloneSettings))
            {
                if (Message.Show(Localization.Manager.GetString("OW_Warning"), "Warning", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return(package);
                }
            }

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = ExtensionProvider.BuildFilterString(
                new SimPe.ExtensionType[] {
                SimPe.ExtensionType.Package,
                SimPe.ExtensionType.AllFiles
            }
                );
            if (sfd.ShowDialog() != DialogResult.OK)
            {
                return(package);
            }

            //create a Cloned Object to get all needed Files for the Process
            WaitingScreen.Wait();
            try
            {
                WaitingScreen.UpdateMessage("Collecting needed Files");

                if ((package == null) && (pfd != null))
                {
                    package = RecolorClone(br, package, pfd, localgroup, settings, false);
                }
            }
            finally { WaitingScreen.Stop(); }

            package.FileName = sfd.FileName;
            package.Save();

            return(package);
        }
示例#3
0
        private void Activate_miSaveCopyAs(object sender, System.EventArgs e)
        {
            sfd.Filter = ExtensionProvider.BuildFilterString(
                new SimPe.ExtensionType[] {
                SimPe.ExtensionType.Package,
                SimPe.ExtensionType.DisabledPackage,
                SimPe.ExtensionType.AllFiles
            }
                );

            sfd.FileName = package.FileName;
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                SimPe.Packages.GeneratableFile gf = (SimPe.Packages.GeneratableFile)package.Package.Clone();
                gf.Save(sfd.FileName);
                //package.UpdateRecentFileMenu(this.miRecent);
            }
        }
示例#4
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();
            }
        }
示例#5
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));
        }
示例#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);
        }
示例#7
0
        protected static SimPe.Packages.GeneratableFile ReColor(CloneSettings.BaseResourceType br, SimPe.Packages.GeneratableFile pkg, Interfaces.Files.IPackedFileDescriptor pfd, uint localgroup, ObjectWorkshopSettings settings, bool pkgcontainsonlybase)
        {
            SimPe.Packages.GeneratableFile package = pkg;
            // we need packages in the Gmaes and the Download Folder

            if (((!System.IO.File.Exists(ScenegraphHelper.GMND_PACKAGE)) || (!System.IO.File.Exists(ScenegraphHelper.MMAT_PACKAGE))) && (settings is OWCloneSettings))
            {
                if (Message.Show(Localization.Manager.GetString("OW_Warning"), "Warning", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return(package);
                }
            }

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = ExtensionProvider.BuildFilterString(
                new SimPe.ExtensionType[] {
                SimPe.ExtensionType.Package,
                SimPe.ExtensionType.AllFiles
            }
                );
            if (sfd.ShowDialog() != DialogResult.OK)
            {
                return(package);
            }

            //create a Cloned Object to get all needed Files for the Process
            WaitingScreen.Wait();
            try
            {
                WaitingScreen.UpdateMessage("Collecting needed Files");

                if ((package == null) && (pfd != null))
                {
                    package = RecolorClone(br, package, pfd, localgroup, settings, pkgcontainsonlybase);
                }
            }
            finally { WaitingScreen.Stop(); }


            /*if (settings is OWRecolorSettings)
             * {
             *      ObjectRecolor or = new ObjectRecolor(package);
             *      or.EnableColorOptions();
             *      or.LoadReferencedMATDs();
             *
             *      //load all Pending Textures
             *      ObjectCloner oc = new ObjectCloner(package);
             * }*/

            /*SimPe.Packages.GeneratableFile dn_pkg = null;
             * if (System.IO.File.Exists(ScenegraphHelper.GMND_PACKAGE)) dn_pkg = SimPe.Packages.GeneratableFile.LoadFromFile(ScenegraphHelper.GMND_PACKAGE);
             * else dn_pkg = SimPe.Packages.GeneratableFile.LoadFromStream((System.IO.BinaryReader)null);
             *
             * SimPe.Packages.GeneratableFile gm_pkg = null;
             * if (System.IO.File.Exists(ScenegraphHelper.MMAT_PACKAGE)) gm_pkg = SimPe.Packages.GeneratableFile.LoadFromFile(ScenegraphHelper.MMAT_PACKAGE);
             * else gm_pkg = SimPe.Packages.GeneratableFile.LoadFromStream((System.IO.BinaryReader)null);*/

            SimPe.Packages.GeneratableFile npackage = SimPe.Packages.GeneratableFile.CreateNew();            //.LoadFromStream((System.IO.BinaryReader)null);

            //Create the Templae for an additional MMAT
            npackage.FileName = sfd.FileName;

            ColorOptions cs = new ColorOptions(package);

            cs.Create(npackage);

            npackage.Save();
            package = npackage;


            WaitingScreen.Stop();
#if DEBUG
#else
            if (package != npackage)
            {
                package = null;
            }
#endif

            return(package);
        }
示例#8
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);
        }