Add the SpriteDatabase to a spritecontroller
This commit is contained in:
parent
b01341439b
commit
743ab78c28
16
SpriteLibrary/Properties/Resources.Designer.cs
generated
16
SpriteLibrary/Properties/Resources.Designer.cs
generated
@ -61,15 +61,23 @@ namespace SpriteLibrary.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
|
||||
///{\colortbl ;\red0\green0\blue255;}
|
||||
///{\*\generator Riched20 10.0.10586}\viewkind4\uc1
|
||||
///\pard\sa200\sl276\slmult1\f0\fs22\lang9 This is the Running Demo, which was created to test out the SpriteController: {{\field{\*\fldinst{HYPERLINK http://www.codeproject.com/Articles/1085446/Using-Sprites-Inside-Windows-Forms }}{\fldrslt{http://www.codeproject.com/Articles/1085446/Using-Sprites-Inside-Windows-Forms\ul0\cf0}}}}\f0 [rest of string was truncated]";.
|
||||
/// Looks up a localized string similar to {\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31505\stshfloch31506\stshfhich31506\stshfbi31507\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0{\fonttbl{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f34\fbidi \froman\fcharset1\fprq2{\*\panose 02040503050406030204}Cambria Math;}
|
||||
///{\f39\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;}{\f40\fbidi \fmodern\fcharset0\fprq1{\*\panose 020b0609020204030204}Consolas;}{\ [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string ChangeLog {
|
||||
get {
|
||||
return ResourceManager.GetString("ChangeLog", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||
/// </summary>
|
||||
internal static System.Drawing.Icon SLIcon {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("SLIcon", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -121,4 +121,7 @@
|
||||
<data name="ChangeLog" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ChangeLog.rtf;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
|
||||
</data>
|
||||
<data name="SLIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\SLIcon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
SpriteLibrary/Resources/SLIcon.ico
Normal file
BIN
SpriteLibrary/Resources/SLIcon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
@ -146,6 +146,12 @@ namespace SpriteLibrary
|
||||
|
||||
private SpriteAdjustmentRatio _AdjustmentRatio;
|
||||
|
||||
/// <summary>
|
||||
/// The Sprite Database has tools to load and save sprite definitions, as well as a tool to help
|
||||
/// developers create sprite definitions.
|
||||
/// </summary>
|
||||
private SpriteDatabase myDatabase = null;
|
||||
|
||||
/// <summary>
|
||||
/// If your sprite images need substantial growing or shrinking when displayed, you can try setting this to "true"
|
||||
/// to see if it makes it run any faster. What it does is to resize the image once, and keep a cached copy of that
|
||||
@ -183,6 +189,39 @@ namespace SpriteLibrary
|
||||
Local_Setup();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a sprite controller, specifying the picturebox on which the sprites
|
||||
/// will be displayed. You want to have the PictureBox already defined, and a background image
|
||||
/// already set for the PictureBox. This constructor also uses a <see cref="SpriteDatabase"/>, which
|
||||
/// loads sprite definitions at construction time, and has tools for making and storing sprites.
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// This is an example of a Form class that defines a SpriteController. The MainDrawingArea is a
|
||||
/// <see cref="System.Windows.Forms.PictureBox">PictureBox.</see>
|
||||
/// <code lang="C#">
|
||||
/// public partial class ShootingFieldForm : Form
|
||||
/// {
|
||||
/// public ShootingFieldForm()
|
||||
/// {
|
||||
/// InitializeComponent();
|
||||
/// MainDrawingArea.BackgroundImage = Properties.Resources.Background;
|
||||
/// MainDrawingArea.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
/// MySpriteDatabase = new SpriteDatabase(Properties.Resources.ResourceManager, "MySpriteDefinitions");
|
||||
/// MySpriteController = new SpriteController(MainDrawingArea, MySpriteDatabase);
|
||||
/// }
|
||||
/// }
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// <param name="Area">The <see cref="System.Windows.Forms.PictureBox">PictureBox.</see>
|
||||
/// that the sprites will be drawn in</param>
|
||||
/// <param name="DatabaseToUse">A <see cref="SpriteLibrary.SpriteDatabase">SpriteDatabase</see> to use</param>
|
||||
public SpriteController(PictureBox Area, SpriteDatabase DatabaseToUse)
|
||||
{
|
||||
myDatabase = DatabaseToUse;
|
||||
DrawingArea = Area;
|
||||
Local_Setup();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a sprite controller, specifying the picturebox on which the sprites
|
||||
/// will be displayed.
|
||||
@ -980,6 +1019,11 @@ namespace SpriteLibrary
|
||||
return Found;
|
||||
}
|
||||
}
|
||||
//If we are here, we have not yet found a sprite. Now we can check our database and see if we have one defined
|
||||
if(myDatabase != null)
|
||||
{
|
||||
return myDatabase.SmartDuplicateSprite(this, Name, true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -87,6 +87,8 @@ namespace SpriteLibrary
|
||||
myToolTip.SetToolTip(btnNewSprite, "Create a new sprite.");
|
||||
myToolTip.SetToolTip(btnDeleteAnim, "Delete the current animation you are looking at.");
|
||||
myToolTip.SetToolTip(btnDelSprite, "Delete the current sprite you are looking at.");
|
||||
|
||||
Icon = Properties.Resources.SLIcon;
|
||||
}
|
||||
|
||||
internal List<SpriteInfo> GetUpdatedList()
|
||||
@ -94,6 +96,11 @@ namespace SpriteLibrary
|
||||
return SpriteInformation;
|
||||
}
|
||||
|
||||
internal void SetIcon(Icon IconImage)
|
||||
{
|
||||
Icon = IconImage;
|
||||
}
|
||||
|
||||
private void PopulateMenu()
|
||||
{
|
||||
ResourceManager rm = myResources;
|
||||
|
@ -85,6 +85,9 @@
|
||||
<ItemGroup>
|
||||
<None Include="Resources\ChangeLog.rtf" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\SLIcon.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
Loading…
Reference in New Issue
Block a user