initial saving working (possibly)

This commit is contained in:
Tim Young 2017-09-16 08:23:47 -05:00
parent 4f2d190b6c
commit e9f1a9a3ed
4 changed files with 22 additions and 9 deletions

View File

@ -22,11 +22,12 @@ namespace SpriteLibrary
/// </summary>
public class SpriteDatabase
{
List<SpriteInfo> SpriteInfoList = new List<SpriteInfo>();
public List<SpriteInfo> SpriteInfoList = new List<SpriteInfo>();
List<ImageStruct> TheImages = new List<ImageStruct>();
ResourceManager myResourceManager = null;
string Filename = "";
Size SnapGridSize = new Size(5, 5);
int CurrentSIIndex = -1; //The information item we are editing. -1 means it is a new one.
public SpriteDatabase(ResourceManager theResourceManager, string filename)
{
@ -40,6 +41,11 @@ namespace SpriteLibrary
LoadSpriteInfo();
}
internal ResourceManager GetResourceManager()
{
return myResourceManager;
}
/// <summary>
/// Tell the database to save the sprite definitions. Use this while you are creating your game.
/// When you are done, you will usually want to take your sprite definition file and add it to the
@ -115,7 +121,7 @@ namespace SpriteLibrary
public void OpenEditWindow(int FirstItemIndex=-1)
{
SpriteEntryForm SEF = new SpriteEntryForm(myResourceManager, SpriteInfoList, SnapGridSize);
SpriteEntryForm SEF = new SpriteEntryForm(this, SpriteInfoList, SnapGridSize);
SEF.ShowDialog();
//Use the updated list returned from the form.
SpriteInfoList.Clear();

View File

@ -247,6 +247,7 @@
this.MinimizeBox = false;
this.Name = "SpriteEntryForm";
this.Text = "SpriteEntryForm";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SpriteEntryForm_FormClosing);
((System.ComponentModel.ISupportInitialize)(this.pbImageField)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();

View File

@ -22,12 +22,13 @@ namespace SpriteLibrary
ResourceManager myResources = null;
List<SpriteInfo> SpriteInformation = new List<SpriteInfo>();
Size SnapGridSize = new Size(5,5);
SpriteDatabase myDatabase = null;
internal SpriteEntryForm(ResourceManager theResourceManager, List<SpriteInfo> ListToWorkOn, Size GridSize)
internal SpriteEntryForm(SpriteDatabase theDatabase, List<SpriteInfo> ListToWorkOn, Size GridSize)
{
InitializeComponent();
if (theResourceManager == null) throw new Exception("NullException: The ResourceManager passed to the SpriteEntryForm cannot be null. Pass it Properties.Resources.ResourceManager");
myResources = theResourceManager;
myDatabase = theDatabase;
myResources = myDatabase.GetResourceManager();
SnapGridSize = GridSize;
LocalSetup();
SpriteInformation.AddRange(ListToWorkOn);
@ -87,5 +88,10 @@ namespace SpriteLibrary
}
}
}
private void SpriteEntryForm_FormClosing(object sender, FormClosingEventArgs e)
{
myDatabase.Save(); //try saving the file
}
}
}

View File

@ -35,11 +35,11 @@ namespace SpriteLibrary
}
}
internal class SpriteInfo
public class SpriteInfo
{
public string SpriteName = "";
public int ViewPercent = 100; //The percent size of the sprite. 100 is full. 50 is half-size
public List<AnimationInfo> Animations = new List<AnimationInfo>();
internal string SpriteName = "";
internal int ViewPercent = 100; //The percent size of the sprite. 100 is full. 50 is half-size
internal List<AnimationInfo> Animations = new List<AnimationInfo>();
/// <summary>
/// A generic cloning method that works when everything is public