Add the SpriteDatabase to a spritecontroller

This commit is contained in:
2017-09-21 06:46:31 -05:00
parent b01341439b
commit 743ab78c28
7 changed files with 93 additions and 4 deletions

View File

@ -36,6 +36,7 @@ namespace SpriteLibrary
ResourceManager myResourceManager = null;
string Filename = "";
Size SnapGridSize = new Size(5, 5);
System.Drawing.Icon LibIcon = null;
/// <summary>
/// The sprite database instantiation function. The filename can either be a file on the computer or it
@ -86,6 +87,15 @@ namespace SpriteLibrary
}
}
/// <summary>
/// Change the Icon for the SpriteEntryForm
/// </summary>
/// <param name="toSet">An icon image</param>
public void SetIcon(System.Drawing.Icon toSet)
{
LibIcon = toSet;
}
/// <summary>
/// The SnapGrid is the block-size that your sprite will be. For example, I will often have sprites with
/// a snapgrid of 50,50. This means that the sprite can be 50x50, 100x50, or anything with a step-size
@ -155,11 +165,25 @@ namespace SpriteLibrary
{
SpriteEntryForm SEF = new SpriteEntryForm(this, SpriteInfoList, SnapGridSize);
SEF.SetInitialSprite(FirstItemIndex);
if (LibIcon != null) SEF.SetIcon(LibIcon);
SEF.ShowDialog();
//Use the updated list returned from the form.
SpriteInfoList.Clear();
SpriteInfoList.AddRange(SEF.GetUpdatedList());
}
/// <summary>
/// Generate a new, named sprite from a sprite template stored in the database. Most of the time you do
/// not want to use this yourself. SpriteControllers that are defined with a database will automatically
/// look up sprite templates that they do not have sprites for. This function is just a wrapper for SmartDuplicateSprite.
/// </summary>
/// <param name="Name">The name of the sprite to load. Names are case-sensitive.</param>
/// <param name="ControllerToUse">The sprite controller that will store the sprite in its cache</param>
/// <returns>A new, named sprite, or null if no such template is found.</returns>
public Sprite SpriteFromName(string Name, SpriteController ControllerToUse)
{
return SmartDuplicateSprite(ControllerToUse, Name, true);
}
#endregion
#region General Functions