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.TabIndex = 11;
this.btnNewSprite.Text = "New Sprite"; this.btnNewSprite.Text = "New Sprite";
this.btnNewSprite.UseVisualStyleBackColor = true; this.btnNewSprite.UseVisualStyleBackColor = true;
this.btnNewSprite.Click += new System.EventHandler(this.btnNewSprite_Click);
// //
// tbAmimationSpeed // tbAmimationSpeed
// //
@ -217,7 +218,7 @@
// btnBack // btnBack
// //
this.btnBack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 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.Name = "btnBack";
this.btnBack.Size = new System.Drawing.Size(29, 23); this.btnBack.Size = new System.Drawing.Size(29, 23);
this.btnBack.TabIndex = 16; this.btnBack.TabIndex = 16;
@ -228,7 +229,7 @@
// btnFwd // btnFwd
// //
this.btnFwd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 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.Name = "btnFwd";
this.btnFwd.Size = new System.Drawing.Size(29, 23); this.btnFwd.Size = new System.Drawing.Size(29, 23);
this.btnFwd.TabIndex = 17; 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.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblCountSprites.AutoSize = true; 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.Name = "lblCountSprites";
this.lblCountSprites.Size = new System.Drawing.Size(16, 17); this.lblCountSprites.Size = new System.Drawing.Size(16, 17);
this.lblCountSprites.TabIndex = 18; this.lblCountSprites.TabIndex = 18;

View File

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