From b8173d688de3bd149435fbcbd90b9c62465f2e20 Mon Sep 17 00:00:00 2001 From: quinnvoker Date: Wed, 19 Dec 2018 09:16:17 -0800 Subject: [PATCH] Restruct: QURO << QURO.Animation; SpriteMapRegion -> Sprite: Now can draw itself --- AnimationEditor/AnimationEditor.csproj | 4 - AnimationEditor/AnimationPreview.cs | 2 +- AnimationEditor/Form1.cs | 28 ++--- PuzzSwap.sln | 6 - QURO.AnimationLibrary/AnimatedSprite.cs | 112 ------------------ QURO.AnimationLibrary/Animation.cs | 25 ---- QURO.AnimationLibrary/AnimationSet.cs | 29 ----- QURO.AnimationLibrary/Frame.cs | 36 ------ SpriteMapEditor/Form1.cs | 44 +++---- .../SpriteMapModifications/AddSprite.cs | 10 +- .../ApplyOriginPreset.cs | 6 +- .../SpriteMapModifications/ModHelper.cs | 2 +- .../SpriteMapModifications/ModifyBounds.cs | 4 +- .../SpriteMapModifications/ModifyOrigin.cs | 4 +- .../SpriteMapModifications/MoveBounds.cs | 8 +- .../MoveSpriteListEntry.cs | 4 +- .../SpriteMapModifications/RemoveSprite.cs | 6 +- .../SpriteMapModifications/RenameSprite.cs | 4 +- SpriteMapEditor/SpriteMapProject.cs | 4 +- 19 files changed, 63 insertions(+), 275 deletions(-) delete mode 100644 QURO.AnimationLibrary/AnimatedSprite.cs delete mode 100644 QURO.AnimationLibrary/Animation.cs delete mode 100644 QURO.AnimationLibrary/AnimationSet.cs delete mode 100644 QURO.AnimationLibrary/Frame.cs diff --git a/AnimationEditor/AnimationEditor.csproj b/AnimationEditor/AnimationEditor.csproj index 9aadbbb..dacf2d5 100644 --- a/AnimationEditor/AnimationEditor.csproj +++ b/AnimationEditor/AnimationEditor.csproj @@ -152,10 +152,6 @@ - - {69dadc27-fbeb-4625-9212-6eb5bed5102a} - QURO.AnimationLibrary - {4581e0c8-b14a-454d-9a7b-52d37535e7e9} QURO diff --git a/AnimationEditor/AnimationPreview.cs b/AnimationEditor/AnimationPreview.cs index 309daa1..44f53eb 100644 --- a/AnimationEditor/AnimationPreview.cs +++ b/AnimationEditor/AnimationPreview.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using MonoGame.Forms.Controls; -using QURO.AnimationLibrary; +using QURO.Animation; namespace AnimationEditor { diff --git a/AnimationEditor/Form1.cs b/AnimationEditor/Form1.cs index f23ea06..2ed7444 100644 --- a/AnimationEditor/Form1.cs +++ b/AnimationEditor/Form1.cs @@ -11,7 +11,7 @@ using System.IO; using System.Xml.Serialization; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using QURO.AnimationLibrary; +using QURO.Animation; using QURO; using System.Xml; using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate; @@ -23,9 +23,9 @@ namespace AnimationEditor private Texture2D spriteSheet; private int frameRate; - private BindingList sprites; + private BindingList sprites; private BindingList frames; - private BindingList subSprites; + private BindingList subSprites; private BindingList animations; private Animation currentAnimation; @@ -82,7 +82,7 @@ namespace AnimationEditor { if (spriteListBox.SelectedItem != null) { - AddFrame(new Frame((SpriteMapRegion)spriteListBox.SelectedItem, importDelay)); + AddFrame(new Frame((Sprite)spriteListBox.SelectedItem, importDelay)); } } @@ -156,7 +156,7 @@ namespace AnimationEditor { if (spriteListBox.SelectedItem != null) { - var currentSprite = (SpriteMapRegion)spriteListBox.SelectedItem; + var currentSprite = (Sprite)spriteListBox.SelectedItem; Stream texture2DToImageStream = new MemoryStream(); Texture2DRegionExtractor.GetTexture2DFromRegion(spriteSheet, spriteSheet.GraphicsDevice, currentSprite.Bounds) .SaveAsPng(texture2DToImageStream, currentSprite.Bounds.Width, currentSprite.Bounds.Height); @@ -177,9 +177,9 @@ namespace AnimationEditor } subSpritePanel.Enabled = true; if (currentFrame.SubSprites != null) - subSprites = new BindingList(currentFrame.SubSprites); + subSprites = new BindingList(currentFrame.SubSprites); else - subSprites = new BindingList(); + subSprites = new BindingList(); subSpriteListBox.DataSource = subSprites; subSpriteListBox.DisplayMember = "Name"; UpdateFrameInformation(); @@ -221,18 +221,18 @@ namespace AnimationEditor LoadSpriteMapFromFile(); } - private Dictionary LoadSpriteMapFromFile() + private Dictionary LoadSpriteMapFromFile() { if (loadSpriteMapDialog.ShowDialog() == DialogResult.OK) { - Dictionary loadedSpriteMap; + Dictionary loadedSpriteMap; using (XmlReader xmlRead = XmlReader.Create(loadSpriteMapDialog.FileName)) { - loadedSpriteMap = IntermediateSerializer.Deserialize>(xmlRead, null); + loadedSpriteMap = IntermediateSerializer.Deserialize>(xmlRead, null); } - sprites = new BindingList(); - foreach (KeyValuePair sprite in loadedSpriteMap) + sprites = new BindingList(); + foreach (KeyValuePair sprite in loadedSpriteMap) { sprites.Add(sprite.Value); } @@ -491,7 +491,7 @@ namespace AnimationEditor using(XmlReader xmlRead = XmlReader.Create(loadSpriteMapDialog.FileName)) { - loadedSpriteMap = IntermediateSerializer.Deserialize>(xmlRead, null); + loadedSpriteMap = IntermediateSerializer.Deserialize>(xmlRead, null); } int updateCounter = 0; @@ -563,7 +563,7 @@ namespace AnimationEditor currentFrame.SubSpritePositions = new List(); currentFrame.SubSpritePositions.Add(Vector2.Zero); if (currentFrame.SubSprites == null) - currentFrame.SubSprites = new List(); + currentFrame.SubSprites = new List(); currentFrame.SubSprites.Add(spriteToAdd); subSprites.Add(spriteToAdd); } diff --git a/PuzzSwap.sln b/PuzzSwap.sln index 9807a64..02b08bc 100644 --- a/PuzzSwap.sln +++ b/PuzzSwap.sln @@ -5,8 +5,6 @@ VisualStudioVersion = 15.0.27703.2047 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PuzzSwap", "PuzzSwap\PuzzSwap.csproj", "{CD753795-0CB4-4F05-A0E7-2D2EFC968D82}" 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}") = "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}" @@ -23,10 +21,6 @@ Global {CD753795-0CB4-4F05-A0E7-2D2EFC968D82}.Debug|Any CPU.Build.0 = Debug|Any CPU {CD753795-0CB4-4F05-A0E7-2D2EFC968D82}.Release|Any CPU.ActiveCfg = Release|Any CPU {CD753795-0CB4-4F05-A0E7-2D2EFC968D82}.Release|Any CPU.Build.0 = Release|Any CPU - {69DADC27-FBEB-4625-9212-6EB5BED5102A}.Debug|Any CPU.ActiveCfg = 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.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 diff --git a/QURO.AnimationLibrary/AnimatedSprite.cs b/QURO.AnimationLibrary/AnimatedSprite.cs deleted file mode 100644 index ecf142a..0000000 --- a/QURO.AnimationLibrary/AnimatedSprite.cs +++ /dev/null @@ -1,112 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using QURO; - -namespace QURO.AnimationLibrary -{ - public class AnimatedSprite - { - public Texture2D SpriteSheet { get; set; } - private Animation currentAnimation; - public Animation CurrentAnimation - { - get { return currentAnimation; } - set - { - currentAnimation = value; - finishedPlaying = false; - CurrentFrameIndex = 0; - timer = CurrentFrame.Delay; - } - } - public int CurrentFrameIndex { get; set; } - public Frame CurrentFrame => CurrentAnimation.Frames[CurrentFrameIndex]; - - private float timer; - private bool finishedPlaying; - - public AnimatedSprite() { } - - public AnimatedSprite(Texture2D spriteSheet, Animation startingAnimation) - { - SpriteSheet = spriteSheet; - CurrentAnimation = startingAnimation; - timer = CurrentFrame.Delay; - finishedPlaying = false; - } - - public void Reset() - { - CurrentFrameIndex = 0; - finishedPlaying = false; - timer = CurrentFrame.Delay; - } - - public void Update(GameTime gameTime) - { - if (!CurrentAnimation.IsStillImage && !finishedPlaying) - { - if (timer <= 0) - { - if (CurrentFrameIndex < CurrentAnimation.Frames.Length - 1) - { - CurrentFrameIndex++; - } - else - { - if (CurrentAnimation.IsLooping) - { - CurrentFrameIndex = 0; - } - else - { - finishedPlaying = true; - } - } - timer = CurrentFrame.Delay; - } - else - { - timer -= (float)gameTime.ElapsedGameTime.TotalSeconds; - } - } - } - - public void Draw(SpriteBatch spriteBatch, Vector2 position, Color tint) - { - spriteBatch.Draw(SpriteSheet, position - CurrentFrame.Origin, CurrentFrame.Bounds, tint); - if (CurrentFrame.SubSprites != null) - DrawSubSprites(spriteBatch, position, tint); - } - - public void Draw(SpriteBatch spriteBatch, Vector2 position, Vector2 spriteMapOffset, Color tint, bool offsetSubSprites = false) - { - Rectangle sourceRect = CurrentFrame.Bounds; - sourceRect.Offset(spriteMapOffset); - - spriteBatch.Draw(SpriteSheet, position, sourceRect, tint); - if (CurrentFrame.SubSprites != null) - DrawSubSprites(spriteBatch, position, tint, offsetSubSprites? (Vector2?)spriteMapOffset : null); - } - - public void DrawSubSprites(SpriteBatch spriteBatch, Vector2 position, Color tint, Vector2? spriteMapOffset = null) - { - if (CurrentFrame.SubSprites.Count != CurrentFrame.SubSpritePositions.Count) - { - System.Console.WriteLine("SubSpriteCount and SubSpritePositionCount are not equal! Skipping subsprites..."); - return; - } - for (int index = 0; index < CurrentFrame.SubSprites.Count; index++) - { - var subSprite = CurrentFrame.SubSprites[index]; - - Rectangle sourceRect = subSprite.Bounds; - - if (spriteMapOffset != null) - sourceRect.Offset((Vector2)spriteMapOffset); - - spriteBatch.Draw(SpriteSheet, position - subSprite.Origin + CurrentFrame.SubSpritePositions[index], sourceRect, tint); - } - } - } -} diff --git a/QURO.AnimationLibrary/Animation.cs b/QURO.AnimationLibrary/Animation.cs deleted file mode 100644 index d4e35d1..0000000 --- a/QURO.AnimationLibrary/Animation.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Microsoft.Xna.Framework; - -namespace QURO.AnimationLibrary -{ - public class Animation - { - public string Name { get; set; } - public bool IsLooping { get; set; } - - public Frame[] Frames { get; set; } - - public bool IsStillImage => Frames.Length <= 1; - - public Animation() : this("unnamed", new Frame[] { new Frame() }, false) - { - } - - public Animation(string name, Frame[] frames, bool loop) - { - Name = name; - Frames = frames; - IsLooping = loop; - } - } -} diff --git a/QURO.AnimationLibrary/AnimationSet.cs b/QURO.AnimationLibrary/AnimationSet.cs deleted file mode 100644 index 9f603ee..0000000 --- a/QURO.AnimationLibrary/AnimationSet.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Collections.Generic; - -namespace QURO.AnimationLibrary -{ - public class AnimationSet - { - public Dictionary Anims; - - public AnimationSet() - { - Anims = new Dictionary(); - } - - public void Add(Animation anim) - { - Anims.Add(anim.Name, anim); - } - - public void Remove(Animation anim) - { - Anims.Remove(anim.Name); - } - - public void Remove(string animName) - { - Anims.Remove(animName); - } - } -} diff --git a/QURO.AnimationLibrary/Frame.cs b/QURO.AnimationLibrary/Frame.cs deleted file mode 100644 index 228d2d0..0000000 --- a/QURO.AnimationLibrary/Frame.cs +++ /dev/null @@ -1,36 +0,0 @@ -using QURO; -using System.Collections.Generic; -using Microsoft.Xna.Framework; - -namespace QURO.AnimationLibrary -{ - public class Frame - { - public SpriteMapRegion Sprite { get; set; } - public List SubSprites { get; set; } - public List SubSpritePositions { get; set; } - - public float Delay { get; set; } - - 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, null, null) - { - } - - public Frame(SpriteMapRegion sprite, float delay) : this(sprite, delay, null, null) - { - } - - public Frame(SpriteMapRegion sprite, float delay, List subSprites, List subSpritePositons) - { - Sprite = sprite; - Delay = delay; - SubSprites = subSprites; - SubSpritePositions = subSpritePositons; - } - } -} diff --git a/SpriteMapEditor/Form1.cs b/SpriteMapEditor/Form1.cs index c3f6c5e..3485217 100644 --- a/SpriteMapEditor/Form1.cs +++ b/SpriteMapEditor/Form1.cs @@ -23,8 +23,8 @@ namespace SpriteMapEditor { private History undoHistory; - private BindingList sprites; - private List selectedSprites; + private BindingList sprites; + private List selectedSprites; private bool highlight = false; private int zoomLevel = 3; @@ -96,8 +96,8 @@ namespace SpriteMapEditor spriteSheetViewer.Width = 1; spriteSheetViewer.Height = 1; - sprites = new BindingList { new SpriteMapRegion() }; - selectedSprites = new List(); + sprites = new BindingList { new Sprite() }; + selectedSprites = new List(); spriteList.DataSource = sprites; spriteList.DisplayMember = "Name"; @@ -123,7 +123,7 @@ namespace SpriteMapEditor CurrentSpriteMapFileLocation = null; CurrentSpriteSheetFileLocation = null; - sprites = new BindingList() { new SpriteMapRegion() }; + sprites = new BindingList() { new Sprite() }; LoadSpriteSheet(); if (spriteSheet == null) return; @@ -152,14 +152,14 @@ namespace SpriteMapEditor { CurrentSpriteMapFileLocation = loadMapDialog.FileName; - Dictionary loadedSpriteMap; + Dictionary loadedSpriteMap; using (XmlReader xmlRead = XmlReader.Create(CurrentSpriteMapFileLocation)) { - loadedSpriteMap = IntermediateSerializer.Deserialize>(xmlRead, null); + loadedSpriteMap = IntermediateSerializer.Deserialize>(xmlRead, null); } - sprites = new BindingList(); - foreach (KeyValuePair sprite in loadedSpriteMap) + sprites = new BindingList(); + foreach (KeyValuePair sprite in loadedSpriteMap) { sprites.Add(sprite.Value); } @@ -210,7 +210,7 @@ namespace SpriteMapEditor importSpriteSheetToolStripMenuItem.Text = "Replace Sprite Sheet..."; - sprites = new BindingList(loadedProject.SpriteMap); + sprites = new BindingList(loadedProject.SpriteMap); spriteList.DataSource = sprites; saveProjectToolStripMenuItem.Enabled = true; @@ -240,7 +240,7 @@ namespace SpriteMapEditor e.Graphics.DrawImage(highlightMask.Bitmap, highlightBounds); } - foreach (SpriteMapRegion currentSprite in selectedSprites) + foreach (Sprite currentSprite in selectedSprites) { DrawHighContrastOutline(GetDrawingRect(currentSprite.Bounds), e.Graphics); DrawOriginPoint(currentSprite, e.Graphics); @@ -265,7 +265,7 @@ namespace SpriteMapEditor } else if(spriteList.SelectedIndices.Count > 0) { - SpriteMapRegion currentSprite = selectedSprites[0]; + Sprite currentSprite = selectedSprites[0]; spriteNameBox.Text = currentSprite.Name; spriteXPosBox.Value = currentSprite.Bounds.X; spriteXPosBox.Text = currentSprite.Bounds.X.ToString(); @@ -298,7 +298,7 @@ namespace SpriteMapEditor return drawingRect; } - private Point GetOriginDrawingPoint(SpriteMapRegion sprite) + private Point GetOriginDrawingPoint(Sprite sprite) { var drawingPoint = new Point(sprite.Bounds.X, sprite.Bounds.Y); drawingPoint.X = drawingPoint.X * zoomLevel; @@ -308,7 +308,7 @@ namespace SpriteMapEditor return drawingPoint; } - private void DrawOriginPoint(SpriteMapRegion sprite, Graphics graphics) + private void DrawOriginPoint(Sprite sprite, Graphics graphics) { if (editingOrigin) { @@ -335,7 +335,7 @@ namespace SpriteMapEditor if (highlight) { InitializeMask(); - foreach (SpriteMapRegion currentSprite in selectedSprites) + foreach (Sprite currentSprite in selectedSprites) { var highlightRect = currentSprite.Bounds; @@ -518,7 +518,7 @@ namespace SpriteMapEditor Microsoft.Xna.Framework.Rectangle rightMost = selectedSprites[0].Bounds; Microsoft.Xna.Framework.Rectangle bottomMost = selectedSprites[0].Bounds; - foreach (SpriteMapRegion currentSprite in selectedSprites) + foreach (Sprite currentSprite in selectedSprites) { if (currentSprite.Bounds.X < leftMost.X) leftMost = currentSprite.Bounds; @@ -537,8 +537,8 @@ namespace SpriteMapEditor private void exportMapToolStripMenuItem_Click(object sender, EventArgs e) { - var exportDict = new Dictionary(); - foreach (SpriteMapRegion sprite in sprites) + var exportDict = new Dictionary(); + foreach (Sprite sprite in sprites) { if (exportDict.ContainsKey(sprite.Name)) { @@ -577,7 +577,7 @@ namespace SpriteMapEditor bool hovering = false; - foreach (SpriteMapRegion currentSprite in selectedSprites) + foreach (Sprite currentSprite in selectedSprites) { if (GetDrawingRect(currentSprite.Bounds).Contains(mousePosition)) { @@ -602,7 +602,7 @@ namespace SpriteMapEditor groupRect.Y + groupRect.Height + differenceY > spriteSheet.Height) differenceY = 0; - foreach (SpriteMapRegion spriteToMove in selectedSprites) + foreach (Sprite spriteToMove in selectedSprites) { var newBounds = spriteToMove.Bounds; newBounds.X += differenceX; @@ -626,13 +626,13 @@ namespace SpriteMapEditor Point mousePosition = new Point(e.X, e.Y); - foreach (SpriteMapRegion currentSprite in selectedSprites) + foreach (Sprite currentSprite in selectedSprites) { if (GetDrawingRect(currentSprite.Bounds).Contains(mousePosition)) { movingWithMouse = true; preDragBounds = new List(); - foreach (SpriteMapRegion sprite in selectedSprites) + foreach (Sprite sprite in selectedSprites) { preDragBounds.Add(sprite.Bounds); } diff --git a/SpriteMapEditor/SpriteMapModifications/AddSprite.cs b/SpriteMapEditor/SpriteMapModifications/AddSprite.cs index 84b5552..623fc7c 100644 --- a/SpriteMapEditor/SpriteMapModifications/AddSprite.cs +++ b/SpriteMapEditor/SpriteMapModifications/AddSprite.cs @@ -11,14 +11,14 @@ namespace SpriteMapEditor.SpriteMapModifications { class AddSprite : ISpriteMapModification { - private readonly BindingList allSprites; + private readonly BindingList allSprites; - private readonly SpriteMapRegion selectedSprite; + private readonly Sprite selectedSprite; private List preChangeSelection; private List postChangeSelection; - public AddSprite(BindingList spriteList, SpriteMapRegion selected = null) + public AddSprite(BindingList spriteList, Sprite selected = null) { allSprites = spriteList; @@ -28,9 +28,9 @@ namespace SpriteMapEditor.SpriteMapModifications public void Do() { if (selectedSprite != null) - allSprites.Add(new SpriteMapRegion(selectedSprite.Name, selectedSprite.Bounds, selectedSprite.Origin)); + allSprites.Add(new Sprite(selectedSprite.Name, selectedSprite.Bounds, selectedSprite.Origin)); else - allSprites.Add(new SpriteMapRegion()); + allSprites.Add(new Sprite()); } public void Undo() diff --git a/SpriteMapEditor/SpriteMapModifications/ApplyOriginPreset.cs b/SpriteMapEditor/SpriteMapModifications/ApplyOriginPreset.cs index c92d965..1bc4781 100644 --- a/SpriteMapEditor/SpriteMapModifications/ApplyOriginPreset.cs +++ b/SpriteMapEditor/SpriteMapModifications/ApplyOriginPreset.cs @@ -10,7 +10,7 @@ namespace SpriteMapEditor.SpriteMapModifications { class ApplyOriginPreset : ISpriteMapModification { - private readonly List sprites; + private readonly List sprites; private readonly OriginPreset preset; @@ -19,7 +19,7 @@ namespace SpriteMapEditor.SpriteMapModifications private List preChangeSelection; private List postChangeSelection; - public ApplyOriginPreset(List spritesToEditOrigin, OriginPreset presetToApply) + public ApplyOriginPreset(List spritesToEditOrigin, OriginPreset presetToApply) { sprites = spritesToEditOrigin.ToList(); preset = presetToApply; @@ -33,7 +33,7 @@ namespace SpriteMapEditor.SpriteMapModifications public void Do() { - foreach(SpriteMapRegion sprite in sprites) + foreach(Sprite sprite in sprites) { Vector2 newOrigin = sprite.Origin; diff --git a/SpriteMapEditor/SpriteMapModifications/ModHelper.cs b/SpriteMapEditor/SpriteMapModifications/ModHelper.cs index 0880c82..9f11b94 100644 --- a/SpriteMapEditor/SpriteMapModifications/ModHelper.cs +++ b/SpriteMapEditor/SpriteMapModifications/ModHelper.cs @@ -46,7 +46,7 @@ namespace SpriteMapEditor.SpriteMapModifications public static void SelectFromList(ListBox listBox, List newSelection) { listBox.SelectedIndices.Clear(); - var source = (BindingList)listBox.DataSource; + var source = (BindingList)listBox.DataSource; foreach (int currentIndex in newSelection) { if(currentIndex < source.Count) diff --git a/SpriteMapEditor/SpriteMapModifications/ModifyBounds.cs b/SpriteMapEditor/SpriteMapModifications/ModifyBounds.cs index 7e76231..584a3bb 100644 --- a/SpriteMapEditor/SpriteMapModifications/ModifyBounds.cs +++ b/SpriteMapEditor/SpriteMapModifications/ModifyBounds.cs @@ -11,7 +11,7 @@ namespace SpriteMapEditor.SpriteMapModifications { class ModifyBounds : ISpriteMapModification { - private readonly List sprites; + private readonly List sprites; private readonly int newXPosition; private readonly int newYPosition; @@ -23,7 +23,7 @@ namespace SpriteMapEditor.SpriteMapModifications private List preChangeSelection; private List postChangeSelection; - public ModifyBounds(List spritesToModify, int x = -1, int y = -1, int width = -1, int height = -1) + public ModifyBounds(List spritesToModify, int x = -1, int y = -1, int width = -1, int height = -1) { sprites = spritesToModify.ToList(); newXPosition = x; diff --git a/SpriteMapEditor/SpriteMapModifications/ModifyOrigin.cs b/SpriteMapEditor/SpriteMapModifications/ModifyOrigin.cs index 64a3d40..6379e30 100644 --- a/SpriteMapEditor/SpriteMapModifications/ModifyOrigin.cs +++ b/SpriteMapEditor/SpriteMapModifications/ModifyOrigin.cs @@ -10,7 +10,7 @@ namespace SpriteMapEditor.SpriteMapModifications { class ModifyOrigin : ISpriteMapModification { - private readonly List sprites; + private readonly List sprites; private readonly int newOriginX; private readonly int newOriginY; @@ -20,7 +20,7 @@ namespace SpriteMapEditor.SpriteMapModifications private List preChangeSelection; private List postChangeSelection; - public ModifyOrigin(List spritesToEditOrigin, int x = -1, int y = -1) + public ModifyOrigin(List spritesToEditOrigin, int x = -1, int y = -1) { sprites = spritesToEditOrigin.ToList(); newOriginX = x; diff --git a/SpriteMapEditor/SpriteMapModifications/MoveBounds.cs b/SpriteMapEditor/SpriteMapModifications/MoveBounds.cs index 5fb8ed3..80ce9be 100644 --- a/SpriteMapEditor/SpriteMapModifications/MoveBounds.cs +++ b/SpriteMapEditor/SpriteMapModifications/MoveBounds.cs @@ -10,7 +10,7 @@ namespace SpriteMapEditor.SpriteMapModifications { class MoveBounds : ISpriteMapModification { - private readonly List sprites; + private readonly List sprites; private readonly int xDiff; private readonly int yDiff; @@ -19,7 +19,7 @@ namespace SpriteMapEditor.SpriteMapModifications private List preChangeSelection; private List postChangeSelection; - public MoveBounds(List spritesToMove, int xDifference, int yDifference, List preDragBounds = null) + public MoveBounds(List spritesToMove, int xDifference, int yDifference, List preDragBounds = null) { sprites = spritesToMove.ToList(); xDiff = xDifference; @@ -29,7 +29,7 @@ namespace SpriteMapEditor.SpriteMapModifications public void Do() { - foreach (SpriteMapRegion sprite in sprites) + foreach (Sprite sprite in sprites) { var newBounds = sprite.Bounds; newBounds.X += xDiff; @@ -48,7 +48,7 @@ namespace SpriteMapEditor.SpriteMapModifications } else { - foreach (SpriteMapRegion sprite in sprites) + foreach (Sprite sprite in sprites) { var newBounds = sprite.Bounds; newBounds.X -= xDiff; diff --git a/SpriteMapEditor/SpriteMapModifications/MoveSpriteListEntry.cs b/SpriteMapEditor/SpriteMapModifications/MoveSpriteListEntry.cs index c5beaab..dd4809f 100644 --- a/SpriteMapEditor/SpriteMapModifications/MoveSpriteListEntry.cs +++ b/SpriteMapEditor/SpriteMapModifications/MoveSpriteListEntry.cs @@ -10,7 +10,7 @@ namespace SpriteMapEditor.SpriteMapModifications { class MoveSpriteListEntry : ISpriteMapModification { - private readonly BindingList allSprites; + private readonly BindingList allSprites; private readonly int selectedIndex; private readonly int dir; @@ -18,7 +18,7 @@ namespace SpriteMapEditor.SpriteMapModifications private List preChangeSelection; private List postChangeSelection; - public MoveSpriteListEntry(BindingList spriteList, int selection, int direction) + public MoveSpriteListEntry(BindingList spriteList, int selection, int direction) { allSprites = spriteList; selectedIndex = selection; diff --git a/SpriteMapEditor/SpriteMapModifications/RemoveSprite.cs b/SpriteMapEditor/SpriteMapModifications/RemoveSprite.cs index 458bae6..20eb7d0 100644 --- a/SpriteMapEditor/SpriteMapModifications/RemoveSprite.cs +++ b/SpriteMapEditor/SpriteMapModifications/RemoveSprite.cs @@ -10,16 +10,16 @@ namespace SpriteMapEditor.SpriteMapModifications { class RemoveSprite : ISpriteMapModification { - private readonly BindingList allSprites; + private readonly BindingList allSprites; private readonly int index; - private readonly SpriteMapRegion removedSprite; + private readonly Sprite removedSprite; private List preChangeSelection; private List postChangeSelection; - public RemoveSprite(BindingList spriteList, int indexToRemove) + public RemoveSprite(BindingList spriteList, int indexToRemove) { allSprites = spriteList; index = indexToRemove; diff --git a/SpriteMapEditor/SpriteMapModifications/RenameSprite.cs b/SpriteMapEditor/SpriteMapModifications/RenameSprite.cs index c729eb8..cf3d61b 100644 --- a/SpriteMapEditor/SpriteMapModifications/RenameSprite.cs +++ b/SpriteMapEditor/SpriteMapModifications/RenameSprite.cs @@ -9,7 +9,7 @@ namespace SpriteMapEditor.SpriteMapModifications { class RenameSprite : ISpriteMapModification { - private readonly SpriteMapRegion sprite; + private readonly Sprite sprite; private readonly string newName; private readonly string oldName; @@ -17,7 +17,7 @@ namespace SpriteMapEditor.SpriteMapModifications private List preChangeSelection; private List postChangeSelection; - public RenameSprite(SpriteMapRegion spriteToRename, string name) + public RenameSprite(Sprite spriteToRename, string name) { sprite = spriteToRename; newName = name; diff --git a/SpriteMapEditor/SpriteMapProject.cs b/SpriteMapEditor/SpriteMapProject.cs index d4785a5..bd8cfdb 100644 --- a/SpriteMapEditor/SpriteMapProject.cs +++ b/SpriteMapEditor/SpriteMapProject.cs @@ -7,14 +7,14 @@ namespace SpriteMapEditor public class SpriteMapProject { public string SpriteSheetFileLocation { get; set; } - public List SpriteMap { get; set; } + public List SpriteMap { get; set; } public SpriteMapProject() { } - public SpriteMapProject(string spriteSheetLocation, List spriteMap) + public SpriteMapProject(string spriteSheetLocation, List spriteMap) { SpriteSheetFileLocation = spriteSheetLocation; SpriteMap = spriteMap;