FRBDK/SpriteEditor/GameData.cs
/// <summary>
/// Returns a unique name for the passed Sprite, or a unique name if the spriteInMemory is null.
/// </summary>
/// <remarks>
/// This function is used to create a unique name for a new named object.
/// This is done by looping through the argument array of named objects
/// to see if the an object with the same name already exists.
/// 
/// Since the object being checked could already be in the argument array,
/// the function has to make sure that the argument and object in the array are
/// not the same.  If there there is an object in the array of the same name and it
/// is not the same object as the argument object, the number at the end is incremented.
/// 
/// If no objects of the same name are found in the array, tempObject will be null and
/// the method will return the nameToCheck
/// </remarks>
/// <param name="nameToCheck"></param>
/// <param name="spriteInMemory"></param>
/// <param name="attachableList"></param>
/// <returns></returns>
Returns a unique name for the passed Sprite, or a unique name if the spriteInMemory is null.
Returns a unique name for the passed Sprite or a unique name if the spriteInMemory is null .
public static string GetUniqueNameForObject<T>(string nameToCheck, T objectToCheckTheNameOf) where T: class, INameable
		{
			object temporaryObject = null;
			do
			{
                temporaryObject = null;
                foreach (Sprite s in mScene.Sprites)
                {
                    if (s.Name == nameToCheck && s != objectToCheckTheNameOf)
                    {
                        temporaryObject = s;
                        break;
                    }
                }
                foreach (SpriteFrame sf in Scene.SpriteFrames)
                {
                    if (sf.Name == nameToCheck && sf != objectToCheckTheNameOf)
                    {
                        temporaryObject = sf;
                        break;
                    }
                }
                foreach (SpriteGrid spriteGrid in Scene.SpriteGrids)
                {
                    if (spriteGrid.Name == nameToCheck && spriteGrid != objectToCheckTheNameOf)
                    {
                        temporaryObject = spriteGrid;
                        break;
                    }
                }
                foreach (PositionedModel pm in Scene.PositionedModels)
                {
                    if (pm.Name == nameToCheck && pm != objectToCheckTheNameOf)
                    {
                        temporaryObject = pm;
                        break;
                    }
                }
				if(temporaryObject == null)
					return nameToCheck;
				nameToCheck = StringFunctions.IncrementNumberAtEnd(nameToCheck);
			}while(temporaryObject != null);
			return nameToCheck;
		}
public static string GetUniqueNameForObject < T > ( string nameToCheck , T objectToCheckTheNameOf ) where T : class , INameable { object temporaryObject = null ; do { temporaryObject = null ; foreach ( Sprite s in mScene . Sprites ) { if ( s . Name == nameToCheck && s != objectToCheckTheNameOf ) { temporaryObject = s ; break ; } } foreach ( SpriteFrame sf in Scene . SpriteFrames ) { if ( sf . Name == nameToCheck && sf != objectToCheckTheNameOf ) { temporaryObject = sf ; break ; } } foreach ( SpriteGrid spriteGrid in Scene . SpriteGrids ) { if ( spriteGrid . Name == nameToCheck && spriteGrid != objectToCheckTheNameOf ) { temporaryObject = spriteGrid ; break ; } } foreach ( PositionedModel pm in Scene . PositionedModels ) { if ( pm . Name == nameToCheck && pm != objectToCheckTheNameOf ) { temporaryObject = pm ; break ; } } if ( temporaryObject == null ) return nameToCheck ; nameToCheck = StringFunctions . IncrementNumberAtEnd ( nameToCheck ) ; } while ( temporaryObject != null ) ; return nameToCheck ; }
Returns a unique name for the passed Sprite, or a unique name if the spriteInMemory is null.
Returns a unique name for the passed Sprite or a unique name if the spriteInMemory is null .
// See if there is already an object // using the objectToCheckTheNameOf's Name. // If so, increment the number at the end and // try again. // we have one sprite.  Let's see if it's the only sprite
None
nameToCheck
string
None
objectToCheckTheNameOf
T
spriteInMemory
None
attachableList
None
remarks
This function is used to create a unique name for a new named object.
This is done by looping through the argument array of named objects
to see if the an object with the same name already exists.

Since the object being checked could already be in the argument array,
the function has to make sure that the argument and object in the array are
not the same.  If there there is an object in the array of the same name and it
is not the same object as the argument object, the number at the end is incremented.

If no objects of the same name are found in the array, tempObject will be null and
the method will return the nameToCheck
This function is used to create a unique name for a new named object . This is done by looping through the argument array of named objects to see if the an object with the same name already exists . Since the object being checked could already be in the argument array the function has to make sure that the argument and object in the array are not the same . If there there is an object in the array of the same name and it is not the same object as the argument object the number at the end is incremented . If no objects of the same name are found in the array tempObject will be null and the method will return the nameToCheck