Fixed some bugs with forward/back and applying new sprites.

This commit is contained in:
Tim Young 2017-09-18 10:31:47 -05:00
parent 273c381389
commit fac2461875
2 changed files with 37 additions and 11 deletions

View File

@ -181,6 +181,7 @@
this.btnNewSprite.TabIndex = 11;
this.btnNewSprite.Text = "New Sprite";
this.btnNewSprite.UseVisualStyleBackColor = true;
this.btnNewSprite.Click += new System.EventHandler(this.btnNewSprite_Click);
//
// tbAmimationSpeed
//
@ -217,7 +218,7 @@
// btnBack
//
this.btnBack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnBack.Location = new System.Drawing.Point(49, 322);
this.btnBack.Location = new System.Drawing.Point(25, 322);
this.btnBack.Name = "btnBack";
this.btnBack.Size = new System.Drawing.Size(29, 23);
this.btnBack.TabIndex = 16;
@ -228,7 +229,7 @@
// btnFwd
//
this.btnFwd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnFwd.Location = new System.Drawing.Point(131, 322);
this.btnFwd.Location = new System.Drawing.Point(177, 322);
this.btnFwd.Name = "btnFwd";
this.btnFwd.Size = new System.Drawing.Size(29, 23);
this.btnFwd.TabIndex = 17;
@ -240,7 +241,7 @@
//
this.lblCountSprites.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblCountSprites.AutoSize = true;
this.lblCountSprites.Location = new System.Drawing.Point(95, 325);
this.lblCountSprites.Location = new System.Drawing.Point(75, 325);
this.lblCountSprites.Name = "lblCountSprites";
this.lblCountSprites.Size = new System.Drawing.Size(16, 17);
this.lblCountSprites.TabIndex = 18;

View File

@ -42,6 +42,10 @@ namespace SpriteLibrary
SnapGridSize = GridSize;
LocalSetup();
SpriteInformation.AddRange(ListToWorkOn);
if (SpriteInformation.Count > 0)
{
SelectNewIndex(0);
}
}
private void LocalSetup()
@ -93,7 +97,7 @@ namespace SpriteLibrary
private void UpdateMenu()
{
SuspendLayout();
lblCountSprites.Text = SpriteInformation.Count.ToString();
lblCountSprites.Text = CurrentSIIndex+":"+CurrentSIAnimation+" of " + SpriteInformation.Count.ToString();
if (TempInformation == null) SetUpEmptyInfo();
//Put in numbers into the combo-box of which frame to base ourselves off of
@ -328,22 +332,35 @@ namespace SpriteLibrary
}
else
{
string Try = SpriteDatabase.WriteToXMLString<SpriteInfo>(TempInformation);
SpriteInformation.Add(TempInformation);
SpriteInformation.Add(TempInformation.Clone());
CurrentSIIndex = SpriteInformation.IndexOf(TempInformation);
}
UpdateMenu();
}
private void WeHaveNewItem()
{
TempInformation.CopyFrom(SpriteInformation[CurrentSIIndex]);
SpriteInformationToForm();
UpdateMenu();
}
private void SelectNewIndex(int nindex)
{
if (nindex < 0) return;
if (nindex >= SpriteInformation.Count) return;
CurrentSIIndex = nindex;
TempInformation = SpriteInformation[nindex].Clone();
WeHaveNewItem();
UpdateMenu();
}
private void btnFwd_Click(object sender, EventArgs e)
{
if (SpriteInformation.Count == 0) return; //nothing to do
CurrentSIIndex++;
if (CurrentSIIndex >= SpriteInformation.Count) CurrentSIIndex = 0;
if (TempInformation == null) TempInformation = new SpriteInfo();
TempInformation.CopyFrom(SpriteInformation[CurrentSIIndex]);
SpriteInformationToForm();
UpdateMenu();
WeHaveNewItem();
}
private void btnBack_Click(object sender, EventArgs e)
@ -352,7 +369,15 @@ namespace SpriteLibrary
CurrentSIIndex--;
if (CurrentSIIndex < 0) CurrentSIIndex = SpriteInformation.Count - 1;
if (TempInformation == null) TempInformation = new SpriteInfo();
TempInformation.CopyFrom(SpriteInformation[CurrentSIIndex]);
WeHaveNewItem();
}
private void btnNewSprite_Click(object sender, EventArgs e)
{
TempInformation = null;
CurrentSIIndex = -1;
SetUpEmptyInfo();
SpriteInformationToForm();
UpdateMenu();
}