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:
@@ -39,14 +39,20 @@
|
|||||||
<HintPath>..\packages\MonoGame.Forms.DX.2.1.0.2\lib\net451\MonoGame.Framework.dll</HintPath>
|
<HintPath>..\packages\MonoGame.Forms.DX.2.1.0.2\lib\net451\MonoGame.Framework.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="SharpDX, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
|
<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>
|
||||||
<Reference Include="SharpDX.Direct3D11, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
|
<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>
|
<HintPath>..\packages\MonoGame.Forms.DX.2.1.0.2\lib\net451\SharpDX.Direct3D11.dll</HintPath>
|
||||||
</Reference>
|
</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">
|
<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>
|
<HintPath>..\packages\MonoGame.Forms.DX.2.1.0.2\lib\net451\SharpDX.DXGI.dll</HintPath>
|
||||||
</Reference>
|
</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" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
|||||||
Generated
+10
-6
@@ -88,9 +88,9 @@
|
|||||||
//
|
//
|
||||||
// loadSpriteMapDialog
|
// loadSpriteMapDialog
|
||||||
//
|
//
|
||||||
this.loadSpriteMapDialog.DefaultExt = "xml";
|
this.loadSpriteMapDialog.DefaultExt = "smap";
|
||||||
this.loadSpriteMapDialog.FileName = "openFileDialog1";
|
this.loadSpriteMapDialog.FileName = "openFileDialog1";
|
||||||
this.loadSpriteMapDialog.Filter = "Xml Files|*.xml";
|
this.loadSpriteMapDialog.Filter = "QUROGames SpriteMap|*smap";
|
||||||
//
|
//
|
||||||
// spriteListBox
|
// spriteListBox
|
||||||
//
|
//
|
||||||
@@ -321,17 +321,19 @@
|
|||||||
//
|
//
|
||||||
// saveAnimationDialog
|
// saveAnimationDialog
|
||||||
//
|
//
|
||||||
this.saveAnimationDialog.DefaultExt = "xml";
|
this.saveAnimationDialog.DefaultExt = "anim";
|
||||||
this.saveAnimationDialog.Filter = "Xml Files|*.xml";
|
this.saveAnimationDialog.Filter = "QUROGames Animation|*.anim";
|
||||||
//
|
//
|
||||||
// saveAnimationSetDialog
|
// saveAnimationSetDialog
|
||||||
//
|
//
|
||||||
this.saveAnimationSetDialog.DefaultExt = "xml";
|
this.saveAnimationSetDialog.DefaultExt = "animset";
|
||||||
this.saveAnimationSetDialog.Filter = "Xml files|*.xml";
|
this.saveAnimationSetDialog.Filter = "QUROGames AnimationSet|*.animSet";
|
||||||
//
|
//
|
||||||
// loadAnimationDialog
|
// loadAnimationDialog
|
||||||
//
|
//
|
||||||
|
this.loadAnimationDialog.DefaultExt = "anim";
|
||||||
this.loadAnimationDialog.FileName = "openFileDialog1";
|
this.loadAnimationDialog.FileName = "openFileDialog1";
|
||||||
|
this.loadAnimationDialog.Filter = "QUROGames Animation|*.anim";
|
||||||
//
|
//
|
||||||
// addAnimationButton
|
// addAnimationButton
|
||||||
//
|
//
|
||||||
@@ -497,7 +499,9 @@
|
|||||||
//
|
//
|
||||||
// loadAnimationSetDialog
|
// loadAnimationSetDialog
|
||||||
//
|
//
|
||||||
|
this.loadAnimationSetDialog.DefaultExt = "animset";
|
||||||
this.loadAnimationSetDialog.FileName = "openFileDialog1";
|
this.loadAnimationSetDialog.FileName = "openFileDialog1";
|
||||||
|
this.loadAnimationSetDialog.Filter = "QUROGames AnimationSet|*.animSet";
|
||||||
//
|
//
|
||||||
// Form1
|
// Form1
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -85,9 +85,12 @@ namespace AnimationEditor
|
|||||||
animationPreview.Enabled = true;
|
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.DataSource = Animations;
|
||||||
animationBox.DisplayMember = "Name";
|
animationBox.DisplayMember = "Name";
|
||||||
}
|
}
|
||||||
@@ -210,6 +213,7 @@ namespace AnimationEditor
|
|||||||
FileStream fileStream = new FileStream(loadSpriteSheetDialog.FileName, FileMode.Open);
|
FileStream fileStream = new FileStream(loadSpriteSheetDialog.FileName, FileMode.Open);
|
||||||
SpriteSheet = Texture2D.FromStream(animationPreview.Editor.graphics, fileStream);
|
SpriteSheet = Texture2D.FromStream(animationPreview.Editor.graphics, fileStream);
|
||||||
EnableMapAndAnimationLoadingControls();
|
EnableMapAndAnimationLoadingControls();
|
||||||
|
fileStream.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,6 +242,7 @@ namespace AnimationEditor
|
|||||||
Frames = new BindingList<Frame>();
|
Frames = new BindingList<Frame>();
|
||||||
frameListBox.DataSource = Frames;
|
frameListBox.DataSource = Frames;
|
||||||
frameListBox.DisplayMember = "Name";
|
frameListBox.DisplayMember = "Name";
|
||||||
|
InitiateAnimationList();
|
||||||
}
|
}
|
||||||
|
|
||||||
EnableSpriteMapControls();
|
EnableSpriteMapControls();
|
||||||
@@ -420,10 +425,10 @@ namespace AnimationEditor
|
|||||||
|
|
||||||
private void saveAnimationSetToolStripMenuItem_Click(object sender, EventArgs e)
|
private void saveAnimationSetToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var animSet = new Dictionary<string, Animation>();
|
var animSet = new AnimationSet();
|
||||||
foreach(Animation anim in Animations)
|
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 errorMessage = "Duplicate names found! Please ensure all animations have unique names.";
|
||||||
string caption = "Save Aborted";
|
string caption = "Save Aborted";
|
||||||
@@ -434,7 +439,7 @@ namespace AnimationEditor
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
animSet.Add(anim.Name, anim);
|
animSet.Add(anim);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,19 +456,19 @@ namespace AnimationEditor
|
|||||||
{
|
{
|
||||||
if (loadAnimationSetDialog.ShowDialog() == DialogResult.OK)
|
if (loadAnimationSetDialog.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
Dictionary<string, Animation> loadedAnimSet;
|
AnimationSet loadedAnimSet;
|
||||||
|
|
||||||
using (XmlReader xmlRead = XmlReader.Create(loadAnimationSetDialog.FileName))
|
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)
|
if (animationBox.Enabled == false)
|
||||||
{
|
{
|
||||||
EnableAnimationEditingControls();
|
EnableAnimationEditingControls();
|
||||||
}
|
}
|
||||||
InitiateAnimationList();
|
InitiateAnimationList(newAnimation: false);
|
||||||
foreach(KeyValuePair<string,Animation> currentEntry in loadedAnimSet)
|
foreach(KeyValuePair<string,Animation> currentEntry in loadedAnimSet.Anims)
|
||||||
{
|
{
|
||||||
Animations.Add(currentEntry.Value);
|
Animations.Add(currentEntry.Value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="MonoGame.Forms.DX" version="2.1.0.2" targetFramework="net451" />
|
<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>
|
</packages>
|
||||||
@@ -7,8 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PuzzSwap", "PuzzSwap\PuzzSw
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QURO.AnimationLibrary", "QURO.AnimationLibrary\QURO.AnimationLibrary.csproj", "{69DADC27-FBEB-4625-9212-6EB5BED5102A}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QURO.AnimationLibrary", "QURO.AnimationLibrary\QURO.AnimationLibrary.csproj", "{69DADC27-FBEB-4625-9212-6EB5BED5102A}"
|
||||||
EndProject
|
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}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QURO", "QURO\QURO.csproj", "{4581E0C8-B14A-454D-9A7B-52D37535E7E9}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpriteMapEditor", "SpriteMapEditor\SpriteMapEditor.csproj", "{2AF6999F-93F0-4096-9BC1-863CEE5E7791}"
|
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}.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.ActiveCfg = Release|Any CPU
|
||||||
{69DADC27-FBEB-4625-9212-6EB5BED5102A}.Release|Any CPU.Build.0 = 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.ActiveCfg = Debug|Any CPU
|
||||||
{4581E0C8-B14A-454D-9A7B-52D37535E7E9}.Debug|Any CPU.Build.0 = 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
|
{4581E0C8-B14A-454D-9A7B-52D37535E7E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
|||||||
@@ -11,11 +11,8 @@ namespace QURO.AnimationLibrary
|
|||||||
|
|
||||||
public bool IsStillImage => Frames.Length <= 1;
|
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)
|
public Animation(string name, Frame[] frames, bool loop)
|
||||||
@@ -24,18 +21,5 @@ namespace QURO.AnimationLibrary
|
|||||||
Frames = frames;
|
Frames = frames;
|
||||||
IsLooping = loop;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,47 +3,22 @@ using Microsoft.Xna.Framework;
|
|||||||
|
|
||||||
namespace QURO.AnimationLibrary
|
namespace QURO.AnimationLibrary
|
||||||
{
|
{
|
||||||
public class Frame : SpriteMapRegion
|
public class Frame
|
||||||
{
|
{
|
||||||
|
public SpriteMapRegion Sprite { get; set; }
|
||||||
public float Delay { 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)
|
public Frame(SpriteMapRegion sprite, float delay)
|
||||||
{
|
{
|
||||||
Name = sprite.Name;
|
Sprite = sprite;
|
||||||
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;
|
|
||||||
Delay = delay;
|
Delay = delay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+4
-3
@@ -388,13 +388,14 @@
|
|||||||
//
|
//
|
||||||
// loadMapDialog
|
// loadMapDialog
|
||||||
//
|
//
|
||||||
|
this.loadMapDialog.DefaultExt = "smap";
|
||||||
this.loadMapDialog.FileName = "openFileDialog1";
|
this.loadMapDialog.FileName = "openFileDialog1";
|
||||||
this.loadMapDialog.Filter = "Xml files|*.xml";
|
this.loadMapDialog.Filter = "QUROGame SpriteMap|*.smap";
|
||||||
//
|
//
|
||||||
// saveMapDialog
|
// saveMapDialog
|
||||||
//
|
//
|
||||||
this.saveMapDialog.DefaultExt = "xml";
|
this.saveMapDialog.DefaultExt = "smap";
|
||||||
this.saveMapDialog.Filter = "Xml files|*.xml";
|
this.saveMapDialog.Filter = "QUROGame SpriteMap|*.smap";
|
||||||
//
|
//
|
||||||
// fillButton
|
// fillButton
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user