Thank you so much!
It works brilliantly!
Saves a ton of time tinting sprites
Any way I can use the color picker for this though? Instead of defining the color string in the script itself.
Thanks a lot Tokei!
For both the answer and for developing Act Editor!
Oh, meanwhile, if you are planning to update it..
There are a lot of bugs in the Palette Editor.
Sometimes selecting a gradient palette, and pasting ARGB color does not update the palette. (Unless I first move the color picker around)
And the Undo tends to revert to the wrong colors.
I also have a suggestion for the ability to assign which area of the sprite will use which part of the palette.
(Sometimes I need a quick fix to those pesky nose color palettes!)
This might not be the place to report bugs, but I am not sure where to report.
Other than that, thanks a lot
------------------------------------------------------
EDIT: Edited the script, added the ability to preview the color in editor following the examples from other scripts.
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 GrfToWpfBridge;
using TokeiLibrary;
using TokeiLibrary.WPF;
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 "Fill Color"; }
}
public string Group {
get { return "Scripts"; }
}
public string InputGesture {
get { return "Ctrl-Shift-N"; }
}
public string Image {
get { return "pal.png"; }
}
public void Execute(Act act, int selectedActionIndex, int selectedFrameIndex, int[] selectedLayerIndexes) {
if (act == null) return;
var frame = act[selectedActionIndex, selectedFrameIndex];
GrfColor startColor;
if (frame.Layers.Count == 0) {
startColor = GrfColor.White;
}
else {
startColor = act[selectedActionIndex, selectedFrameIndex, 0].Color;
}
ColorPicker.PickerDialog picker = new ColorPicker.PickerDialog(startColor.ToColor(), ColorPicker.Core.ColorMode.Hue);
picker.Owner = WpfUtilities.TopWindow;
picker.PickerControl.PreviewColorChanged += (s, color) => _previewUpdate(act, color.ToGrfColor());
picker.PickerControl.ColorChanged += (s, color) => _previewUpdate(act, color.ToGrfColor());
picker.ShowDialog();
act.Commands.SetColor(startColor);
if (picker.DialogResult) {
try {
act.Commands.Begin();
GrfColor newColor = picker.PickerControl.SelectedColor.ToGrfColor();
act.Commands.SetColor(newColor);
}
catch (Exception err) {
act.Commands.CancelEdit();
ErrorHandler.HandleException(err, ErrorLevel.Warning);
}
finally {
act.Commands.End();
act.InvalidateVisual();
}
}
}
public bool CanExecute(Act act, int selectedActionIndex, int selectedFrameIndex, int[] selectedLayerIndexes) {
return act != null;
}
private void _previewUpdate(Act act, GrfColor color) {
act.Commands.SetColor(color);
act.InvalidateVisual();
}
}
}
I hope I am doing this right, just sharing for people who is looking for the same script