Added mods: ChangeFrameDelay, MoveSprite(NC), RenameAnimation, RenameFrame, ReorderSprite, ReplaceFrame, SetSpritePosition(NC); Changed: Removed opening conditionals from several mods
This commit is contained in:
@@ -18,7 +18,8 @@ namespace AnimationEditor.Modifications
|
||||
|
||||
private BindingList<Frame> frames;
|
||||
private ListBox frameListBox;
|
||||
private Frame frameToAdd;
|
||||
private Frame frameToAdd;
|
||||
private int index;
|
||||
|
||||
public AddFrame(BindingList<Frame> frameList, ListBox frameBox, Frame frame = null)
|
||||
{
|
||||
@@ -27,6 +28,7 @@ namespace AnimationEditor.Modifications
|
||||
if (frame != null)
|
||||
frameToAdd = frame;
|
||||
else frameToAdd = new Frame();
|
||||
index = frameListBox.SelectedIndex;
|
||||
}
|
||||
|
||||
public void Do()
|
||||
@@ -42,15 +44,15 @@ namespace AnimationEditor.Modifications
|
||||
frames.Clear();
|
||||
}
|
||||
|
||||
if (frameListBox.SelectedItem == null || frameListBox.SelectedIndex == frames.Count - 1)
|
||||
if (frameListBox.SelectedItem == null || index == frames.Count - 1)
|
||||
{
|
||||
frames.Add(frameToAdd);
|
||||
newSelectedIndex = frames.Count - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
frames.Insert(frameListBox.SelectedIndex + 1, frameToAdd);
|
||||
newSelectedIndex = frameListBox.SelectedIndex + 1;
|
||||
frames.Insert(index + 1, frameToAdd);
|
||||
newSelectedIndex = index + 1;
|
||||
}
|
||||
ModHelper.SetSingleSelection(frameListBox, newSelectedIndex);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
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 ChangeFrameDelay : IModification
|
||||
{
|
||||
private SelectionState preChangeSelection;
|
||||
private SelectionState postChangeSelection;
|
||||
|
||||
private BindingList<Frame> frames;
|
||||
private ListBox listBox;
|
||||
private List<int> indices;
|
||||
private Dictionary<int, float> originalDelays;
|
||||
private float newDelay;
|
||||
|
||||
public ChangeFrameDelay(BindingList<Frame> frameList, ListBox frameListBox, float delay)
|
||||
{
|
||||
frames = frameList;
|
||||
listBox = frameListBox;
|
||||
indices = new List<int>();
|
||||
originalDelays = new Dictionary<int, float>();
|
||||
foreach (int i in frameListBox.SelectedIndices)
|
||||
{
|
||||
indices.Add(i);
|
||||
originalDelays.Add(i, frames[i].Delay);
|
||||
}
|
||||
newDelay = delay;
|
||||
}
|
||||
|
||||
public void Do()
|
||||
{
|
||||
foreach (int index in indices)
|
||||
{
|
||||
frames[index].Delay = newDelay;
|
||||
}
|
||||
frames.ResetBindings();
|
||||
listBox.SelectedIndices.Clear();
|
||||
foreach (int index in indices)
|
||||
{
|
||||
listBox.SelectedIndices.Add(index);
|
||||
}
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
foreach (int index in indices)
|
||||
{
|
||||
frames[index].Delay = originalDelays[index];
|
||||
}
|
||||
frames.ResetBindings();
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
if (indices.Count == 1)
|
||||
return "Change Frame Delay";
|
||||
else
|
||||
return "Change Frame Delays";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,13 +40,13 @@ namespace AnimationEditor.Modifications
|
||||
frameBox.SelectedIndices.Clear();
|
||||
foreach(int index in selection.SelectedFrames)
|
||||
{
|
||||
frameBox.SelectedIndex = index;
|
||||
frameBox.SelectedIndices.Add(index);
|
||||
}
|
||||
|
||||
frameSpriteBox.SelectedIndices.Clear();
|
||||
foreach(int index in selection.SelectedFrameSprites)
|
||||
{
|
||||
frameSpriteBox.SelectedIndex = index;
|
||||
frameSpriteBox.SelectedIndices.Add(index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
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 MoveSprite : IModification
|
||||
{
|
||||
private SelectionState preChangeSelection;
|
||||
private SelectionState postChangeSelection;
|
||||
|
||||
private BindingList<Sprite> sprites;
|
||||
private ListBox listBox;
|
||||
private List<int> indices;
|
||||
private Dictionary<int, Vector2> originalPositions;
|
||||
private Vector2 dist;
|
||||
|
||||
public MoveSprite(BindingList<Sprite> spriteList, ListBox spriteListBox, Vector2 distance)
|
||||
{
|
||||
sprites = spriteList;
|
||||
listBox = spriteListBox;
|
||||
indices = new List<int>();
|
||||
originalPositions = new Dictionary<int, Vector2>();
|
||||
foreach (int i in spriteListBox.SelectedIndices)
|
||||
{
|
||||
indices.Add(i);
|
||||
originalPositions.Add(i, sprites[i].Offset);
|
||||
}
|
||||
dist = distance;
|
||||
}
|
||||
|
||||
public void Do()
|
||||
{
|
||||
foreach (int index in indices)
|
||||
{
|
||||
sprites[index].Offset += dist;
|
||||
}
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
foreach (int index in indices)
|
||||
{
|
||||
sprites[index].Offset = originalPositions[index];
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
if (indices.Count == 1)
|
||||
return "Move Sprite";
|
||||
else
|
||||
return "Move Sprites";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,20 +31,17 @@ namespace AnimationEditor.Modifications
|
||||
|
||||
public void Do()
|
||||
{
|
||||
if (removeIndex > -1 && removeIndex < animations.Count)
|
||||
removedAnim = animations[removeIndex];
|
||||
if (animations.Count == 1)
|
||||
{
|
||||
removedAnim = animations[removeIndex];
|
||||
if (animations.Count == 1)
|
||||
animations[removeIndex] = new Animation();
|
||||
}
|
||||
else
|
||||
{
|
||||
animations.RemoveAt(removeIndex);
|
||||
if (animationBox.SelectedIndex > animations.Count - 1)
|
||||
{
|
||||
animations[removeIndex] = new Animation();
|
||||
}
|
||||
else
|
||||
{
|
||||
animations.RemoveAt(removeIndex);
|
||||
if (animationBox.SelectedIndex > animations.Count - 1)
|
||||
{
|
||||
animationBox.SelectedIndex--;
|
||||
}
|
||||
animationBox.SelectedIndex--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,22 +31,19 @@ namespace AnimationEditor.Modifications
|
||||
|
||||
public void Do()
|
||||
{
|
||||
if(removeIndex > -1 && removeIndex < frames.Count)
|
||||
removedFrame = frames[removeIndex];
|
||||
|
||||
if(frames.Count == 1)
|
||||
{
|
||||
removedFrame = frames[removeIndex];
|
||||
frames.Clear();
|
||||
frames.Add(new Frame());
|
||||
}
|
||||
else
|
||||
frames.RemoveAt(removeIndex);
|
||||
|
||||
if(frames.Count == 1)
|
||||
{
|
||||
frames.Clear();
|
||||
frames.Add(new Frame());
|
||||
}
|
||||
else
|
||||
frames.RemoveAt(removeIndex);
|
||||
|
||||
if (frames.Count > -1 && frameListBox.SelectedIndex > frames.Count - 1)
|
||||
{
|
||||
ModHelper.SetSingleSelection(frameListBox, frames.Count - 1);
|
||||
}
|
||||
if (frames.Count > -1 && frameListBox.SelectedIndex > frames.Count - 1)
|
||||
{
|
||||
ModHelper.SetSingleSelection(frameListBox, frames.Count - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,21 +30,18 @@ namespace AnimationEditor.Modifications
|
||||
|
||||
public void Do()
|
||||
{
|
||||
if(removeIndex > -1 && removeIndex < sprites.Count)
|
||||
removedSprite = sprites[removeIndex];
|
||||
|
||||
if(sprites.Count == 1)
|
||||
{
|
||||
removedSprite = sprites[removeIndex];
|
||||
sprites.Clear();
|
||||
}
|
||||
else
|
||||
sprites.RemoveAt(removeIndex);
|
||||
|
||||
if(sprites.Count == 1)
|
||||
{
|
||||
sprites.Clear();
|
||||
}
|
||||
else
|
||||
sprites.RemoveAt(removeIndex);
|
||||
|
||||
if (sprites.Count > -1 && spriteListBox.SelectedIndex > sprites.Count - 1)
|
||||
{
|
||||
ModHelper.SetSingleSelection(spriteListBox, sprites.Count - 1);
|
||||
}
|
||||
if (sprites.Count > -1 && spriteListBox.SelectedIndex > sprites.Count - 1)
|
||||
{
|
||||
ModHelper.SetSingleSelection(spriteListBox, sprites.Count - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +73,7 @@ namespace AnimationEditor.Modifications
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Remove Frame";
|
||||
return "Remove Sprite";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
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 RenameAnimation : IModification
|
||||
{
|
||||
private SelectionState preChangeSelection;
|
||||
private SelectionState postChangeSelection;
|
||||
|
||||
private BindingList<Animation> anims;
|
||||
private int index;
|
||||
private string originalName;
|
||||
private string newName;
|
||||
|
||||
public RenameAnimation(BindingList<Animation> animList, int index, string name)
|
||||
{
|
||||
anims = animList;
|
||||
this.index = index;
|
||||
originalName = anims[index].Name;
|
||||
newName = name;
|
||||
}
|
||||
|
||||
public void Do()
|
||||
{
|
||||
anims[index].Name = newName;
|
||||
anims.ResetBindings();
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
anims[index].Name = originalName;
|
||||
anims.ResetBindings();
|
||||
}
|
||||
|
||||
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 "Rename Animation";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
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 RenameFrame : IModification
|
||||
{
|
||||
private SelectionState preChangeSelection;
|
||||
private SelectionState postChangeSelection;
|
||||
|
||||
private BindingList<Frame> frames;
|
||||
private ListBox listBox;
|
||||
private List<int> indices;
|
||||
private Dictionary<int, string> originalNames;
|
||||
private string newName;
|
||||
|
||||
public RenameFrame(BindingList<Frame> frameList, ListBox frameListBox, string name)
|
||||
{
|
||||
frames = frameList;
|
||||
listBox = frameListBox;
|
||||
indices = new List<int>();
|
||||
originalNames = new Dictionary<int, string>();
|
||||
foreach(int i in frameListBox.SelectedIndices)
|
||||
{
|
||||
indices.Add(i);
|
||||
originalNames.Add(i, frames[i].Name);
|
||||
}
|
||||
newName = name;
|
||||
}
|
||||
|
||||
public void Do()
|
||||
{
|
||||
foreach (int index in indices)
|
||||
{
|
||||
frames[index].Name = newName;
|
||||
}
|
||||
frames.ResetBindings();
|
||||
listBox.SelectedIndices.Clear();
|
||||
foreach (int index in indices)
|
||||
{
|
||||
listBox.SelectedIndices.Add(index);
|
||||
}
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
foreach (int index in indices)
|
||||
{
|
||||
frames[index].Name = originalNames[index];
|
||||
}
|
||||
frames.ResetBindings();
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
if (indices.Count == 1)
|
||||
return "Rename Frame";
|
||||
else
|
||||
return "Rename Frames";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@ namespace AnimationEditor.Modifications
|
||||
private SelectionState preChangeSelection;
|
||||
private SelectionState postChangeSelection;
|
||||
|
||||
private BindingList<Frame> frames;
|
||||
private ListBox listBox;
|
||||
private int index;
|
||||
private int dir;
|
||||
private readonly BindingList<Frame> frames;
|
||||
private readonly ListBox listBox;
|
||||
private readonly int index;
|
||||
private readonly int dir;
|
||||
|
||||
public ReorderFrame(BindingList<Frame> frameList, ListBox frameListBox, int direction)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
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 ReorderSprite : IModification
|
||||
{
|
||||
private SelectionState preChangeSelection;
|
||||
private SelectionState postChangeSelection;
|
||||
|
||||
private BindingList<Sprite> sprites;
|
||||
private ListBox listBox;
|
||||
private int index;
|
||||
private int dir;
|
||||
|
||||
public ReorderSprite(BindingList<Sprite> spriteList, ListBox spriteListBox, int direction)
|
||||
{
|
||||
sprites = spriteList;
|
||||
listBox = spriteListBox;
|
||||
index = spriteListBox.SelectedIndex;
|
||||
dir = Math.Sign(direction);
|
||||
}
|
||||
|
||||
public void Do()
|
||||
{
|
||||
var movingFrame = sprites[index];
|
||||
sprites[index] = sprites[index + dir];
|
||||
sprites[index + dir] = movingFrame;
|
||||
ModHelper.SetSingleSelection(listBox, index + dir);
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
var movingFrame = sprites[index + dir];
|
||||
sprites[index + dir] = sprites[index];
|
||||
sprites[index] = movingFrame;
|
||||
ModHelper.SetSingleSelection(listBox, index);
|
||||
}
|
||||
|
||||
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 "Move Sprite";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
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 ReplaceSprite : IModification
|
||||
{
|
||||
private SelectionState preChangeSelection;
|
||||
private SelectionState postChangeSelection;
|
||||
|
||||
private BindingList<Sprite> sprites;
|
||||
private int index;
|
||||
private Sprite original;
|
||||
private Sprite replacement;
|
||||
|
||||
public ReplaceSprite(BindingList<Sprite> spriteList, int origIndex, Sprite newSprite)
|
||||
{
|
||||
sprites = spriteList;
|
||||
index = origIndex;
|
||||
original = sprites[index].Clone();
|
||||
replacement = newSprite;
|
||||
}
|
||||
|
||||
public void Do()
|
||||
{
|
||||
sprites[index].Name = replacement.Name;
|
||||
sprites[index].Bounds = replacement.Bounds;
|
||||
sprites[index].Origin = replacement.Origin;
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
sprites[index].Name = original.Name;
|
||||
sprites[index].Bounds = original.Bounds;
|
||||
sprites[index].Origin = original.Origin;
|
||||
}
|
||||
|
||||
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 "Replace Sprite";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
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 SetSpritePosition : IModification
|
||||
{
|
||||
private SelectionState preChangeSelection;
|
||||
private SelectionState postChangeSelection;
|
||||
|
||||
private BindingList<Sprite> sprites;
|
||||
private ListBox listBox;
|
||||
private int index;
|
||||
private Vector2 originalPosition;
|
||||
private Vector2 newPosition;
|
||||
|
||||
public SetSpritePosition(BindingList<Sprite> spriteList, ListBox spriteListBox, Vector2 newPos)
|
||||
{
|
||||
sprites = spriteList;
|
||||
listBox = spriteListBox;
|
||||
index = spriteListBox.SelectedIndex;
|
||||
originalPosition = sprites[index].Offset;
|
||||
newPosition = newPos;
|
||||
}
|
||||
|
||||
public void Do()
|
||||
{
|
||||
sprites[index].Offset = newPosition;
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
sprites[index].Offset = originalPosition;
|
||||
}
|
||||
|
||||
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 "Set Sprite Position";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user