Beispiel #1
0
        protected string AddTxtr(GenericRcol txtr, string unique, GenericRcol txmt, MaterialDefinition md)
        {
            string old = Hashes.StripHashFromName(txtr.FileName.Trim().ToLower());

            if (old.EndsWith("_txtr"))
            {
                old = old.Substring(0, old.Length - 5);
            }
            //Console.WriteLine("Adding Texture: "+old);

            string name = txtr.FileName.Trim();

            if (name.ToLower().EndsWith("_txtr"))
            {
                name = name.Substring(0, name.Length - 5);
            }

            string tname = RenameForm.ReplaceOldUnique(name, unique, true);

            txtr.FileName = tname + "_txtr";

            txtr.FileDescriptor = ScenegraphHelper.BuildPfd(txtr.FileName, Data.MetaData.TXTR, Data.MetaData.CUSTOM_GROUP);

            for (int i = 0; i < md.Listing.Length; i++)
            {
                if (Hashes.StripHashFromName(md.Listing[i].Trim().ToLower()) == old)
                {
                    md.Listing[i] = "##0x" + Helper.HexString(Data.MetaData.CUSTOM_GROUP) + "!" + tname;
                }
            }

            //update References
            foreach (string k in txmt.ReferenceChains.Keys)
            {
                if (k == "TXTR" || k == "Generic")
                {
                    continue;
                }
                //Console.WriteLine("    Checking Property "+k);
                string thisname = Hashes.StripHashFromName(md.FindProperty(k).Value.Trim().ToLower());

                if (thisname == old)
                {
                    string nname = "##0x" + Helper.HexString(Data.MetaData.CUSTOM_GROUP) + "!" + tname;
                    //Console.WriteLine("    --> Updating to "+nname);
                    md.FindProperty(k).Value = nname;
                }
            }

            //Load the Lifos into the Texture File
            ImageData id = (ImageData)txtr.Blocks[0];

            id.GetReferencedLifos();

            return(name);
        }
Beispiel #2
0
        public static Hashtable Execute(SimPe.Interfaces.Files.IPackageFile package, bool uniquename, ref FixVersion ver)
        {
            RenameForm rf = new RenameForm();

            rf.ok           = false;
            rf.package      = package;
            rf.cbv2.Checked = (ver == FixVersion.UniversityReady2);

            string old = Hashes.StripHashFromName(FindMainOldName(package).ToLower().Trim());

            current_unique = GetUniqueName();
            if (old.EndsWith("_cres"))
            {
                old = old.Substring(0, old.Length - 5);
            }
            if (uniquename)
            {
                string name = RenameForm.ReplaceOldUnique(old, current_unique, true);
                if (name == old)
                {
                    name = old + current_unique;
                }
                rf.tbname.Text = name;
            }
            else
            {
                rf.tbname.Text = old;
            }

            GetNames(uniquename, package, rf.lv, rf.tbname.Text);
            rf.ShowDialog();


            if (rf.ok)
            {
                if (rf.cbv2.Checked)
                {
                    ver = FixVersion.UniversityReady2;
                }
                else
                {
                    ver = FixVersion.UniversityReady;
                }
                return(rf.GetReplacementMap());
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
        public static void Fix(string package, string modelname, FixVersion ver)
        {
            if (System.IO.File.Exists(package))
            {
                SimPe.Packages.GeneratableFile pkg = SimPe.Packages.GeneratableFile.LoadFromFile(package);

                System.Collections.Hashtable map = RenameForm.GetNames((modelname.Trim() != ""), pkg, null, modelname);
                FixObject fo = new FixObject(pkg, ver, false);
                fo.Fix(map, false);
                fo.CleanUp();
                fo.FixGroup();

                pkg.Save();
            }
        }
Beispiel #4
0
        /// <summary>
        /// Adds the MMAT Files specified in the map to the new package
        /// </summary>
        /// <param name="newpkg"></param>
        /// <param name="map">Contains the MMATs that should be added</param>
        /// <param name="fullmap">Contains a List of all available MMATs</param>
        public void ProcessMmatMap(IPackageFile newpkg, Hashtable map, Hashtable fullmap)
        {
            if (WaitingScreen.Running)
            {
                WaitingScreen.UpdateMessage("Loading Slave Subsets");
            }
            AddSlavesSubsets(map, fullmap);
            Hashtable slaves = Scenegraph.GetSlaveSubsets(package);

            uint   inst   = 0x6000;
            string unique = RenameForm.GetUniqueName(true);

            foreach (Hashtable ht in map.Values)
            {
                foreach (ArrayList list in ht.Values)
                {
                    string family = System.Guid.NewGuid().ToString();
                    if (unique == null)
                    {
                        unique = family;
                    }

                    foreach (SimPe.Plugin.MmatWrapper mmat in list)
                    {
                        mmat.FileDescriptor          = Scenegraph.Clone(mmat.FileDescriptor);
                        mmat.FileDescriptor.Instance = inst++;
                        mmat.FileDescriptor.Group    = Data.MetaData.LOCAL_GROUP;
                        mmat.Family          = family;
                        mmat.DefaultMaterial = false;

                        GenericRcol txmt = mmat.TXMT;
                        GenericRcol txtr = mmat.TXTR;
                        this.AddTxmt(newpkg, mmat, txmt, txtr, unique, slaves);

                        mmat.SynchronizeUserData();
                        newpkg.Add(mmat.FileDescriptor);
                    }
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Returns a unique name tht is still working
        /// </summary>
        /// <param name="name">The existing Name of the Object</param>
        /// <param name="unique">a unique strung that sould be added</param>
        /// <param name="subsetname">the name of the Subset</param>
        /// <param name="ext">true, if you want the _txmt Extension</param>
        /// <returns>the new Name</returns>
        public static string GetUniqueTxmtName(string name, string unique, string subsetname, bool ext)
        {
            name = name.Trim();
            name = RenameForm.ReplaceOldUnique(name, "", false);

            if (name.ToLower().EndsWith("_txmt"))
            {
                name = name.Substring(0, name.Length - 5);
            }


            string[] parts = name.Split("_".ToCharArray());
            if (parts.Length > 0)
            {
                //oild method used to assigne the additional Name to the subset Part, now we assign it to the ModelName-Part

                /*
                 * subsetname = subsetname.Trim().ToLower();
                 * name = "";
                 * bool foundsubset = false;
                 * bool addedunique = false;
                 * for (int i=0; i<parts.Length; i++)
                 * {
                 *      if (i!=0) name += "_";
                 *      name += parts[i];
                 *
                 *      if (foundsubset && !addedunique)
                 *      {
                 *              name += unique;
                 *              addedunique = true;
                 *      }
                 *
                 *      if (parts[i].ToLower()==subsetname) foundsubset=true;
                 *
                 * }
                 * if (!addedunique) name += unique;				*/

                name = "";
                bool first = true;
                foreach (string s in parts)
                {
                    if (!first)
                    {
                        name += "_";
                    }
                    name += s;
                    if (first)
                    {
                        first = false;
                        name += "-" + unique;
                    }
                }
            }
            else
            {
                name += unique;
            }

            if (ext)
            {
                name += "_txmt";
            }
            return(name);
        }
Beispiel #6
0
 /// <summary>
 /// Builds a Name map
 /// </summary>
 /// <param name="uniquename">true, if you want to create a unique name</param>
 /// <returns></returns>
 public Hashtable GetNameMap(bool uniquename)
 {
     return(RenameForm.Execute(package, uniquename, ref ver));
 }