Added mod: AddSprite; Changed: Stability increased for AddFrame and RemoveFrame

This commit is contained in:
quinnvoker
2018-12-27 21:10:33 -08:00
parent aaa80bd654
commit 748d772079
5 changed files with 86 additions and 8 deletions
+1
View File
@@ -67,6 +67,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Modifications\AddAnimation.cs" />
<Compile Include="Modifications\AddSprite.cs" />
<Compile Include="Modifications\RemoveAnimation.cs" />
<Compile Include="Modifications\RemoveSprite.cs" />
<Compile Include="Modifications\RemoveFrame.cs" />
+6 -6
View File
@@ -608,8 +608,8 @@ namespace AnimationEditor
private void ReadSpriteOffset()
{
reading = true;
spriteXPosBox.Value = (int)currentFrame.Sprites[frameSpriteListBox.SelectedIndex].Offset.X;
spriteYPosBox.Value = (int)currentFrame.Sprites[frameSpriteListBox.SelectedIndex].Offset.Y;
spriteXPosBox.Value = (int)frameSprites[frameSpriteListBox.SelectedIndex].Offset.X;
spriteYPosBox.Value = (int)frameSprites[frameSpriteListBox.SelectedIndex].Offset.Y;
reading = false;
}
@@ -638,10 +638,10 @@ namespace AnimationEditor
private void addSpriteToFrameSpritesButton_Click(object sender, EventArgs e)
{
var spriteToAdd = spriteSet[spriteListBox.SelectedIndex].Clone();
if (currentFrame.Sprites == null)
currentFrame.Sprites = new List<Sprite>();
currentFrame.Sprites.Add(spriteToAdd);
frameSprites.ResetBindings();
var mod = new AddSprite(frameSprites, frameSpriteListBox, currentFrame, spriteToAdd);
ModHelper.DoModificationWithSelectionTracking(mod, animationBox, frameListBox, frameSpriteListBox);
undoHistory.Add(mod);
}
private void addEmptyFrameButton_Click(object sender, EventArgs e)
+2 -1
View File
@@ -7,6 +7,7 @@ using System.ComponentModel;
using QURO;
using QURO.Animation;
using System.Windows.Forms;
using Microsoft.Xna.Framework;
namespace AnimationEditor.Modifications
{
@@ -36,7 +37,7 @@ namespace AnimationEditor.Modifications
if (frameToAdd.Name != "empty" &&
frames.Count == 1 &&
frames[0].Sprites.Count == 1 &&
frames[0].Sprites[0].Name == "empty")
frames[0].Sprites[0].Bounds == Rectangle.Empty)
{
frames.Clear();
}
@@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using QURO;
using QURO.Animation;
using System.Windows.Forms;
using Microsoft.Xna.Framework;
namespace AnimationEditor.Modifications
{
class AddSprite : IModification
{
private SelectionState preChangeSelection;
private SelectionState postChangeSelection;
private BindingList<Sprite> sprites;
private Frame currentFrame;
private ListBox spriteBox;
private Sprite spriteToAdd;
public AddSprite(BindingList<Sprite> spriteList, ListBox sprBox, Frame currFrame, Sprite sprite = null)
{
sprites = spriteList;
spriteBox = sprBox;
currentFrame = currFrame;
if (sprite != null)
spriteToAdd = sprite;
else spriteToAdd = new Sprite();
}
public void Do()
{
if (sprites.Count == 1 && sprites[0].Bounds == Rectangle.Empty)
sprites.Clear();
sprites.Add(spriteToAdd);
currentFrame.Sprites = sprites.ToList();
ModHelper.SetSingleSelection(spriteBox, sprites.Count - 1);
}
public void Undo()
{
sprites.RemoveAt(sprites.Count - 1);
if (sprites.Count == 0)
sprites.Add(new Sprite());
currentFrame.Sprites = sprites.ToList();
}
public SelectionState GetPreChangeSelection()
{
return preChangeSelection;
}
public void SetPreChangeSelection(SelectionState currentSelection)
{
preChangeSelection = currentSelection;
}
public SelectionState GetPostChangeSelection()
{
return postChangeSelection;
}
public void SetPostChangeSelection(SelectionState currentSelection)
{
postChangeSelection = currentSelection;
}
public override string ToString()
{
return "Add Sprite";
}
}
}
+2 -1
View File
@@ -7,6 +7,7 @@ using System.ComponentModel;
using QURO;
using QURO.Animation;
using System.Windows.Forms;
using Microsoft.Xna.Framework;
namespace AnimationEditor.Modifications
{
@@ -53,7 +54,7 @@ namespace AnimationEditor.Modifications
{
if(removedFrame != null)
{
if(frames.Count == 1 && removeIndex == 0)
if (frames.Count == 1 && removeIndex == 0 && (frames[0].Sprites == null || frames[0].Sprites[0].Bounds == Rectangle.Empty))
{
frames.Clear();
frames.Add(removedFrame);