Example #1
0
        private void llscan_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
#if DEBUG
            FileTable.FileIndex.Load();

            System.IO.StreamWriter sw = System.IO.File.CreateText(@"G:\txmt.txt");
            Hashtable ht = new Hashtable();
            FileTable.FileIndex.AddIndexFromFolder(@":G:\EA Games\Die Sims 2\");
            try
            {
                SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFile(Data.MetaData.TXMT, true);
                foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in items)
                {
                    Rcol txmt = new SimPe.Plugin.GenericRcol(null, false);
                    txmt.ProcessData(item);
                    SimPe.Plugin.MaterialDefinition md = (SimPe.Plugin.MaterialDefinition)txmt.Blocks[0];
                    foreach (MaterialDefinitionProperty mdp in md.Properties)
                    {
                        if (!ht.ContainsKey(mdp.Name))
                        {
                            ht.Add(mdp.Name, "| " + mdp.Value + " | ");
                        }
                        else
                        {
                            string s = (string)ht[mdp.Name];
                            if (s.IndexOf("| " + mdp.Value + " |") == -1)
                            {
                                s           += mdp.Value + " | ";
                                ht[mdp.Name] = s;
                            }
                        }
                    }
                }



                foreach (string k in ht.Keys)
                {
                    //if (!MaterialDefinition.PropertyParser.Properties.ContainsKey(k))
                    {
                        string   v     = (string)ht[k];
                        string[] parts = v.Split("|".ToCharArray(), 3);
                        sw.Write(k + "; ");
                        sw.WriteLine((string)ht[k]);
                    }
                }
            }
            finally
            {
                sw.Close();
                sw.Dispose();
                sw = null;
            }
#endif
        }
Example #2
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);
        }
Example #3
0
        private SimPe.Plugin.GenericRcol getRcolPkg(String filename, String pkg)
        {
            IPackageFile p = SimPe.Packages.File.LoadFromFile(pkg);

            if (p == null)
            {
                return(null);
            }

            IPackedFileDescriptor[] apr = p.FindFile(filename);
            if (apr == null || apr.Length != 1)
            {
                return(null);
            }

            SimPe.Plugin.GenericRcol tgt = new SimPe.Plugin.GenericRcol();
            tgt.ProcessData(apr[0], p);

            return(tgt);
        }
Example #4
0
        private SimPe.Plugin.GenericRcol getRcolPkg(IPackedFileDescriptor tgtpfd, String pkg)
        {
            IPackageFile p = SimPe.Packages.File.LoadFromFile(pkg);

            if (p == null)
            {
                return(null);
            }

            IPackedFileDescriptor pr = p.FindFile(tgtpfd);

            if (pr == null)
            {
                return(null);
            }

            SimPe.Plugin.GenericRcol tgt = new SimPe.Plugin.GenericRcol();
            tgt.ProcessData(pr, p);

            return(tgt);
        }
Example #5
0
		internal static System.Drawing.Image SetFromTxtr(SimPe.Interfaces.Files.IPackageFile pkg)
		{
			SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(Data.MetaData.TXTR);
			if (pfds.Length>0) 
			{
				SimPe.Interfaces.Files.IPackedFileDescriptor pfd = pfds[0];
				foreach (SimPe.Interfaces.Files.IPackedFileDescriptor p in pfds)				
					if (p.Size>pfd.Size) pfd = p;
				
				SimPe.Plugin.Rcol rcol = new SimPe.Plugin.GenericRcol();
				rcol.ProcessData(pfd, pkg);
				if (rcol.Blocks.Length>0) 
				{
					SimPe.Plugin.ImageData id = rcol.Blocks[0] as SimPe.Plugin.ImageData;
					if (id!=null)
					{
						SimPe.Plugin.MipMap m = id.GetLargestTexture(new System.Drawing.Size(PackageInfo.IMAGESIZE, PackageInfo.IMAGESIZE));
						if (m!=null) return m.Texture;
					}
				}
			}	
		
			return null;
		}
Example #6
0
        protected void LoadSkinImageFormPackage(SimPe.Interfaces.Files.IPackageFile package)
        {
            Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(0xAC506764);
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                try
                {
                    SimPe.Plugin.RefFile reffile = new SimPe.Plugin.RefFile();
                    reffile.ProcessData(pfd, package);
                    refs.Add(reffile);
                }
                catch (Exception) {}
            }

            pfds = package.FindFiles(0x49596978);
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                try
                {
                    SimPe.Plugin.Rcol matd = new SimPe.Plugin.GenericRcol(null, true);
                    matd.ProcessData(pfd, package);
                    matds.Add(matd);
                }
                catch (Exception) {}
            }

            //Material Files
            Interfaces.Files.IPackedFileDescriptor[] nmap_pfd = package.FindFiles(Data.MetaData.NAME_MAP);
            pfds = package.FindFiles(0x49596978);
            Plugin.Nmap nmap = new SimPe.Plugin.Nmap(null);
            if (nmap_pfd.Length > 0)
            {
                nmap.ProcessData(nmap_pfd[0], package);
            }
            bool check = false;

            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                try
                {
                    SimPe.Plugin.Rcol matd = new SimPe.Plugin.GenericRcol(null, true);
                    check = false;

                    foreach (Interfaces.Files.IPackedFileDescriptor epfd in nmap.Items)
                    {
                        if (
                            (epfd.Group == pfd.Group) &&
                            (epfd.Instance == pfd.Instance)
                            )
                        {
                            matd.FileDescriptor = pfd;
                            matd.Package        = package;
                            matds.Add(matd);
                            check = true;
                        }
                    }

                    //not found in the FileMap, so process Normally
                    if (!check)
                    {
                        matd.ProcessData(pfd, package);
                        matds.Add(matd);
                    }
                }
                catch (Exception) {}
            }

            //Texture Files
            nmap_pfd = package.FindFiles(Data.MetaData.NAME_MAP);
            pfds     = package.FindFiles(0x1C4A276C);
            check    = false;

            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                try
                {
                    SimPe.Plugin.Txtr txtr = new SimPe.Plugin.Txtr(null, true);
                    check = false;

                    foreach (Interfaces.Files.IPackedFileDescriptor epfd in nmap.Items)
                    {
                        if (
                            (epfd.Group == pfd.Group) &&
                            (epfd.Instance == pfd.Instance)
                            )
                        {
                            txtr.FileDescriptor = pfd;
                            txtr.Package        = package;
                            txtrs.Add(epfd.Filename, txtr);
                            continue;
                        }
                    }

                    //not found in the FileMap, so process Normally
                    if (!check)
                    {
                        txtr.ProcessData(pfd, package);
                        foreach (SimPe.Plugin.ImageData id in txtr.Blocks)
                        {
                            txtrs.Add(id.NameResource.FileName.ToLower(), txtr);
                        }
                    }
                }
                catch (Exception) {}
            }
        }
Example #7
0
        public void ExecuteEventHandler(object sender, SimPe.Events.ResourceEventArgs es)
        {
            if (!RealChangeEnabledStateEventHandler(null, es))
            {
                System.Windows.Forms.MessageBox.Show(Localization.GetString("This is not an appropriate context in which to use this tool"),
                                                     Localization.GetString(this.ToString()));
                return;
            }

            SimPe.Interfaces.Files.IPackedFileDescriptor pfd = null;
            for (int i = 0; i < es.Count; i++)
            {
                if (es[i].HasFileDescriptor)
                {
                    pfd = es[i].Resource.FileDescriptor; break;
                }
            }

            Data.TypeAlias a = Helper.TGILoader.GetByType(pfd.Type);
            if (Data.MetaData.RcolList.Contains(a.Id))
            {
                SimPe.Packages.PackedFileDescriptor fd = new SimPe.Packages.PackedFileDescriptor();
                fd.Type     = Data.MetaData.NAME_MAP;
                fd.Group    = 0x52737256;
                fd.Instance = a.Id;
                fd.SubType  = 0;

                SimPe.Plugin.Nmap nmap = new SimPe.Plugin.Nmap(FileTable.ProviderRegistry);
                nmap.FileDescriptor = fd;
                bool add = false;
                if (es.LoadedPackage.Package.FindFile(fd) == null)
                {
                    add = true;
                }

                System.Collections.ArrayList list = new System.Collections.ArrayList();
                foreach (SimPe.Events.ResourceContainer e in es)
                {
                    if (!e.HasFileDescriptor)
                    {
                        continue;
                    }
                    if (e.Resource.FileDescriptor.Type != a.Id)
                    {
                        continue;
                    }
                    try
                    {
                        SimPe.Packages.PackedFileDescriptor p = (SimPe.Packages.PackedFileDescriptor)e.Resource.FileDescriptor;

                        SimPe.Plugin.Rcol rcol = new SimPe.Plugin.GenericRcol(null, false);
                        rcol.ProcessData(p, es.LoadedPackage.Package);

                        p.Filename = rcol.FileName;
                        list.Add(p);
                    }
                    catch (Exception) {}
                }                 //foreach

                nmap.Items = new SimPe.Packages.PackedFileDescriptor[list.Count];
                list.CopyTo(nmap.Items);

                nmap.SynchronizeUserData();
                if (add)
                {
                    es.LoadedPackage.Package.Add(nmap.FileDescriptor);
                }
            }
        }