Added: ReorderFrame

This commit is contained in:
quinnvoker
2018-12-29 07:11:27 -08:00
parent 748d772079
commit e2702bb932
3 changed files with 86 additions and 0 deletions
+1
View File
@@ -68,6 +68,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="Modifications\AddAnimation.cs" /> <Compile Include="Modifications\AddAnimation.cs" />
<Compile Include="Modifications\AddSprite.cs" /> <Compile Include="Modifications\AddSprite.cs" />
<Compile Include="Modifications\ReorderFrame.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" />
+14
View File
@@ -370,11 +370,14 @@ namespace AnimationEditor
{ {
if (frameListBox.SelectedIndices.Count == 1 && frameListBox.SelectedIndex < frames.Count - 1) if (frameListBox.SelectedIndices.Count == 1 && frameListBox.SelectedIndex < frames.Count - 1)
{ {
MoveListItem(frames, frameListBox, 1);
/*
var frameBelow = frames[frameListBox.SelectedIndex + 1]; var frameBelow = frames[frameListBox.SelectedIndex + 1];
frames[frameListBox.SelectedIndex + 1] = currentFrame; frames[frameListBox.SelectedIndex + 1] = currentFrame;
frames[frameListBox.SelectedIndex] = frameBelow; frames[frameListBox.SelectedIndex] = frameBelow;
UpdateAnimation(); UpdateAnimation();
frameListBox_SetSingleSelection(frameListBox.SelectedIndex + 1); frameListBox_SetSingleSelection(frameListBox.SelectedIndex + 1);
*/
} }
} }
@@ -382,14 +385,25 @@ namespace AnimationEditor
{ {
if (frameListBox.SelectedIndices.Count == 1 && frameListBox.SelectedIndex > 0) if (frameListBox.SelectedIndices.Count == 1 && frameListBox.SelectedIndex > 0)
{ {
MoveListItem(frames, frameListBox, -1);
/*
var frameAbove = frames[frameListBox.SelectedIndex - 1]; var frameAbove = frames[frameListBox.SelectedIndex - 1];
frames[frameListBox.SelectedIndex - 1] = currentFrame; frames[frameListBox.SelectedIndex - 1] = currentFrame;
frames[frameListBox.SelectedIndex] = frameAbove; frames[frameListBox.SelectedIndex] = frameAbove;
UpdateAnimation(); UpdateAnimation();
frameListBox_SetSingleSelection(frameListBox.SelectedIndex - 1); frameListBox_SetSingleSelection(frameListBox.SelectedIndex - 1);
*/
} }
} }
private void MoveListItem(BindingList<Frame> frameList, ListBox frameBox, int dir)
{
var mod = new ReorderFrame(frameList, frameBox, dir);
ModHelper.DoModificationWithSelectionTracking(mod, animationBox, frameListBox, frameSpriteListBox);
undoHistory.Add(mod);
UpdateAnimation();
}
private void removeFrameButton_Click(object sender, EventArgs e) private void removeFrameButton_Click(object sender, EventArgs e)
{ {
if(frameListBox.SelectedIndices.Count == 1 && frameListBox.SelectedIndex > -1 && frameListBox.SelectedIndex < frames.Count) if(frameListBox.SelectedIndices.Count == 1 && frameListBox.SelectedIndex > -1 && frameListBox.SelectedIndex < frames.Count)
@@ -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 ReorderFrame : IModification
{
private SelectionState preChangeSelection;
private SelectionState postChangeSelection;
private BindingList<Frame> frames;
private ListBox listBox;
private int index;
private int dir;
public ReorderFrame(BindingList<Frame> frameList, ListBox frameListBox, int direction)
{
frames = frameList;
listBox = frameListBox;
index = frameListBox.SelectedIndex;
dir = Math.Sign(direction);
}
public void Do()
{
var movingFrame = frames[index];
frames[index] = frames[index + dir];
frames[index + dir] = movingFrame;
ModHelper.SetSingleSelection(listBox, index + dir);
}
public void Undo()
{
var movingFrame = frames[index + dir];
frames[index + dir] = frames[index];
frames[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 Frame";
}
}
}