using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using ErrorManager;
using GRF.FileFormats.ActFormat;
using GRF.FileFormats.SprFormat;
using GRF.FileFormats.PalFormat;
using GRF.Image;
using GRF.Image.Decoders;
using GRF.Graphics;
using GRF.Core;
using GRF.IO;
using GRF.System;
using GrfToWpfBridge;
using TokeiLibrary;
using TokeiLibrary.WPF;
using Utilities;
using Utilities.Extension;
using Action = GRF.FileFormats.ActFormat.Action;
using Frame = GRF.FileFormats.ActFormat.Frame;
using Point = System.Windows.Point;
namespace Scripts {
public class Script : IActScript {
public object DisplayName {
get { return "MyCustomScript"; }
}
public string Group {
get { return "Scripts"; }
}
public string InputGesture {
get { return null; }
}
public string Image {
get { return null; }
}
public void Execute(Act act, int selectedActionIndex, int selectedFrameIndex, int[] selectedLayerIndexes) {
if (act == null) return;
try {
act.Commands.Begin();
act.Commands.Backup(_ => {
foreach (var action in act) {
foreach (var frame in action) {
Layer layer = new Layer(act.Sprite.Images.Count - 1, act.Sprite);
layer.OffsetX = 0;
layer.OffsetY = -144;
layer.Mirror = false;
frame.Layers.Add(layer);
}
}
}, "MyCustomScript", true);
}
catch (Exception err) {
act.Commands.CancelEdit();
ErrorHandler.HandleException(err, ErrorLevel.Warning);
}
finally {
act.Commands.End();
act.InvalidateVisual();
act.InvalidateSpriteVisual();
}
}
public bool CanExecute(Act act, int selectedActionIndex, int selectedFrameIndex, int[] selectedLayerIndexes) {
return true;
//return act != null;
}
}
}