Add a search interface for visually filtering all slots (#4712)

* Add slot search to box editor
Alt-Click: Clears the current search.
Shift-Click: Jump to the next box with a result.
This commit is contained in:
Kurt 2026-02-09 22:03:18 -06:00 committed by GitHub
parent 0f8321cda4
commit 20905cbe67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
43 changed files with 1502 additions and 476 deletions

View File

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
namespace PKHeX.Core;
@ -48,4 +49,11 @@ public interface ISlotViewer<T>
/// Save data the <see cref="ISlotViewer{T}"/> is showing data from.
/// </summary>
SaveFile SAV { get; }
/// <summary>
/// Instructs the viewer to cache the provided filter and apply it to all slots, showing only those that match the filter.
/// </summary>
/// <param name="filter">Filter function to apply to the viewer's slots. Only slots for which this function returns true will be shown in the viewer.</param>
/// <param name="reload">Trigger a reload of the viewer after applying the new filter. This is required to update the viewer's display after changing the filter.</param>
void ApplyNewFilter(Func<PKM, bool>? filter, bool reload = true);
}

View File

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
namespace PKHeX.Core;
@ -11,6 +12,7 @@ public sealed class SlotPublisher<T>
/// All <see cref="ISlotViewer{T}"/> instances that provide a view on individual <see cref="ISlotInfo"/> content.
/// </summary>
private List<ISlotViewer<T>> Subscribers { get; } = [];
private Func<PKM, bool>? Filter { get; set; }
public ISlotInfo? Previous { get; private set; }
public SlotTouchType PreviousType { get; private set; } = SlotTouchType.None;
@ -49,4 +51,11 @@ public void ResetView(ISlotViewer<T> sub)
public void Subscribe(ISlotViewer<T> sub) => Subscribers.Add(sub);
public bool Unsubscribe(ISlotViewer<T> sub) => Subscribers.Remove(sub);
public void UpdateFilter(Func<PKM, bool>? searchFilter, bool reload = true)
{
Filter = searchFilter;
foreach (var sub in Subscribers)
sub.ApplyNewFilter(Filter, reload);
}
}

View File

@ -0,0 +1,26 @@
using System;
namespace PKHeX.Core;
/// <summary>
/// Specifies the visibility options for a slot when it is displayed in the user interface.
/// </summary>
/// <remarks>This enumeration supports bitwise combination of its values to allow multiple visibility behaviors to be applied simultaneously.</remarks>
[Flags]
public enum SlotVisibilityType
{
/// <summary>
/// No special visibility handling.
/// </summary>
None,
/// <summary>
/// Check the legality of the slot when displaying it.
/// </summary>
CheckLegalityIndicate = 1 << 0,
/// <summary>
/// Fade-out the slot if it does not match the current filter.
/// </summary>
FilterMismatch = 1 << 1,
}

View File

@ -27,13 +27,19 @@ public static class SearchUtil
_ => pk.Generation == generation,
};
public static bool SatisfiesFilterLevel(PKM pk, SearchComparison option, byte level) => option switch
public static bool SatisfiesFilterLevel(PKM pk, SearchComparison option, byte level)
{
SearchComparison.LessThanEquals => pk.Stat_Level <= level,
SearchComparison.Equals => pk.Stat_Level == level,
SearchComparison.GreaterThanEquals => pk.Stat_Level >= level,
_ => true,
};
var current = pk.Stat_Level;
if (current == 0)
current = pk.CurrentLevel;
return option switch
{
SearchComparison.LessThanEquals => current <= level,
SearchComparison.Equals => current == level,
SearchComparison.GreaterThanEquals => current >= level,
_ => true,
};
}
public static bool SatisfiesFilterEVs(PKM pk, int option) => option switch
{
@ -127,7 +133,37 @@ public static bool SatisfiesFilterNickname(PKM pk, ReadOnlySpan<char> nicknameSu
int length = pk.LoadString(pk.NicknameTrash, name);
name = name[..length];
// Compare the nickname filter against the PKM's nickname, ignoring case.
// Compare the nickname filter against the Entity's nickname, ignoring case.
return name.Contains(nicknameSubstring, StringComparison.OrdinalIgnoreCase);
}
public static bool TrySeekNext(SaveFile sav, Func<PKM, bool> searchFilter, out (int Box, int Slot) result, int current = -1)
{
// Search from next box, wrapping around
var boxCount = sav.BoxCount;
var boxSlotCount = sav.BoxSlotCount;
var startBox = (current + 1) % boxCount;
for (int i = 0; i < boxCount; i++)
{
var box = (startBox + i) % boxCount;
for (int slot = 0; slot < boxSlotCount; slot++)
{
var pk = sav.GetBoxSlotAtIndex(box, slot);
if (pk.Species == 0)
continue;
if (!searchFilter(pk))
continue;
// Match found. Seek to the box, and Focus on the slot.
result = (box, slot);
return true;
}
}
// None found.
result = default;
return false;
}
}

View File

@ -14,7 +14,7 @@ public static class QRImageUtil
/// <param name="qr">The base QR code image.</param>
/// <param name="preview">The preview image to overlay.</param>
/// <returns>A new bitmap with the preview image centered on the QR code.</returns>
public static Bitmap GetQRImage(Image qr, Image preview)
public static Bitmap GetQRImage(Bitmap qr, Image preview)
{
// create a small area with the pk sprite, with a white background
var foreground = new Bitmap(preview.Width + 4, preview.Height + 4);
@ -45,7 +45,7 @@ public static Bitmap GetQRImage(Image qr, Image preview)
/// <param name="lines">The lines of text to display.</param>
/// <param name="extraText">Additional text to display.</param>
/// <returns>A new bitmap with the preview image and extended text.</returns>
public static Bitmap GetQRImageExtended(Font font, Image qr, Image pk, int width, int height, ReadOnlySpan<string> lines, string extraText)
public static Bitmap GetQRImageExtended(Font font, Bitmap qr, Image pk, int width, int height, ReadOnlySpan<string> lines, string extraText)
{
var pic = GetQRImage(qr, pk);
return ExtendImage(font, qr, width, height, pic, lines, extraText);

View File

@ -24,9 +24,9 @@ private static Bitmap GetSprite(MysteryGift gift)
var img = GetBaseImage(gift);
if (SpriteBuilder.ShowEncounterColor != SpriteBackgroundType.None)
img = SpriteUtil.ApplyEncounterColor(gift, img, SpriteBuilder.ShowEncounterColor);
SpriteUtil.ApplyEncounterColor(gift, img, SpriteBuilder.ShowEncounterColor);
if (gift.GiftUsed)
img = ImageUtil.ChangeOpacity(img, 0.3);
img.ChangeOpacity(0.3);
return img;
}

View File

@ -64,4 +64,14 @@ public interface ISpriteSettings
/// Opacity of the Tera Type stripe overlay.
/// </summary>
byte ShowTeraOpacityStripe { get; set; }
/// <summary>
/// Opacity of an entity that does not match a filter.
/// </summary>
float FilterMismatchOpacity { get; set; }
/// <summary>
/// Grayscale amount to apply to an entity that does not match a filter (0.0f = no grayscale, 1.0f = fully grayscale).
/// </summary>
float FilterMismatchGrayscale { get; set; }
}

View File

@ -18,6 +18,8 @@ public abstract class SpriteBuilder : ISpriteBuilder<Bitmap>
public static byte ShowEncounterOpacityStripe { get; set; }
public static byte ShowEncounterOpacityBackground { get; set; }
public static int ShowEncounterThicknessStripe { get; set; }
public static float FilterMismatchOpacity { get; set; }
public static float FilterMismatchGrayscale { get; set; }
/// <summary> Width of the generated Sprite image. </summary>
public abstract int Width { get; }
@ -180,7 +182,7 @@ private Bitmap GetBaseImageFallback(ushort species, byte form, byte gender, uint
return ImageUtil.LayerImage(baseImage, Unknown, 0, 0, UnknownFormTransparency);
}
private Bitmap LayerOverImageItem(Image baseImage, int item, EntityContext context)
private Bitmap LayerOverImageItem(Bitmap baseImage, int item, EntityContext context)
{
var lump = HeldItemLumpUtil.GetIsLump(item, context);
var itemimg = lump switch
@ -196,7 +198,7 @@ private Bitmap LayerOverImageItem(Image baseImage, int item, EntityContext conte
return ImageUtil.LayerImage(baseImage, itemimg, x, y);
}
private static Bitmap LayerOverImageShiny(Image baseImage, Shiny shiny)
private static Bitmap LayerOverImageShiny(Bitmap baseImage, Shiny shiny)
{
// Add shiny star to top left of image.
Bitmap rare;
@ -207,23 +209,23 @@ private static Bitmap LayerOverImageShiny(Image baseImage, Shiny shiny)
return ImageUtil.LayerImage(baseImage, rare, 0, 0, ShinyTransparency);
}
private Bitmap LayerOverImageEgg(Image baseImage, ushort species, bool hasItem)
private Bitmap LayerOverImageEgg(Bitmap baseImage, ushort species, bool hasItem)
{
if (ShowEggSpriteAsItem && !hasItem)
return LayerOverImageEggAsItem(baseImage, species);
return LayerOverImageEggTransparentSpecies(baseImage, species);
}
private Bitmap LayerOverImageEggTransparentSpecies(Image baseImage, ushort species)
private Bitmap LayerOverImageEggTransparentSpecies(Bitmap baseImage, ushort species)
{
// Partially transparent species.
baseImage = ImageUtil.ChangeOpacity(baseImage, EggUnderLayerTransparency);
baseImage.ChangeOpacity(EggUnderLayerTransparency);
// Add the egg layer over-top with full opacity.
var egg = GetEggSprite(species);
return ImageUtil.LayerImage(baseImage, egg, 0, 0);
}
private Bitmap LayerOverImageEggAsItem(Image baseImage, ushort species)
private Bitmap LayerOverImageEggAsItem(Bitmap baseImage, ushort species)
{
var egg = GetEggSprite(species);
return ImageUtil.LayerImage(baseImage, egg, EggItemShiftX, EggItemShiftY); // similar to held item, since they can't have any
@ -245,5 +247,8 @@ public static void LoadSettings(ISpriteSettings sprite)
ShowTeraThicknessStripe = sprite.ShowTeraThicknessStripe;
ShowTeraOpacityBackground = sprite.ShowTeraOpacityBackground;
ShowTeraOpacityStripe = sprite.ShowTeraOpacityStripe;
FilterMismatchOpacity = sprite.FilterMismatchOpacity;
FilterMismatchGrayscale = sprite.FilterMismatchGrayscale;
}
}

View File

@ -95,7 +95,7 @@ private static Bitmap GetSprite(PKM pk)
return img;
}
private static Bitmap GetSprite(PKM pk, SaveFile sav, int box, int slot, bool flagIllegal = false, StorageSlotType storage = StorageSlotType.None)
private static Bitmap GetSprite(PKM pk, SaveFile sav, int box, int slot, SlotVisibilityType visibility = SlotVisibilityType.None, StorageSlotType storage = StorageSlotType.None)
{
bool inBox = (uint)slot < MaxSlotCount;
bool empty = pk.Species == 0;
@ -107,9 +107,9 @@ private static Bitmap GetSprite(PKM pk, SaveFile sav, int box, int slot, bool fl
{
var type = t.TeraType;
if (TeraTypeUtil.IsOverrideValid((byte)type))
sprite = ApplyTeraColor((byte)type, sprite, SpriteBuilder.ShowTeraType);
ApplyTeraColor((byte)type, sprite, SpriteBuilder.ShowTeraType);
}
if (flagIllegal)
if (visibility.HasFlag(SlotVisibilityType.CheckLegalityIndicate))
{
var la = pk.GetType() == sav.PKMType // quick sanity check
? new LegalityAnalysis(pk, sav.Personal, storage)
@ -121,10 +121,10 @@ private static Bitmap GetSprite(PKM pk, SaveFile sav, int box, int slot, bool fl
sprite = ImageUtil.LayerImage(sprite, Resources.hint, 0, FlagIllegalShiftY);
if (SpriteBuilder.ShowEncounterColorPKM != SpriteBackgroundType.None)
sprite = ApplyEncounterColor(la.EncounterOriginal, sprite, SpriteBuilder.ShowEncounterColorPKM);
ApplyEncounterColor(la.EncounterOriginal, sprite, SpriteBuilder.ShowEncounterColorPKM);
if (SpriteBuilder.ShowExperiencePercent)
sprite = ApplyExperience(pk, sprite, la.EncounterMatch);
ApplyExperience(pk, sprite, la.EncounterMatch);
}
}
if (inBox) // in box
@ -146,32 +146,32 @@ private static Bitmap GetSprite(PKM pk, SaveFile sav, int box, int slot, bool fl
sprite = ImageUtil.LayerImage(sprite, Resources.starter, 0, 0);
}
if (SpriteBuilder.ShowExperiencePercent && !flagIllegal)
sprite = ApplyExperience(pk, sprite);
if (SpriteBuilder.ShowExperiencePercent && !visibility.HasFlag(SlotVisibilityType.CheckLegalityIndicate))
ApplyExperience(pk, sprite);
return sprite;
}
private static Bitmap ApplyTeraColor(byte elementalType, Bitmap img, SpriteBackgroundType type)
private static void ApplyTeraColor(byte elementalType, Bitmap img, SpriteBackgroundType type)
{
var color = TypeColor.GetTeraSpriteColor(elementalType);
var thk = SpriteBuilder.ShowTeraThicknessStripe;
var op = SpriteBuilder.ShowTeraOpacityStripe;
var bg = SpriteBuilder.ShowTeraOpacityBackground;
return ApplyColor(img, type, color, thk, op, bg);
ApplyColor(img, type, color, thk, op, bg);
}
public static Bitmap ApplyEncounterColor(IEncounterTemplate enc, Bitmap img, SpriteBackgroundType type)
public static void ApplyEncounterColor(IEncounterTemplate enc, Bitmap img, SpriteBackgroundType type)
{
var index = (enc.GetType().Name.GetHashCode() * 0x43FD43FD);
var color = Color.FromArgb(index);
var thk = SpriteBuilder.ShowEncounterThicknessStripe;
var op = SpriteBuilder.ShowEncounterOpacityStripe;
var bg = SpriteBuilder.ShowEncounterOpacityBackground;
return ApplyColor(img, type, color, thk, op, bg);
ApplyColor(img, type, color, thk, op, bg);
}
private static Bitmap ApplyColor(Bitmap img, SpriteBackgroundType type, Color color, int thick, byte opacStripe, byte opacBack)
private static void ApplyColor(Bitmap img, SpriteBackgroundType type, Color color, int thick, byte opacStripe, byte opacBack)
{
if (type == SpriteBackgroundType.BottomStripe)
{
@ -179,38 +179,43 @@ private static Bitmap ApplyColor(Bitmap img, SpriteBackgroundType type, Color co
if ((uint)stripeHeight > img.Height) // clamp negative & too-high values back to height.
stripeHeight = img.Height;
return ImageUtil.BlendTransparentTo(img, color, opacStripe, img.Width * 4 * (img.Height - stripeHeight));
img.BlendTransparentTo(color, opacStripe, img.Width * 4 * (img.Height - stripeHeight));
}
if (type == SpriteBackgroundType.TopStripe)
else if (type == SpriteBackgroundType.TopStripe)
{
int stripeHeight = thick; // from top
if ((uint)stripeHeight > img.Height) // clamp negative & too-high values back to height.
stripeHeight = img.Height;
return ImageUtil.BlendTransparentTo(img, color, opacStripe, 0, (img.Width * 4 * stripeHeight) - 4);
img.BlendTransparentTo(color, opacStripe, 0, img.Width * 4 * stripeHeight);
}
if (type == SpriteBackgroundType.FullBackground) // full background
else if (type == SpriteBackgroundType.FullBackground) // full background
{
return ImageUtil.ChangeTransparentTo(img, color, opacBack);
img.ChangeTransparentTo(color, opacBack);
}
return img;
}
private static Bitmap ApplyExperience(PKM pk, Bitmap img, IEncounterTemplate? enc = null)
private static void ApplyExperience(PKM pk, Bitmap img, IEncounterTemplate? enc = null)
{
const int bpp = 4;
int start = bpp * SpriteWidth * (SpriteHeight - 1);
var level = pk.CurrentLevel;
if (level == Experience.MaxLevel)
return ImageUtil.WritePixels(img, Color.Lime, start, start + (SpriteWidth * bpp));
{
img.WritePixels(Color.Lime, start, start + (SpriteWidth * bpp));
return;
}
var pct = Experience.GetEXPToLevelUpPercentage(level, pk.EXP, pk.PersonalInfo.EXPGrowth);
if (pct is not 0)
return ImageUtil.WritePixels(img, Color.DodgerBlue, start, start + (int)(SpriteWidth * pct * bpp));
{
img.WritePixels(Color.DodgerBlue, start, start + (int)(SpriteWidth * pct * bpp));
return;
}
var encLevel = enc is { IsEgg: true } ? enc.LevelMin : pk.MetLevel;
var color = level != encLevel && pk.HasOriginalMetLocation ? Color.DarkOrange : Color.Yellow;
return ImageUtil.WritePixels(img, color, start, start + (SpriteWidth * bpp));
img.WritePixels(color, start, start + (SpriteWidth * bpp));
}
private static readonly Bitmap[] PartyMarks =
@ -218,7 +223,7 @@ private static Bitmap ApplyExperience(PKM pk, Bitmap img, IEncounterTemplate? en
Resources.party1, Resources.party2, Resources.party3, Resources.party4, Resources.party5, Resources.party6,
];
public static void GetSpriteGlow(PKM pk, byte blue, byte green, byte red, out byte[] pixels, out Image baseSprite, bool forceHollow = false)
public static void GetSpriteGlow(PKM pk, byte blue, byte green, byte red, out byte[] pixels, out Bitmap baseSprite, bool forceHollow = false)
{
bool egg = pk.IsEgg;
var formarg = pk is IFormArgument f ? f.FormArgument : 0;
@ -227,9 +232,9 @@ public static void GetSpriteGlow(PKM pk, byte blue, byte green, byte red, out by
GetSpriteGlow(baseSprite, blue, green, red, out pixels, forceHollow || egg);
}
public static void GetSpriteGlow(Image baseSprite, byte blue, byte green, byte red, out byte[] pixels, bool forceHollow = false)
public static void GetSpriteGlow(Bitmap baseSprite, byte blue, byte green, byte red, out byte[] pixels, bool forceHollow = false)
{
pixels = ImageUtil.GetPixelData((Bitmap)baseSprite);
pixels = baseSprite.GetBitmapData();
if (!forceHollow)
{
ImageUtil.GlowEdges(pixels, blue, green, red, baseSprite.Width);
@ -279,7 +284,7 @@ public static Bitmap Sprite(this IEncounterTemplate enc)
img = ImageUtil.LayerImage(img, alpha, SlotTeamShiftX, 0);
}
if (SpriteBuilder.ShowEncounterColor != SpriteBackgroundType.None)
img = ApplyEncounterColor(enc, img, SpriteBuilder.ShowEncounterColor);
ApplyEncounterColor(enc, img, SpriteBuilder.ShowEncounterColor);
return img;
}
@ -291,8 +296,17 @@ public static Bitmap Sprite(this IEncounterTemplate enc)
};
public static Bitmap Sprite(this PKM pk, SaveFile sav, int box = -1, int slot = -1,
bool flagIllegal = false, StorageSlotType storage = StorageSlotType.None)
=> GetSprite(pk, sav, box, slot, flagIllegal, storage);
SlotVisibilityType visibility = SlotVisibilityType.None, StorageSlotType storage = StorageSlotType.None)
{
var result = GetSprite(pk, sav, box, slot, visibility, storage);
if (visibility.HasFlag(SlotVisibilityType.FilterMismatch))
{
// Fade out the sprite.
result.ToGrayscale(SpriteBuilder.FilterMismatchGrayscale);
result.ChangeOpacity(SpriteBuilder.FilterMismatchOpacity);
}
return result;
}
public static Bitmap GetMysteryGiftPreviewPoke(MysteryGift gift)
{

View File

@ -11,92 +11,180 @@ namespace PKHeX.Drawing;
/// </summary>
public static class ImageUtil
{
public static Bitmap LayerImage(Image baseLayer, Image overLayer, int x, int y, double transparency)
extension(Bitmap bmp)
{
overLayer = ChangeOpacity(overLayer, transparency);
/// <summary>
/// Locks the bitmap and returns a span containing its raw pixel data in the specified pixel format.
/// </summary>
/// <remarks>
/// The returned span provides direct access to the bitmap's memory. Modifying the span will update the bitmap.
/// The caller is responsible for unlocking the bitmap using <see cref="Bitmap.UnlockBits"/> after processing. This method is not thread-safe.
/// </remarks>
/// <param name="bmpData">
/// When this method returns, contains a BitmapData object representing the locked bitmap area.
/// The caller must unlock the bitmap after processing the data.
/// </param>
/// <param name="format">
/// The pixel format to use when locking the bitmap.
/// Defaults to <see cref="PixelFormat.Format32bppArgb"/> to ensure the usages within this utility class process pixels in the expected way.
/// </param>
/// <returns>A span of bytes representing the bitmap's pixel data. The span covers the entire bitmap in the specified pixel format.</returns>
public Span<byte> GetBitmapData(out BitmapData bmpData, PixelFormat format = PixelFormat.Format32bppArgb)
{
bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, format);
var bpp = Image.GetPixelFormatSize(format) / 8;
return GetSpan(bmpData.Scan0, bmp.Width * bmp.Height * bpp);
}
public void GetBitmapData(Span<byte> data, PixelFormat format = PixelFormat.Format32bppArgb)
{
var span = bmp.GetBitmapData(out var bmpData, format);
span.CopyTo(data);
bmp.UnlockBits(bmpData);
}
public void GetBitmapData(Span<int> data)
{
var span = bmp.GetBitmapData(out var bmpData);
var src = MemoryMarshal.Cast<byte, int>(span);
src.CopyTo(data);
bmp.UnlockBits(bmpData);
}
public void SetBitmapData(ReadOnlySpan<byte> data, PixelFormat format = PixelFormat.Format32bppArgb)
{
var span = bmp.GetBitmapData(out var bmpData, format);
data.CopyTo(span);
bmp.UnlockBits(bmpData);
}
public void SetBitmapData(Span<int> data)
{
var span = bmp.GetBitmapData(out var bmpData);
var dest = MemoryMarshal.Cast<byte, int>(span);
data.CopyTo(dest);
bmp.UnlockBits(bmpData);
}
public byte[] GetBitmapData()
{
var format = bmp.PixelFormat;
var bpp = Image.GetPixelFormatSize(format) / 8;
var result = new byte[bmp.Width * bmp.Height * bpp];
bmp.GetBitmapData(result, format);
return result;
}
public void ToGrayscale(float intensity)
{
if (intensity is <= 0.01f or > 1f)
return; // don't care
var data = bmp.GetBitmapData(out var bmpData);
SetAllColorToGrayScale(data, intensity);
bmp.UnlockBits(bmpData);
}
public void ChangeOpacity(double trans)
{
if (trans is <= 0.01f or > 1f)
return; // don't care
var data = bmp.GetBitmapData(out var bmpData);
SetAllTransparencyTo(data, trans);
bmp.UnlockBits(bmpData);
}
public void BlendTransparentTo(Color c, byte trans, int start = 0, int end = -1)
{
var data = bmp.GetBitmapData(out var bmpData);
if (end == -1)
end = data.Length;
BlendAllTransparencyTo(data[start..end], c, trans);
bmp.UnlockBits(bmpData);
}
public void ChangeAllColorTo(Color c)
{
var data = bmp.GetBitmapData(out var bmpData);
ChangeAllColorTo(data, c);
bmp.UnlockBits(bmpData);
}
public void ChangeTransparentTo(Color c, byte trans, int start = 0, int end = -1)
{
var data = bmp.GetBitmapData(out var bmpData);
if (end == -1)
end = data.Length;
SetAllTransparencyTo(data[start..end], c, trans);
bmp.UnlockBits(bmpData);
}
public void WritePixels(Color c, int start, int end)
{
var data = bmp.GetBitmapData(out var bmpData);
ChangeAllTo(data, c, start, end);
bmp.UnlockBits(bmpData);
}
public int GetAverageColor()
{
var data = bmp.GetBitmapData(out var bmpData);
var avg = GetAverageColor(data);
bmp.UnlockBits(bmpData);
return avg;
}
}
private static Span<byte> GetSpan(IntPtr ptr, int length)
=> MemoryMarshal.CreateSpan(ref Unsafe.AddByteOffset(ref Unsafe.NullRef<byte>(), ptr), length);
public static Bitmap LayerImage(Bitmap baseLayer, Bitmap overLayer, int x, int y, double transparency)
{
overLayer = CopyChangeOpacity(overLayer, transparency);
return LayerImage(baseLayer, overLayer, x, y);
}
public static Bitmap LayerImage(Image baseLayer, Image overLayer, int x, int y)
public static Bitmap LayerImage(Bitmap baseLayer, Image overLayer, int x, int y)
{
Bitmap img = new(baseLayer);
using Graphics gr = Graphics.FromImage(img);
var bmp = new Bitmap(baseLayer);
using var gr = Graphics.FromImage(bmp);
gr.DrawImage(overLayer, x, y, overLayer.Width, overLayer.Height);
return img;
}
public static Bitmap ChangeOpacity(Image img, double trans)
{
var bmp = (Bitmap)img.Clone();
GetBitmapData(bmp, out var bmpData, out var data);
SetAllTransparencyTo(data, trans);
bmp.UnlockBits(bmpData);
return bmp;
}
public static Bitmap ChangeAllColorTo(Image img, Color c)
public static Bitmap CopyChangeOpacity(Bitmap img, double trans)
{
var bmp = (Bitmap)img.Clone();
GetBitmapData(bmp, out var bmpData, out var data);
ChangeAllColorTo(data, c);
bmp.UnlockBits(bmpData);
bmp.ChangeOpacity(trans);
return bmp;
}
public static Bitmap ChangeTransparentTo(Image img, Color c, byte trans, int start = 0, int end = -1)
public static Bitmap CopyChangeAllColorTo(Bitmap img, Color c)
{
var bmp = (Bitmap)img.Clone();
GetBitmapData(bmp, out var bmpData, out var data);
if (end == -1)
end = data.Length - 4;
SetAllTransparencyTo(data, c, trans, start, end);
bmp.UnlockBits(bmpData);
bmp.ChangeAllColorTo(c);
return bmp;
}
public static Bitmap BlendTransparentTo(Image img, Color c, byte trans, int start = 0, int end = -1)
public static Bitmap CopyChangeTransparentTo(Bitmap img, Color c, byte trans, int start = 0, int end = -1)
{
var bmp = (Bitmap)img.Clone();
GetBitmapData(bmp, out var bmpData, out var data);
if (end == -1)
end = data.Length - 4;
BlendAllTransparencyTo(data, c, trans, start, end);
bmp.UnlockBits(bmpData);
bmp.ChangeTransparentTo(c, trans, start, end);
return bmp;
}
public static Bitmap WritePixels(Image img, Color c, int start, int end)
public static Bitmap CopyWritePixels(Bitmap img, Color c, int start, int end)
{
var bmp = (Bitmap)img.Clone();
GetBitmapData(bmp, out var bmpData, out var data);
ChangeAllTo(data, c, start, end);
bmp.UnlockBits(bmpData);
bmp.WritePixels(c, start, end);
return bmp;
}
public static Bitmap ToGrayscale(Image img)
{
var bmp = (Bitmap)img.Clone();
GetBitmapData(bmp, out var bmpData, out var data);
SetAllColorToGrayScale(data);
bmp.UnlockBits(bmpData);
return bmp;
}
private static void GetBitmapData(Bitmap bmp, out BitmapData bmpData, out Span<byte> data)
{
bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
var length = bmp.Width * bmp.Height * 4;
data = MemoryMarshal.CreateSpan(ref Unsafe.AddByteOffset(ref Unsafe.NullRef<byte>(), bmpData.Scan0), length);
}
public static Bitmap GetBitmap(ReadOnlySpan<byte> data, int width, int height, int length, PixelFormat format = PixelFormat.Format32bppArgb)
{
var bmp = new Bitmap(width, height, format);
var bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, format);
var span = MemoryMarshal.CreateSpan(ref Unsafe.AddByteOffset(ref Unsafe.NullRef<byte>(), bmpData.Scan0), length);
var span = bmp.GetBitmapData(out var bmpData);
data[..length].CopyTo(span);
bmp.UnlockBits(bmpData);
return bmp;
@ -107,18 +195,9 @@ public static Bitmap GetBitmap(ReadOnlySpan<byte> data, int width, int height, P
return GetBitmap(data, width, height, data.Length, format);
}
public static byte[] GetPixelData(Bitmap bitmap)
{
var argbData = new byte[bitmap.Width * bitmap.Height * 4];
var bd = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, bitmap.PixelFormat);
Marshal.Copy(bd.Scan0, argbData, 0, bitmap.Width * bitmap.Height * 4);
bitmap.UnlockBits(bd);
return argbData;
}
public static void SetAllUsedPixelsOpaque(Span<byte> data)
{
for (int i = 0; i < data.Length; i += 4)
for (int i = data.Length - 4; i >= 0; i -= 4)
{
if (data[i + 3] != 0)
data[i + 3] = 0xFF;
@ -137,26 +216,26 @@ public static void RemovePixels(Span<byte> pixels, ReadOnlySpan<byte> original)
private static void SetAllTransparencyTo(Span<byte> data, double trans)
{
for (int i = 0; i < data.Length; i += 4)
for (int i = data.Length - 4; i >= 0; i -= 4)
data[i + 3] = (byte)(data[i + 3] * trans);
}
public static void SetAllTransparencyTo(Span<byte> data, Color c, byte trans, int start, int end)
private static void SetAllTransparencyTo(Span<byte> data, Color c, byte trans)
{
var arr = MemoryMarshal.Cast<byte, int>(data);
var value = Color.FromArgb(trans, c).ToArgb();
for (int i = end; i >= start; i -= 4)
for (int i = data.Length - 4; i >= 0; i -= 4)
{
if (data[i + 3] == 0)
arr[i >> 2] = value;
}
}
public static void BlendAllTransparencyTo(Span<byte> data, Color c, byte trans, int start, int end)
private static void BlendAllTransparencyTo(Span<byte> data, Color c, byte trans)
{
var arr = MemoryMarshal.Cast<byte, int>(data);
var value = Color.FromArgb(trans, c).ToArgb();
for (int i = end; i >= start; i -= 4)
for (int i = data.Length - 4; i >= 0; i -= 4)
{
var alpha = data[i + 3];
if (alpha == 0)
@ -166,11 +245,11 @@ public static void BlendAllTransparencyTo(Span<byte> data, Color c, byte trans,
}
}
public static int GetAverageColor(Span<byte> data)
private static int GetAverageColor(Span<byte> data)
{
long r = 0, g = 0, b = 0;
int count = 0;
for (int i = 0; i < data.Length; i += 4)
for (int i = data.Length - 4; i >= 0; i -= 4)
{
var alpha = data[i + 3];
if (alpha == 0)
@ -209,7 +288,7 @@ private static int BlendColor(int color1, int color2, double amount = 0.2)
return (a << 24) | (r << 16) | (g << 8) | b;
}
public static void ChangeAllTo(Span<byte> data, Color c, int start, int end)
private static void ChangeAllTo(Span<byte> data, Color c, int start, int end)
{
var arr = MemoryMarshal.Cast<byte, int>(data[start..end]);
var value = c.ToArgb();
@ -221,7 +300,7 @@ public static void ChangeAllColorTo(Span<byte> data, Color c)
byte R = c.R;
byte G = c.G;
byte B = c.B;
for (int i = 0; i < data.Length; i += 4)
for (int i = data.Length - 4; i >= 0; i -= 4)
{
if (data[i + 3] == 0)
continue;
@ -231,9 +310,32 @@ public static void ChangeAllColorTo(Span<byte> data, Color c)
}
}
private static void SetAllColorToGrayScale(Span<byte> data, float intensity)
{
if (intensity <= 0f)
return;
if (intensity >= 0.999f)
{
SetAllColorToGrayScale(data);
return;
}
float inverse = 1f - intensity;
for (int i = data.Length - 4; i >= 0; i -= 4)
{
if (data[i + 3] == 0)
continue;
byte greyS = (byte)((0.3 * data[i + 2]) + (0.59 * data[i + 1]) + (0.11 * data[i + 0]));
data[i + 0] = (byte)((data[i + 0] * inverse) + (greyS * intensity));
data[i + 1] = (byte)((data[i + 1] * inverse) + (greyS * intensity));
data[i + 2] = (byte)((data[i + 2] * inverse) + (greyS * intensity));
}
}
private static void SetAllColorToGrayScale(Span<byte> data)
{
for (int i = 0; i < data.Length; i += 4)
for (int i = data.Length - 4; i >= 0; i -= 4)
{
if (data[i + 3] == 0)
continue;
@ -256,7 +358,7 @@ private static void PollutePixels(Span<byte> data, int width, int reach, double
{
int stride = width * 4;
int height = data.Length / stride;
for (int i = 0; i < data.Length; i += 4)
for (int i = data.Length - 4; i >= 0; i -= 4)
{
// only pollute outwards if the current pixel is fully opaque
if (data[i + 3] == 0)
@ -286,7 +388,7 @@ private static void PollutePixels(Span<byte> data, int width, int reach, double
private static void CleanPollutedPixels(Span<byte> data, byte blue, byte green, byte red)
{
for (int i = 0; i < data.Length; i += 4)
for (int i = data.Length - 4; i >= 0; i -= 4)
{
// only clean if the current pixel isn't transparent
if (data[i + 3] != 0)

View File

@ -83,11 +83,11 @@ private void InitializeComponent()
CB_Ability.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
CB_Ability.FormattingEnabled = true;
CB_Ability.Items.AddRange(new object[] { "Item" });
CB_Ability.Location = new System.Drawing.Point(101, 104);
CB_Ability.Location = new System.Drawing.Point(101, 130);
CB_Ability.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_Ability.Name = "CB_Ability";
CB_Ability.Size = new System.Drawing.Size(142, 25);
CB_Ability.TabIndex = 70;
CB_Ability.TabIndex = 4;
//
// CB_HeldItem
//
@ -95,11 +95,11 @@ private void InitializeComponent()
CB_HeldItem.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
CB_HeldItem.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
CB_HeldItem.FormattingEnabled = true;
CB_HeldItem.Location = new System.Drawing.Point(101, 78);
CB_HeldItem.Location = new System.Drawing.Point(101, 104);
CB_HeldItem.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_HeldItem.Name = "CB_HeldItem";
CB_HeldItem.Size = new System.Drawing.Size(142, 25);
CB_HeldItem.TabIndex = 69;
CB_HeldItem.TabIndex = 3;
//
// CB_Nature
//
@ -107,11 +107,11 @@ private void InitializeComponent()
CB_Nature.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
CB_Nature.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
CB_Nature.FormattingEnabled = true;
CB_Nature.Location = new System.Drawing.Point(101, 52);
CB_Nature.Location = new System.Drawing.Point(101, 78);
CB_Nature.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_Nature.Name = "CB_Nature";
CB_Nature.Size = new System.Drawing.Size(142, 25);
CB_Nature.TabIndex = 68;
CB_Nature.TabIndex = 2;
//
// CB_Species
//
@ -123,7 +123,7 @@ private void InitializeComponent()
CB_Species.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_Species.Name = "CB_Species";
CB_Species.Size = new System.Drawing.Size(142, 25);
CB_Species.TabIndex = 67;
CB_Species.TabIndex = 0;
//
// TB_Nickname
//
@ -132,7 +132,7 @@ private void InitializeComponent()
TB_Nickname.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
TB_Nickname.Name = "TB_Nickname";
TB_Nickname.Size = new System.Drawing.Size(142, 25);
TB_Nickname.TabIndex = 68;
TB_Nickname.TabIndex = 1;
//
// CB_Move4
//
@ -140,11 +140,11 @@ private void InitializeComponent()
CB_Move4.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
CB_Move4.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
CB_Move4.FormattingEnabled = true;
CB_Move4.Location = new System.Drawing.Point(101, 312);
CB_Move4.Location = new System.Drawing.Point(101, 338);
CB_Move4.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_Move4.Name = "CB_Move4";
CB_Move4.Size = new System.Drawing.Size(142, 25);
CB_Move4.TabIndex = 74;
CB_Move4.TabIndex = 13;
//
// CB_Move3
//
@ -152,11 +152,11 @@ private void InitializeComponent()
CB_Move3.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
CB_Move3.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
CB_Move3.FormattingEnabled = true;
CB_Move3.Location = new System.Drawing.Point(101, 286);
CB_Move3.Location = new System.Drawing.Point(101, 312);
CB_Move3.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_Move3.Name = "CB_Move3";
CB_Move3.Size = new System.Drawing.Size(142, 25);
CB_Move3.TabIndex = 73;
CB_Move3.TabIndex = 12;
//
// CB_Move2
//
@ -164,11 +164,11 @@ private void InitializeComponent()
CB_Move2.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
CB_Move2.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
CB_Move2.FormattingEnabled = true;
CB_Move2.Location = new System.Drawing.Point(101, 260);
CB_Move2.Location = new System.Drawing.Point(101, 286);
CB_Move2.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_Move2.Name = "CB_Move2";
CB_Move2.Size = new System.Drawing.Size(142, 25);
CB_Move2.TabIndex = 72;
CB_Move2.TabIndex = 11;
//
// CB_Move1
//
@ -176,11 +176,11 @@ private void InitializeComponent()
CB_Move1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
CB_Move1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
CB_Move1.FormattingEnabled = true;
CB_Move1.Location = new System.Drawing.Point(101, 234);
CB_Move1.Location = new System.Drawing.Point(101, 260);
CB_Move1.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_Move1.Name = "CB_Move1";
CB_Move1.Size = new System.Drawing.Size(142, 25);
CB_Move1.TabIndex = 71;
CB_Move1.TabIndex = 10;
//
// TB_Level
//
@ -191,18 +191,18 @@ private void InitializeComponent()
TB_Level.Mask = "000";
TB_Level.Name = "TB_Level";
TB_Level.Size = new System.Drawing.Size(25, 25);
TB_Level.TabIndex = 89;
TB_Level.TabIndex = 5;
TB_Level.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// Label_CurLevel
//
Label_CurLevel.Anchor = System.Windows.Forms.AnchorStyles.Right;
Label_CurLevel.AutoSize = true;
Label_CurLevel.Location = new System.Drawing.Point(57, 134);
Label_CurLevel.Location = new System.Drawing.Point(57, 160);
Label_CurLevel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
Label_CurLevel.Name = "Label_CurLevel";
Label_CurLevel.Size = new System.Drawing.Size(40, 17);
Label_CurLevel.TabIndex = 88;
Label_CurLevel.TabIndex = 95;
Label_CurLevel.Text = "Level:";
Label_CurLevel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
@ -210,7 +210,7 @@ private void InitializeComponent()
//
Label_HeldItem.Anchor = System.Windows.Forms.AnchorStyles.Right;
Label_HeldItem.AutoSize = true;
Label_HeldItem.Location = new System.Drawing.Point(30, 82);
Label_HeldItem.Location = new System.Drawing.Point(30, 108);
Label_HeldItem.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
Label_HeldItem.Name = "Label_HeldItem";
Label_HeldItem.Size = new System.Drawing.Size(67, 17);
@ -222,11 +222,11 @@ private void InitializeComponent()
//
Label_Ability.Anchor = System.Windows.Forms.AnchorStyles.Right;
Label_Ability.AutoSize = true;
Label_Ability.Location = new System.Drawing.Point(51, 108);
Label_Ability.Location = new System.Drawing.Point(51, 134);
Label_Ability.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
Label_Ability.Name = "Label_Ability";
Label_Ability.Size = new System.Drawing.Size(46, 17);
Label_Ability.TabIndex = 92;
Label_Ability.TabIndex = 94;
Label_Ability.Text = "Ability:";
Label_Ability.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
@ -234,11 +234,11 @@ private void InitializeComponent()
//
Label_Nature.Anchor = System.Windows.Forms.AnchorStyles.Right;
Label_Nature.AutoSize = true;
Label_Nature.Location = new System.Drawing.Point(46, 56);
Label_Nature.Location = new System.Drawing.Point(46, 82);
Label_Nature.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
Label_Nature.Name = "Label_Nature";
Label_Nature.Size = new System.Drawing.Size(51, 17);
Label_Nature.TabIndex = 91;
Label_Nature.TabIndex = 92;
Label_Nature.Text = "Nature:";
Label_Nature.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
@ -258,10 +258,10 @@ private void InitializeComponent()
//
Label_Nickname.Anchor = System.Windows.Forms.AnchorStyles.Right;
Label_Nickname.AutoSize = true;
Label_Nickname.Location = new System.Drawing.Point(20, 56);
Label_Nickname.Location = new System.Drawing.Point(29, 56);
Label_Nickname.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
Label_Nickname.Name = "Label_Nickname";
Label_Nickname.Size = new System.Drawing.Size(77, 17);
Label_Nickname.Size = new System.Drawing.Size(68, 17);
Label_Nickname.TabIndex = 91;
Label_Nickname.Text = "Nickname:";
Label_Nickname.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
@ -273,11 +273,11 @@ private void InitializeComponent()
CB_EVTrain.DropDownWidth = 85;
CB_EVTrain.FormattingEnabled = true;
CB_EVTrain.Items.AddRange(new object[] { "Any", "None (0)", "Some (127-1)", "Half (128-507)", "Full (508+)" });
CB_EVTrain.Location = new System.Drawing.Point(101, 182);
CB_EVTrain.Location = new System.Drawing.Point(101, 208);
CB_EVTrain.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_EVTrain.Name = "CB_EVTrain";
CB_EVTrain.Size = new System.Drawing.Size(109, 25);
CB_EVTrain.TabIndex = 94;
CB_EVTrain.TabIndex = 8;
//
// CB_HPType
//
@ -286,21 +286,21 @@ private void InitializeComponent()
CB_HPType.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
CB_HPType.DropDownWidth = 80;
CB_HPType.FormattingEnabled = true;
CB_HPType.Location = new System.Drawing.Point(101, 208);
CB_HPType.Location = new System.Drawing.Point(101, 234);
CB_HPType.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_HPType.Name = "CB_HPType";
CB_HPType.Size = new System.Drawing.Size(142, 25);
CB_HPType.TabIndex = 96;
CB_HPType.TabIndex = 9;
//
// Label_HiddenPowerPrefix
//
Label_HiddenPowerPrefix.Anchor = System.Windows.Forms.AnchorStyles.Right;
Label_HiddenPowerPrefix.AutoSize = true;
Label_HiddenPowerPrefix.Location = new System.Drawing.Point(4, 212);
Label_HiddenPowerPrefix.Location = new System.Drawing.Point(4, 238);
Label_HiddenPowerPrefix.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
Label_HiddenPowerPrefix.Name = "Label_HiddenPowerPrefix";
Label_HiddenPowerPrefix.Size = new System.Drawing.Size(93, 17);
Label_HiddenPowerPrefix.TabIndex = 95;
Label_HiddenPowerPrefix.TabIndex = 98;
Label_HiddenPowerPrefix.Text = "Hidden Power:";
Label_HiddenPowerPrefix.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
@ -309,11 +309,11 @@ private void InitializeComponent()
CB_GameOrigin.Anchor = System.Windows.Forms.AnchorStyles.Left;
CB_GameOrigin.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
CB_GameOrigin.FormattingEnabled = true;
CB_GameOrigin.Location = new System.Drawing.Point(101, 338);
CB_GameOrigin.Location = new System.Drawing.Point(101, 364);
CB_GameOrigin.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_GameOrigin.Name = "CB_GameOrigin";
CB_GameOrigin.Size = new System.Drawing.Size(142, 25);
CB_GameOrigin.TabIndex = 97;
CB_GameOrigin.TabIndex = 14;
CB_GameOrigin.SelectedIndexChanged += ChangeGame;
//
// CB_IV
@ -323,11 +323,11 @@ private void InitializeComponent()
CB_IV.DropDownWidth = 85;
CB_IV.FormattingEnabled = true;
CB_IV.Items.AddRange(new object[] { "Any", "<= 90", "91-120", "121-150", "151-179", "180+", "== 186" });
CB_IV.Location = new System.Drawing.Point(101, 156);
CB_IV.Location = new System.Drawing.Point(101, 182);
CB_IV.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_IV.Name = "CB_IV";
CB_IV.Size = new System.Drawing.Size(109, 25);
CB_IV.TabIndex = 100;
CB_IV.TabIndex = 7;
//
// CB_Level
//
@ -340,18 +340,18 @@ private void InitializeComponent()
CB_Level.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_Level.Name = "CB_Level";
CB_Level.Size = new System.Drawing.Size(76, 25);
CB_Level.TabIndex = 103;
CB_Level.TabIndex = 6;
CB_Level.SelectedIndexChanged += ChangeLevel;
//
// L_Version
//
L_Version.Anchor = System.Windows.Forms.AnchorStyles.Right;
L_Version.AutoSize = true;
L_Version.Location = new System.Drawing.Point(23, 342);
L_Version.Location = new System.Drawing.Point(23, 368);
L_Version.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
L_Version.Name = "L_Version";
L_Version.Size = new System.Drawing.Size(74, 17);
L_Version.TabIndex = 104;
L_Version.TabIndex = 103;
L_Version.Text = "OT Version:";
L_Version.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
@ -359,11 +359,11 @@ private void InitializeComponent()
//
L_Move1.Anchor = System.Windows.Forms.AnchorStyles.Right;
L_Move1.AutoSize = true;
L_Move1.Location = new System.Drawing.Point(42, 238);
L_Move1.Location = new System.Drawing.Point(42, 264);
L_Move1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
L_Move1.Name = "L_Move1";
L_Move1.Size = new System.Drawing.Size(55, 17);
L_Move1.TabIndex = 105;
L_Move1.TabIndex = 99;
L_Move1.Text = "Move 1:";
L_Move1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
@ -371,11 +371,11 @@ private void InitializeComponent()
//
L_Move2.Anchor = System.Windows.Forms.AnchorStyles.Right;
L_Move2.AutoSize = true;
L_Move2.Location = new System.Drawing.Point(42, 264);
L_Move2.Location = new System.Drawing.Point(42, 290);
L_Move2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
L_Move2.Name = "L_Move2";
L_Move2.Size = new System.Drawing.Size(55, 17);
L_Move2.TabIndex = 106;
L_Move2.TabIndex = 100;
L_Move2.Text = "Move 2:";
L_Move2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
@ -383,11 +383,11 @@ private void InitializeComponent()
//
L_Move3.Anchor = System.Windows.Forms.AnchorStyles.Right;
L_Move3.AutoSize = true;
L_Move3.Location = new System.Drawing.Point(42, 290);
L_Move3.Location = new System.Drawing.Point(42, 316);
L_Move3.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
L_Move3.Name = "L_Move3";
L_Move3.Size = new System.Drawing.Size(55, 17);
L_Move3.TabIndex = 107;
L_Move3.TabIndex = 101;
L_Move3.Text = "Move 3:";
L_Move3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
@ -395,11 +395,11 @@ private void InitializeComponent()
//
L_Move4.Anchor = System.Windows.Forms.AnchorStyles.Right;
L_Move4.AutoSize = true;
L_Move4.Location = new System.Drawing.Point(42, 316);
L_Move4.Location = new System.Drawing.Point(42, 342);
L_Move4.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
L_Move4.Name = "L_Move4";
L_Move4.Size = new System.Drawing.Size(55, 17);
L_Move4.TabIndex = 108;
L_Move4.TabIndex = 102;
L_Move4.Text = "Move 4:";
L_Move4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
@ -407,11 +407,11 @@ private void InitializeComponent()
//
L_Potential.Anchor = System.Windows.Forms.AnchorStyles.Right;
L_Potential.AutoSize = true;
L_Potential.Location = new System.Drawing.Point(21, 160);
L_Potential.Location = new System.Drawing.Point(21, 186);
L_Potential.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
L_Potential.Name = "L_Potential";
L_Potential.Size = new System.Drawing.Size(76, 17);
L_Potential.TabIndex = 109;
L_Potential.TabIndex = 96;
L_Potential.Text = "IV Potential:";
L_Potential.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
@ -419,11 +419,11 @@ private void InitializeComponent()
//
L_EVTraining.Anchor = System.Windows.Forms.AnchorStyles.Right;
L_EVTraining.AutoSize = true;
L_EVTraining.Location = new System.Drawing.Point(21, 186);
L_EVTraining.Location = new System.Drawing.Point(21, 212);
L_EVTraining.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
L_EVTraining.Name = "L_EVTraining";
L_EVTraining.Size = new System.Drawing.Size(76, 17);
L_EVTraining.TabIndex = 110;
L_EVTraining.TabIndex = 97;
L_EVTraining.Text = "EV Training:";
L_EVTraining.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
@ -431,11 +431,11 @@ private void InitializeComponent()
//
L_Generation.Anchor = System.Windows.Forms.AnchorStyles.Right;
L_Generation.AutoSize = true;
L_Generation.Location = new System.Drawing.Point(22, 368);
L_Generation.Location = new System.Drawing.Point(22, 394);
L_Generation.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
L_Generation.Name = "L_Generation";
L_Generation.Size = new System.Drawing.Size(75, 17);
L_Generation.TabIndex = 116;
L_Generation.TabIndex = 114;
L_Generation.Text = "Generation:";
L_Generation.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
@ -445,11 +445,11 @@ private void InitializeComponent()
CB_Generation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
CB_Generation.FormattingEnabled = true;
CB_Generation.Items.AddRange(new object[] { "Any", "Gen 1 (RBY/GSC)", "Gen 2 (RBY/GSC)", "Gen 3 (RSE/FRLG/CXD)", "Gen 4 (DPPt/HGSS)", "Gen 5 (BW/B2W2)", "Gen 6 (XY/ORAS)", "Gen 7 (SM/USUM/LGPE)", "Gen 8 (SWSH/BDSP/LA)", "Gen 9 (SV)" });
CB_Generation.Location = new System.Drawing.Point(101, 364);
CB_Generation.Location = new System.Drawing.Point(101, 390);
CB_Generation.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_Generation.Name = "CB_Generation";
CB_Generation.Size = new System.Drawing.Size(142, 25);
CB_Generation.TabIndex = 115;
CB_Generation.TabIndex = 15;
CB_Generation.SelectedIndexChanged += ChangeGeneration;
//
// FLP_Egg
@ -475,7 +475,7 @@ private void InitializeComponent()
CHK_IsEgg.Margin = new System.Windows.Forms.Padding(0, 4, 0, 1);
CHK_IsEgg.Name = "CHK_IsEgg";
CHK_IsEgg.Size = new System.Drawing.Size(50, 21);
CHK_IsEgg.TabIndex = 98;
CHK_IsEgg.TabIndex = 51;
CHK_IsEgg.Text = "Egg";
CHK_IsEgg.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
CHK_IsEgg.ThreeState = true;
@ -489,7 +489,7 @@ private void InitializeComponent()
L_ESV.Margin = new System.Windows.Forms.Padding(0);
L_ESV.Name = "L_ESV";
L_ESV.Size = new System.Drawing.Size(50, 20);
L_ESV.TabIndex = 113;
L_ESV.TabIndex = 53;
L_ESV.Text = "ESV:";
L_ESV.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
L_ESV.Visible = false;
@ -503,7 +503,7 @@ private void InitializeComponent()
MT_ESV.Mask = "0000";
MT_ESV.Name = "MT_ESV";
MT_ESV.Size = new System.Drawing.Size(36, 25);
MT_ESV.TabIndex = 112;
MT_ESV.TabIndex = 52;
MT_ESV.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
MT_ESV.Visible = false;
//
@ -517,7 +517,7 @@ private void InitializeComponent()
CHK_Shiny.Margin = new System.Windows.Forms.Padding(0, 4, 0, 1);
CHK_Shiny.Name = "CHK_Shiny";
CHK_Shiny.Size = new System.Drawing.Size(57, 21);
CHK_Shiny.TabIndex = 99;
CHK_Shiny.TabIndex = 50;
CHK_Shiny.Text = "Shiny";
CHK_Shiny.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
CHK_Shiny.ThreeState = true;
@ -597,7 +597,7 @@ private void InitializeComponent()
FLP_Format.AutoSize = true;
FLP_Format.Controls.Add(CB_FormatComparator);
FLP_Format.Controls.Add(CB_Format);
FLP_Format.Location = new System.Drawing.Point(101, 390);
FLP_Format.Location = new System.Drawing.Point(101, 416);
FLP_Format.Margin = new System.Windows.Forms.Padding(0);
FLP_Format.Name = "FLP_Format";
FLP_Format.Size = new System.Drawing.Size(141, 26);
@ -613,7 +613,7 @@ private void InitializeComponent()
CB_FormatComparator.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_FormatComparator.Name = "CB_FormatComparator";
CB_FormatComparator.Size = new System.Drawing.Size(62, 25);
CB_FormatComparator.TabIndex = 122;
CB_FormatComparator.TabIndex = 16;
CB_FormatComparator.SelectedIndexChanged += ChangeFormatFilter;
//
// CB_Format
@ -626,18 +626,18 @@ private void InitializeComponent()
CB_Format.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_Format.Name = "CB_Format";
CB_Format.Size = new System.Drawing.Size(79, 25);
CB_Format.TabIndex = 121;
CB_Format.TabIndex = 17;
CB_Format.Visible = false;
//
// L_Format
//
L_Format.Anchor = System.Windows.Forms.AnchorStyles.Right;
L_Format.AutoSize = true;
L_Format.Location = new System.Drawing.Point(45, 394);
L_Format.Location = new System.Drawing.Point(45, 420);
L_Format.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
L_Format.Name = "L_Format";
L_Format.Size = new System.Drawing.Size(52, 17);
L_Format.TabIndex = 122;
L_Format.TabIndex = 125;
L_Format.Text = "Format:";
L_Format.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
@ -647,11 +647,11 @@ private void InitializeComponent()
FLP_Level.AutoSize = true;
FLP_Level.Controls.Add(TB_Level);
FLP_Level.Controls.Add(CB_Level);
FLP_Level.Location = new System.Drawing.Point(101, 130);
FLP_Level.Location = new System.Drawing.Point(101, 156);
FLP_Level.Margin = new System.Windows.Forms.Padding(0);
FLP_Level.Name = "FLP_Level";
FLP_Level.Size = new System.Drawing.Size(101, 26);
FLP_Level.TabIndex = 119;
FLP_Level.TabIndex = 5;
//
// EntitySearchControl
//

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows.Forms;
using PKHeX.Core;
@ -10,17 +11,31 @@ namespace PKHeX.WinForms.Controls;
public partial class EntitySearchControl : UserControl
{
public int MaxFormat { get; set; } = Latest.Generation;
public int SaveGeneration { get; set; } = Latest.Generation;
public EntitySearchControl() => InitializeComponent();
// don't allow in Designer
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[EditorBrowsable(EditorBrowsableState.Never)]
[Bindable(false)]
[Browsable(false)]
public int MaxFormat { private get; set; } = Latest.Generation;
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[EditorBrowsable(EditorBrowsableState.Never)]
[Bindable(false)]
[Browsable(false)]
public int SaveGeneration { private get; set; } = Latest.Generation;
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[EditorBrowsable(EditorBrowsableState.Never)]
[Bindable(false)]
[Browsable(false)]
public int FormatComparatorSelectedIndex
{
get => CB_FormatComparator.SelectedIndex;
set => CB_FormatComparator.SelectedIndex = value;
}
public EntitySearchControl() => InitializeComponent();
/// <summary>
/// Creates a filter function based on the current search settings, including any batch instructions.
/// </summary>
@ -80,6 +95,8 @@ public void PopulateComboBoxes()
cb.InitializeBinding();
cb.DataSource = new BindingSource(moves, string.Empty);
}
ResetFilters();
}
/// <summary>

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -31,12 +31,13 @@ private void InitializeComponent()
components = new System.ComponentModel.Container();
L_PropValue = new System.Windows.Forms.Label();
L_PropType = new System.Windows.Forms.Label();
CB_Require = new System.Windows.Forms.ComboBox();
B_Require = new System.Windows.Forms.Button();
CB_Property = new System.Windows.Forms.ComboBox();
CB_Format = new System.Windows.Forms.ComboBox();
toolTip1 = new System.Windows.Forms.ToolTip(components);
toolTip2 = new System.Windows.Forms.ToolTip(components);
toolTip3 = new System.Windows.Forms.ToolTip(components);
requireMenu = new System.Windows.Forms.ContextMenuStrip(components);
SuspendLayout();
//
// L_PropValue
@ -60,17 +61,17 @@ private void InitializeComponent()
L_PropType.TabIndex = 17;
L_PropType.Text = "PropertyType";
//
// CB_Require
// B_Require
//
CB_Require.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
CB_Require.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
CB_Require.FormattingEnabled = true;
CB_Require.Items.AddRange(new object[] { "Set", "==", "!=", ">", ">=", "<", "<=" });
CB_Require.Location = new System.Drawing.Point(236, 0);
CB_Require.Margin = new System.Windows.Forms.Padding(4);
CB_Require.Name = "CB_Require";
CB_Require.Size = new System.Drawing.Size(100, 25);
CB_Require.TabIndex = 2;
B_Require.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
B_Require.Location = new System.Drawing.Point(236, 0);
B_Require.Margin = new System.Windows.Forms.Padding(4);
B_Require.Name = "B_Require";
B_Require.Size = new System.Drawing.Size(40, 25);
B_Require.TabIndex = 2;
B_Require.Text = "Set";
B_Require.UseVisualStyleBackColor = true;
B_Require.Click += B_Require_Click;
//
// CB_Property
//
@ -97,17 +98,22 @@ private void InitializeComponent()
CB_Format.TabIndex = 0;
CB_Format.SelectedIndexChanged += CB_Format_SelectedIndexChanged;
//
// requireMenu
//
requireMenu.Name = "requireMenu";
requireMenu.Size = new System.Drawing.Size(181, 26);
//
// EntityInstructionBuilder
//
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
Controls.Add(L_PropValue);
Controls.Add(L_PropType);
Controls.Add(CB_Require);
Controls.Add(B_Require);
Controls.Add(CB_Property);
Controls.Add(CB_Format);
Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
Name = "EntityInstructionBuilder";
Size = new System.Drawing.Size(338, 46);
Size = new System.Drawing.Size(360, 46);
ResumeLayout(false);
PerformLayout();
}
@ -116,11 +122,12 @@ private void InitializeComponent()
private System.Windows.Forms.Label L_PropValue;
private System.Windows.Forms.Label L_PropType;
private System.Windows.Forms.ComboBox CB_Require;
private System.Windows.Forms.Button B_Require;
private System.Windows.Forms.ComboBox CB_Property;
private System.Windows.Forms.ComboBox CB_Format;
private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.ToolTip toolTip2;
private System.Windows.Forms.ToolTip toolTip3;
private System.Windows.Forms.ContextMenuStrip requireMenu;
}
}

View File

@ -11,12 +11,34 @@ public partial class EntityInstructionBuilder : UserControl
private readonly Func<PKM> Getter;
private PKM Entity => Getter();
private static ReadOnlySpan<char> Prefixes => StringInstruction.Prefixes;
private int currentFormat = -1;
private int requirementIndex;
private bool readOnlyMode;
private readonly ToolStripMenuItem[] requireMenuItems = new ToolStripMenuItem[Prefixes.Length];
public EntityInstructionBuilder(Func<PKM> pk)
{
Getter = pk;
InitializeComponent();
for (int i = 0; i < Prefixes.Length; i++)
{
var text = i == 0 ? "Set" : Prefixes[i].ToString();
var item = new ToolStripMenuItem(text)
{
Name = $"mnu_{text}",
Tag = i,
};
item.Click += RequireItem_Click;
requireMenu.Items.Add(item);
requireMenuItems[i] = item;
}
// Allow translation of the menu item.
WinFormsTranslator.TranslateControls("BatchEdit", requireMenuItems, Main.CurrentLanguage);
B_Require.ContextMenuStrip = requireMenu;
CB_Format.Items.Clear();
CB_Format.Items.Add(MsgAny);
@ -24,7 +46,9 @@ public EntityInstructionBuilder(Func<PKM> pk)
CB_Format.Items.Add(t.Name.ToLowerInvariant());
CB_Format.Items.Add(MsgAll);
CB_Format.SelectedIndex = CB_Require.SelectedIndex = 0;
CB_Format.SelectedIndex = 0;
SetRequirementIndex(0);
UpdateRequireMenuVisibility();
toolTip1.SetToolTip(CB_Property, MsgBEToolTipPropName);
toolTip2.SetToolTip(L_PropType, MsgBEToolTipPropType);
toolTip3.SetToolTip(L_PropValue, MsgBEToolTipPropValue);
@ -66,6 +90,36 @@ private void CB_Property_SelectedIndexChanged(object sender, EventArgs e)
}
}
private void B_Require_Click(object? sender, EventArgs e) => requireMenu.Show(B_Require, 0, B_Require.Height);
private void RequireItem_Click(object? sender, EventArgs e)
{
if (sender is not ToolStripMenuItem { Tag: int index })
return;
SetRequirementIndex(index);
}
private void SetRequirementIndex(int index)
{
if ((uint)index >= Prefixes.Length)
return;
requirementIndex = index;
B_Require.Text = requireMenuItems[index].Text;
for (int i = 0; i < requireMenuItems.Length; i++)
requireMenuItems[i].Checked = i == index;
}
private void UpdateRequireMenuVisibility()
{
requireMenuItems[0].Visible = !readOnlyMode;
if (readOnlyMode && requirementIndex == 0)
SetRequirementIndex(1);
}
private static bool GetPropertyDisplayText(PropertyInfo pi, PKM pk, out string display)
{
var type = pi.PropertyType;
@ -94,9 +148,8 @@ public string Create()
if (CB_Property.SelectedIndex < 0)
return string.Empty;
var prefixes = StringInstruction.Prefixes;
var prefix = prefixes[CB_Require.SelectedIndex];
var property = CB_Property.Items[CB_Property.SelectedIndex];
var prefix = Prefixes[requirementIndex];
const char equals = StringInstruction.SplitInstruction;
return $"{prefix}{property}{equals}";
}
@ -105,15 +158,8 @@ public bool ReadOnly
{
set
{
if (value)
{
CB_Require.Visible = false;
CB_Require.SelectedIndex = 1;
}
else
{
CB_Require.Visible = true;
}
readOnlyMode = value;
UpdateRequireMenuVisibility();
}
}
}

View File

@ -557,14 +557,14 @@ private void SetMarkings()
static void SetMarkingImage(PictureBox pb, Color color, bool active)
{
var img = pb.InitialImage;
if (img is not Bitmap bmp)
throw new Exception();
var bmp = pb.InitialImage as Bitmap;
ArgumentNullException.ThrowIfNull(bmp);
if (color.ToArgb() != Color.Black.ToArgb())
img = ImageUtil.ChangeAllColorTo(bmp, color);
bmp = ImageUtil.CopyChangeAllColorTo(bmp, color);
if (!active)
img = ImageUtil.ChangeOpacity(img, 1/8f);
pb.Image = img;
bmp = ImageUtil.CopyChangeOpacity(bmp, 1/8f);
pb.Image = bmp;
}
}
@ -2198,10 +2198,11 @@ private void CB_BattleVersion_SelectedValueChanged(object sender, EventArgs e)
private static Bitmap GetMarkSprite(PictureBox p, bool opaque, double trans = 0.175)
{
var img = p.InitialImage;
if (img is not Bitmap sprite)
throw new Exception();
return opaque ? sprite : ImageUtil.ChangeOpacity(sprite, trans);
var bmp = p.InitialImage as Bitmap;
ArgumentNullException.ThrowIfNull(bmp);
if (!opaque)
bmp = ImageUtil.CopyChangeOpacity(bmp, trans);
return bmp;
}
private void ClickVersionMarking(object sender, EventArgs e)

View File

@ -41,7 +41,7 @@ private void UpdateFlagState(object sender, EventArgs e)
if (sender is not CheckBox c)
return;
Image resource;
Bitmap resource;
if (CHK_C == c)
{
resource = Resources.crown;
@ -55,7 +55,7 @@ private void UpdateFlagState(object sender, EventArgs e)
CHK_C.Enabled = true;
}
if (!c.Checked)
resource = ImageUtil.ChangeOpacity(resource, 0.4);
resource = ImageUtil.CopyChangeOpacity(resource, 0.4);
c.Image = resource;
}

View File

@ -19,8 +19,8 @@ public sealed class BitmapAnimator : IDisposable
private int imgHeight;
private ReadOnlyMemory<byte> GlowData;
private Image? ExtraLayer;
private Image?[]? GlowCache;
private Image? OriginalBackground;
private Bitmap?[]? GlowCache;
private Bitmap? OriginalBackground;
private readonly Lock Lock = new();
private PictureBox? pb;
@ -50,14 +50,14 @@ public void Stop()
GlowCache[i] = null;
}
public void Start(PictureBox pbox, Image baseImage, ReadOnlyMemory<byte> glowData, Image? original, Image extra)
public void Start(PictureBox pbox, Image baseImage, ReadOnlyMemory<byte> glowData, Bitmap? original, Image extra)
{
Enabled = false;
imgWidth = baseImage.Width;
imgHeight = baseImage.Height;
GlowData = glowData;
GlowCounter = 0;
GlowCache = new Image[GlowFps];
GlowCache = new Bitmap[GlowFps];
GlowInterval = 1000 / GlowFps;
Timer.Interval = GlowInterval;
lock (Lock)
@ -105,7 +105,7 @@ private Image GetFrame(int frameIndex)
var frameSpan = frameData.AsSpan(0, GlowData.Length);
GlowData.Span.CopyTo(frameSpan);
ImageUtil.ChangeAllColorTo(frameSpan, frameColor);
frame = ImageUtil.GetBitmap(frameData, imgWidth, imgHeight, GlowData.Length);
frame = ImageUtil.GetBitmap(frameSpan, imgWidth, imgHeight);
frameSpan.Clear();
ArrayPool<byte>.Shared.Return(frameData);

View File

@ -4,6 +4,7 @@
using System.IO;
using System.Windows.Forms;
using PKHeX.Core;
using PKHeX.Core.Searching;
using PKHeX.Drawing.Misc;
using PKHeX.Drawing.PokeSprite;
using static PKHeX.Core.MessageStrings;
@ -12,9 +13,9 @@ namespace PKHeX.WinForms.Controls;
public partial class BoxEditor : UserControl, ISlotViewer<PictureBox>
{
private bool _gridInitialized;
public IList<PictureBox> SlotPictureBoxes { get; private set; } = [];
public SaveFile SAV => M?.SE.SAV ?? throw new ArgumentNullException(nameof(SAV));
public int BoxSlotCount { get; private set; }
public SlotChangeManager? M { get; set; }
public bool FlagIllegal { get; set; }
@ -25,6 +26,10 @@ public partial class BoxEditor : UserControl, ISlotViewer<PictureBox>
public BoxEditor()
{
InitializeComponent();
SizeChanged += BoxEditor_SizeChanged;
ParentChanged += BoxEditor_ParentChanged;
DpiChangedAfterParent += BoxEditor_DpiChangedAfterParent;
HandleCreated += BoxEditor_HandleCreated;
}
internal bool InitializeGrid()
@ -34,26 +39,55 @@ internal bool InitializeGrid()
var height = count / width;
if (!BoxPokeGrid.InitializeGrid(width, height, SpriteUtil.Spriter))
return false;
_gridInitialized = true;
RecenterControls();
InitializeSlots();
return true;
}
private void BoxEditor_SizeChanged(object? sender, EventArgs e)
{
if (!_gridInitialized)
return;
RecenterControls();
}
private void BoxEditor_ParentChanged(object? sender, EventArgs e)
{
if (!_gridInitialized)
return;
RecenterControls();
}
private void BoxEditor_DpiChangedAfterParent(object? sender, EventArgs e)
{
if (!_gridInitialized)
return;
RecenterControls();
}
private void BoxEditor_HandleCreated(object? sender, EventArgs e)
{
if (!_gridInitialized)
return;
RecenterControls();
}
public void RecenterControls()
{
if (Width < BoxPokeGrid.Width)
Width = BoxPokeGrid.Width;
BoxPokeGrid.HorizontallyCenter(this.Parent!);
BoxPokeGrid.HorizontallyCenter(this);
int p1 = CB_BoxSelect.Location.X;
CB_BoxSelect.HorizontallyCenter(this.Parent!);
CB_BoxSelect.HorizontallyCenter(this);
int p2 = CB_BoxSelect.Location.X;
var delta = p2 - p1;
if (delta == 0)
return;
B_BoxLeft.SetBounds(B_BoxLeft.Location.X + delta, 0, 0, 0, BoundsSpecified.X);
B_BoxRight.SetBounds(B_BoxRight.Location.X + delta, 0, 0, 0, BoundsSpecified.X);
B_BoxLeft.Left += delta;
B_BoxRight.Left += delta;
}
private void InitializeSlots()
@ -93,7 +127,25 @@ public void NotifySlotChanged(ISlotInfo slot, SlotTouchType type, PKM pk)
return;
var pb = SlotPictureBoxes[index];
SlotUtil.UpdateSlot(pb, slot, pk, SAV, FlagIllegal, type);
var flags = GetFlags(pk);
SlotUtil.UpdateSlot(pb, slot, pk, SAV, flags, type);
}
public void ApplyNewFilter(Func<PKM, bool>? filter, bool reload = true)
{
_searchFilter = filter;
if (reload)
ResetSlots();
}
private SlotVisibilityType GetFlags(PKM pk)
{
var result = SlotVisibilityType.None;
if (FlagIllegal)
result |= SlotVisibilityType.CheckLegalityIndicate;
if (_searchFilter != null && !_searchFilter(pk))
result |= SlotVisibilityType.FilterMismatch;
return result;
}
public int GetViewIndex(ISlotInfo slot)
@ -209,7 +261,9 @@ public void ResetSlots()
continue;
}
pb.Visible = true;
SlotUtil.UpdateSlot(pb, (SlotInfoBox)GetSlotData(pb), Editor[i], SAV, FlagIllegal);
var pk = Editor[i];
var flags = GetFlags(pk);
SlotUtil.UpdateSlot(pb, (SlotInfoBox)GetSlotData(pb), pk, SAV, flags);
}
if (M?.Env.Slots.Publisher.Previous is SlotInfoBox b && b.Box == CurrentBox)
@ -296,4 +350,28 @@ public bool InitializeFromSAV(SaveFile sav)
Editor.LoadBox(box);
return result;
}
private Func<PKM, bool>? _searchFilter;
public void ApplySearchFilter(Func<PKM, bool>? searchFilter, bool isInit = false)
{
_searchFilter = searchFilter;
if (isInit)
return;
ResetSlots();
}
public void SeekNext(Func<PKM, bool> searchFilter)
{
// Search from next box, wrapping around
if (!SearchUtil.TrySeekNext(SAV, searchFilter, out var result, CurrentBox))
{
// Not found
System.Media.SystemSounds.Exclamation.Play();
return;
}
CurrentBox = result.Box;
BoxPokeGrid.Entries[result.Slot].Focus();
System.Media.SystemSounds.Asterisk.Play();
}
}

View File

@ -15,11 +15,20 @@ public partial class PartyEditor : UserControl, ISlotViewer<PictureBox>
public SlotChangeManager? M { get; set; }
public bool FlagIllegal { get; set; }
private Func<PKM, bool>? _searchFilter;
public PartyEditor()
{
InitializeComponent();
}
public void ApplyNewFilter(Func<PKM, bool>? filter, bool reload = true)
{
_searchFilter = filter;
if (reload)
ResetSlots();
}
internal bool InitializeGrid()
{
const int width = 2;
@ -75,7 +84,18 @@ public void NotifySlotChanged(ISlotInfo slot, SlotTouchType type, PKM pk)
}
var pb = SlotPictureBoxes[index];
SlotUtil.UpdateSlot(pb, slot, pk, SAV, FlagIllegal, type);
var flags = GetFlags(pk);
SlotUtil.UpdateSlot(pb, slot, pk, SAV, flags, type);
}
private SlotVisibilityType GetFlags(PKM pk)
{
var result = SlotVisibilityType.None;
if (FlagIllegal)
result |= SlotVisibilityType.CheckLegalityIndicate;
if (_searchFilter != null && !_searchFilter(pk))
result |= SlotVisibilityType.FilterMismatch;
return result;
}
public int GetViewIndex(ISlotInfo slot)
@ -108,7 +128,8 @@ public void ResetSlots()
foreach (var pb in SlotPictureBoxes)
{
var slot = (SlotInfoParty) GetSlotData(pb);
SlotUtil.UpdateSlot(pb, slot, slot.Read(SAV), SAV, FlagIllegal);
var pk = slot.Read(SAV);
SlotUtil.UpdateSlot(pb, slot, pk, SAV, GetFlags(pk));
}
if (M?.Env.Slots.Publisher.Previous is SlotInfoParty p)

View File

@ -34,6 +34,7 @@ private void InitializeComponent()
{
tabBoxMulti = new System.Windows.Forms.TabControl();
Tab_Box = new System.Windows.Forms.TabPage();
B_SearchBox = new System.Windows.Forms.Button();
Box = new BoxEditor();
Tab_PartyBattle = new System.Windows.Forms.TabPage();
SL_Party = new PartyEditor();
@ -70,6 +71,7 @@ private void InitializeComponent()
B_OpenHallofFame = new System.Windows.Forms.Button();
B_OUTPasserby = new System.Windows.Forms.Button();
B_DLC = new System.Windows.Forms.Button();
B_Donuts = new System.Windows.Forms.Button();
B_OpenPokeBeans = new System.Windows.Forms.Button();
B_CellsStickers = new System.Windows.Forms.Button();
B_OpenMiscEditor = new System.Windows.Forms.Button();
@ -110,7 +112,6 @@ private void InitializeComponent()
TB_Secure1 = new System.Windows.Forms.TextBox();
L_GameSync = new System.Windows.Forms.Label();
TB_GameSync = new System.Windows.Forms.TextBox();
B_Donuts = new System.Windows.Forms.Button();
tabBoxMulti.SuspendLayout();
Tab_Box.SuspendLayout();
Tab_PartyBattle.SuspendLayout();
@ -146,6 +147,7 @@ private void InitializeComponent()
// Tab_Box
//
Tab_Box.AllowDrop = true;
Tab_Box.Controls.Add(B_SearchBox);
Tab_Box.Controls.Add(Box);
Tab_Box.Location = new System.Drawing.Point(4, 26);
Tab_Box.Name = "Tab_Box";
@ -155,6 +157,18 @@ private void InitializeComponent()
Tab_Box.Text = "Box";
Tab_Box.UseVisualStyleBackColor = true;
//
// B_SearchBox
//
B_SearchBox.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
B_SearchBox.Image = Properties.Resources.other;
B_SearchBox.Location = new System.Drawing.Point(414, 3);
B_SearchBox.Margin = new System.Windows.Forms.Padding(0);
B_SearchBox.Name = "B_SearchBox";
B_SearchBox.Size = new System.Drawing.Size(24, 24);
B_SearchBox.TabIndex = 2;
B_SearchBox.UseVisualStyleBackColor = true;
B_SearchBox.Click += B_SearchBox_Click;
//
// Box
//
Box.AllowDrop = true;
@ -168,7 +182,7 @@ private void InitializeComponent()
Box.Location = new System.Drawing.Point(107, 7);
Box.M = null;
Box.Name = "Box";
Box.Size = new System.Drawing.Size(251, 185);
Box.Size = new System.Drawing.Size(251, 187);
Box.TabIndex = 1;
//
// Tab_PartyBattle
@ -341,7 +355,7 @@ private void InitializeComponent()
//
// L_ReadOnlyOther
//
L_ReadOnlyOther.ForeColor = WinFormsUtil.ColorWarn;
L_ReadOnlyOther.ForeColor = System.Drawing.Color.Red;
L_ReadOnlyOther.Location = new System.Drawing.Point(32, 208);
L_ReadOnlyOther.Name = "L_ReadOnlyOther";
L_ReadOnlyOther.Size = new System.Drawing.Size(176, 24);
@ -599,6 +613,17 @@ private void InitializeComponent()
B_DLC.UseVisualStyleBackColor = true;
B_DLC.Click += B_DLC_Click;
//
// B_Donuts
//
B_Donuts.Location = new System.Drawing.Point(4, 164);
B_Donuts.Margin = new System.Windows.Forms.Padding(4);
B_Donuts.Name = "B_Donuts";
B_Donuts.Size = new System.Drawing.Size(96, 32);
B_Donuts.TabIndex = 11;
B_Donuts.Text = "Donuts";
B_Donuts.UseVisualStyleBackColor = true;
B_Donuts.Click += B_Donuts_Click;
//
// B_OpenPokeBeans
//
B_OpenPokeBeans.Location = new System.Drawing.Point(108, 164);
@ -1040,17 +1065,6 @@ private void InitializeComponent()
TB_GameSync.TabIndex = 10;
TB_GameSync.Validated += UpdateStringSeed;
//
// B_Donuts
//
B_Donuts.Location = new System.Drawing.Point(4, 164);
B_Donuts.Margin = new System.Windows.Forms.Padding(4);
B_Donuts.Name = "B_Donuts";
B_Donuts.Size = new System.Drawing.Size(96, 32);
B_Donuts.TabIndex = 11;
B_Donuts.Text = "Donuts";
B_Donuts.UseVisualStyleBackColor = true;
B_Donuts.Click += B_Donuts_Click;
//
// SAVEditor
//
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
@ -1155,5 +1169,6 @@ private void InitializeComponent()
private System.Windows.Forms.Button B_OpenGear;
private System.Windows.Forms.Button B_OpenFashion;
private System.Windows.Forms.Button B_Donuts;
private System.Windows.Forms.Button B_SearchBox;
}
}

View File

@ -111,6 +111,15 @@ private void InitializeEvents()
GB_Daycare.Click += (_, _) => SwitchDaycare();
FLP_SAVtools.Scroll += WinFormsUtil.PanelScroll;
SortMenu.Opening += (_, x) => x.Cancel = !tabBoxMulti.GetTabRect(tabBoxMulti.SelectedIndex).Contains(PointToClient(MousePosition));
Tab_Box.SizeChanged += Tab_Box_SizeChanged;
}
private void Tab_Box_SizeChanged(object? sender, EventArgs e)
{
if (!SAV.HasBox)
return;
Box.HorizontallyCenter(Tab_Box);
BoxSearchAlignButton();
}
private void InitializeDragDrop(Control pb)
@ -204,7 +213,16 @@ public void NotifySlotChanged(ISlotInfo slot, SlotTouchType type, PKM pk)
ResetParty(); // lots of slots change, just update
var pb = SlotPictureBoxes[index];
SlotUtil.UpdateSlot(pb, slot, pk, SAV, Box.FlagIllegal, type);
var flags = GetFlags(pk);
SlotUtil.UpdateSlot(pb, slot, pk, SAV, flags, type);
}
private SlotVisibilityType GetFlags(PKM pk, bool ignoreLegality = false)
{
var result = SlotVisibilityType.None;
if (FlagIllegal && !ignoreLegality)
result |= SlotVisibilityType.CheckLegalityIndicate;
return result;
}
public ISlotInfo GetSlotData(PictureBox view)
@ -242,8 +260,9 @@ private void ResetMiscSlots()
{
var info = SL_Extra.GetSlotData(i);
var pb = slots[i];
var showLegality = info is not SlotInfoMisc { HideLegality: true };
SlotUtil.UpdateSlot(pb, info, info.Read(SAV), SAV, Box.FlagIllegal && showLegality);
var pk = info.Read(SAV);
var hideLegality = info is SlotInfoMisc { HideLegality: true };
SlotUtil.UpdateSlot(pb, info, pk, SAV, GetFlags(pk, hideLegality));
}
}
@ -295,9 +314,8 @@ private void ResetDaycare()
{
L_SlotOccupied[i].Text = $"{i + 1}: ✘";
var pb = UpdateSlot(i);
var current = pb.Image;
if (current is not null)
pb.Image = ImageUtil.ChangeOpacity(current, 0.6);
if (pb.Image is Bitmap current)
pb.Image = ImageUtil.CopyChangeOpacity(current, 0.6);
}
}
@ -370,7 +388,8 @@ private PictureBox UpdateSlot(int relIndex)
{
var info = GetSlotData(relIndex);
var pb = SlotPictureBoxes[relIndex];
SlotUtil.UpdateSlot(pb, info, info.Read(SAV), SAV, Box.FlagIllegal);
var pk = info.Read(SAV);
SlotUtil.UpdateSlot(pb, info, pk, SAV, GetFlags(pk));
return pb;
}
@ -1141,6 +1160,7 @@ public bool ToggleInterface()
SetPKMBoxes(); // Reload all Entity picture boxes
ToggleViewMisc(SAV);
BoxSearchAlignButton();
FieldsLoaded = true;
return WindowTranslationRequired;
@ -1172,6 +1192,7 @@ private void ToggleViewReset()
form?.Height += height - allowed;
}
}
BoxSearchClear();
}
if (SAV.HasParty)
{
@ -1530,4 +1551,89 @@ private static async Task DeleteAsync(string path, int delay)
try { File.Delete(path); }
catch (Exception ex) { Debug.WriteLine(ex.Message); }
}
private EntitySearchSetup? _searchForm;
private Func<PKM, bool>? _searchFilter;
private void B_SearchBox_Click(object sender, EventArgs e)
{
if (_searchForm is not null)
{
if (ModifierKeys == Keys.Alt)
{
_searchForm.ForceReset();
_searchForm.Hide();
return;
}
if (ModifierKeys == Keys.Shift)
{
BoxSearchSeek();
return;
}
}
if (_searchForm is null || !_searchForm.IsSameSaveFile(SAV))
_searchForm = CreateSearcher(SAV, EditEnv.PKMEditor);
// Set the searcher Position immediately to the right of this parent form, and vertically aligned tops of forms.
var parent = FindForm();
if (parent is not null)
{
var location = parent.Location;
location.X += parent.Width;
_searchForm.StartPosition = FormStartPosition.Manual;
_searchForm.Location = location;
_searchForm.TopMost = true;
}
_searchForm.Show();
_searchForm.BringToFront();
}
private EntitySearchSetup CreateSearcher(SaveFile sav, IPKMView edit)
{
BoxSearchClear();
var result = new EntitySearchSetup();
result.Initialize(sav, edit);
result.ResetRequested += UpdateSearch;
result.SearchRequested += UpdateSearch;
return result;
}
private void UpdateSearch(object? sender, EventArgs e)
{
_searchFilter = _searchForm!.SearchFilter;
EditEnv.Slots.Publisher.UpdateFilter(_searchFilter);
}
private void BoxSearchClear()
{
_searchFilter = null;
EditEnv.Slots.Publisher.UpdateFilter(_searchFilter);
if (_searchForm is { } form)
{
form.ResetRequested -= UpdateSearch;
form.SearchRequested -= UpdateSearch;
form.Close(); // get rid of previous searcher if it exists
}
_searchForm = null;
}
private void BoxSearchAlignButton()
{
// Move the Search button so that it is vertically aligned to the navigation buttons, and right-edge aligned with the last picturebox in the grid.
var navButton = Box.B_BoxRight;
B_SearchBox.Top = Box.Top + navButton.Top;
B_SearchBox.Left = Box.Left + Box.BoxPokeGrid.Right - B_SearchBox.Width;
}
private void BoxSearchSeek()
{
if (_searchFilter is null)
return;
Box.SeekNext(_searchFilter);
}
public void ApplyNewFilter(Func<PKM, bool>? filter, bool reload = true) => Box.ApplySearchFilter(filter, reload);
}

View File

@ -71,10 +71,10 @@ private void Generate(int width, int height)
ResumeLayout();
}
public void SetBackground(Image img)
public void SetBackground(Bitmap img)
{
if (Application.IsDarkModeEnabled)
img = Drawing.ImageUtil.ChangeOpacity(img, 0.5);
img = Drawing.ImageUtil.CopyChangeOpacity(img, 0.5);
BackgroundImage = img;
}

View File

@ -23,7 +23,7 @@ public sealed class SlotHoverHandler : IDisposable
public bool GlowHover { private get; set; } = true;
private readonly SummaryPreviewer Preview = new();
private static Bitmap Hover => Application.IsDarkModeEnabled ? ImageUtil.ChangeOpacity(SpriteUtil.Spriter.Hover, 0.5) : SpriteUtil.Spriter.Hover;
private static Bitmap Hover => Application.IsDarkModeEnabled ? ImageUtil.CopyChangeOpacity(SpriteUtil.Spriter.Hover, 0.5) : SpriteUtil.Spriter.Hover;
private readonly BitmapAnimator HoverWorker = new();
@ -45,7 +45,7 @@ public void Start(PictureBox pb, SlotTrackerImage lastSlot)
Slot = pb;
LastSlot = lastSlot;
var orig = LastSlot.OriginalBackground = pb.BackgroundImage;
var orig = (Bitmap?)(LastSlot.OriginalBackground = pb.BackgroundImage);
Bitmap bg;
if (GlowHover)
@ -53,11 +53,11 @@ public void Start(PictureBox pb, SlotTrackerImage lastSlot)
HoverWorker.Stop();
var hover = Hover;
var glow = Draw.GlowInitial;
SpriteUtil.GetSpriteGlow(pk, glow.B, glow.G, glow.R, out var glowdata, out var imgGlowBase);
SpriteUtil.GetSpriteGlow(pk, glow.B, glow.G, glow.R, out var glowData, out var imgGlowBase);
bg = ImageUtil.LayerImage(imgGlowBase, hover, 0, 0);
HoverWorker.GlowToColor = Draw.GlowFinal;
HoverWorker.GlowFromColor = Draw.GlowInitial;
HoverWorker.Start(pb, imgGlowBase, glowdata, orig, hover);
HoverWorker.Start(pb, imgGlowBase, glowData, orig, hover);
}
else
{

View File

@ -27,6 +27,7 @@ public static string[] GetEnumNames()
public int SlotCount { get; private set; }
public SaveFile SAV { get; set; } = null!;
public bool FlagIllegal { get; set; }
private Func<PKM, bool>? _searchFilter;
public SlotList()
{
@ -70,8 +71,39 @@ public void NotifySlotChanged(ISlotInfo slot, SlotTouchType type, PKM pk)
if (index < 0)
return;
var pb = slots[index];
var showLegality = m is not { HideLegality: true };
SlotUtil.UpdateSlot(pb, slot, pk, SAV, FlagIllegal && showLegality, type);
var hideLegality = m is { HideLegality: true };
var flags = GetFlags(pk, hideLegality);
SlotUtil.UpdateSlot(pb, slot, pk, SAV, flags, type);
}
public void ApplyNewFilter(Func<PKM, bool>? filter, bool reload = true)
{
_searchFilter = filter;
if (reload)
ResetSlots();
}
private void ResetSlots()
{
for (int i = 0; i < SlotOffsets.Count; i++)
{
var info = SlotOffsets[i];
var pb = slots[i];
var hideLegality = info is { HideLegality: true };
var flags = GetFlags(info.Read(SAV), hideLegality);
var type = SlotTouchType.None;
SlotUtil.UpdateSlot(pb, info, info.Read(SAV), SAV, flags, type);
}
}
private SlotVisibilityType GetFlags(PKM pk, bool ignoreLegality = false)
{
var result = SlotVisibilityType.None;
if (FlagIllegal && !ignoreLegality)
result |= SlotVisibilityType.CheckLegalityIndicate;
if (_searchFilter != null && !_searchFilter(pk))
result |= SlotVisibilityType.FilterMismatch;
return result;
}
public int GetViewIndex(ISlotInfo info) => SlotOffsets.FindIndex(info.Equals);

View File

@ -40,7 +40,7 @@ public static class SlotUtil
/// <summary>
/// Refreshes a <see cref="PictureBox"/> with the appropriate display content.
/// </summary>
public static void UpdateSlot(PictureBox pb, ISlotInfo info, PKM pk, SaveFile sav, bool flagIllegal, SlotTouchType t = SlotTouchType.None)
public static void UpdateSlot(PictureBox pb, ISlotInfo info, PKM pk, SaveFile sav, SlotVisibilityType flags, SlotTouchType t = SlotTouchType.None)
{
pb.BackgroundImage = GetTouchTypeBackground(t);
if (pk.Species == 0) // Nothing in slot
@ -59,7 +59,7 @@ public static void UpdateSlot(PictureBox pb, ISlotInfo info, PKM pk, SaveFile sa
return;
}
pb.Image = GetImage(info, pk, sav, flagIllegal);
pb.Image = GetImage(info, pk, sav, flags);
pb.BackColor = GoodDataColor;
// Get an accessible description for the slot (for screen readers)
@ -70,10 +70,10 @@ public static void UpdateSlot(PictureBox pb, ISlotInfo info, PKM pk, SaveFile sa
pb.AccessibleDescription = ShowdownParsing.GetLocalizedPreviewText(pk, settings);
}
private static Bitmap GetImage(ISlotInfo info, PKM pk, SaveFile sav, bool flagIllegal) => info switch
private static Bitmap GetImage(ISlotInfo info, PKM pk, SaveFile sav, SlotVisibilityType flags) => info switch
{
SlotInfoBox b => pk.Sprite(sav, b.Box, b.Slot, flagIllegal, b.Type),
SlotInfoParty ps => pk.Sprite(sav, -1, ps.Slot, flagIllegal, ps.Type),
_ => pk.Sprite(sav, -1, -1, flagIllegal, info.Type),
SlotInfoBox b => pk.Sprite(sav, b.Box, b.Slot, flags, b.Type),
SlotInfoParty ps => pk.Sprite(sav, -1, ps.Slot, flags, ps.Type),
_ => pk.Sprite(sav, -1, -1, flags, info.Type),
};
}

View File

@ -1139,8 +1139,7 @@ private void GetPreview(PictureBox pb, PKM? pk = null)
var img = pk.Sprite(C_SAV.SAV);
if (Application.IsDarkModeEnabled)
{
var data = ImageUtil.GetPixelData(img);
var avg = ImageUtil.GetAverageColor(data);
var avg = img.GetAverageColor();
var c = Color.FromArgb(avg);
SpriteUtil.GetSpriteGlow(img, c.B, c.G, c.R, out var pixels, true);
var layer = ImageUtil.GetBitmap(pixels, img.Width, img.Height, img.PixelFormat);

View File

@ -11,12 +11,12 @@ public partial class QR : Form
{
private readonly PKM? Entity;
private readonly Image icon;
private Image qr;
private Bitmap qr;
private readonly string[] Lines;
private string extraText = string.Empty;
public QR(Image qr, Image icon, params string[] lines)
public QR(Bitmap qr, Image icon, params string[] lines)
{
InitializeComponent();
WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
@ -28,7 +28,7 @@ public QR(Image qr, Image icon, params string[] lines)
ResizeWindow();
}
public QR(Image qr, Image icon, PKM pk, params string[] lines)
public QR(Bitmap qr, Image icon, PKM pk, params string[] lines)
{
InitializeComponent();
this.qr = qr;

View File

@ -46,4 +46,10 @@ public sealed class SpriteSettings : ISpriteSettings
[LocalizedDescription("Opacity for the Tera Type stripe layer.")]
public byte ShowTeraOpacityStripe { get; set; } = 0xAF; // 0xFF opaque
[LocalizedDescription("Opacity of an entity that does not match a filter.")]
public float FilterMismatchOpacity { get; set; } = 0.40f; // 1.0f opaque; Mostly transparent
[LocalizedDescription("Grayscale amount to apply to an entity that does not match a filter (0.0 = no grayscale, 1.0 = fully grayscale).")]
public float FilterMismatchGrayscale { get; set; } = 0.70f; // 1.0f fully grayscale; Mostly grayscale
}

View File

@ -0,0 +1,189 @@
namespace PKHeX.WinForms
{
partial class EntitySearchSetup
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
TLP_Main = new System.Windows.Forms.TableLayoutPanel();
TC_SearchSettings = new System.Windows.Forms.TabControl();
Tab_General = new System.Windows.Forms.TabPage();
UC_EntitySearch = new PKHeX.WinForms.Controls.EntitySearchControl();
Tab_Advanced = new System.Windows.Forms.TabPage();
B_Add = new System.Windows.Forms.Button();
RTB_Instructions = new System.Windows.Forms.RichTextBox();
B_Search = new System.Windows.Forms.Button();
B_Reset = new System.Windows.Forms.Button();
TLP_Main.SuspendLayout();
TC_SearchSettings.SuspendLayout();
Tab_General.SuspendLayout();
Tab_Advanced.SuspendLayout();
SuspendLayout();
//
// TLP_Main
//
TLP_Main.ColumnCount = 1;
TLP_Main.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
TLP_Main.Controls.Add(TC_SearchSettings, 0, 0);
TLP_Main.Controls.Add(B_Search, 0, 1);
TLP_Main.Dock = System.Windows.Forms.DockStyle.Fill;
TLP_Main.Location = new System.Drawing.Point(0, 0);
TLP_Main.Margin = new System.Windows.Forms.Padding(0);
TLP_Main.Name = "TLP_Main";
TLP_Main.RowCount = 2;
TLP_Main.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
TLP_Main.RowStyles.Add(new System.Windows.Forms.RowStyle());
TLP_Main.Size = new System.Drawing.Size(320, 540);
TLP_Main.TabIndex = 0;
//
// TC_SearchSettings
//
TC_SearchSettings.Controls.Add(Tab_General);
TC_SearchSettings.Controls.Add(Tab_Advanced);
TC_SearchSettings.Dock = System.Windows.Forms.DockStyle.Fill;
TC_SearchSettings.Location = new System.Drawing.Point(0, 0);
TC_SearchSettings.Margin = new System.Windows.Forms.Padding(0);
TC_SearchSettings.Name = "TC_SearchSettings";
TC_SearchSettings.Padding = new System.Drawing.Point(0, 0);
TC_SearchSettings.SelectedIndex = 0;
TC_SearchSettings.Size = new System.Drawing.Size(320, 510);
TC_SearchSettings.TabIndex = 2;
//
// Tab_General
//
Tab_General.Controls.Add(UC_EntitySearch);
Tab_General.Location = new System.Drawing.Point(4, 26);
Tab_General.Margin = new System.Windows.Forms.Padding(0);
Tab_General.Name = "Tab_General";
Tab_General.Size = new System.Drawing.Size(312, 480);
Tab_General.TabIndex = 0;
Tab_General.Text = "General";
Tab_General.UseVisualStyleBackColor = true;
//
// UC_EntitySearch
//
UC_EntitySearch.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
UC_EntitySearch.Dock = System.Windows.Forms.DockStyle.Fill;
UC_EntitySearch.Location = new System.Drawing.Point(0, 0);
UC_EntitySearch.Margin = new System.Windows.Forms.Padding(0);
UC_EntitySearch.MaxFormat = 9;
UC_EntitySearch.Name = "UC_EntitySearch";
UC_EntitySearch.SaveGeneration = 9;
UC_EntitySearch.Size = new System.Drawing.Size(312, 480);
UC_EntitySearch.TabIndex = 0;
//
// Tab_Advanced
//
Tab_Advanced.Controls.Add(B_Add);
Tab_Advanced.Controls.Add(RTB_Instructions);
Tab_Advanced.Location = new System.Drawing.Point(4, 26);
Tab_Advanced.Margin = new System.Windows.Forms.Padding(0);
Tab_Advanced.Name = "Tab_Advanced";
Tab_Advanced.Size = new System.Drawing.Size(312, 480);
Tab_Advanced.TabIndex = 1;
Tab_Advanced.Text = "Advanced";
Tab_Advanced.UseVisualStyleBackColor = true;
//
// B_Add
//
B_Add.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
B_Add.Location = new System.Drawing.Point(248, 0);
B_Add.Margin = new System.Windows.Forms.Padding(0);
B_Add.Name = "B_Add";
B_Add.Size = new System.Drawing.Size(66, 27);
B_Add.TabIndex = 1;
B_Add.Text = "Add";
B_Add.UseVisualStyleBackColor = true;
B_Add.Click += B_Add_Click;
//
// RTB_Instructions
//
RTB_Instructions.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
RTB_Instructions.Location = new System.Drawing.Point(0, 55);
RTB_Instructions.Margin = new System.Windows.Forms.Padding(0);
RTB_Instructions.Name = "RTB_Instructions";
RTB_Instructions.Size = new System.Drawing.Size(312, 425);
RTB_Instructions.TabIndex = 0;
RTB_Instructions.Text = "";
//
// B_Search
//
B_Search.Dock = System.Windows.Forms.DockStyle.Fill;
B_Search.Location = new System.Drawing.Point(0, 510);
B_Search.Margin = new System.Windows.Forms.Padding(0);
B_Search.Name = "B_Search";
B_Search.Size = new System.Drawing.Size(320, 30);
B_Search.TabIndex = 3;
B_Search.Text = "Search!";
B_Search.UseVisualStyleBackColor = true;
B_Search.Click += B_Search_Click;
//
// B_Reset
//
B_Reset.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
B_Reset.Location = new System.Drawing.Point(214, 0);
B_Reset.Margin = new System.Windows.Forms.Padding(0);
B_Reset.Name = "B_Reset";
B_Reset.Size = new System.Drawing.Size(104, 27);
B_Reset.TabIndex = 0;
B_Reset.Text = "Reset Filters";
B_Reset.UseVisualStyleBackColor = true;
B_Reset.Click += B_Reset_Click;
//
// EntitySearchSetup
//
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
ClientSize = new System.Drawing.Size(320, 540);
Controls.Add(B_Reset);
Controls.Add(TLP_Main);
FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
KeyPreview = true;
MaximizeBox = false;
MinimizeBox = false;
Name = "EntitySearchSetup";
StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
Text = "Search";
KeyDown += OnKeyDown;
TLP_Main.ResumeLayout(false);
TC_SearchSettings.ResumeLayout(false);
Tab_General.ResumeLayout(false);
Tab_Advanced.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TableLayoutPanel TLP_Main;
private System.Windows.Forms.Button B_Reset;
private System.Windows.Forms.TabControl TC_SearchSettings;
private System.Windows.Forms.TabPage Tab_General;
private Controls.EntitySearchControl UC_EntitySearch;
private System.Windows.Forms.TabPage Tab_Advanced;
private System.Windows.Forms.Button B_Add;
private System.Windows.Forms.RichTextBox RTB_Instructions;
private System.Windows.Forms.Button B_Search;
}
}

View File

@ -0,0 +1,134 @@
using System;
using System.Windows.Forms;
using PKHeX.Core;
using PKHeX.WinForms.Controls;
using static PKHeX.Core.MessageStrings;
namespace PKHeX.WinForms;
public partial class EntitySearchSetup : Form
{
private EntityInstructionBuilder? UC_Builder;
private SaveFile? CurrentSave;
public Func<PKM, bool>? SearchFilter { get; private set; }
public EntitySearchSetup()
{
InitializeComponent();
WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
}
/// <summary>
/// Occurs when the Search action is requested.
/// </summary>
public event EventHandler? SearchRequested;
/// <summary>
/// Occurs when the Reset action is requested.
/// </summary>
public event EventHandler? ResetRequested;
/// <summary>
/// Initializes the search setup controls using the provided save file.
/// </summary>
/// <param name="sav">Save file used to configure search settings.</param>
/// <param name="edit">Editor to provide the current PKM.</param>
public void Initialize(SaveFile sav, IPKMView edit)
{
ArgumentNullException.ThrowIfNull(sav);
UC_EntitySearch.MaxFormat = Latest.Generation;
UC_EntitySearch.SaveGeneration = sav.Generation;
UC_EntitySearch.PopulateComboBoxes();
UC_EntitySearch.SetFormatAnyText(MsgAny);
UC_EntitySearch.FormatComparatorSelectedIndex = 3; // <=
CurrentSave = sav;
EnsureBuilder(edit);
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
UC_EntitySearch.ResetComboBoxSelections();
}
private void OnKeyDown(object sender, KeyEventArgs e)
{
// Quick close with Ctrl+W
if (e.KeyCode == Keys.W && ModifierKeys == Keys.Control)
Hide();
}
protected override void OnFormClosing(FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
e.Cancel = true;
Hide();
return;
}
CurrentSave = null;
SearchFilter = null;
base.OnFormClosing(e);
}
private void EnsureBuilder(IPKMView edit)
{
if (UC_Builder is not null)
return;
UC_Builder = new EntityInstructionBuilder(() => edit.PreparePKM())
{
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
Dock = DockStyle.Top,
ReadOnly = true,
};
Tab_Advanced.Controls.Add(UC_Builder);
UC_Builder.SendToBack();
}
private void B_Search_Click(object? sender, EventArgs e)
{
SearchFilter = UC_EntitySearch.GetFilter(RTB_Instructions.Text);
SearchRequested?.Invoke(this, EventArgs.Empty);
System.Media.SystemSounds.Asterisk.Play();
}
private void B_Reset_Click(object? sender, EventArgs e)
{
UC_EntitySearch.ResetFilters();
RTB_Instructions.Clear();
SearchFilter = null;
ResetRequested?.Invoke(this, EventArgs.Empty);
System.Media.SystemSounds.Asterisk.Play();
}
private void B_Add_Click(object? sender, EventArgs e)
{
if (UC_Builder is null)
return;
var s = UC_Builder.Create();
if (s.Length == 0)
{
WinFormsUtil.Alert(MsgBEPropertyInvalid);
return;
}
var tb = RTB_Instructions;
var batchText = tb.Text;
if (batchText.Length != 0 && !batchText.EndsWith('\n'))
tb.AppendText(Environment.NewLine);
tb.AppendText(s);
}
public bool IsSameSaveFile(SaveFile sav) => CurrentSave is not null && CurrentSave == sav;
public void ForceReset()
{
SearchFilter = null;
UC_EntitySearch.ResetFilters();
RTB_Instructions.Clear();
ResetRequested?.Invoke(this, EventArgs.Empty);
}
}

View File

@ -47,8 +47,8 @@ private void InitializeComponent()
Menu_Import = new System.Windows.Forms.ToolStripMenuItem();
Menu_DeleteClones = new System.Windows.Forms.ToolStripMenuItem();
P_Results = new System.Windows.Forms.Panel();
DatabasePokeGrid = new Controls.PokeGrid();
UC_EntitySearch = new Controls.EntitySearchControl();
DatabasePokeGrid = new PKHeX.WinForms.Controls.PokeGrid();
UC_EntitySearch = new PKHeX.WinForms.Controls.EntitySearchControl();
B_Search = new System.Windows.Forms.Button();
B_Reset = new System.Windows.Forms.Button();
L_Count = new System.Windows.Forms.Label();
@ -76,7 +76,7 @@ private void InitializeComponent()
SCR_Box.LargeChange = 1;
SCR_Box.Location = new System.Drawing.Point(299, 3);
SCR_Box.Name = "SCR_Box";
SCR_Box.Size = new System.Drawing.Size(24, 397);
SCR_Box.Size = new System.Drawing.Size(24, 479);
SCR_Box.TabIndex = 1;
SCR_Box.Scroll += UpdateScroll;
//
@ -87,7 +87,7 @@ private void InitializeComponent()
menuStrip1.Location = new System.Drawing.Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Padding = new System.Windows.Forms.Padding(7, 2, 0, 2);
menuStrip1.Size = new System.Drawing.Size(670, 24);
menuStrip1.Size = new System.Drawing.Size(692, 25);
menuStrip1.TabIndex = 65;
menuStrip1.Text = "menuStrip1";
//
@ -95,7 +95,7 @@ private void InitializeComponent()
//
Menu_Close.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { Menu_Exit });
Menu_Close.Name = "Menu_Close";
Menu_Close.Size = new System.Drawing.Size(37, 20);
Menu_Close.Size = new System.Drawing.Size(39, 21);
Menu_Close.Text = "File";
//
// Menu_Exit
@ -104,7 +104,7 @@ private void InitializeComponent()
Menu_Exit.Name = "Menu_Exit";
Menu_Exit.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E;
Menu_Exit.ShowShortcutKeys = false;
Menu_Exit.Size = new System.Drawing.Size(96, 22);
Menu_Exit.Size = new System.Drawing.Size(100, 22);
Menu_Exit.Text = "&Close";
Menu_Exit.Click += Menu_Exit_Click;
//
@ -112,7 +112,7 @@ private void InitializeComponent()
//
Menu_Tools.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { Menu_SearchSettings, Menu_OpenDB, Menu_Report, Menu_Export, Menu_Import, Menu_DeleteClones });
Menu_Tools.Name = "Menu_Tools";
Menu_Tools.Size = new System.Drawing.Size(46, 20);
Menu_Tools.Size = new System.Drawing.Size(51, 21);
Menu_Tools.Text = "Tools";
//
// Menu_SearchSettings
@ -120,7 +120,7 @@ private void InitializeComponent()
Menu_SearchSettings.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { Menu_SearchBoxes, Menu_SearchDatabase, Menu_SearchBackups, Menu_SearchLegal, Menu_SearchIllegal, Menu_SearchClones });
Menu_SearchSettings.Image = Properties.Resources.settings;
Menu_SearchSettings.Name = "Menu_SearchSettings";
Menu_SearchSettings.Size = new System.Drawing.Size(209, 22);
Menu_SearchSettings.Size = new System.Drawing.Size(226, 22);
Menu_SearchSettings.Text = "Search Settings";
//
// Menu_SearchBoxes
@ -129,7 +129,7 @@ private void InitializeComponent()
Menu_SearchBoxes.CheckOnClick = true;
Menu_SearchBoxes.CheckState = System.Windows.Forms.CheckState.Checked;
Menu_SearchBoxes.Name = "Menu_SearchBoxes";
Menu_SearchBoxes.Size = new System.Drawing.Size(198, 22);
Menu_SearchBoxes.Size = new System.Drawing.Size(214, 22);
Menu_SearchBoxes.Text = "Search Within Boxes";
//
// Menu_SearchDatabase
@ -138,7 +138,7 @@ private void InitializeComponent()
Menu_SearchDatabase.CheckOnClick = true;
Menu_SearchDatabase.CheckState = System.Windows.Forms.CheckState.Checked;
Menu_SearchDatabase.Name = "Menu_SearchDatabase";
Menu_SearchDatabase.Size = new System.Drawing.Size(198, 22);
Menu_SearchDatabase.Size = new System.Drawing.Size(214, 22);
Menu_SearchDatabase.Text = "Search Within Database";
//
// Menu_SearchBackups
@ -147,7 +147,7 @@ private void InitializeComponent()
Menu_SearchBackups.CheckOnClick = true;
Menu_SearchBackups.CheckState = System.Windows.Forms.CheckState.Checked;
Menu_SearchBackups.Name = "Menu_SearchBackups";
Menu_SearchBackups.Size = new System.Drawing.Size(198, 22);
Menu_SearchBackups.Size = new System.Drawing.Size(214, 22);
Menu_SearchBackups.Text = "Search Within Backups";
//
// Menu_SearchLegal
@ -156,7 +156,7 @@ private void InitializeComponent()
Menu_SearchLegal.CheckOnClick = true;
Menu_SearchLegal.CheckState = System.Windows.Forms.CheckState.Checked;
Menu_SearchLegal.Name = "Menu_SearchLegal";
Menu_SearchLegal.Size = new System.Drawing.Size(198, 22);
Menu_SearchLegal.Size = new System.Drawing.Size(214, 22);
Menu_SearchLegal.Text = "Show Legal";
//
// Menu_SearchIllegal
@ -165,21 +165,21 @@ private void InitializeComponent()
Menu_SearchIllegal.CheckOnClick = true;
Menu_SearchIllegal.CheckState = System.Windows.Forms.CheckState.Checked;
Menu_SearchIllegal.Name = "Menu_SearchIllegal";
Menu_SearchIllegal.Size = new System.Drawing.Size(198, 22);
Menu_SearchIllegal.Size = new System.Drawing.Size(214, 22);
Menu_SearchIllegal.Text = "Show Illegal";
//
// Menu_SearchClones
//
Menu_SearchClones.CheckOnClick = true;
Menu_SearchClones.Name = "Menu_SearchClones";
Menu_SearchClones.Size = new System.Drawing.Size(198, 22);
Menu_SearchClones.Size = new System.Drawing.Size(214, 22);
Menu_SearchClones.Text = "Clones Only";
//
// Menu_OpenDB
//
Menu_OpenDB.Image = Properties.Resources.folder;
Menu_OpenDB.Name = "Menu_OpenDB";
Menu_OpenDB.Size = new System.Drawing.Size(209, 22);
Menu_OpenDB.Size = new System.Drawing.Size(226, 22);
Menu_OpenDB.Text = "Open Database Folder";
Menu_OpenDB.Click += OpenDB;
//
@ -187,7 +187,7 @@ private void InitializeComponent()
//
Menu_Report.Image = Properties.Resources.report;
Menu_Report.Name = "Menu_Report";
Menu_Report.Size = new System.Drawing.Size(209, 22);
Menu_Report.Size = new System.Drawing.Size(226, 22);
Menu_Report.Text = "Create Data Report";
Menu_Report.Click += GenerateDBReport;
//
@ -195,7 +195,7 @@ private void InitializeComponent()
//
Menu_Export.Image = Properties.Resources.export;
Menu_Export.Name = "Menu_Export";
Menu_Export.Size = new System.Drawing.Size(209, 22);
Menu_Export.Size = new System.Drawing.Size(226, 22);
Menu_Export.Text = "Export Results to Folder";
Menu_Export.Click += Menu_Export_Click;
//
@ -203,7 +203,7 @@ private void InitializeComponent()
//
Menu_Import.Image = Properties.Resources.savePKM;
Menu_Import.Name = "Menu_Import";
Menu_Import.Size = new System.Drawing.Size(209, 22);
Menu_Import.Size = new System.Drawing.Size(226, 22);
Menu_Import.Text = "Import Results to SaveFile";
Menu_Import.Click += Menu_Import_Click;
//
@ -211,7 +211,7 @@ private void InitializeComponent()
//
Menu_DeleteClones.Image = Properties.Resources.nocheck;
Menu_DeleteClones.Name = "Menu_DeleteClones";
Menu_DeleteClones.Size = new System.Drawing.Size(209, 22);
Menu_DeleteClones.Size = new System.Drawing.Size(226, 22);
Menu_DeleteClones.Text = "Delete Clones";
Menu_DeleteClones.Click += Menu_DeleteClones_Click;
//
@ -225,7 +225,7 @@ private void InitializeComponent()
P_Results.Location = new System.Drawing.Point(14, 37);
P_Results.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
P_Results.Name = "P_Results";
P_Results.Size = new System.Drawing.Size(332, 406);
P_Results.Size = new System.Drawing.Size(332, 488);
P_Results.TabIndex = 66;
//
// DatabasePokeGrid
@ -234,15 +234,26 @@ private void InitializeComponent()
DatabasePokeGrid.Location = new System.Drawing.Point(2, 2);
DatabasePokeGrid.Margin = new System.Windows.Forms.Padding(0);
DatabasePokeGrid.Name = "DatabasePokeGrid";
DatabasePokeGrid.Size = new System.Drawing.Size(293, 399);
DatabasePokeGrid.Size = new System.Drawing.Size(293, 484);
DatabasePokeGrid.TabIndex = 2;
//
// UC_EntitySearch
//
UC_EntitySearch.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
UC_EntitySearch.Dock = System.Windows.Forms.DockStyle.Fill;
UC_EntitySearch.Location = new System.Drawing.Point(4, 3);
UC_EntitySearch.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
UC_EntitySearch.Name = "UC_EntitySearch";
UC_EntitySearch.Size = new System.Drawing.Size(314, 449);
UC_EntitySearch.TabIndex = 118;
//
// B_Search
//
B_Search.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
B_Search.Location = new System.Drawing.Point(384, 412);
B_Search.Location = new System.Drawing.Point(355, 495);
B_Search.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
B_Search.Name = "B_Search";
B_Search.Size = new System.Drawing.Size(240, 32);
B_Search.Size = new System.Drawing.Size(330, 32);
B_Search.TabIndex = 102;
B_Search.Text = "Search!";
B_Search.UseVisualStyleBackColor = true;
@ -251,7 +262,7 @@ private void InitializeComponent()
// B_Reset
//
B_Reset.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
B_Reset.Location = new System.Drawing.Point(582, 0);
B_Reset.Location = new System.Drawing.Point(604, 0);
B_Reset.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
B_Reset.Name = "B_Reset";
B_Reset.Size = new System.Drawing.Size(88, 27);
@ -274,36 +285,26 @@ private void InitializeComponent()
//
L_Viewed.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
L_Viewed.AutoSize = true;
L_Viewed.Location = new System.Drawing.Point(10, 446);
L_Viewed.Location = new System.Drawing.Point(10, 528);
L_Viewed.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
L_Viewed.Name = "L_Viewed";
L_Viewed.Size = new System.Drawing.Size(89, 15);
L_Viewed.Size = new System.Drawing.Size(99, 17);
L_Viewed.TabIndex = 117;
L_Viewed.Text = "Last Viewed: {0}";
L_Viewed.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
L_Viewed.MouseEnter += L_Viewed_MouseEnter;
//
//
// UC_EntitySearch
//
UC_EntitySearch.Dock = System.Windows.Forms.DockStyle.Fill;
UC_EntitySearch.Location = new System.Drawing.Point(4, 3);
UC_EntitySearch.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
UC_EntitySearch.Name = "UC_EntitySearch";
UC_EntitySearch.Size = new System.Drawing.Size(292, 369);
UC_EntitySearch.TabIndex = 118;
//
// mnu
//
mnu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { mnuView, mnuDelete });
mnu.Name = "mnu";
mnu.Size = new System.Drawing.Size(108, 48);
mnu.Size = new System.Drawing.Size(114, 48);
//
// mnuView
//
mnuView.Image = Properties.Resources.other;
mnuView.Name = "mnuView";
mnuView.Size = new System.Drawing.Size(107, 22);
mnuView.Size = new System.Drawing.Size(113, 22);
mnuView.Text = "View";
mnuView.Click += ClickView;
//
@ -311,7 +312,7 @@ private void InitializeComponent()
//
mnuDelete.Image = Properties.Resources.nocheck;
mnuDelete.Name = "mnuDelete";
mnuDelete.Size = new System.Drawing.Size(107, 22);
mnuDelete.Size = new System.Drawing.Size(113, 22);
mnuDelete.Text = "Delete";
mnuDelete.Click += ClickDelete;
//
@ -323,18 +324,19 @@ private void InitializeComponent()
TC_SearchSettings.Location = new System.Drawing.Point(355, 9);
TC_SearchSettings.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
TC_SearchSettings.Name = "TC_SearchSettings";
TC_SearchSettings.Padding = new System.Drawing.Point(0, 0);
TC_SearchSettings.SelectedIndex = 0;
TC_SearchSettings.Size = new System.Drawing.Size(308, 403);
TC_SearchSettings.Size = new System.Drawing.Size(330, 485);
TC_SearchSettings.TabIndex = 120;
//
// Tab_General
//
Tab_General.Controls.Add(UC_EntitySearch);
Tab_General.Location = new System.Drawing.Point(4, 24);
Tab_General.Location = new System.Drawing.Point(4, 26);
Tab_General.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
Tab_General.Name = "Tab_General";
Tab_General.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3);
Tab_General.Size = new System.Drawing.Size(300, 375);
Tab_General.Size = new System.Drawing.Size(322, 455);
Tab_General.TabIndex = 0;
Tab_General.Text = "General";
Tab_General.UseVisualStyleBackColor = true;
@ -343,10 +345,10 @@ private void InitializeComponent()
//
Tab_Advanced.Controls.Add(B_Add);
Tab_Advanced.Controls.Add(RTB_Instructions);
Tab_Advanced.Location = new System.Drawing.Point(4, 24);
Tab_Advanced.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
Tab_Advanced.Location = new System.Drawing.Point(4, 26);
Tab_Advanced.Margin = new System.Windows.Forms.Padding(0);
Tab_Advanced.Name = "Tab_Advanced";
Tab_Advanced.Size = new System.Drawing.Size(300, 380);
Tab_Advanced.Size = new System.Drawing.Size(322, 455);
Tab_Advanced.TabIndex = 1;
Tab_Advanced.Text = "Advanced";
Tab_Advanced.UseVisualStyleBackColor = true;
@ -354,10 +356,10 @@ private void InitializeComponent()
// B_Add
//
B_Add.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
B_Add.Location = new System.Drawing.Point(229, -1);
B_Add.Location = new System.Drawing.Point(252, 0);
B_Add.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
B_Add.Name = "B_Add";
B_Add.Size = new System.Drawing.Size(66, 27);
B_Add.Size = new System.Drawing.Size(70, 27);
B_Add.TabIndex = 122;
B_Add.Text = "Add";
B_Add.UseVisualStyleBackColor = true;
@ -366,17 +368,17 @@ private void InitializeComponent()
// RTB_Instructions
//
RTB_Instructions.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
RTB_Instructions.Location = new System.Drawing.Point(0, 48);
RTB_Instructions.Location = new System.Drawing.Point(0, 59);
RTB_Instructions.Margin = new System.Windows.Forms.Padding(0);
RTB_Instructions.Name = "RTB_Instructions";
RTB_Instructions.Size = new System.Drawing.Size(298, 329);
RTB_Instructions.Size = new System.Drawing.Size(322, 396);
RTB_Instructions.TabIndex = 120;
RTB_Instructions.Text = "";
//
// SAV_Database
//
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
ClientSize = new System.Drawing.Size(670, 463);
ClientSize = new System.Drawing.Size(692, 545);
Controls.Add(B_Reset);
Controls.Add(TC_SearchSettings);
Controls.Add(B_Search);

View File

@ -575,7 +575,11 @@ private void FillPKXBoxes(int start)
int begin = start * RES_MIN;
int end = Math.Min(RES_MAX, Results.Count - begin);
for (int i = 0; i < end; i++)
PKXBOXES[i].Image = Results[i + begin].Entity.Sprite(SAV, flagIllegal: true, storage: Results[i + begin].Source.Type);
{
var slot = Results[i + begin];
var pk = Results[i + begin].Entity;
PKXBOXES[i].Image = pk.Sprite(SAV, visibility: GetFlags(pk), storage: slot.Source.Type);
}
for (int i = end; i < RES_MAX; i++)
PKXBOXES[i].Image = null;
@ -585,6 +589,14 @@ private void FillPKXBoxes(int start)
PKXBOXES[slotSelected - begin].BackgroundImage = slotColor ?? SpriteUtil.Spriter.View;
}
private SlotVisibilityType GetFlags(PKM pk, bool ignoreLegality = false)
{
var result = SlotVisibilityType.None;
if (!ignoreLegality)
result |= SlotVisibilityType.CheckLegalityIndicate;
return result;
}
// Misc Update Methods
private void Menu_Exit_Click(object sender, EventArgs e) => Close();

View File

@ -103,7 +103,7 @@ private void InitializeComponent()
menuStrip1.Location = new System.Drawing.Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Padding = new System.Windows.Forms.Padding(7, 2, 0, 2);
menuStrip1.Size = new System.Drawing.Size(670, 25);
menuStrip1.Size = new System.Drawing.Size(692, 25);
menuStrip1.TabIndex = 65;
menuStrip1.Text = "menuStrip1";
//
@ -149,10 +149,10 @@ private void InitializeComponent()
// B_Search
//
B_Search.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
B_Search.Location = new System.Drawing.Point(355, 408);
B_Search.Location = new System.Drawing.Point(355, 411);
B_Search.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
B_Search.Name = "B_Search";
B_Search.Size = new System.Drawing.Size(308, 35);
B_Search.Size = new System.Drawing.Size(330, 32);
B_Search.TabIndex = 102;
B_Search.Text = "Search!";
B_Search.UseVisualStyleBackColor = true;
@ -161,10 +161,10 @@ private void InitializeComponent()
// B_Reset
//
B_Reset.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
B_Reset.Location = new System.Drawing.Point(196, 0);
B_Reset.Location = new System.Drawing.Point(604, 0);
B_Reset.Margin = new System.Windows.Forms.Padding(0);
B_Reset.Name = "B_Reset";
B_Reset.Size = new System.Drawing.Size(104, 24);
B_Reset.Size = new System.Drawing.Size(88, 27);
B_Reset.TabIndex = 111;
B_Reset.Text = "Reset Filters";
B_Reset.UseVisualStyleBackColor = true;
@ -195,10 +195,10 @@ private void InitializeComponent()
// RTB_Instructions
//
RTB_Instructions.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
RTB_Instructions.Location = new System.Drawing.Point(0, 48);
RTB_Instructions.Location = new System.Drawing.Point(0, 55);
RTB_Instructions.Margin = new System.Windows.Forms.Padding(0);
RTB_Instructions.Name = "RTB_Instructions";
RTB_Instructions.Size = new System.Drawing.Size(300, 318);
RTB_Instructions.Size = new System.Drawing.Size(322, 318);
RTB_Instructions.TabIndex = 119;
RTB_Instructions.Text = "";
//
@ -225,8 +225,9 @@ private void InitializeComponent()
TC_SearchOptions.Location = new System.Drawing.Point(355, 9);
TC_SearchOptions.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
TC_SearchOptions.Name = "TC_SearchOptions";
TC_SearchOptions.Padding = new System.Drawing.Point(0, 0);
TC_SearchOptions.SelectedIndex = 0;
TC_SearchOptions.Size = new System.Drawing.Size(308, 392);
TC_SearchOptions.Size = new System.Drawing.Size(330, 403);
TC_SearchOptions.TabIndex = 120;
//
// Tab_General
@ -235,20 +236,20 @@ private void InitializeComponent()
Tab_General.Location = new System.Drawing.Point(4, 26);
Tab_General.Margin = new System.Windows.Forms.Padding(0);
Tab_General.Name = "Tab_General";
Tab_General.Size = new System.Drawing.Size(300, 362);
Tab_General.Size = new System.Drawing.Size(322, 373);
Tab_General.TabIndex = 0;
Tab_General.Text = "General";
Tab_General.UseVisualStyleBackColor = true;
//
// TLP_Filters
//
TLP_Filters.AutoScroll = true;
TLP_Filters.AutoScrollMargin = new System.Drawing.Size(3, 3);
TLP_Filters.AutoSize = true;
TLP_Filters.ColumnCount = 2;
TLP_Filters.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 96F));
TLP_Filters.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
TLP_Filters.Controls.Add(Label_Species, 0, 2);
TLP_Filters.Controls.Add(B_Reset, 1, 0);
TLP_Filters.Controls.Add(CB_Species, 1, 2);
TLP_Filters.Controls.Add(FLP_Level, 1, 6);
TLP_Filters.Controls.Add(L_Move1, 0, 10);
@ -289,14 +290,14 @@ private void InitializeComponent()
TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle());
TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle());
TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 23F));
TLP_Filters.Size = new System.Drawing.Size(300, 362);
TLP_Filters.Size = new System.Drawing.Size(322, 373);
TLP_Filters.TabIndex = 120;
//
// Label_Species
//
Label_Species.Anchor = System.Windows.Forms.AnchorStyles.Right;
Label_Species.AutoSize = true;
Label_Species.Location = new System.Drawing.Point(37, 49);
Label_Species.Location = new System.Drawing.Point(37, 30);
Label_Species.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
Label_Species.Name = "Label_Species";
Label_Species.Size = new System.Drawing.Size(55, 17);
@ -310,7 +311,7 @@ private void InitializeComponent()
CB_Species.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
CB_Species.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
CB_Species.FormattingEnabled = true;
CB_Species.Location = new System.Drawing.Point(96, 45);
CB_Species.Location = new System.Drawing.Point(96, 26);
CB_Species.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_Species.Name = "CB_Species";
CB_Species.Size = new System.Drawing.Size(142, 25);
@ -321,7 +322,7 @@ private void InitializeComponent()
//
FLP_Level.Anchor = System.Windows.Forms.AnchorStyles.Left;
FLP_Level.AutoSize = true;
FLP_Level.Location = new System.Drawing.Point(96, 71);
FLP_Level.Location = new System.Drawing.Point(96, 52);
FLP_Level.Margin = new System.Windows.Forms.Padding(0);
FLP_Level.Name = "FLP_Level";
FLP_Level.Size = new System.Drawing.Size(0, 0);
@ -331,7 +332,7 @@ private void InitializeComponent()
//
L_Move1.Anchor = System.Windows.Forms.AnchorStyles.Right;
L_Move1.AutoSize = true;
L_Move1.Location = new System.Drawing.Point(37, 75);
L_Move1.Location = new System.Drawing.Point(37, 56);
L_Move1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
L_Move1.Name = "L_Move1";
L_Move1.Size = new System.Drawing.Size(55, 17);
@ -345,7 +346,7 @@ private void InitializeComponent()
CB_Move1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
CB_Move1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
CB_Move1.FormattingEnabled = true;
CB_Move1.Location = new System.Drawing.Point(96, 71);
CB_Move1.Location = new System.Drawing.Point(96, 52);
CB_Move1.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_Move1.Name = "CB_Move1";
CB_Move1.Size = new System.Drawing.Size(142, 25);
@ -355,7 +356,7 @@ private void InitializeComponent()
//
L_Move2.Anchor = System.Windows.Forms.AnchorStyles.Right;
L_Move2.AutoSize = true;
L_Move2.Location = new System.Drawing.Point(37, 101);
L_Move2.Location = new System.Drawing.Point(37, 82);
L_Move2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
L_Move2.Name = "L_Move2";
L_Move2.Size = new System.Drawing.Size(55, 17);
@ -369,7 +370,7 @@ private void InitializeComponent()
CB_Move2.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
CB_Move2.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
CB_Move2.FormattingEnabled = true;
CB_Move2.Location = new System.Drawing.Point(96, 97);
CB_Move2.Location = new System.Drawing.Point(96, 78);
CB_Move2.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_Move2.Name = "CB_Move2";
CB_Move2.Size = new System.Drawing.Size(142, 25);
@ -379,7 +380,7 @@ private void InitializeComponent()
//
L_Move3.Anchor = System.Windows.Forms.AnchorStyles.Right;
L_Move3.AutoSize = true;
L_Move3.Location = new System.Drawing.Point(37, 127);
L_Move3.Location = new System.Drawing.Point(37, 108);
L_Move3.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
L_Move3.Name = "L_Move3";
L_Move3.Size = new System.Drawing.Size(55, 17);
@ -393,7 +394,7 @@ private void InitializeComponent()
CB_Move3.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
CB_Move3.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
CB_Move3.FormattingEnabled = true;
CB_Move3.Location = new System.Drawing.Point(96, 123);
CB_Move3.Location = new System.Drawing.Point(96, 104);
CB_Move3.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_Move3.Name = "CB_Move3";
CB_Move3.Size = new System.Drawing.Size(142, 25);
@ -403,7 +404,7 @@ private void InitializeComponent()
//
L_Move4.Anchor = System.Windows.Forms.AnchorStyles.Right;
L_Move4.AutoSize = true;
L_Move4.Location = new System.Drawing.Point(37, 153);
L_Move4.Location = new System.Drawing.Point(37, 134);
L_Move4.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
L_Move4.Name = "L_Move4";
L_Move4.Size = new System.Drawing.Size(55, 17);
@ -417,7 +418,7 @@ private void InitializeComponent()
CB_Move4.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
CB_Move4.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
CB_Move4.FormattingEnabled = true;
CB_Move4.Location = new System.Drawing.Point(96, 149);
CB_Move4.Location = new System.Drawing.Point(96, 130);
CB_Move4.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_Move4.Name = "CB_Move4";
CB_Move4.Size = new System.Drawing.Size(142, 25);
@ -428,7 +429,7 @@ private void InitializeComponent()
CB_GameOrigin.Anchor = System.Windows.Forms.AnchorStyles.Left;
CB_GameOrigin.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
CB_GameOrigin.FormattingEnabled = true;
CB_GameOrigin.Location = new System.Drawing.Point(96, 175);
CB_GameOrigin.Location = new System.Drawing.Point(96, 156);
CB_GameOrigin.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_GameOrigin.Name = "CB_GameOrigin";
CB_GameOrigin.Size = new System.Drawing.Size(142, 25);
@ -438,7 +439,7 @@ private void InitializeComponent()
//
L_Version.Anchor = System.Windows.Forms.AnchorStyles.Right;
L_Version.AutoSize = true;
L_Version.Location = new System.Drawing.Point(18, 179);
L_Version.Location = new System.Drawing.Point(18, 160);
L_Version.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
L_Version.Name = "L_Version";
L_Version.Size = new System.Drawing.Size(74, 17);
@ -449,10 +450,10 @@ private void InitializeComponent()
// TypeFilters
//
TypeFilters.Dock = System.Windows.Forms.DockStyle.Fill;
TypeFilters.Location = new System.Drawing.Point(96, 201);
TypeFilters.Location = new System.Drawing.Point(96, 182);
TypeFilters.Margin = new System.Windows.Forms.Padding(0);
TypeFilters.Name = "TypeFilters";
TypeFilters.Size = new System.Drawing.Size(204, 161);
TypeFilters.Size = new System.Drawing.Size(226, 191);
TypeFilters.TabIndex = 123;
//
// CHK_IsEgg
@ -461,8 +462,8 @@ private void InitializeComponent()
CHK_IsEgg.AutoSize = true;
CHK_IsEgg.Checked = true;
CHK_IsEgg.CheckState = System.Windows.Forms.CheckState.Indeterminate;
CHK_IsEgg.Location = new System.Drawing.Point(96, 24);
CHK_IsEgg.Margin = new System.Windows.Forms.Padding(0);
CHK_IsEgg.Location = new System.Drawing.Point(96, 4);
CHK_IsEgg.Margin = new System.Windows.Forms.Padding(0, 4, 0, 1);
CHK_IsEgg.Name = "CHK_IsEgg";
CHK_IsEgg.Size = new System.Drawing.Size(50, 21);
CHK_IsEgg.TabIndex = 125;
@ -475,7 +476,7 @@ private void InitializeComponent()
//
FLP_Egg.Anchor = System.Windows.Forms.AnchorStyles.Left;
FLP_Egg.AutoSize = true;
FLP_Egg.Location = new System.Drawing.Point(0, 281);
FLP_Egg.Location = new System.Drawing.Point(0, 277);
FLP_Egg.Margin = new System.Windows.Forms.Padding(0);
FLP_Egg.Name = "FLP_Egg";
FLP_Egg.Size = new System.Drawing.Size(0, 0);
@ -487,8 +488,8 @@ private void InitializeComponent()
CHK_Shiny.AutoSize = true;
CHK_Shiny.Checked = true;
CHK_Shiny.CheckState = System.Windows.Forms.CheckState.Indeterminate;
CHK_Shiny.Location = new System.Drawing.Point(39, 24);
CHK_Shiny.Margin = new System.Windows.Forms.Padding(0);
CHK_Shiny.Location = new System.Drawing.Point(39, 4);
CHK_Shiny.Margin = new System.Windows.Forms.Padding(0, 4, 0, 1);
CHK_Shiny.Name = "CHK_Shiny";
CHK_Shiny.Size = new System.Drawing.Size(57, 21);
CHK_Shiny.TabIndex = 126;
@ -502,9 +503,9 @@ private void InitializeComponent()
Tab_Advanced.Controls.Add(B_Add);
Tab_Advanced.Controls.Add(RTB_Instructions);
Tab_Advanced.Location = new System.Drawing.Point(4, 26);
Tab_Advanced.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
Tab_Advanced.Margin = new System.Windows.Forms.Padding(0);
Tab_Advanced.Name = "Tab_Advanced";
Tab_Advanced.Size = new System.Drawing.Size(300, 362);
Tab_Advanced.Size = new System.Drawing.Size(322, 373);
Tab_Advanced.TabIndex = 1;
Tab_Advanced.Text = "Advanced";
Tab_Advanced.UseVisualStyleBackColor = true;
@ -512,8 +513,8 @@ private void InitializeComponent()
// B_Add
//
B_Add.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
B_Add.Location = new System.Drawing.Point(230, 0);
B_Add.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
B_Add.Location = new System.Drawing.Point(252, 0);
B_Add.Margin = new System.Windows.Forms.Padding(0);
B_Add.Name = "B_Add";
B_Add.Size = new System.Drawing.Size(70, 27);
B_Add.TabIndex = 122;
@ -527,7 +528,7 @@ private void InitializeComponent()
Tab_Criteria.Location = new System.Drawing.Point(4, 26);
Tab_Criteria.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
Tab_Criteria.Name = "Tab_Criteria";
Tab_Criteria.Size = new System.Drawing.Size(300, 362);
Tab_Criteria.Size = new System.Drawing.Size(322, 373);
Tab_Criteria.TabIndex = 2;
Tab_Criteria.Text = "Criteria";
Tab_Criteria.UseVisualStyleBackColor = true;
@ -549,7 +550,7 @@ private void InitializeComponent()
// SC_Criteria.Panel2
//
SC_Criteria.Panel2.Controls.Add(PG_Criteria);
SC_Criteria.Size = new System.Drawing.Size(300, 362);
SC_Criteria.Size = new System.Drawing.Size(322, 373);
SC_Criteria.SplitterDistance = 40;
SC_Criteria.TabIndex = 0;
//
@ -564,7 +565,7 @@ private void InitializeComponent()
FLP_CriteriaButtons.Margin = new System.Windows.Forms.Padding(0);
FLP_CriteriaButtons.Name = "FLP_CriteriaButtons";
FLP_CriteriaButtons.Padding = new System.Windows.Forms.Padding(3);
FLP_CriteriaButtons.Size = new System.Drawing.Size(300, 40);
FLP_CriteriaButtons.Size = new System.Drawing.Size(322, 40);
FLP_CriteriaButtons.TabIndex = 0;
//
// B_CriteriaReset
@ -597,7 +598,7 @@ private void InitializeComponent()
PG_Criteria.Dock = System.Windows.Forms.DockStyle.Fill;
PG_Criteria.Location = new System.Drawing.Point(0, 0);
PG_Criteria.Name = "PG_Criteria";
PG_Criteria.Size = new System.Drawing.Size(300, 318);
PG_Criteria.Size = new System.Drawing.Size(322, 329);
PG_Criteria.TabIndex = 0;
PG_Criteria.ToolbarVisible = false;
PG_Criteria.PropertyValueChanged += PG_Criteria_PropertyValueChanged;
@ -605,7 +606,8 @@ private void InitializeComponent()
// SAV_Encounters
//
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
ClientSize = new System.Drawing.Size(670, 463);
ClientSize = new System.Drawing.Size(692, 463);
Controls.Add(B_Reset);
Controls.Add(TC_SearchOptions);
Controls.Add(B_Search);
Controls.Add(L_Viewed);

View File

@ -38,7 +38,7 @@ private void InitializeComponent()
Menu_Export = new System.Windows.Forms.ToolStripMenuItem();
Menu_Import = new System.Windows.Forms.ToolStripMenuItem();
P_Results = new System.Windows.Forms.Panel();
MysteryPokeGrid = new Controls.PokeGrid();
MysteryPokeGrid = new PKHeX.WinForms.Controls.PokeGrid();
CB_HeldItem = new System.Windows.Forms.ComboBox();
CB_Species = new System.Windows.Forms.ComboBox();
CB_Move4 = new System.Windows.Forms.ComboBox();
@ -55,7 +55,6 @@ private void InitializeComponent()
B_Reset = new System.Windows.Forms.Button();
L_Count = new System.Windows.Forms.Label();
L_Viewed = new System.Windows.Forms.Label();
FLP_Egg = new System.Windows.Forms.FlowLayoutPanel();
CHK_IsEgg = new System.Windows.Forms.CheckBox();
CHK_Shiny = new System.Windows.Forms.CheckBox();
TLP_Filters = new System.Windows.Forms.TableLayoutPanel();
@ -76,7 +75,6 @@ private void InitializeComponent()
RTB_Instructions = new System.Windows.Forms.RichTextBox();
menuStrip1.SuspendLayout();
P_Results.SuspendLayout();
FLP_Egg.SuspendLayout();
TLP_Filters.SuspendLayout();
FLP_Format.SuspendLayout();
mnu.SuspendLayout();
@ -102,7 +100,7 @@ private void InitializeComponent()
menuStrip1.Location = new System.Drawing.Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Padding = new System.Windows.Forms.Padding(7, 2, 0, 2);
menuStrip1.Size = new System.Drawing.Size(670, 24);
menuStrip1.Size = new System.Drawing.Size(692, 25);
menuStrip1.TabIndex = 65;
menuStrip1.Text = "menuStrip1";
//
@ -110,7 +108,7 @@ private void InitializeComponent()
//
Menu_Close.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { Menu_Exit });
Menu_Close.Name = "Menu_Close";
Menu_Close.Size = new System.Drawing.Size(37, 20);
Menu_Close.Size = new System.Drawing.Size(39, 21);
Menu_Close.Text = "File";
//
// Menu_Exit
@ -119,7 +117,7 @@ private void InitializeComponent()
Menu_Exit.Name = "Menu_Exit";
Menu_Exit.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E;
Menu_Exit.ShowShortcutKeys = false;
Menu_Exit.Size = new System.Drawing.Size(96, 22);
Menu_Exit.Size = new System.Drawing.Size(100, 22);
Menu_Exit.Text = "&Close";
Menu_Exit.Click += Menu_Exit_Click;
//
@ -127,14 +125,14 @@ private void InitializeComponent()
//
Menu_Tools.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { Menu_OpenDB, Menu_Export, Menu_Import });
Menu_Tools.Name = "Menu_Tools";
Menu_Tools.Size = new System.Drawing.Size(46, 20);
Menu_Tools.Size = new System.Drawing.Size(51, 21);
Menu_Tools.Text = "Tools";
//
// Menu_OpenDB
//
Menu_OpenDB.Image = Properties.Resources.folder;
Menu_OpenDB.Name = "Menu_OpenDB";
Menu_OpenDB.Size = new System.Drawing.Size(209, 22);
Menu_OpenDB.Size = new System.Drawing.Size(226, 22);
Menu_OpenDB.Text = "Open Database Folder";
Menu_OpenDB.Click += OpenDB;
//
@ -142,7 +140,7 @@ private void InitializeComponent()
//
Menu_Export.Image = Properties.Resources.export;
Menu_Export.Name = "Menu_Export";
Menu_Export.Size = new System.Drawing.Size(209, 22);
Menu_Export.Size = new System.Drawing.Size(226, 22);
Menu_Export.Text = "Export Results to Folder";
Menu_Export.Click += Menu_Export_Click;
//
@ -150,7 +148,7 @@ private void InitializeComponent()
//
Menu_Import.Image = Properties.Resources.savePKM;
Menu_Import.Name = "Menu_Import";
Menu_Import.Size = new System.Drawing.Size(209, 22);
Menu_Import.Size = new System.Drawing.Size(226, 22);
Menu_Import.Text = "Import Results to SaveFile";
Menu_Import.Click += Menu_Import_Click;
//
@ -182,10 +180,10 @@ private void InitializeComponent()
CB_HeldItem.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
CB_HeldItem.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
CB_HeldItem.FormattingEnabled = true;
CB_HeldItem.Location = new System.Drawing.Point(70, 42);
CB_HeldItem.Margin = new System.Windows.Forms.Padding(0);
CB_HeldItem.Location = new System.Drawing.Point(75, 52);
CB_HeldItem.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_HeldItem.Name = "CB_HeldItem";
CB_HeldItem.Size = new System.Drawing.Size(142, 23);
CB_HeldItem.Size = new System.Drawing.Size(142, 25);
CB_HeldItem.TabIndex = 69;
//
// CB_Species
@ -194,10 +192,10 @@ private void InitializeComponent()
CB_Species.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
CB_Species.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
CB_Species.FormattingEnabled = true;
CB_Species.Location = new System.Drawing.Point(70, 19);
CB_Species.Margin = new System.Windows.Forms.Padding(0);
CB_Species.Location = new System.Drawing.Point(75, 26);
CB_Species.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_Species.Name = "CB_Species";
CB_Species.Size = new System.Drawing.Size(142, 23);
CB_Species.Size = new System.Drawing.Size(142, 25);
CB_Species.TabIndex = 67;
//
// CB_Move4
@ -206,10 +204,10 @@ private void InitializeComponent()
CB_Move4.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
CB_Move4.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
CB_Move4.FormattingEnabled = true;
CB_Move4.Location = new System.Drawing.Point(70, 134);
CB_Move4.Margin = new System.Windows.Forms.Padding(0);
CB_Move4.Location = new System.Drawing.Point(75, 156);
CB_Move4.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_Move4.Name = "CB_Move4";
CB_Move4.Size = new System.Drawing.Size(142, 23);
CB_Move4.Size = new System.Drawing.Size(142, 25);
CB_Move4.TabIndex = 74;
//
// CB_Move3
@ -218,10 +216,10 @@ private void InitializeComponent()
CB_Move3.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
CB_Move3.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
CB_Move3.FormattingEnabled = true;
CB_Move3.Location = new System.Drawing.Point(70, 111);
CB_Move3.Margin = new System.Windows.Forms.Padding(0);
CB_Move3.Location = new System.Drawing.Point(75, 130);
CB_Move3.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_Move3.Name = "CB_Move3";
CB_Move3.Size = new System.Drawing.Size(142, 23);
CB_Move3.Size = new System.Drawing.Size(142, 25);
CB_Move3.TabIndex = 73;
//
// CB_Move2
@ -230,10 +228,10 @@ private void InitializeComponent()
CB_Move2.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
CB_Move2.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
CB_Move2.FormattingEnabled = true;
CB_Move2.Location = new System.Drawing.Point(70, 88);
CB_Move2.Margin = new System.Windows.Forms.Padding(0);
CB_Move2.Location = new System.Drawing.Point(75, 104);
CB_Move2.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_Move2.Name = "CB_Move2";
CB_Move2.Size = new System.Drawing.Size(142, 23);
CB_Move2.Size = new System.Drawing.Size(142, 25);
CB_Move2.TabIndex = 72;
//
// CB_Move1
@ -242,20 +240,20 @@ private void InitializeComponent()
CB_Move1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
CB_Move1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
CB_Move1.FormattingEnabled = true;
CB_Move1.Location = new System.Drawing.Point(70, 65);
CB_Move1.Margin = new System.Windows.Forms.Padding(0);
CB_Move1.Location = new System.Drawing.Point(75, 78);
CB_Move1.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_Move1.Name = "CB_Move1";
CB_Move1.Size = new System.Drawing.Size(142, 23);
CB_Move1.Size = new System.Drawing.Size(142, 25);
CB_Move1.TabIndex = 71;
//
// Label_HeldItem
//
Label_HeldItem.Anchor = System.Windows.Forms.AnchorStyles.Right;
Label_HeldItem.AutoSize = true;
Label_HeldItem.Location = new System.Drawing.Point(4, 46);
Label_HeldItem.Location = new System.Drawing.Point(4, 56);
Label_HeldItem.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
Label_HeldItem.Name = "Label_HeldItem";
Label_HeldItem.Size = new System.Drawing.Size(62, 15);
Label_HeldItem.Size = new System.Drawing.Size(67, 17);
Label_HeldItem.TabIndex = 93;
Label_HeldItem.Text = "Held Item:";
Label_HeldItem.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
@ -264,10 +262,10 @@ private void InitializeComponent()
//
Label_Species.Anchor = System.Windows.Forms.AnchorStyles.Right;
Label_Species.AutoSize = true;
Label_Species.Location = new System.Drawing.Point(17, 23);
Label_Species.Location = new System.Drawing.Point(16, 30);
Label_Species.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
Label_Species.Name = "Label_Species";
Label_Species.Size = new System.Drawing.Size(49, 15);
Label_Species.Size = new System.Drawing.Size(55, 17);
Label_Species.TabIndex = 90;
Label_Species.Text = "Species:";
Label_Species.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
@ -275,10 +273,10 @@ private void InitializeComponent()
// B_Search
//
B_Search.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
B_Search.Location = new System.Drawing.Point(388, 408);
B_Search.Location = new System.Drawing.Point(355, 411);
B_Search.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
B_Search.Name = "B_Search";
B_Search.Size = new System.Drawing.Size(240, 35);
B_Search.Size = new System.Drawing.Size(330, 32);
B_Search.TabIndex = 102;
B_Search.Text = "Search!";
B_Search.UseVisualStyleBackColor = true;
@ -288,10 +286,10 @@ private void InitializeComponent()
//
L_Move1.Anchor = System.Windows.Forms.AnchorStyles.Right;
L_Move1.AutoSize = true;
L_Move1.Location = new System.Drawing.Point(17, 69);
L_Move1.Location = new System.Drawing.Point(16, 82);
L_Move1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
L_Move1.Name = "L_Move1";
L_Move1.Size = new System.Drawing.Size(49, 15);
L_Move1.Size = new System.Drawing.Size(55, 17);
L_Move1.TabIndex = 105;
L_Move1.Text = "Move 1:";
L_Move1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
@ -300,10 +298,10 @@ private void InitializeComponent()
//
L_Move2.Anchor = System.Windows.Forms.AnchorStyles.Right;
L_Move2.AutoSize = true;
L_Move2.Location = new System.Drawing.Point(17, 92);
L_Move2.Location = new System.Drawing.Point(16, 108);
L_Move2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
L_Move2.Name = "L_Move2";
L_Move2.Size = new System.Drawing.Size(49, 15);
L_Move2.Size = new System.Drawing.Size(55, 17);
L_Move2.TabIndex = 106;
L_Move2.Text = "Move 2:";
L_Move2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
@ -312,10 +310,10 @@ private void InitializeComponent()
//
L_Move3.Anchor = System.Windows.Forms.AnchorStyles.Right;
L_Move3.AutoSize = true;
L_Move3.Location = new System.Drawing.Point(17, 115);
L_Move3.Location = new System.Drawing.Point(16, 134);
L_Move3.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
L_Move3.Name = "L_Move3";
L_Move3.Size = new System.Drawing.Size(49, 15);
L_Move3.Size = new System.Drawing.Size(55, 17);
L_Move3.TabIndex = 107;
L_Move3.Text = "Move 3:";
L_Move3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
@ -324,10 +322,10 @@ private void InitializeComponent()
//
L_Move4.Anchor = System.Windows.Forms.AnchorStyles.Right;
L_Move4.AutoSize = true;
L_Move4.Location = new System.Drawing.Point(17, 138);
L_Move4.Location = new System.Drawing.Point(16, 160);
L_Move4.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
L_Move4.Name = "L_Move4";
L_Move4.Size = new System.Drawing.Size(49, 15);
L_Move4.Size = new System.Drawing.Size(55, 17);
L_Move4.TabIndex = 108;
L_Move4.Text = "Move 4:";
L_Move4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
@ -335,7 +333,7 @@ private void InitializeComponent()
// B_Reset
//
B_Reset.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
B_Reset.Location = new System.Drawing.Point(582, 0);
B_Reset.Location = new System.Drawing.Point(604, 0);
B_Reset.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
B_Reset.Name = "B_Reset";
B_Reset.Size = new System.Drawing.Size(88, 27);
@ -361,32 +359,21 @@ private void InitializeComponent()
L_Viewed.Location = new System.Drawing.Point(10, 445);
L_Viewed.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
L_Viewed.Name = "L_Viewed";
L_Viewed.Size = new System.Drawing.Size(89, 15);
L_Viewed.Size = new System.Drawing.Size(99, 17);
L_Viewed.TabIndex = 117;
L_Viewed.Text = "Last Viewed: {0}";
L_Viewed.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// FLP_Egg
//
FLP_Egg.Anchor = System.Windows.Forms.AnchorStyles.Left;
FLP_Egg.AutoSize = true;
FLP_Egg.Controls.Add(CHK_IsEgg);
FLP_Egg.Location = new System.Drawing.Point(70, 0);
FLP_Egg.Margin = new System.Windows.Forms.Padding(0);
FLP_Egg.Name = "FLP_Egg";
FLP_Egg.Size = new System.Drawing.Size(46, 19);
FLP_Egg.TabIndex = 120;
//
// CHK_IsEgg
//
CHK_IsEgg.Anchor = System.Windows.Forms.AnchorStyles.Left;
CHK_IsEgg.AutoSize = true;
CHK_IsEgg.Checked = true;
CHK_IsEgg.CheckState = System.Windows.Forms.CheckState.Indeterminate;
CHK_IsEgg.Location = new System.Drawing.Point(0, 0);
CHK_IsEgg.Margin = new System.Windows.Forms.Padding(0);
CHK_IsEgg.Location = new System.Drawing.Point(75, 4);
CHK_IsEgg.Margin = new System.Windows.Forms.Padding(0, 4, 0, 1);
CHK_IsEgg.Name = "CHK_IsEgg";
CHK_IsEgg.Size = new System.Drawing.Size(46, 19);
CHK_IsEgg.Size = new System.Drawing.Size(50, 21);
CHK_IsEgg.TabIndex = 98;
CHK_IsEgg.Text = "Egg";
CHK_IsEgg.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
@ -399,10 +386,10 @@ private void InitializeComponent()
CHK_Shiny.AutoSize = true;
CHK_Shiny.Checked = true;
CHK_Shiny.CheckState = System.Windows.Forms.CheckState.Indeterminate;
CHK_Shiny.Location = new System.Drawing.Point(15, 0);
CHK_Shiny.Margin = new System.Windows.Forms.Padding(0);
CHK_Shiny.Location = new System.Drawing.Point(18, 4);
CHK_Shiny.Margin = new System.Windows.Forms.Padding(0, 4, 0, 1);
CHK_Shiny.Name = "CHK_Shiny";
CHK_Shiny.Size = new System.Drawing.Size(55, 19);
CHK_Shiny.Size = new System.Drawing.Size(57, 21);
CHK_Shiny.TabIndex = 99;
CHK_Shiny.Text = "Shiny";
CHK_Shiny.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
@ -419,7 +406,6 @@ private void InitializeComponent()
TLP_Filters.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
TLP_Filters.Controls.Add(FLP_Format, 1, 15);
TLP_Filters.Controls.Add(L_Format, 0, 15);
TLP_Filters.Controls.Add(FLP_Egg, 1, 0);
TLP_Filters.Controls.Add(CHK_Shiny, 0, 0);
TLP_Filters.Controls.Add(Label_Species, 0, 1);
TLP_Filters.Controls.Add(CB_Species, 1, 1);
@ -434,9 +420,10 @@ private void InitializeComponent()
TLP_Filters.Controls.Add(CB_Move3, 1, 11);
TLP_Filters.Controls.Add(L_Move4, 0, 12);
TLP_Filters.Controls.Add(CB_Move4, 1, 12);
TLP_Filters.Controls.Add(CHK_IsEgg, 1, 0);
TLP_Filters.Dock = System.Windows.Forms.DockStyle.Fill;
TLP_Filters.Location = new System.Drawing.Point(4, 3);
TLP_Filters.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
TLP_Filters.Location = new System.Drawing.Point(0, 0);
TLP_Filters.Margin = new System.Windows.Forms.Padding(0);
TLP_Filters.Name = "TLP_Filters";
TLP_Filters.RowCount = 17;
TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle());
@ -456,7 +443,7 @@ private void InitializeComponent()
TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle());
TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle());
TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle());
TLP_Filters.Size = new System.Drawing.Size(292, 358);
TLP_Filters.Size = new System.Drawing.Size(322, 373);
TLP_Filters.TabIndex = 118;
//
// FLP_Format
@ -464,10 +451,10 @@ private void InitializeComponent()
FLP_Format.AutoSize = true;
FLP_Format.Controls.Add(CB_FormatComparator);
FLP_Format.Controls.Add(CB_Format);
FLP_Format.Location = new System.Drawing.Point(70, 157);
FLP_Format.Location = new System.Drawing.Point(75, 182);
FLP_Format.Margin = new System.Windows.Forms.Padding(0);
FLP_Format.Name = "FLP_Format";
FLP_Format.Size = new System.Drawing.Size(141, 23);
FLP_Format.Size = new System.Drawing.Size(141, 26);
FLP_Format.TabIndex = 124;
//
// CB_FormatComparator
@ -477,9 +464,9 @@ private void InitializeComponent()
CB_FormatComparator.FormattingEnabled = true;
CB_FormatComparator.Items.AddRange(new object[] { "Any", ">=", "==", "<=" });
CB_FormatComparator.Location = new System.Drawing.Point(0, 0);
CB_FormatComparator.Margin = new System.Windows.Forms.Padding(0);
CB_FormatComparator.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_FormatComparator.Name = "CB_FormatComparator";
CB_FormatComparator.Size = new System.Drawing.Size(62, 23);
CB_FormatComparator.Size = new System.Drawing.Size(62, 25);
CB_FormatComparator.TabIndex = 122;
CB_FormatComparator.SelectedIndexChanged += ChangeFormatFilter;
//
@ -491,9 +478,9 @@ private void InitializeComponent()
CB_Format.FormattingEnabled = true;
CB_Format.Items.AddRange(new object[] { "Any", ".wc9", ".wc8", ".wc7", ".wc6", ".pgf", ".pcd/pgt/.wc4" });
CB_Format.Location = new System.Drawing.Point(62, 0);
CB_Format.Margin = new System.Windows.Forms.Padding(0);
CB_Format.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_Format.Name = "CB_Format";
CB_Format.Size = new System.Drawing.Size(79, 23);
CB_Format.Size = new System.Drawing.Size(79, 25);
CB_Format.TabIndex = 121;
CB_Format.Visible = false;
//
@ -501,10 +488,10 @@ private void InitializeComponent()
//
L_Format.Anchor = System.Windows.Forms.AnchorStyles.Right;
L_Format.AutoSize = true;
L_Format.Location = new System.Drawing.Point(18, 161);
L_Format.Location = new System.Drawing.Point(19, 186);
L_Format.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
L_Format.Name = "L_Format";
L_Format.Size = new System.Drawing.Size(48, 15);
L_Format.Size = new System.Drawing.Size(52, 17);
L_Format.TabIndex = 122;
L_Format.Text = "Format:";
L_Format.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
@ -513,7 +500,7 @@ private void InitializeComponent()
//
FLP_Level.Anchor = System.Windows.Forms.AnchorStyles.Left;
FLP_Level.AutoSize = true;
FLP_Level.Location = new System.Drawing.Point(70, 65);
FLP_Level.Location = new System.Drawing.Point(75, 78);
FLP_Level.Margin = new System.Windows.Forms.Padding(0);
FLP_Level.Name = "FLP_Level";
FLP_Level.Size = new System.Drawing.Size(0, 0);
@ -523,13 +510,13 @@ private void InitializeComponent()
//
mnu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { mnuView, mnuSaveMG, mnuSavePK });
mnu.Name = "contextMenuStrip1";
mnu.Size = new System.Drawing.Size(127, 70);
mnu.Size = new System.Drawing.Size(135, 70);
//
// mnuView
//
mnuView.Image = Properties.Resources.other;
mnuView.Name = "mnuView";
mnuView.Size = new System.Drawing.Size(126, 22);
mnuView.Size = new System.Drawing.Size(134, 22);
mnuView.Text = "View";
mnuView.Click += ClickView;
//
@ -537,7 +524,7 @@ private void InitializeComponent()
//
mnuSaveMG.Image = Properties.Resources.gift;
mnuSaveMG.Name = "mnuSaveMG";
mnuSaveMG.Size = new System.Drawing.Size(126, 22);
mnuSaveMG.Size = new System.Drawing.Size(134, 22);
mnuSaveMG.Text = "Save Gift";
mnuSaveMG.Click += ClickSaveMG;
//
@ -545,7 +532,7 @@ private void InitializeComponent()
//
mnuSavePK.Image = Properties.Resources.savePKM;
mnuSavePK.Name = "mnuSavePK";
mnuSavePK.Size = new System.Drawing.Size(126, 22);
mnuSavePK.Size = new System.Drawing.Size(134, 22);
mnuSavePK.Text = "Save PKM";
mnuSavePK.Click += ClickSavePK;
//
@ -558,17 +545,16 @@ private void InitializeComponent()
TC_SearchSettings.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
TC_SearchSettings.Name = "TC_SearchSettings";
TC_SearchSettings.SelectedIndex = 0;
TC_SearchSettings.Size = new System.Drawing.Size(308, 392);
TC_SearchSettings.Size = new System.Drawing.Size(330, 403);
TC_SearchSettings.TabIndex = 120;
//
// Tab_General
//
Tab_General.Controls.Add(TLP_Filters);
Tab_General.Location = new System.Drawing.Point(4, 24);
Tab_General.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
Tab_General.Location = new System.Drawing.Point(4, 26);
Tab_General.Margin = new System.Windows.Forms.Padding(0);
Tab_General.Name = "Tab_General";
Tab_General.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3);
Tab_General.Size = new System.Drawing.Size(300, 364);
Tab_General.Size = new System.Drawing.Size(322, 373);
Tab_General.TabIndex = 0;
Tab_General.Text = "General";
Tab_General.UseVisualStyleBackColor = true;
@ -577,10 +563,10 @@ private void InitializeComponent()
//
Tab_Advanced.Controls.Add(B_Add);
Tab_Advanced.Controls.Add(RTB_Instructions);
Tab_Advanced.Location = new System.Drawing.Point(4, 24);
Tab_Advanced.Location = new System.Drawing.Point(4, 26);
Tab_Advanced.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
Tab_Advanced.Name = "Tab_Advanced";
Tab_Advanced.Size = new System.Drawing.Size(300, 364);
Tab_Advanced.Size = new System.Drawing.Size(322, 373);
Tab_Advanced.TabIndex = 1;
Tab_Advanced.Text = "Advanced";
Tab_Advanced.UseVisualStyleBackColor = true;
@ -588,10 +574,10 @@ private void InitializeComponent()
// B_Add
//
B_Add.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
B_Add.Location = new System.Drawing.Point(229, -1);
B_Add.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
B_Add.Location = new System.Drawing.Point(252, 0);
B_Add.Margin = new System.Windows.Forms.Padding(0);
B_Add.Name = "B_Add";
B_Add.Size = new System.Drawing.Size(66, 27);
B_Add.Size = new System.Drawing.Size(70, 27);
B_Add.TabIndex = 121;
B_Add.Text = "Add";
B_Add.UseVisualStyleBackColor = true;
@ -600,17 +586,17 @@ private void InitializeComponent()
// RTB_Instructions
//
RTB_Instructions.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
RTB_Instructions.Location = new System.Drawing.Point(0, 48);
RTB_Instructions.Location = new System.Drawing.Point(0, 55);
RTB_Instructions.Margin = new System.Windows.Forms.Padding(0);
RTB_Instructions.Name = "RTB_Instructions";
RTB_Instructions.Size = new System.Drawing.Size(298, 313);
RTB_Instructions.Size = new System.Drawing.Size(322, 318);
RTB_Instructions.TabIndex = 120;
RTB_Instructions.Text = "";
//
// SAV_MysteryGiftDB
//
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
ClientSize = new System.Drawing.Size(670, 463);
ClientSize = new System.Drawing.Size(692, 463);
Controls.Add(B_Reset);
Controls.Add(TC_SearchSettings);
Controls.Add(B_Search);
@ -629,8 +615,6 @@ private void InitializeComponent()
menuStrip1.ResumeLayout(false);
menuStrip1.PerformLayout();
P_Results.ResumeLayout(false);
FLP_Egg.ResumeLayout(false);
FLP_Egg.PerformLayout();
TLP_Filters.ResumeLayout(false);
TLP_Filters.PerformLayout();
FLP_Format.ResumeLayout(false);
@ -672,7 +656,6 @@ private void InitializeComponent()
private System.Windows.Forms.TableLayoutPanel TLP_Filters;
public System.Windows.Forms.CheckBox CHK_Shiny;
public System.Windows.Forms.CheckBox CHK_IsEgg;
private System.Windows.Forms.FlowLayoutPanel FLP_Egg;
private System.Windows.Forms.FlowLayoutPanel FLP_Level;
private System.Windows.Forms.Label L_Format;
private System.Windows.Forms.FlowLayoutPanel FLP_Format;

View File

@ -149,7 +149,7 @@ private void ClickView(object sender, EventArgs e)
int index = GetSenderIndex(sender);
if (index < 0)
return;
var temp = Results[index].ConvertToPKM(SAV);
var temp = Results[index].ConvertToPKM(SAV, EncounterCriteria.Unrestricted);
var pk = EntityConverter.ConvertToType(temp, SAV.PKMType, out var c);
if (pk is null)
{

View File

@ -441,7 +441,17 @@ private void LoadCurrent(BattlePass pdata)
NUD_RecordStargazerColosseumClears.Value = pdata.RecordStargazerColosseumClears;
for (int i = 0; i < BattlePass.Count; i++)
Box.Entries[i].Image = pdata.GetPartySlotPresent(i) ? pdata.GetPartySlotAtIndex(i).Sprite(SAV, flagIllegal: true) : SpriteUtil.Spriter.None;
{
var pb = Box.Entries[i];
if (!pdata.GetPartySlotPresent(i))
{
pb.Image = SpriteUtil.Spriter.None;
continue;
}
var pk = pdata.GetPartySlotAtIndex(i);
pb.Image = pk.Sprite(SAV, visibility: GetFlags(pk));
}
if (slotSelected != -1 && (uint)slotSelected < Box.Entries.Count)
Box.Entries[slotSelected].BackgroundImage = groupSelected != CurrentPassIndex ? null : SpriteUtil.Spriter.View;
@ -449,6 +459,14 @@ private void LoadCurrent(BattlePass pdata)
loading = false;
}
private SlotVisibilityType GetFlags(PKM pk, bool ignoreLegality = false)
{
var result = SlotVisibilityType.None;
if (!ignoreLegality)
result |= SlotVisibilityType.CheckLegalityIndicate;
return result;
}
private void SaveCurrent(BattlePass pdata)
{
pdata.Name = TB_Name.Text;

View File

@ -35,7 +35,7 @@ public static TiledImageStat GetCGearBackground(Bitmap img, CGearBackground bg)
ArgumentOutOfRangeException.ThrowIfNotEqual((uint)img.PixelFormat, (uint)PixelFormat.Format32bppArgb);
// get raw bytes of image
byte[] data = ImageUtil.GetPixelData(img);
byte[] data = img.GetBitmapData();
const int bpp = 4;
Debug.Assert(data.Length == Width * Height * bpp);

View File

@ -326,7 +326,15 @@ private void LoadBattleAgency()
private void LoadPictureBox()
{
for (int i = 0; i < 3; i++)
PBs[i].Image = p[i].Sprite(SAV, flagIllegal: true);
PBs[i].Image = p[i].Sprite(SAV, visibility: GetFlags(p[i]));
}
private SlotVisibilityType GetFlags(PKM pk, bool ignoreLegality = false)
{
var result = SlotVisibilityType.None;
if (!ignoreLegality)
result |= SlotVisibilityType.CheckLegalityIndicate;
return result;
}
private readonly NumericUpDown[] NUD_Trainers = new NumericUpDown[3];

View File

@ -120,7 +120,7 @@ private void LoadGroup(int index)
var sav = SAV;
for (int i = 0; i < slots.Length; i++)
Box.Entries[i].Image = slots[i].Sprite(sav, flagIllegal: true, storage: type);
Box.Entries[i].Image = slots[i].Sprite(sav, visibility: GetFlags(slots[i]), storage: type);
if (slotSelected != -1 && (uint)slotSelected < Box.Entries.Count)
Box.Entries[slotSelected].BackgroundImage = groupSelected != index ? null : SpriteUtil.Spriter.View;
@ -128,6 +128,14 @@ private void LoadGroup(int index)
CurrentGroup = index;
}
private SlotVisibilityType GetFlags(PKM pk, bool ignoreLegality = false)
{
var result = SlotVisibilityType.None;
if (!ignoreLegality)
result |= SlotVisibilityType.CheckLegalityIndicate;
return result;
}
public int MoveLeft(bool max = false)
{
int newBox = max ? 0 : (CurrentGroup + Groups.Count - 1) % Groups.Count;

View File

@ -433,7 +433,7 @@ private void ExportQRFromView()
return;
}
Image qr = QREncode.GenerateQRCode(mg);
var qr = QREncode.GenerateQRCode(mg);
string desc = $"({mg.Type}) {string.Join(Environment.NewLine, mg.GetDescription())}";

View File

@ -69,6 +69,16 @@ internal static void TranslateControls(IEnumerable<Control> controls, string bas
context.GetTranslatedText(c.Name, c.Text);
}
public static void TranslateControls(string formName, IEnumerable<ToolStripMenuItem> controls, string baseLanguage)
{
var context = GetContext(baseLanguage);
foreach (var c in controls)
{
if (c.Name is { } name)
context.GetTranslatedText($"{formName}.{name}", c.Text);
}
}
private static string GetSaneFormName(string formName)
{
// Strip out generic form names
@ -212,6 +222,8 @@ private static void ReformatDark(Control z)
else if (z is ButtonBase b)
{
b.FlatStyle = FlatStyle.Popup;
if (b.Image is System.Drawing.Bitmap bmp)
b.Image = WinFormsUtil.BlackToWhite(bmp);
}
}

View File

@ -562,13 +562,13 @@ public static void InvertToolStripIcons(ToolStripItemCollection collection)
if (o is not ToolStripMenuItem item)
continue;
InvertToolStripIcons(item.DropDownItems);
if (item.Image is not { } x)
if (item.Image is not Bitmap x)
continue;
item.Image = BlackToWhite(x);
}
}
public static Bitmap BlackToWhite(Image img) => Drawing.ImageUtil.ChangeAllColorTo(img, Color.White);
public static Bitmap BlackToWhite(Bitmap bmp) => Drawing.ImageUtil.CopyChangeAllColorTo(bmp, Color.White);
// SystemColor equivalents for dark mode support
public static Color ColorWarn => Application.IsDarkModeEnabled ? Color.OrangeRed : Color.Red;