public void AddNewEntry() { var entryId = string.Empty; _editService.Edit($"Add {typeof(T).Name} Entry {entryId}", () => entryId = _palette.AddEntry().Id, () => _palette.RemoveEntry(entryId), markAsIdOrNameDirty: true); }
public MinisteckPalette() { _palette = new Palette("Ministeck"); #if true _palette.AddEntry("first", new RGB(253, 254, 253)); _palette.AddEntry("", new RGB(206, 153, 50)); _palette.AddEntry("", new RGB(155, 101, 52)); _palette.AddEntry("", new RGB( 50, 50, 50)); _palette.AddEntry("", new RGB( 4, 3, 98)); _palette.AddEntry("", new RGB( 2, 102, 54)); _palette.AddEntry("", new RGB( 2, 50, 154)); _palette.AddEntry("", new RGB(254, 50, 102)); _palette.AddEntry("", new RGB(206, 154, 102)); _palette.AddEntry("", new RGB(254, 254, 50)); _palette.AddEntry("", new RGB(250, 90, 6)); _palette.AddEntry("", new RGB( 55, 101, 53)); _palette.AddEntry("", new RGB(103, 102, 101)); _palette.AddEntry("", new RGB(206, 2, 50)); _palette.AddEntry("", new RGB(254, 154, 54)); _palette.AddEntry("", new RGB(102, 50, 50)); _palette.AddEntry("", new RGB(253, 154, 154)); _palette.AddEntry("", new RGB( 50, 102, 206)); _palette.AddEntry("", new RGB( 3, 50, 56)); _palette.AddEntry("", new RGB( 50, 2, 102)); _palette.AddEntry("", new RGB(251, 155, 101)); _palette.AddEntry("", new RGB(254, 254, 202)); _palette.AddEntry("", new RGB( 4, 2, 2)); _palette.AddEntry("last", new RGB(206, 206, 206)); #else _palette.AddEntry("black" , new RGB( 7, 7, 7)); _palette.AddEntry("dark blue", new RGB( 64, 10, 121)); _palette.AddEntry("light blue", new RGB( 59, 138, 207)); _palette.AddEntry("light blue"), new RGB( 59, 138, 207)); #endif }
/// <summary> /// Changes the images starting from index. /// </summary> /// <param name="groupID"></param> /// <param name="index"></param> /// <param name="newDatas"></param> /// <returns></returns> public void ChangeImageData(string groupID, int index, ImageData[] newDatas) { if (newDatas[0].GetUsedColors().Length > 255) { throw new Exception("Imported images cannot have more than 255 colors!"); } //Prepare the new palette Palette p = paletteCollection.GetPalette(); int palettePosition = 0; int addedLength = 0; int oldIndex = (GetImage(index) as GfxImage)?.jobIndex ?? 0; for (int j = 0; j < newDatas.Length; j++) { if (index + j >= images.Length) { Array.Resize(ref images, index + j + 1); paletteCollection.GetPilFile().Resize(images.Length); p.AddEntry(); paletteCollection.GetPilFile().SetOffset(index + j, (paletteCollection.GetPilFile().GetOffset(index + j - 1) + 256 * 2)); images[index + j] = new GfxImage( null, p, paletteCollection.GetOffset(index + j)); images[index + j].jobIndex = index + j; offsetTable.AddOffset(); offsetTable.offsetTable[index + j] = (int)baseStream.Length + addedLength; } GfxImage i = images[index + j]; if (i.jobIndex != oldIndex) { palettePosition = 0; } int start = paletteCollection.GetOffset(i.jobIndex); i.Width = newDatas[j].width; i.Height = newDatas[j].height; //i.DataOffset = offsetTable.GetImageOffset(index + j) + 12; palettePosition += RecreatePaletteAt(start, palettePosition, newDatas[j]); i.buffer = i.CreateImageData(newDatas[j]); addedLength += i.buffer.Length; int nextImageStartOffset = offsetTable.GetImageOffset(index + j + 1); //Get the current offset of the next image int offset = Math.Max(0, offsetTable.GetImageOffset(index + j) + i.HeaderSize + i.buffer.Length - nextImageStartOffset - 1); //Our data could be larger, calculate how much larger if (offset != 0) //We want to move all images that follow our changed image, if our new image is bigger { offsetTable.AddOffsetToFollowing(index + j + 1, offset); } i.DataOffset = 0; //Hack, the data is still at the same offset, but the way the we handle the reading forces us to set it to 0, as we write the new image data to buffer[0...] instead of buffer[DataOffset...] oldIndex = i.jobIndex; Console.WriteLine($"{j}/{newDatas.Length} importing..."); } //return GetDataBufferCollection(groupID); }