Extensions & Frame Restructuring

Implemented Custom Extensions for SpriteMaps (*.smap), Animations (*.anim) and AnimationSets (*.animset).

Also restructured Frame to be a container for SpriteMapRegions rather than an extension of them. This will enable easier access to updating them when loading SpriteMaps in the Editor.
This commit is contained in:
quinnvoker
2018-11-25 21:28:32 -08:00
parent f57a0334cf
commit 3e24ac9527
8 changed files with 47 additions and 75 deletions
+7 -1
View File
@@ -39,14 +39,20 @@
<HintPath>..\packages\MonoGame.Forms.DX.2.1.0.2\lib\net451\MonoGame.Framework.dll</HintPath>
</Reference>
<Reference Include="SharpDX, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\packages\MonoGame.Forms.DX.2.1.0.2\lib\net451\SharpDX.dll</HintPath>
<HintPath>..\packages\SharpDX.4.0.1\lib\net45\SharpDX.dll</HintPath>
</Reference>
<Reference Include="SharpDX.Direct3D11, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\packages\MonoGame.Forms.DX.2.1.0.2\lib\net451\SharpDX.Direct3D11.dll</HintPath>
</Reference>
<Reference Include="SharpDX.Direct3D9, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\packages\SharpDX.Direct3D9.4.0.1\lib\net45\SharpDX.Direct3D9.dll</HintPath>
</Reference>
<Reference Include="SharpDX.DXGI, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\packages\MonoGame.Forms.DX.2.1.0.2\lib\net451\SharpDX.DXGI.dll</HintPath>
</Reference>
<Reference Include="SharpDX.Mathematics, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\packages\SharpDX.Mathematics.4.0.1\lib\net45\SharpDX.Mathematics.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
+10 -6
View File
@@ -88,9 +88,9 @@
//
// loadSpriteMapDialog
//
this.loadSpriteMapDialog.DefaultExt = "xml";
this.loadSpriteMapDialog.DefaultExt = "smap";
this.loadSpriteMapDialog.FileName = "openFileDialog1";
this.loadSpriteMapDialog.Filter = "Xml Files|*.xml";
this.loadSpriteMapDialog.Filter = "QUROGames SpriteMap|*smap";
//
// spriteListBox
//
@@ -321,17 +321,19 @@
//
// saveAnimationDialog
//
this.saveAnimationDialog.DefaultExt = "xml";
this.saveAnimationDialog.Filter = "Xml Files|*.xml";
this.saveAnimationDialog.DefaultExt = "anim";
this.saveAnimationDialog.Filter = "QUROGames Animation|*.anim";
//
// saveAnimationSetDialog
//
this.saveAnimationSetDialog.DefaultExt = "xml";
this.saveAnimationSetDialog.Filter = "Xml files|*.xml";
this.saveAnimationSetDialog.DefaultExt = "animset";
this.saveAnimationSetDialog.Filter = "QUROGames AnimationSet|*.animSet";
//
// loadAnimationDialog
//
this.loadAnimationDialog.DefaultExt = "anim";
this.loadAnimationDialog.FileName = "openFileDialog1";
this.loadAnimationDialog.Filter = "QUROGames Animation|*.anim";
//
// addAnimationButton
//
@@ -497,7 +499,9 @@
//
// loadAnimationSetDialog
//
this.loadAnimationSetDialog.DefaultExt = "animset";
this.loadAnimationSetDialog.FileName = "openFileDialog1";
this.loadAnimationSetDialog.Filter = "QUROGames AnimationSet|*.animSet";
//
// Form1
//
+14 -9
View File
@@ -85,9 +85,12 @@ namespace AnimationEditor
animationPreview.Enabled = true;
}
private void InitiateAnimationList()
private void InitiateAnimationList(bool newAnimation = true)
{
Animations = new BindingList<Animation>();
if (newAnimation)
Animations = new BindingList<Animation>() { new Animation() };
else
Animations = new BindingList<Animation>();
animationBox.DataSource = Animations;
animationBox.DisplayMember = "Name";
}
@@ -210,6 +213,7 @@ namespace AnimationEditor
FileStream fileStream = new FileStream(loadSpriteSheetDialog.FileName, FileMode.Open);
SpriteSheet = Texture2D.FromStream(animationPreview.Editor.graphics, fileStream);
EnableMapAndAnimationLoadingControls();
fileStream.Close();
}
}
@@ -238,6 +242,7 @@ namespace AnimationEditor
Frames = new BindingList<Frame>();
frameListBox.DataSource = Frames;
frameListBox.DisplayMember = "Name";
InitiateAnimationList();
}
EnableSpriteMapControls();
@@ -420,10 +425,10 @@ namespace AnimationEditor
private void saveAnimationSetToolStripMenuItem_Click(object sender, EventArgs e)
{
var animSet = new Dictionary<string, Animation>();
var animSet = new AnimationSet();
foreach(Animation anim in Animations)
{
if (animSet.ContainsKey(anim.Name))
if (animSet.Anims.ContainsKey(anim.Name))
{
string errorMessage = "Duplicate names found! Please ensure all animations have unique names.";
string caption = "Save Aborted";
@@ -434,7 +439,7 @@ namespace AnimationEditor
}
else
{
animSet.Add(anim.Name, anim);
animSet.Add(anim);
}
}
@@ -451,19 +456,19 @@ namespace AnimationEditor
{
if (loadAnimationSetDialog.ShowDialog() == DialogResult.OK)
{
Dictionary<string, Animation> loadedAnimSet;
AnimationSet loadedAnimSet;
using (XmlReader xmlRead = XmlReader.Create(loadAnimationSetDialog.FileName))
{
loadedAnimSet = IntermediateSerializer.Deserialize<Dictionary<string, Animation>>(xmlRead, null);
loadedAnimSet = IntermediateSerializer.Deserialize<AnimationSet>(xmlRead, null);
}
if (animationBox.Enabled == false)
{
EnableAnimationEditingControls();
}
InitiateAnimationList();
foreach(KeyValuePair<string,Animation> currentEntry in loadedAnimSet)
InitiateAnimationList(newAnimation: false);
foreach(KeyValuePair<string,Animation> currentEntry in loadedAnimSet.Anims)
{
Animations.Add(currentEntry.Value);
}
+3
View File
@@ -1,4 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MonoGame.Forms.DX" version="2.1.0.2" targetFramework="net451" />
<package id="SharpDX" version="4.0.1" targetFramework="net451" />
<package id="SharpDX.Direct3D9" version="4.0.1" targetFramework="net451" />
<package id="SharpDX.Mathematics" version="4.0.1" targetFramework="net451" />
</packages>
-6
View File
@@ -7,8 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PuzzSwap", "PuzzSwap\PuzzSw
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QURO.AnimationLibrary", "QURO.AnimationLibrary\QURO.AnimationLibrary.csproj", "{69DADC27-FBEB-4625-9212-6EB5BED5102A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnimationGenerator", "AnimationGenerator\AnimationGenerator.csproj", "{B1938BD7-A474-427F-91F1-F8A1875B28CE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QURO", "QURO\QURO.csproj", "{4581E0C8-B14A-454D-9A7B-52D37535E7E9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpriteMapEditor", "SpriteMapEditor\SpriteMapEditor.csproj", "{2AF6999F-93F0-4096-9BC1-863CEE5E7791}"
@@ -29,10 +27,6 @@ Global
{69DADC27-FBEB-4625-9212-6EB5BED5102A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69DADC27-FBEB-4625-9212-6EB5BED5102A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69DADC27-FBEB-4625-9212-6EB5BED5102A}.Release|Any CPU.Build.0 = Release|Any CPU
{B1938BD7-A474-427F-91F1-F8A1875B28CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B1938BD7-A474-427F-91F1-F8A1875B28CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1938BD7-A474-427F-91F1-F8A1875B28CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1938BD7-A474-427F-91F1-F8A1875B28CE}.Release|Any CPU.Build.0 = Release|Any CPU
{4581E0C8-B14A-454D-9A7B-52D37535E7E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4581E0C8-B14A-454D-9A7B-52D37535E7E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4581E0C8-B14A-454D-9A7B-52D37535E7E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+1 -17
View File
@@ -11,11 +11,8 @@ namespace QURO.AnimationLibrary
public bool IsStillImage => Frames.Length <= 1;
public Animation()
public Animation() : this("unnamed", new Frame[] { new Frame() }, false)
{
Name = "unnamed";
Frames = new Frame[] { new Frame() };
IsLooping = false;
}
public Animation(string name, Frame[] frames, bool loop)
@@ -24,18 +21,5 @@ namespace QURO.AnimationLibrary
Frames = frames;
IsLooping = loop;
}
public Animation(string name, Rectangle[] sourceRects, float delay, bool loop)
{
Name = name;
Frames = new Frame[sourceRects.Length];
for(int index = 0; index < sourceRects.Length; index++)
{
Frames[index] = new Frame(sourceRects[index], delay);
}
IsLooping = loop;
}
}
}
+8 -33
View File
@@ -3,47 +3,22 @@ using Microsoft.Xna.Framework;
namespace QURO.AnimationLibrary
{
public class Frame : SpriteMapRegion
public class Frame
{
public SpriteMapRegion Sprite { get; set; }
public float Delay { get; set; }
public Frame()
public string Name { get { return Sprite.Name; } }
public Rectangle Bounds { get { return Sprite.Bounds; } }
public Vector2 Origin { get { return Sprite.Origin; } }
public Frame() : this(new SpriteMapRegion(), 0)
{
Name = "empty";
Bounds = Rectangle.Empty;
Origin = Vector2.Zero;
Delay = 0;
}
public Frame(SpriteMapRegion sprite, float delay)
{
Name = sprite.Name;
Bounds = sprite.Bounds;
Origin = sprite.Origin;
Delay = delay;
}
public Frame(string name, Rectangle bounds, float delay, Vector2 origin)
{
Name = name;
Bounds = bounds;
Origin = origin;
Delay = delay;
}
public Frame(Rectangle bounds, float delay, Vector2 origin)
{
Name = "unnamed";
Bounds = bounds;
Origin = origin;
Delay = delay;
}
public Frame(Rectangle bounds, float delay)
{
Name = "unnamed";
Bounds = bounds;
Origin = Vector2.Zero;
Sprite = sprite;
Delay = delay;
}
}
+4 -3
View File
@@ -388,13 +388,14 @@
//
// loadMapDialog
//
this.loadMapDialog.DefaultExt = "smap";
this.loadMapDialog.FileName = "openFileDialog1";
this.loadMapDialog.Filter = "Xml files|*.xml";
this.loadMapDialog.Filter = "QUROGame SpriteMap|*.smap";
//
// saveMapDialog
//
this.saveMapDialog.DefaultExt = "xml";
this.saveMapDialog.Filter = "Xml files|*.xml";
this.saveMapDialog.DefaultExt = "smap";
this.saveMapDialog.Filter = "QUROGame SpriteMap|*.smap";
//
// fillButton
//