Exemplo n.º 1
0
        protected static void UpdateDescription(OWCloneSettings cs, SimPe.PackedFiles.Wrapper.Str str)
        {
            str.ClearNonDefault();
            while (str.Items.Length < 2)
            {
                str.Add(new SimPe.PackedFiles.Wrapper.StrToken(str.Items.Length, 1, "", ""));
            }

            str.Items[0].Title = cs.Title;
            str.Items[1].Title = cs.Description;

            str.SynchronizeUserData();
        }
Exemplo n.º 2
0
        protected static void PrepareForClone(SimPe.Interfaces.Files.IPackageFile package, out SimPe.Interfaces.IAlias a, out uint localgroup, out SimPe.Interfaces.Files.IPackedFileDescriptor pfd, out OWCloneSettings cs)
        {
            ObjectWorkshopHelper.PrepareForClone(package, null, out a, out localgroup, out pfd);

            cs = new OWCloneSettings();
            cs.IncludeWallmask           = false;
            cs.OnlyDefaultMmats          = false;
            cs.IncludeAnimationResources = false;
            cs.CustomGroup                    = false;
            cs.FixResources                   = false;
            cs.RemoveUselessResource          = false;
            cs.StandAloneObject               = false;
            cs.RemoveNonDefaultTextReferences = false;
            cs.KeepOriginalMesh               = false;
            cs.PullResourcesByStr             = true;
            cs.ChangeObjectDescription        = false;
            cs.OpenWithRemoteControl          = false;
        }
Exemplo n.º 3
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.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cs"></param>
        /// <param name="cpf"></param>
        /// <returns>ResourceDescriptor for the references String</returns>
        protected static SimPe.Interfaces.Files.IPackedFileDescriptor UpdateDescription(OWCloneSettings cs, SimPe.Packages.GeneratableFile package, SimPe.PackedFiles.Wrapper.Cpf cpf)
        {
            cpf.GetSaveItem("cost").UIntegerValue      = (uint)cs.Price;
            cpf.GetSaveItem("name").StringValue        = cs.Title.Replace("\n", " ").Replace("\t", "    ").Replace("\r", " ");
            cpf.GetSaveItem("description").StringValue = cs.Description.Replace("\n", " ").Replace("\t", "    ").Replace("\r", " ");
            cpf.SynchronizeUserData();

            SimPe.Interfaces.Files.IPackedFileDescriptor pfd = package.FindFile(cpf.GetSaveItem("stringsetrestypeid").UIntegerValue, 0, cpf.GetSaveItem("stringsetgroupid").UIntegerValue, cpf.GetSaveItem("stringsetid").UIntegerValue);

            return(pfd);
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cs"></param>
        /// <param name="cpf"></param>
        /// <returns>ResourceDescriptor for the references String</returns>
        protected static SimPe.Interfaces.Files.IPackedFileDescriptor UpdateDescription(OWCloneSettings cs, SimPe.Packages.GeneratableFile package, SimPe.PackedFiles.Wrapper.ExtObjd obj)
        {
            obj.Price      = cs.Price;
            obj.Data[0x22] = (short)Math.Floor(cs.Price * 0.035); // sale price
            obj.Data[0x23] = (short)Math.Floor(cs.Price * 0.15);  // initial depreciation
            obj.Data[0x24] = (short)Math.Floor(cs.Price * 0.10);  // daily depreciation
            obj.Data[0x25] = 0;                                   // self depreciation
            obj.Data[0x26] = (short)Math.Floor(cs.Price * 0.40);  // depreciation limit
            obj.SynchronizeUserData();
            SimPe.Interfaces.Files.IPackedFileDescriptor pfd = package.FindFile(Data.MetaData.CTSS_FILE, 0, obj.FileDescriptor.Group, obj.CTSSInstance);

            return(pfd);
        }
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);
        }