Added: ReorderFrame
This commit is contained in:
@@ -68,6 +68,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Modifications\AddAnimation.cs" />
|
||||
<Compile Include="Modifications\AddSprite.cs" />
|
||||
<Compile Include="Modifications\ReorderFrame.cs" />
|
||||
<Compile Include="Modifications\RemoveAnimation.cs" />
|
||||
<Compile Include="Modifications\RemoveSprite.cs" />
|
||||
<Compile Include="Modifications\RemoveFrame.cs" />
|
||||
|
||||
@@ -370,11 +370,14 @@ namespace AnimationEditor
|
||||
{
|
||||
if (frameListBox.SelectedIndices.Count == 1 && frameListBox.SelectedIndex < frames.Count - 1)
|
||||
{
|
||||
MoveListItem(frames, frameListBox, 1);
|
||||
/*
|
||||
var frameBelow = frames[frameListBox.SelectedIndex + 1];
|
||||
frames[frameListBox.SelectedIndex + 1] = currentFrame;
|
||||
frames[frameListBox.SelectedIndex] = frameBelow;
|
||||
UpdateAnimation();
|
||||
frameListBox_SetSingleSelection(frameListBox.SelectedIndex + 1);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,14 +385,25 @@ namespace AnimationEditor
|
||||
{
|
||||
if (frameListBox.SelectedIndices.Count == 1 && frameListBox.SelectedIndex > 0)
|
||||
{
|
||||
MoveListItem(frames, frameListBox, -1);
|
||||
/*
|
||||
var frameAbove = frames[frameListBox.SelectedIndex - 1];
|
||||
frames[frameListBox.SelectedIndex - 1] = currentFrame;
|
||||
frames[frameListBox.SelectedIndex] = frameAbove;
|
||||
UpdateAnimation();
|
||||
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)
|
||||
{
|
||||
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";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user