Made AnimationEditor compatible with Dictionary SpriteMaps

Added MonoGame Pipeline's IntermediateSerializer and needed classes from the pipeline and  MonoGame.Framework.Utilities to make AnimationEditor capable of reading Dictionaries
This commit is contained in:
quinnvoker
2018-11-24 16:43:44 -08:00
parent 82ad36e485
commit c585f312a5
52 changed files with 3576 additions and 64 deletions
+37 -37
View File
@@ -37,6 +37,8 @@
this.saveMapButton = new System.Windows.Forms.Button();
this.filePanel = new System.Windows.Forms.Panel();
this.spriteListPanel = new System.Windows.Forms.Panel();
this.moveDownButton = new System.Windows.Forms.Button();
this.moveUpButton = new System.Windows.Forms.Button();
this.spritesLabel = new System.Windows.Forms.Label();
this.spritePanel = new System.Windows.Forms.Panel();
this.originYPosBox = new System.Windows.Forms.NumericUpDown();
@@ -54,17 +56,15 @@
this.label2 = new System.Windows.Forms.Label();
this.spriteSettingsLabel = new System.Windows.Forms.Label();
this.spriteNameBox = new System.Windows.Forms.TextBox();
this.loadSpriteSheetDialogue = new System.Windows.Forms.OpenFileDialog();
this.loadMapDialogue = new System.Windows.Forms.OpenFileDialog();
this.saveMapDialogue = new System.Windows.Forms.SaveFileDialog();
this.loadSpriteSheetDialog = new System.Windows.Forms.OpenFileDialog();
this.loadMapDialog = new System.Windows.Forms.OpenFileDialog();
this.saveMapDialog = new System.Windows.Forms.SaveFileDialog();
this.fillButton = new System.Windows.Forms.Button();
this.spriteViewerPanel = new System.Windows.Forms.Panel();
this.spriteSheetViewer = new SpriteMapEditor.PictureBoxWithInterpolationMode();
this.zoomInButton = new System.Windows.Forms.Button();
this.zoomOutButton = new System.Windows.Forms.Button();
this.zoomLabel = new System.Windows.Forms.Label();
this.moveDownButton = new System.Windows.Forms.Button();
this.moveUpButton = new System.Windows.Forms.Button();
this.filePanel.SuspendLayout();
this.spriteListPanel.SuspendLayout();
this.spritePanel.SuspendLayout();
@@ -165,6 +165,26 @@
this.spriteListPanel.Size = new System.Drawing.Size(190, 254);
this.spriteListPanel.TabIndex = 8;
//
// moveDownButton
//
this.moveDownButton.Location = new System.Drawing.Point(39, 233);
this.moveDownButton.Name = "moveDownButton";
this.moveDownButton.Size = new System.Drawing.Size(70, 18);
this.moveDownButton.TabIndex = 5;
this.moveDownButton.Text = "▼";
this.moveDownButton.UseVisualStyleBackColor = true;
this.moveDownButton.Click += new System.EventHandler(this.moveDownButton_Click);
//
// moveUpButton
//
this.moveUpButton.Location = new System.Drawing.Point(115, 233);
this.moveUpButton.Name = "moveUpButton";
this.moveUpButton.Size = new System.Drawing.Size(71, 18);
this.moveUpButton.TabIndex = 6;
this.moveUpButton.Text = "▲";
this.moveUpButton.UseVisualStyleBackColor = true;
this.moveUpButton.Click += new System.EventHandler(this.moveUpButton_Click);
//
// spritesLabel
//
this.spritesLabel.AutoSize = true;
@@ -361,20 +381,20 @@
this.spriteNameBox.TabIndex = 0;
this.spriteNameBox.TextChanged += new System.EventHandler(this.spriteNameBox_TextChanged);
//
// loadSpriteSheetDialogue
// loadSpriteSheetDialog
//
this.loadSpriteSheetDialogue.FileName = "openFileDialog1";
this.loadSpriteSheetDialogue.Filter = "PNG files|*.png";
this.loadSpriteSheetDialog.FileName = "openFileDialog1";
this.loadSpriteSheetDialog.Filter = "PNG files|*.png";
//
// loadMapDialogue
// loadMapDialog
//
this.loadMapDialogue.FileName = "openFileDialog1";
this.loadMapDialogue.Filter = "Xml files|*.xml";
this.loadMapDialog.FileName = "openFileDialog1";
this.loadMapDialog.Filter = "Xml files|*.xml";
//
// saveMapDialogue
// saveMapDialog
//
this.saveMapDialogue.DefaultExt = "xml";
this.saveMapDialogue.Filter = "Xml files|*.xml";
this.saveMapDialog.DefaultExt = "xml";
this.saveMapDialog.Filter = "Xml files|*.xml";
//
// fillButton
//
@@ -444,26 +464,6 @@
this.zoomLabel.TabIndex = 15;
this.zoomLabel.Text = "Zoom: 3X";
//
// moveDownButton
//
this.moveDownButton.Location = new System.Drawing.Point(39, 233);
this.moveDownButton.Name = "moveDownButton";
this.moveDownButton.Size = new System.Drawing.Size(70, 18);
this.moveDownButton.TabIndex = 5;
this.moveDownButton.Text = "▼";
this.moveDownButton.UseVisualStyleBackColor = true;
this.moveDownButton.Click += new System.EventHandler(this.moveDownButton_Click);
//
// moveUpButton
//
this.moveUpButton.Location = new System.Drawing.Point(115, 233);
this.moveUpButton.Name = "moveUpButton";
this.moveUpButton.Size = new System.Drawing.Size(71, 18);
this.moveUpButton.TabIndex = 6;
this.moveUpButton.Text = "▲";
this.moveUpButton.UseVisualStyleBackColor = true;
this.moveUpButton.Click += new System.EventHandler(this.moveUpButton_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -517,9 +517,9 @@
private System.Windows.Forms.Label heightLabel;
private System.Windows.Forms.Label widthLabel;
private System.Windows.Forms.Label yPosLabel;
private System.Windows.Forms.OpenFileDialog loadSpriteSheetDialogue;
private System.Windows.Forms.OpenFileDialog loadMapDialogue;
private System.Windows.Forms.SaveFileDialog saveMapDialogue;
private System.Windows.Forms.OpenFileDialog loadSpriteSheetDialog;
private System.Windows.Forms.OpenFileDialog loadMapDialog;
private System.Windows.Forms.SaveFileDialog saveMapDialog;
private System.Windows.Forms.Button fillButton;
private PictureBoxWithInterpolationMode spriteSheetViewer;
private System.Windows.Forms.Panel spriteViewerPanel;
+18 -17
View File
@@ -64,9 +64,9 @@ namespace SpriteMapEditor
private void loadSpriteSheetButton_Click(object sender, EventArgs e)
{
if(loadSpriteSheetDialogue.ShowDialog() == System.Windows.Forms.DialogResult.OK)
if(loadSpriteSheetDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
spriteSheetViewer.Image = Image.FromFile(loadSpriteSheetDialogue.FileName);
spriteSheetViewer.Image = Image.FromFile(loadSpriteSheetDialog.FileName);
}
}
@@ -282,23 +282,24 @@ namespace SpriteMapEditor
private void saveMapButton_Click(object sender, EventArgs e)
{
if (saveMapDialogue.ShowDialog() == System.Windows.Forms.DialogResult.OK)
var exportDict = new Dictionary<string, SpriteMapRegion>();
foreach (SpriteMapRegion sprite in sprites)
{
var exportDict = new Dictionary<string, SpriteMapRegion>();
foreach(SpriteMapRegion sprite in sprites)
if (exportDict.ContainsKey(sprite.Name))
{
if (exportDict.ContainsKey(sprite.Name))
{
string errorMessage = "Duplicate names found! Please ensure all sprites have unique names.";
string caption = "Save Aborted";
MessageBoxButtons saveError = MessageBoxButtons.OK;
string errorMessage = "Duplicate names found! Please ensure all sprites have unique names.";
string caption = "Save Aborted";
MessageBoxButtons saveError = MessageBoxButtons.OK;
MessageBox.Show(errorMessage, caption, saveError);
}
else
exportDict.Add(sprite.Name, sprite);
MessageBox.Show(errorMessage, caption, saveError);
return;
}
using (XmlWriter writer = XmlWriter.Create(saveMapDialogue.FileName))
exportDict.Add(sprite.Name, sprite);
}
if (saveMapDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
using (XmlWriter writer = XmlWriter.Create(saveMapDialog.FileName))
{
IntermediateSerializer.Serialize(writer, exportDict, null);
}
@@ -307,10 +308,10 @@ namespace SpriteMapEditor
private void loadMapButton_Click(object sender, EventArgs e)
{
if(loadMapDialogue.ShowDialog() == System.Windows.Forms.DialogResult.OK)
if(loadMapDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
Dictionary<string, SpriteMapRegion> loadedSpriteMap;
using (XmlReader xmlRead = XmlReader.Create(loadMapDialogue.FileName))
using (XmlReader xmlRead = XmlReader.Create(loadMapDialog.FileName))
{
loadedSpriteMap = IntermediateSerializer.Deserialize<Dictionary<string, SpriteMapRegion>>(xmlRead, null);
}
+6 -6
View File
@@ -117,14 +117,14 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="loadSpriteSheetDialogue.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="loadSpriteSheetDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>152, 17</value>
</metadata>
<metadata name="loadMapDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="loadMapDialogue.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>204, 17</value>
</metadata>
<metadata name="saveMapDialogue.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>353, 17</value>
<metadata name="saveMapDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>325, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="spriteSheetViewer.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">