From fac246187526b4c0359ad7612df96d3af8e9a67f Mon Sep 17 00:00:00 2001 From: Tim Young Date: Mon, 18 Sep 2017 10:31:47 -0500 Subject: [PATCH] Fixed some bugs with forward/back and applying new sprites. --- SpriteLibrary/SpriteEntryForm.Designer.cs | 7 ++-- SpriteLibrary/SpriteEntryForm.cs | 41 ++++++++++++++++++----- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/SpriteLibrary/SpriteEntryForm.Designer.cs b/SpriteLibrary/SpriteEntryForm.Designer.cs index 80d9a88..1d094af 100644 --- a/SpriteLibrary/SpriteEntryForm.Designer.cs +++ b/SpriteLibrary/SpriteEntryForm.Designer.cs @@ -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; diff --git a/SpriteLibrary/SpriteEntryForm.cs b/SpriteLibrary/SpriteEntryForm.cs index 52948a9..26452a3 100644 --- a/SpriteLibrary/SpriteEntryForm.cs +++ b/SpriteLibrary/SpriteEntryForm.cs @@ -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 @@ -186,7 +190,7 @@ namespace SpriteLibrary pbImageField.BackgroundImage = new Bitmap(NewImage); pbImageField.Invalidate(); } - } + } } /// @@ -328,22 +332,35 @@ namespace SpriteLibrary } else { - string Try = SpriteDatabase.WriteToXMLString(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(); }