Added mod: AddSprite; Changed: Stability increased for AddFrame and RemoveFrame
This commit is contained in:
@@ -67,6 +67,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Modifications\AddAnimation.cs" />
|
<Compile Include="Modifications\AddAnimation.cs" />
|
||||||
|
<Compile Include="Modifications\AddSprite.cs" />
|
||||||
<Compile Include="Modifications\RemoveAnimation.cs" />
|
<Compile Include="Modifications\RemoveAnimation.cs" />
|
||||||
<Compile Include="Modifications\RemoveSprite.cs" />
|
<Compile Include="Modifications\RemoveSprite.cs" />
|
||||||
<Compile Include="Modifications\RemoveFrame.cs" />
|
<Compile Include="Modifications\RemoveFrame.cs" />
|
||||||
|
|||||||
@@ -608,8 +608,8 @@ namespace AnimationEditor
|
|||||||
private void ReadSpriteOffset()
|
private void ReadSpriteOffset()
|
||||||
{
|
{
|
||||||
reading = true;
|
reading = true;
|
||||||
spriteXPosBox.Value = (int)currentFrame.Sprites[frameSpriteListBox.SelectedIndex].Offset.X;
|
spriteXPosBox.Value = (int)frameSprites[frameSpriteListBox.SelectedIndex].Offset.X;
|
||||||
spriteYPosBox.Value = (int)currentFrame.Sprites[frameSpriteListBox.SelectedIndex].Offset.Y;
|
spriteYPosBox.Value = (int)frameSprites[frameSpriteListBox.SelectedIndex].Offset.Y;
|
||||||
reading = false;
|
reading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -638,10 +638,10 @@ namespace AnimationEditor
|
|||||||
private void addSpriteToFrameSpritesButton_Click(object sender, EventArgs e)
|
private void addSpriteToFrameSpritesButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var spriteToAdd = spriteSet[spriteListBox.SelectedIndex].Clone();
|
var spriteToAdd = spriteSet[spriteListBox.SelectedIndex].Clone();
|
||||||
if (currentFrame.Sprites == null)
|
|
||||||
currentFrame.Sprites = new List<Sprite>();
|
var mod = new AddSprite(frameSprites, frameSpriteListBox, currentFrame, spriteToAdd);
|
||||||
currentFrame.Sprites.Add(spriteToAdd);
|
ModHelper.DoModificationWithSelectionTracking(mod, animationBox, frameListBox, frameSpriteListBox);
|
||||||
frameSprites.ResetBindings();
|
undoHistory.Add(mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addEmptyFrameButton_Click(object sender, EventArgs e)
|
private void addEmptyFrameButton_Click(object sender, EventArgs e)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using System.ComponentModel;
|
|||||||
using QURO;
|
using QURO;
|
||||||
using QURO.Animation;
|
using QURO.Animation;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
|
||||||
namespace AnimationEditor.Modifications
|
namespace AnimationEditor.Modifications
|
||||||
{
|
{
|
||||||
@@ -36,7 +37,7 @@ namespace AnimationEditor.Modifications
|
|||||||
if (frameToAdd.Name != "empty" &&
|
if (frameToAdd.Name != "empty" &&
|
||||||
frames.Count == 1 &&
|
frames.Count == 1 &&
|
||||||
frames[0].Sprites.Count == 1 &&
|
frames[0].Sprites.Count == 1 &&
|
||||||
frames[0].Sprites[0].Name == "empty")
|
frames[0].Sprites[0].Bounds == Rectangle.Empty)
|
||||||
{
|
{
|
||||||
frames.Clear();
|
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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ using System.ComponentModel;
|
|||||||
using QURO;
|
using QURO;
|
||||||
using QURO.Animation;
|
using QURO.Animation;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
|
||||||
namespace AnimationEditor.Modifications
|
namespace AnimationEditor.Modifications
|
||||||
{
|
{
|
||||||
@@ -53,7 +54,7 @@ namespace AnimationEditor.Modifications
|
|||||||
{
|
{
|
||||||
if(removedFrame != null)
|
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.Clear();
|
||||||
frames.Add(removedFrame);
|
frames.Add(removedFrame);
|
||||||
|
|||||||
Reference in New Issue
Block a user