SpriteMapEditor Rework

-Renamed Sprite to SpriteMapRegion
-Updated Frame code in QURO.AnimationLibrary to use SpriteMapRegions instead of Rectangles
-Replaced Drag and drop sprite rearrangement behaviour in Editor with simpler, less buggy up/down button system
-Changed Editor's save/load format to be a MonoGame compatible Dictionary<string, SpriteMapRegion> rather than a List
This commit is contained in:
quinnvoker
2018-11-23 23:30:24 -08:00
parent acda9d30fc
commit 82ad36e485
10 changed files with 299 additions and 165 deletions
+4 -1
View File
@@ -71,7 +71,6 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Sprite.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
@@ -103,6 +102,10 @@
<Project>{69dadc27-fbeb-4625-9212-6eb5bed5102a}</Project>
<Name>QURO.AnimationLibrary</Name>
</ProjectReference>
<ProjectReference Include="..\QURO\QURO.csproj">
<Project>{4581e0c8-b14a-454d-9a7b-52d37535e7e9}</Project>
<Name>QURO</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+21 -22
View File
@@ -32,9 +32,9 @@
this.loadSpriteSheetDialog = new System.Windows.Forms.OpenFileDialog();
this.loadSpriteMapButton = new System.Windows.Forms.Button();
this.loadSpriteMapDialog = new System.Windows.Forms.OpenFileDialog();
this.spritesListBox = new System.Windows.Forms.ListBox();
this.spriteListBox = new System.Windows.Forms.ListBox();
this.animationPreview = new AnimationEditor.AnimationPreview();
this.listBox1 = new System.Windows.Forms.ListBox();
this.frameListBox = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// loadSpriteSheetButton
@@ -70,41 +70,40 @@
this.loadSpriteMapDialog.FileName = "openFileDialog1";
this.loadSpriteMapDialog.Filter = "Xml Files|*.xml";
//
// spritesListBox
// spriteListBox
//
this.spritesListBox.FormattingEnabled = true;
this.spritesListBox.Location = new System.Drawing.Point(28, 104);
this.spritesListBox.Name = "spritesListBox";
this.spritesListBox.Size = new System.Drawing.Size(119, 264);
this.spritesListBox.TabIndex = 3;
this.spriteListBox.FormattingEnabled = true;
this.spriteListBox.Location = new System.Drawing.Point(28, 104);
this.spriteListBox.Name = "spriteListBox";
this.spriteListBox.Size = new System.Drawing.Size(119, 264);
this.spriteListBox.TabIndex = 3;
this.spriteListBox.MouseDown += new System.Windows.Forms.MouseEventHandler(this.spriteListBox_MouseDown);
//
// animationPreview
//
this.animationPreview.CurrentAnimation = null;
this.animationPreview.Location = new System.Drawing.Point(351, 73);
this.animationPreview.Location = new System.Drawing.Point(413, 74);
this.animationPreview.Name = "animationPreview";
this.animationPreview.PreviewSprite = null;
this.animationPreview.Size = new System.Drawing.Size(253, 198);
this.animationPreview.SpriteSheet = null;
this.animationPreview.TabIndex = 0;
this.animationPreview.Text = "animationPreview1";
//
// listBox1
// frameListBox
//
this.listBox1.AllowDrop = true;
this.listBox1.FormattingEnabled = true;
this.listBox1.Location = new System.Drawing.Point(166, 104);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(120, 264);
this.listBox1.TabIndex = 4;
this.frameListBox.AllowDrop = true;
this.frameListBox.FormattingEnabled = true;
this.frameListBox.Location = new System.Drawing.Point(166, 104);
this.frameListBox.Name = "frameListBox";
this.frameListBox.Size = new System.Drawing.Size(120, 264);
this.frameListBox.TabIndex = 4;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.spritesListBox);
this.Controls.Add(this.frameListBox);
this.Controls.Add(this.spriteListBox);
this.Controls.Add(this.loadSpriteMapButton);
this.Controls.Add(this.loadSpriteSheetButton);
this.Controls.Add(this.animationPreview);
@@ -121,8 +120,8 @@
private System.Windows.Forms.OpenFileDialog loadSpriteSheetDialog;
private System.Windows.Forms.Button loadSpriteMapButton;
private System.Windows.Forms.OpenFileDialog loadSpriteMapDialog;
private System.Windows.Forms.ListBox spritesListBox;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.ListBox spriteListBox;
private System.Windows.Forms.ListBox frameListBox;
}
}
+16 -6
View File
@@ -12,12 +12,14 @@ using System.Xml.Serialization;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using QURO.AnimationLibrary;
using QURO;
namespace AnimationEditor
{
public partial class Form1 : Form
{
public BindingList<Sprite> Sprites { get; set; }
private SpriteMapRegion draggedSprite;
public BindingList<SpriteMapRegion> Sprites { get; set; }
public Form1()
{
@@ -39,18 +41,26 @@ namespace AnimationEditor
if (loadSpriteMapDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
XmlSerializer mapSerializer = new XmlSerializer(typeof(List<Sprite>));
XmlSerializer mapSerializer = new XmlSerializer(typeof(List<SpriteMapRegion>));
TextReader mapReader = new StreamReader(loadSpriteMapDialog.FileName);
Sprites = new BindingList<Sprite>((List<Sprite>)mapSerializer.Deserialize(mapReader));
spritesListBox.DataSource = Sprites;
spritesListBox.DisplayMember = "Name";
spritesListBox.ValueMember = "Bounds";
Sprites = new BindingList<SpriteMapRegion>((List<SpriteMapRegion>)mapSerializer.Deserialize(mapReader));
spriteListBox.DataSource = Sprites;
spriteListBox.DisplayMember = "Name";
spriteListBox.ValueMember = "Bounds";
Rectangle[] frames = new Rectangle[] { Sprites[0].Bounds, Sprites[1].Bounds, Sprites[2].Bounds };
animationPreview.CurrentAnimation = new Animation("Test", frames, 1f / 60f, true);
animationPreview.PreviewSprite = new AnimatedSprite(animationPreview.SpriteSheet, animationPreview.CurrentAnimation);
mapReader.Close();
}
}
private void spriteListBox_MouseDown(object sender, MouseEventArgs e)
{
if (spriteListBox.SelectedItem == null)
return;
spriteListBox.DoDragDrop(spriteListBox.SelectedItem, DragDropEffects.Copy);
draggedSprite = (SpriteMapRegion)spriteListBox.SelectedItem;
}
}
}
-22
View File
@@ -1,22 +0,0 @@
using Microsoft.Xna.Framework;
namespace AnimationEditor
{
public class Sprite
{
public string Name { get; set; }
public Rectangle Bounds { get; set; }
public Sprite()
{
Name = "unnamed";
Bounds = new Rectangle(1, 1, 8, 8);
}
public Sprite(string name, Rectangle bounds)
{
Name = name;
Bounds = bounds;
}
}
}