Пример #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);
        }
Пример #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);
            }
        }
Пример #3
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);
        }