mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-29 23:40:27 +00:00
Add toggleable setting for encounter background types
Fine archit and matt, have it whichever way you want :)
This commit is contained in:
parent
ffcd2e96e0
commit
de2d3a43be
12 changed files with 109 additions and 28 deletions
|
@ -7,9 +7,13 @@ namespace PKHeX.Drawing
|
|||
public abstract class SpriteBuilder : ISpriteBuilder<Image>
|
||||
{
|
||||
public static bool ShowEggSpriteAsItem { get; set; } = true;
|
||||
public static bool ShowEncounterColor { get; set; } = true;
|
||||
public static bool ShowEncounterBall { get; set; } = true;
|
||||
public static bool ShowEncounterColorPKM { get; set; }
|
||||
public static SpriteBackgroundType ShowEncounterColor { get; set; } = SpriteBackgroundType.FullBackground;
|
||||
public static SpriteBackgroundType ShowEncounterColorPKM { get; set; }
|
||||
|
||||
public static byte ShowEncounterOpacityStripe { get; set; }
|
||||
public static byte ShowEncounterOpacityBackground { get; set; }
|
||||
public static int ShowEncounterThicknessStripe { get; set; }
|
||||
|
||||
/// <summary> Width of the generated Sprite image. </summary>
|
||||
public abstract int Width { get; }
|
||||
|
@ -176,6 +180,37 @@ namespace PKHeX.Drawing
|
|||
var egg = GetEggSprite(species);
|
||||
return ImageUtil.LayerImage(baseImage, egg, EggItemShiftX, EggItemShiftY); // similar to held item, since they can't have any
|
||||
}
|
||||
|
||||
public static void LoadSettings(ISpriteSettings sprite)
|
||||
{
|
||||
ShowEggSpriteAsItem = sprite.ShowEggSpriteAsHeldItem;
|
||||
ShowEncounterBall = sprite.ShowEncounterBall;
|
||||
|
||||
ShowEncounterColor = sprite.ShowEncounterColor;
|
||||
ShowEncounterColorPKM = sprite.ShowEncounterColorPKM;
|
||||
ShowEncounterThicknessStripe = sprite.ShowEncounterThicknessStripe;
|
||||
ShowEncounterOpacityBackground = sprite.ShowEncounterOpacityBackground;
|
||||
ShowEncounterOpacityStripe = sprite.ShowEncounterOpacityStripe;
|
||||
}
|
||||
}
|
||||
|
||||
public enum SpriteBackgroundType
|
||||
{
|
||||
None,
|
||||
BottomStripe,
|
||||
FullBackground,
|
||||
}
|
||||
|
||||
public interface ISpriteSettings
|
||||
{
|
||||
bool ShowEggSpriteAsHeldItem { get; set; }
|
||||
bool ShowEncounterBall { get; set; }
|
||||
|
||||
SpriteBackgroundType ShowEncounterColor { get; set; }
|
||||
SpriteBackgroundType ShowEncounterColorPKM { get; set; }
|
||||
int ShowEncounterThicknessStripe { get; set; }
|
||||
byte ShowEncounterOpacityBackground { get; set; }
|
||||
byte ShowEncounterOpacityStripe { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -68,8 +68,8 @@ namespace PKHeX.Drawing
|
|||
return Spriter.None;
|
||||
|
||||
var img = GetBaseImage(gift);
|
||||
if (SpriteBuilder.ShowEncounterColor)
|
||||
img = ApplyStripe(gift, img);
|
||||
if (SpriteBuilder.ShowEncounterColor != SpriteBackgroundType.None)
|
||||
img = ApplyEncounterColor(gift, img, SpriteBuilder.ShowEncounterColor);
|
||||
if (gift.GiftUsed)
|
||||
img = ImageUtil.ChangeOpacity(img, 0.3);
|
||||
return img;
|
||||
|
@ -159,8 +159,8 @@ namespace PKHeX.Drawing
|
|||
sprite = ImageUtil.LayerImage(sprite, Resources.warn, 0, FlagIllegalShiftY);
|
||||
else if (pk.Format >= 8 && pk.Moves.Any(Legal.DummiedMoves_SWSH.Contains))
|
||||
sprite = ImageUtil.LayerImage(sprite, Resources.hint, 0, FlagIllegalShiftY);
|
||||
if (SpriteBuilder.ShowEncounterColorPKM)
|
||||
sprite = ApplyStripe(la.EncounterOriginal, sprite);
|
||||
if (SpriteBuilder.ShowEncounterColorPKM != SpriteBackgroundType.None)
|
||||
sprite = ApplyEncounterColor(la.EncounterOriginal, sprite, SpriteBuilder.ShowEncounterColorPKM);
|
||||
}
|
||||
if (inBox) // in box
|
||||
{
|
||||
|
@ -180,12 +180,21 @@ namespace PKHeX.Drawing
|
|||
return sprite;
|
||||
}
|
||||
|
||||
private static Image ApplyStripe(IEncounterTemplate enc, Image img)
|
||||
private static Image ApplyEncounterColor(IEncounterTemplate enc, Image img, SpriteBackgroundType type)
|
||||
{
|
||||
var index = (enc.GetType().Name.GetHashCode() * 0x43FD43FD);
|
||||
var color = Color.FromArgb(index);
|
||||
const int stripeHeight = 4; // from bottom
|
||||
return ImageUtil.ChangeTransparentTo(img, color, 0x7F, img.Width * 4 * (img.Height - stripeHeight));
|
||||
if (type == SpriteBackgroundType.BottomStripe)
|
||||
{
|
||||
int stripeHeight = SpriteBuilder.ShowEncounterThicknessStripe; // from bottom
|
||||
byte opacity = SpriteBuilder.ShowEncounterOpacityStripe;
|
||||
return ImageUtil.ChangeTransparentTo(img, color, opacity, img.Width * 4 * (img.Height - stripeHeight));
|
||||
}
|
||||
else // full background
|
||||
{
|
||||
byte opacity = SpriteBuilder.ShowEncounterOpacityBackground;
|
||||
return ImageUtil.ChangeTransparentTo(img, color, opacity);
|
||||
}
|
||||
}
|
||||
|
||||
private const int MaxSlotCount = 30; // slots in a box
|
||||
|
@ -251,8 +260,8 @@ namespace PKHeX.Drawing
|
|||
var gm = Resources.dyna;
|
||||
img = ImageUtil.LayerImage(img, gm, (img.Width - gm.Width) / 2, 0);
|
||||
}
|
||||
if (SpriteBuilder.ShowEncounterColor)
|
||||
img = ApplyStripe(enc, img);
|
||||
if (SpriteBuilder.ShowEncounterColor != SpriteBackgroundType.None)
|
||||
img = ApplyEncounterColor(enc, img, SpriteBuilder.ShowEncounterColor);
|
||||
return img;
|
||||
}
|
||||
|
||||
|
|
|
@ -444,7 +444,7 @@ namespace PKHeX.WinForms
|
|||
Draw.LoadBrushes();
|
||||
PKME_Tabs.Unicode = Unicode = settings.Display.Unicode;
|
||||
PKME_Tabs.UpdateUnicode(GenderSymbols);
|
||||
SpriteName.AllowShinySprite = settings.Display.ShinySprites;
|
||||
SpriteName.AllowShinySprite = settings.Sprite.ShinySprites;
|
||||
SaveFile.SetUpdateDex = settings.SlotWrite.SetUpdateDex ? PKMImportSetting.Update : PKMImportSetting.Skip;
|
||||
SaveFile.SetUpdatePKM = settings.SlotWrite.SetUpdatePKM ? PKMImportSetting.Update : PKMImportSetting.Skip;
|
||||
C_SAV.ModifyPKM = PKME_Tabs.ModifyPKM = settings.SlotWrite.SetUpdatePKM;
|
||||
|
@ -452,14 +452,12 @@ namespace PKHeX.WinForms
|
|||
CommonEdits.ShowdownSetBehaviorNature = settings.Import.ApplyNature;
|
||||
C_SAV.FlagIllegal = settings.Display.FlagIllegal;
|
||||
C_SAV.M.Hover.GlowHover = settings.Hover.HoverSlotGlowEdges;
|
||||
SpriteBuilder.ShowEggSpriteAsItem = settings.Display.ShowEggSpriteAsHeldItem;
|
||||
SpriteBuilder.ShowEncounterColor = settings.Display.ShowEncounterColor;
|
||||
SpriteBuilder.ShowEncounterBall = settings.Display.ShowEncounterBall;
|
||||
SpriteBuilder.ShowEncounterColorPKM = settings.Display.ShowEncounterColorPKM;
|
||||
ParseSettings.InitFromSettings(settings.Legality);
|
||||
PKME_Tabs.HideSecretValues = C_SAV.HideSecretDetails = settings.Privacy.HideSecretDetails;
|
||||
PKMConverter.AllowIncompatibleConversion = settings.Advanced.AllowIncompatibleConversion;
|
||||
WinFormsUtil.DetectSaveFileOnFileOpen = settings.Startup.TryDetectRecentSave;
|
||||
|
||||
SpriteBuilder.LoadSettings(settings.Sprite);
|
||||
}
|
||||
|
||||
private void MainMenuBoxLoad(object sender, EventArgs e)
|
||||
|
|
|
@ -5,6 +5,7 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using PKHeX.Core;
|
||||
using PKHeX.Drawing;
|
||||
|
||||
namespace PKHeX.WinForms
|
||||
{
|
||||
|
@ -22,6 +23,7 @@ namespace PKHeX.WinForms
|
|||
|
||||
// UI Tweaks
|
||||
public DisplaySettings Display { get; set; } = new();
|
||||
public SpriteSettings Sprite { get; set; } = new();
|
||||
public SoundSettings Sounds { get; set; } = new();
|
||||
public HoverSettings Hover { get; set; } = new();
|
||||
|
||||
|
@ -316,26 +318,39 @@ namespace PKHeX.WinForms
|
|||
[LocalizedDescription("Show Unicode gender symbol characters, or ASCII when disabled.")]
|
||||
public bool Unicode { get; set; } = true;
|
||||
|
||||
[LocalizedDescription("Show fanmade shiny sprites when the PKM is shiny.")]
|
||||
public bool ShinySprites { get; set; } = true;
|
||||
|
||||
[LocalizedDescription("Show an Egg Sprite As Held Item rather than hiding the PKM")]
|
||||
public bool ShowEggSpriteAsHeldItem { get; set; } = true;
|
||||
|
||||
[LocalizedDescription("Show a background to differentiate an Encounter Template's type")]
|
||||
public bool ShowEncounterColor { get; set; } = true;
|
||||
|
||||
[LocalizedDescription("Show a background to differentiate the recognized Encounter Template type for PKM slots")]
|
||||
public bool ShowEncounterColorPKM { get; set; }
|
||||
|
||||
[LocalizedDescription("Don't show the Legality popup if Legal!")]
|
||||
public bool IgnoreLegalPopup { get; set; }
|
||||
|
||||
[LocalizedDescription("Flag Illegal Slots in Save File")]
|
||||
public bool FlagIllegal { get; set; } = true;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class SpriteSettings : ISpriteSettings
|
||||
{
|
||||
[LocalizedDescription("Show fan-made shiny sprites when the PKM is shiny.")]
|
||||
public bool ShinySprites { get; set; } = true;
|
||||
|
||||
[LocalizedDescription("Show an Egg Sprite As Held Item rather than hiding the PKM")]
|
||||
public bool ShowEggSpriteAsHeldItem { get; set; } = true;
|
||||
|
||||
[LocalizedDescription("Show the required ball for an Encounter Template")]
|
||||
public bool ShowEncounterBall { get; set; } = true;
|
||||
|
||||
[LocalizedDescription("Show a background to differentiate an Encounter Template's type")]
|
||||
public SpriteBackgroundType ShowEncounterColor { get; set; } = SpriteBackgroundType.FullBackground;
|
||||
|
||||
[LocalizedDescription("Show a background to differentiate the recognized Encounter Template type for PKM slots")]
|
||||
public SpriteBackgroundType ShowEncounterColorPKM { get; set; } = SpriteBackgroundType.BottomStripe;
|
||||
|
||||
[LocalizedDescription("Opacity for the Encounter Type background layer.")]
|
||||
public byte ShowEncounterOpacityBackground { get; set; } = 0x3F; // kinda low
|
||||
|
||||
[LocalizedDescription("Opacity for the Encounter Type stripe layer.")]
|
||||
public byte ShowEncounterOpacityStripe { get; set; } = 0x5F; // 0xFF opaque
|
||||
|
||||
[LocalizedDescription("Amount of pixels thick to show when displaying the encounter type color stripe.")]
|
||||
public int ShowEncounterThicknessStripe { get; set; } = 4; // pixels
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
|
|
@ -116,6 +116,9 @@ LocalizedDescription.ShowEggSpriteAsHeldItem=Zeige Ei Sprite als getragenes Item
|
|||
LocalizedDescription.ShowEncounterBall=Show the required ball for an Encounter Template
|
||||
LocalizedDescription.ShowEncounterColor=Show a background to differentiate an Encounter Template's type
|
||||
LocalizedDescription.ShowEncounterColorPKM=Show a background to differentiate the recognized Encounter Template type for PKM slots
|
||||
LocalizedDescription.ShowEncounterOpacityBackground=Opacity for the Encounter Type background layer.
|
||||
LocalizedDescription.ShowEncounterOpacityStripe=Opacity for the Encounter Type stripe layer.
|
||||
LocalizedDescription.ShowEncounterThicknessStripe=Amount of pixels thick to show when displaying the encounter type color stripe.
|
||||
LocalizedDescription.TryDetectRecentSave=Finde automatisch den zuletzt geöffneten Spielstand beim Öffnen einer neuen Datei.
|
||||
LocalizedDescription.Unicode=Unicode
|
||||
LocalizedDescription.UseTabsAsCriteria=Nutze Eigeschaften aus den PKM Editor Tabs um Kriterien wie Geschlecht und Wesen bei der Generierung einer neuen Begegnung zu bestimmen.
|
||||
|
|
|
@ -116,6 +116,9 @@ LocalizedDescription.ShowEggSpriteAsHeldItem=Show Egg Sprite As Held Item
|
|||
LocalizedDescription.ShowEncounterBall=Show the required ball for an Encounter Template
|
||||
LocalizedDescription.ShowEncounterColor=Show a background to differentiate an Encounter Template's type
|
||||
LocalizedDescription.ShowEncounterColorPKM=Show a background to differentiate the recognized Encounter Template type for PKM slots
|
||||
LocalizedDescription.ShowEncounterOpacityBackground=Opacity for the Encounter Type background layer.
|
||||
LocalizedDescription.ShowEncounterOpacityStripe=Opacity for the Encounter Type stripe layer.
|
||||
LocalizedDescription.ShowEncounterThicknessStripe=Amount of pixels thick to show when displaying the encounter type color stripe.
|
||||
LocalizedDescription.TryDetectRecentSave=Automatically locates the most recently saved Save File when opening a new file.
|
||||
LocalizedDescription.Unicode=Unicode
|
||||
LocalizedDescription.UseTabsAsCriteria=Use properties from the PKM Editor tabs to specify criteria like Gender and Nature when generating an encounter.
|
||||
|
|
|
@ -116,6 +116,9 @@ LocalizedDescription.ShowEggSpriteAsHeldItem=Mostrar sprite de huevo como objeto
|
|||
LocalizedDescription.ShowEncounterBall=Show the required ball for an Encounter Template
|
||||
LocalizedDescription.ShowEncounterColor=Show a background to differentiate an Encounter Template's type
|
||||
LocalizedDescription.ShowEncounterColorPKM=Show a background to differentiate the recognized Encounter Template type for PKM slots
|
||||
LocalizedDescription.ShowEncounterOpacityBackground=Opacity for the Encounter Type background layer.
|
||||
LocalizedDescription.ShowEncounterOpacityStripe=Opacity for the Encounter Type stripe layer.
|
||||
LocalizedDescription.ShowEncounterThicknessStripe=Amount of pixels thick to show when displaying the encounter type color stripe.
|
||||
LocalizedDescription.TryDetectRecentSave=Localiza automáticamente el archivo guardado más recientemente al abrir un archivo nuevo.
|
||||
LocalizedDescription.Unicode=Unicode
|
||||
LocalizedDescription.UseTabsAsCriteria=Use properties from the PKM Editor tabs to specify criteria like Gender and Nature when generating an encounter.
|
||||
|
|
|
@ -116,6 +116,9 @@ LocalizedDescription.ShowEggSpriteAsHeldItem=Montrer le sprite de l'Œuf en tant
|
|||
LocalizedDescription.ShowEncounterBall=Show the required ball for an Encounter Template
|
||||
LocalizedDescription.ShowEncounterColor=Show a background to differentiate an Encounter Template's type
|
||||
LocalizedDescription.ShowEncounterColorPKM=Show a background to differentiate the recognized Encounter Template type for PKM slots
|
||||
LocalizedDescription.ShowEncounterOpacityBackground=Opacity for the Encounter Type background layer.
|
||||
LocalizedDescription.ShowEncounterOpacityStripe=Opacity for the Encounter Type stripe layer.
|
||||
LocalizedDescription.ShowEncounterThicknessStripe=Amount of pixels thick to show when displaying the encounter type color stripe.
|
||||
LocalizedDescription.TryDetectRecentSave=Automatically locates the most recently saved Save File when opening a new file.
|
||||
LocalizedDescription.Unicode=Unicode
|
||||
LocalizedDescription.UseTabsAsCriteria=Use properties from the PKM Editor tabs to specify criteria like Gender and Nature when generating an encounter.
|
||||
|
|
|
@ -116,6 +116,9 @@ LocalizedDescription.ShowEggSpriteAsHeldItem=Show Egg Sprite As Held Item
|
|||
LocalizedDescription.ShowEncounterBall=Show the required ball for an Encounter Template
|
||||
LocalizedDescription.ShowEncounterColor=Show a background to differentiate an Encounter Template's type
|
||||
LocalizedDescription.ShowEncounterColorPKM=Show a background to differentiate the recognized Encounter Template type for PKM slots
|
||||
LocalizedDescription.ShowEncounterOpacityBackground=Opacity for the Encounter Type background layer.
|
||||
LocalizedDescription.ShowEncounterOpacityStripe=Opacity for the Encounter Type stripe layer.
|
||||
LocalizedDescription.ShowEncounterThicknessStripe=Amount of pixels thick to show when displaying the encounter type color stripe.
|
||||
LocalizedDescription.TryDetectRecentSave=Automatically locates the most recently saved Save File when opening a new file.
|
||||
LocalizedDescription.Unicode=Unicode
|
||||
LocalizedDescription.UseTabsAsCriteria=Use properties from the PKM Editor tabs to specify criteria like Gender and Nature when generating an encounter.
|
||||
|
|
|
@ -116,6 +116,9 @@ LocalizedDescription.ShowEggSpriteAsHeldItem=Show Egg Sprite As Held Item
|
|||
LocalizedDescription.ShowEncounterBall=Show the required ball for an Encounter Template
|
||||
LocalizedDescription.ShowEncounterColor=Show a background to differentiate an Encounter Template's type
|
||||
LocalizedDescription.ShowEncounterColorPKM=Show a background to differentiate the recognized Encounter Template type for PKM slots
|
||||
LocalizedDescription.ShowEncounterOpacityBackground=Opacity for the Encounter Type background layer.
|
||||
LocalizedDescription.ShowEncounterOpacityStripe=Opacity for the Encounter Type stripe layer.
|
||||
LocalizedDescription.ShowEncounterThicknessStripe=Amount of pixels thick to show when displaying the encounter type color stripe.
|
||||
LocalizedDescription.TryDetectRecentSave=Automatically locates the most recently saved Save File when opening a new file.
|
||||
LocalizedDescription.Unicode=Unicode
|
||||
LocalizedDescription.UseTabsAsCriteria=Use properties from the PKM Editor tabs to specify criteria like Gender and Nature when generating an encounter.
|
||||
|
|
|
@ -116,6 +116,9 @@ LocalizedDescription.ShowEggSpriteAsHeldItem=알 스프라이트를 지닌 물
|
|||
LocalizedDescription.ShowEncounterBall=Show the required ball for an Encounter Template
|
||||
LocalizedDescription.ShowEncounterColor=Show a background to differentiate an Encounter Template's type
|
||||
LocalizedDescription.ShowEncounterColorPKM=Show a background to differentiate the recognized Encounter Template type for PKM slots
|
||||
LocalizedDescription.ShowEncounterOpacityBackground=Opacity for the Encounter Type background layer.
|
||||
LocalizedDescription.ShowEncounterOpacityStripe=Opacity for the Encounter Type stripe layer.
|
||||
LocalizedDescription.ShowEncounterThicknessStripe=Amount of pixels thick to show when displaying the encounter type color stripe.
|
||||
LocalizedDescription.TryDetectRecentSave=Automatically locates the most recently saved Save File when opening a new file.
|
||||
LocalizedDescription.Unicode=유니코드 사용
|
||||
LocalizedDescription.UseTabsAsCriteria=Use properties from the PKM Editor tabs to specify criteria like Gender and Nature when generating an encounter.
|
||||
|
|
|
@ -116,6 +116,9 @@ LocalizedDescription.ShowEggSpriteAsHeldItem=将蛋作为持有物品展示
|
|||
LocalizedDescription.ShowEncounterBall=Show the required ball for an Encounter Template
|
||||
LocalizedDescription.ShowEncounterColor=Show a background to differentiate an Encounter Template's type
|
||||
LocalizedDescription.ShowEncounterColorPKM=Show a background to differentiate the recognized Encounter Template type for PKM slots
|
||||
LocalizedDescription.ShowEncounterOpacityBackground=Opacity for the Encounter Type background layer.
|
||||
LocalizedDescription.ShowEncounterOpacityStripe=Opacity for the Encounter Type stripe layer.
|
||||
LocalizedDescription.ShowEncounterThicknessStripe=Amount of pixels thick to show when displaying the encounter type color stripe.
|
||||
LocalizedDescription.TryDetectRecentSave=打开新存档时,自动定位到上次保存的存档地址。
|
||||
LocalizedDescription.Unicode=使用Unicode显示性别符号,禁用时使用ASCII
|
||||
LocalizedDescription.UseTabsAsCriteria=Use properties from the PKM Editor tabs to specify criteria like Gender and Nature when generating an encounter.
|
||||
|
|
Loading…
Reference in a new issue