コード例 #1
0
        public object FindTxtr(string name)
        {
            if (name == null)
            {
                return(null);
            }
            string file = System.IO.Path.Combine(SimPe.PathProvider.Global[Expansions.BaseGame].InstallFolder, "TSData\\Res\\Sims3D\\Sims07.package");

            if (System.IO.File.Exists(file))
            {
                SimPe.Interfaces.Files.IPackageFile      package = SimPe.Packages.File.LoadFromFile(file);
                Interfaces.Files.IPackedFileDescriptor[] pfds    = package.FindFile(name, 0x1C4A276C);

                //look for the right one
                foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                {
                    SimPe.Plugin.Txtr rcol = new SimPe.Plugin.Txtr(null, false);
                    rcol.ProcessData(pfd, package);
                    if (rcol.FileName.Trim().ToLower() == name.Trim().ToLower())
                    {
                        return(rcol);
                    }
                }
            }

            return(null);
        }
コード例 #2
0
        /// <summary>
        /// Add all Files that could be borrowed from the current package by the passed one, to the passed package
        /// </summary>
        /// <param name="orgmodelnames">List of available modelnames in this package</param>
        /// <param name="pkg">The package that should receive the Files</param>
        /// <remarks>Simply Copies MMAT, LIFO, TXTR and TXMT Files</remarks>
        public void AddParentFiles(string[] orgmodelnames, SimPe.Interfaces.Files.IPackageFile pkg)
        {
            if (WaitingScreen.Running)
            {
                WaitingScreen.UpdateMessage("Loading Parent Files");
            }
            ArrayList names = new ArrayList();

            foreach (string s in orgmodelnames)
            {
                names.Add(s);
            }

            ArrayList types = new ArrayList();

            types.Add(Data.MetaData.MMAT);
            types.Add(Data.MetaData.TXMT);
            types.Add(Data.MetaData.TXTR);
            types.Add(Data.MetaData.LIFO);

            foreach (uint type in types)
            {
                SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(type);
                foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                {
                    if (pkg.FindFile(pfd) != null)
                    {
                        continue;
                    }

                    SimPe.Interfaces.Files.IPackedFile file = package.Read(pfd);
                    pfd.UserData = file.UncompressedData;

                    //Update the modeName in the MMAT
                    if ((pfd.Type == Data.MetaData.MMAT) && (names.Count > 0))
                    {
                        SimPe.Plugin.MmatWrapper mmat = new MmatWrapper();
                        mmat.ProcessData(pfd, package);

                        string n = mmat.ModelName.Trim().ToLower();
                        if (!n.EndsWith("_cres"))
                        {
                            n += "_cres";
                        }

                        if (!names.Contains(n))
                        {
                            n = names[0].ToString();
                            //n = n.Substring(0, n.Length-5);
                            mmat.ModelName = n;
                            mmat.SynchronizeUserData();
                        }
                    }

                    pkg.Add(pfd);
                }
            }             //foreach type
        }
コード例 #3
0
        /// <summary>
        /// Returns the Property Set (=cpf) of a Skin
        /// </summary>
        /// <param name="spfd">The File Description of the File you are looking for</param>
        /// <returns>null or the Property Set File</returns>
        public string FindTxtrName(string matdname)
        {
            if (matdname == null)
            {
                return(null);
            }
            string file = System.IO.Path.Combine(SimPe.PathProvider.Global[Expansions.BaseGame].InstallFolder, "TSData\\Res\\Sims3D\\Sims02.package");

            if (System.IO.File.Exists(file))
            {
                SimPe.Interfaces.Files.IPackageFile      package = SimPe.Packages.File.LoadFromFile(file);
                Interfaces.Files.IPackedFileDescriptor[] pfds    = package.FindFile(matdname.Replace("CASIE_", ""), 0x49596978);
                if (pfds.Length == 0)
                {
                    pfds = package.FindFile(matdname, 0x49596978);
                }
                //try another Package

                /*if (pfds.Length==0)
                 * {
                 *      file = System.IO.Path.Combine(Helper.WindowsRegistry.SimsPath, "TSData\\Res\\Sims3D\\Sims07.package");
                 *      if (System.IO.File.Exists(file))
                 *      {
                 *              package = SimPe.Packages.GeneratableFile.LoadFromFile(file);
                 *              pfds = package.FindFile(matdname, 0x49596978);
                 *      }
                 * }*/

                //look for the right one
                foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                {
                    SimPe.Plugin.Rcol rcol = new SimPe.Plugin.GenericRcol(null, false);
                    rcol.ProcessData(pfd, package);
                    if ((rcol.FileName.Trim().ToLower() == matdname.Trim().ToLower()) || (rcol.FileName.Trim().ToLower() == matdname.Replace("CASIE_", "").Trim().ToLower()))
                    {
                        foreach (SimPe.Plugin.MaterialDefinition md in rcol.Blocks)
                        {
                            return(md.GetProperty("stdMatBaseTextureName").Value + "_txtr");
                        }
                    }
                }
            }
            return(null);
        }
コード例 #4
0
        protected override void StartThread()
        {
            lotfi.Load();
            SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = lotfi.FindFile(0x856DDBAC, Data.MetaData.LOCAL_GROUP, 0x35CA0002, null);
            bool run = Wait.Running;

            if (!run)
            {
                Wait.Start();
            }
            Wait.SubStart(items.Length);
            try
            {
                int ct   = 0;
                int step = Math.Max(2, Wait.MaxProgress / 100);
                foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in items)
                {
                    if (this.HaveToStop)
                    {
                        break;
                    }


                    SimPe.Interfaces.Files.IPackageFile pkg = item.Package;

                    SimPe.Interfaces.Files.IPackedFileDescriptor pfd = pkg.FindFile(Data.MetaData.STRING_FILE, 0, Data.MetaData.LOCAL_GROUP, 0x00000A46);
                    string name = SimPe.Localization.GetString("Unknown");
                    if (pfd != null)
                    {
                        SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                        str.ProcessData(pfd, pkg);

                        SimPe.PackedFiles.Wrapper.StrItemList list = str.FallbackedLanguageItems(Helper.WindowsRegistry.LanguageCode);
                        if (list.Count > 0)
                        {
                            name = list[0].Title;
                        }
                    }

                    SimPe.PackedFiles.Wrapper.Picture pic = new SimPe.PackedFiles.Wrapper.Picture();
                    pic.ProcessData(item);

                    uint inst = GetInstanceFromFilename(pkg.SaveFileName);

                    SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] ltxtitems = ngbhfi.FindFile(0x0BF999E7, Data.MetaData.LOCAL_GROUP, inst, null);
                    SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem   ltxt      = null;
                    if (ltxtitems.Length > 0)
                    {
                        ltxt = ltxtitems[0];
                    }

                    LotItem li = new LotItem(inst, name, pic.Image, ltxt);
                    if (LoadingLot != null)
                    {
                        LoadingLot(this, li);
                    }
                    content[li.Instance] = li;
                    ct++;
                    if (ct % step == 0)
                    {
                        Wait.Message  = name;
                        Wait.Progress = ct;
                    }
                }                //foreach
            }
#if !DEBUG
            catch (Exception ex)
            {
                Helper.ExceptionMessage(ex);
            }
#endif
            finally
            {
                Wait.SubStop();
                if (!run)
                {
                    Wait.Stop();
                }
            }

            ended.Set();
        }
コード例 #5
0
        /// <summary>
        /// Adds a Sim to the List
        /// </summary>
        /// <param name="objd"></param>
        /// <param name="ct"></param>
        /// <param name="step"></param>
        /// <returns>The Alias for that Sim</returns>
        /// <remarks>
        /// Alias.Tag has the following Structure:
        /// [0] : FileName of Character File (if NPC, this will be null)
        /// [1] : Thumbnail
        /// [2] : FamilyName
        /// [3] : Contains Age Data
        /// [4] : When NPC, this will get the Filename
        /// </remarks>
        protected Alias AddSim(SimPe.PackedFiles.Wrapper.ExtObjd objd, ref int ct, int step, bool npc)
        {
            //if (objd.Type!=Data.ObjectTypes.Person) return null;

            SimPe.Interfaces.Files.IPackageFile fl = objd.Package;
            //BinaryReader br = new BinaryReader(File.OpenRead(file));//new StreamReader(file)
            bool hasagedata = fl.FindFiles(0xAC598EAC).Length > 0;           //has Age Data

            object[] tags = new object[5];
            tags[0] = fl.FileName;
            tags[1] = null;
            tags[2] = Localization.Manager.GetString("Unknown");
            tags[3] = hasagedata;
            tags[4] = null;

            /*if (Helper.WindowsRegistry.HiddenMode)
             *      tags[5] = (!hasagedata) && (fl.FindFiles(0xAC506764).Length>0); //if this is true, the Sim has a Problem, and the package was probably split
             * else
             *      tags[5] = false;*/

            //set stuff for NPCs
            if (npc)
            {
                tags[4]  = tags[0];
                tags[0]  = "";
                tags[2] += " (NPC)";
            }

            Alias a = null;



            Interfaces.Files.IPackedFileDescriptor str_pfd = fl.FindFile(Data.MetaData.CTSS_FILE, 0, objd.FileDescriptor.Group, objd.CTSSInstance);

            if (str_pfd != null)
            {
                SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                str.ProcessData(str_pfd, fl);
                SimPe.PackedFiles.Wrapper.StrItemList its = str.FallbackedLanguageItems(Helper.WindowsRegistry.LanguageCode);
                if (its.Length > 0)
                {
#if DEBUG
                    a = new Alias(objd.Guid, its[0].Title, "{name} {2} (0x{id})");
#else
                    a = new Alias(objd.Guid, its[0].Title, "{name} {2} (0x{id})");
#endif
                    if (its.Length > 2)
                    {
                        tags[2] = its[2].Title;
                    }
                }
            }


            if (a != null)
            {
                IPackedFileDescriptor[] piclist = fl.FindFiles(Data.MetaData.SIM_IMAGE_FILE);
                foreach (IPackedFileDescriptor pfd in piclist)
                {
                    if (pfd.Group != objd.FileDescriptor.Group)
                    {
                        continue;
                    }
                    if (pfd.Instance < 0x200)
                    {
                        SimPe.PackedFiles.Wrapper.Picture pic = new SimPe.PackedFiles.Wrapper.Picture();
                        pic.ProcessData(pfd, fl);

                        /*if (Helper.StartedGui==Executable.Classic)
                         *      WaitingScreen.UpdateImage(pic.Image);
                         * else
                         *      Wait.Image = pic.Image;								*/

                        tags[1] = pic.Image;
                        break;
                    }
                }

                a.Tag = tags;
                //if (Helper.StartedGui!=Executable.Classic)
                {
                    ct++;
                    if (ct % step == 1)
                    {
                        Wait.Message  = a.ToString();
                        Wait.Progress = ct;
                    }
                }

                //set stuff for NPCs
                if (npc)
                {
                    a.Tag[2] = a.Tag[2].ToString() + " (NPC)";
                }

                if (names == null)
                {
                    return(null);
                }
                if (!names.Contains(objd.Guid))
                {
                    names.Add(objd.Guid, a);
                }
            }

            return(a);
        }
コード例 #6
0
        /// <summary>
        /// Loads all package Files in the directory and scans them for Name Informations
        /// </summary>
        public void LoadSimsFromFolder()
        {
            names = new Hashtable();
            if (BasePackage == null)
            {
                return;
            }

            SimPe.PackedFiles.Wrapper.Fami fami = new SimPe.PackedFiles.Wrapper.Fami(null);
            Hashtable al = new Hashtable();

            foreach (uint type in fami.AssignableTypes)
            {
                IPackedFileDescriptor[] list = BasePackage.FindFiles(type);

                foreach (IPackedFileDescriptor pfd in list)
                {
                    fami.ProcessData(pfd, BasePackage);
                    al[(ushort)pfd.Instance] = fami.Name;

                    foreach (uint simid in fami.Members)
                    {
                        Alias a = new Alias(simid, fami.Name);
                        if (!names.Contains(simid))
                        {
                            names.Add(simid, a);
                        }
                    }
                }
            }            //foreach

            ///add unlisted Sims
            foreach (SimPe.PackedFiles.Wrapper.SDesc sdesc in FileTable.ProviderRegistry.SimDescriptionProvider.SimInstance.Values)
            {
                //load extern Fami Name
                if (!names.Contains(sdesc.SimId))
                {
                    if (sdesc.Package.SaveFileName.Trim().ToLower() != BasePackage.SaveFileName.Trim().ToLower())
                    {
                        SimPe.Interfaces.Files.IPackageFile pkg = sdesc.Package;
                        if (pkg != null)
                        {
                            SimPe.Interfaces.Files.IPackedFileDescriptor pfd = pkg.FindFile(fami.AssignableTypes[0], 0, Data.MetaData.LOCAL_GROUP, sdesc.FamilyInstance);
                            if (pfd != null)
                            {
                                fami.ProcessData(pfd, pkg);
                                Alias a = new Alias(sdesc.SimId, fami.Name);
                                names.Add(sdesc.SimId, a);
                            }
                        }
                    }
                    else
                    {
                        object o = al[sdesc.FamilyInstance];
                        if (o != null)
                        {
                            Alias a = new Alias(sdesc.SimId, o.ToString());
                            names.Add(sdesc.SimId, a);
                        }
                    }
                }
            }

            al.Clear();

            /*names = new Alias[al.Count];
             * al.CopyTo(names);*/
        }