diff --git a/PKHeX.Drawing/Sprites/SpriteBuilder.cs b/PKHeX.Drawing/Sprites/SpriteBuilder.cs index f748215dc..87b9eb110 100644 --- a/PKHeX.Drawing/Sprites/SpriteBuilder.cs +++ b/PKHeX.Drawing/Sprites/SpriteBuilder.cs @@ -7,9 +7,13 @@ namespace PKHeX.Drawing public abstract class SpriteBuilder : ISpriteBuilder { 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; } /// Width of the generated Sprite image. public abstract int Width { get; } @@ -176,6 +180,37 @@ private Image LayerOverImageEggAsItem(Image baseImage, int species) 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; } } /// diff --git a/PKHeX.Drawing/Sprites/SpriteUtil.cs b/PKHeX.Drawing/Sprites/SpriteUtil.cs index caebe4eb3..9f350f60d 100644 --- a/PKHeX.Drawing/Sprites/SpriteUtil.cs +++ b/PKHeX.Drawing/Sprites/SpriteUtil.cs @@ -68,8 +68,8 @@ private static Image GetSprite(MysteryGift gift) 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 @@ private static Image GetSprite(PKM pk, SaveFile sav, int box, int slot, bool fla 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 @@ private static Image GetSprite(PKM pk, SaveFile sav, int box, int slot, bool fla 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 @@ public static Image Sprite(this IEncounterTemplate enc) 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; } diff --git a/PKHeX.WinForms/MainWindow/Main.cs b/PKHeX.WinForms/MainWindow/Main.cs index f19fdd3e0..9f0a95f10 100644 --- a/PKHeX.WinForms/MainWindow/Main.cs +++ b/PKHeX.WinForms/MainWindow/Main.cs @@ -444,7 +444,7 @@ private void ReloadProgramSettings(PKHeXSettings settings) 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 @@ private void ReloadProgramSettings(PKHeXSettings settings) 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) diff --git a/PKHeX.WinForms/Properties/PKHeXSettings.cs b/PKHeX.WinForms/Properties/PKHeXSettings.cs index 2a2aa702c..8e8e6ad59 100644 --- a/PKHeX.WinForms/Properties/PKHeXSettings.cs +++ b/PKHeX.WinForms/Properties/PKHeXSettings.cs @@ -5,6 +5,7 @@ using System.IO; using Newtonsoft.Json; using PKHeX.Core; +using PKHeX.Drawing; namespace PKHeX.WinForms { @@ -22,6 +23,7 @@ public sealed class PKHeXSettings // 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 @@ public sealed class DisplaySettings [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] diff --git a/PKHeX.WinForms/Resources/text/lang_de.txt b/PKHeX.WinForms/Resources/text/lang_de.txt index 23d176a2c..e47fbbd35 100644 --- a/PKHeX.WinForms/Resources/text/lang_de.txt +++ b/PKHeX.WinForms/Resources/text/lang_de.txt @@ -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. diff --git a/PKHeX.WinForms/Resources/text/lang_en.txt b/PKHeX.WinForms/Resources/text/lang_en.txt index d746f53a2..d874a341d 100644 --- a/PKHeX.WinForms/Resources/text/lang_en.txt +++ b/PKHeX.WinForms/Resources/text/lang_en.txt @@ -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. diff --git a/PKHeX.WinForms/Resources/text/lang_es.txt b/PKHeX.WinForms/Resources/text/lang_es.txt index 5cf10c650..8027ea73c 100644 --- a/PKHeX.WinForms/Resources/text/lang_es.txt +++ b/PKHeX.WinForms/Resources/text/lang_es.txt @@ -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. diff --git a/PKHeX.WinForms/Resources/text/lang_fr.txt b/PKHeX.WinForms/Resources/text/lang_fr.txt index df4dd7d17..b3286bc9d 100644 --- a/PKHeX.WinForms/Resources/text/lang_fr.txt +++ b/PKHeX.WinForms/Resources/text/lang_fr.txt @@ -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. diff --git a/PKHeX.WinForms/Resources/text/lang_it.txt b/PKHeX.WinForms/Resources/text/lang_it.txt index c9e1600c5..16203d799 100644 --- a/PKHeX.WinForms/Resources/text/lang_it.txt +++ b/PKHeX.WinForms/Resources/text/lang_it.txt @@ -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. diff --git a/PKHeX.WinForms/Resources/text/lang_ja.txt b/PKHeX.WinForms/Resources/text/lang_ja.txt index 01842548a..59b2644d1 100644 --- a/PKHeX.WinForms/Resources/text/lang_ja.txt +++ b/PKHeX.WinForms/Resources/text/lang_ja.txt @@ -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. diff --git a/PKHeX.WinForms/Resources/text/lang_ko.txt b/PKHeX.WinForms/Resources/text/lang_ko.txt index 1233e367e..7f79fc8f6 100644 --- a/PKHeX.WinForms/Resources/text/lang_ko.txt +++ b/PKHeX.WinForms/Resources/text/lang_ko.txt @@ -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. diff --git a/PKHeX.WinForms/Resources/text/lang_zh.txt b/PKHeX.WinForms/Resources/text/lang_zh.txt index cb740c493..11b47b259 100644 --- a/PKHeX.WinForms/Resources/text/lang_zh.txt +++ b/PKHeX.WinForms/Resources/text/lang_zh.txt @@ -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.