private void AssignSpritesToView(List<int> spriteNumbers, AssignToView dialog)
{
int loop = dialog.LoopNumber;
if (dialog.ReverseFrames)
{
spriteNumbers.Reverse();
}
AGS.Types.View view = Factory.AGSEditor.CurrentGame.FindViewByID(dialog.ViewNumber);
if (view == null)
{
Factory.GUIController.ShowMessage("The view number you selected (" + dialog.ViewNumber + ") does not exist.", MessageBoxIcon.Warning);
return;
}
while (loop >= view.Loops.Count)
{
view.AddNewLoop();
}
if (!dialog.AddFramesToExistingLoop)
{
view.Loops[loop].Frames.Clear();
}
foreach (int spriteNum in spriteNumbers)
{
if (view.Loops[loop].Full)
{
if (!dialog.ContinueIntoNextLoop)
{
Factory.GUIController.ShowMessage("The selected loop is now full. Not all the selected sprites were assigned.", MessageBoxIcon.Information);
view.NotifyClientsOfUpdate();
return;
}
loop++;
if (loop >= view.Loops.Count)
{
view.AddNewLoop();
}
view.Loops[loop - 1].RunNextLoop = true;
}
ViewFrame newFrame = new ViewFrame();
newFrame.ID = view.Loops[loop].Frames.Count;
newFrame.Image = spriteNum;
if (dialog.FlipFrames)
{
newFrame.Flipped = true;
}
view.Loops[loop].Frames.Add(newFrame);
}
Factory.GUIController.ShowMessage("The selected sprites were assigned successfully.", MessageBoxIcon.Information);
view.NotifyClientsOfUpdate();
}