diff --git a/PKHeX.Core/Editing/Bulk/BatchEditing.cs b/PKHeX.Core/Editing/Bulk/BatchEditing.cs index 24bfbdb3b..f62b05d34 100644 --- a/PKHeX.Core/Editing/Bulk/BatchEditing.cs +++ b/PKHeX.Core/Editing/Bulk/BatchEditing.cs @@ -514,7 +514,7 @@ private static bool SetComplexProperty(PKM pk, StringInstruction cmd) else if (cmd.PropertyName == nameof(PKM.EncryptionConstant) && cmd.PropertyValue == nameof(PKM.PID)) pk.EncryptionConstant = pk.PID; else if (cmd.PropertyName == nameof(PKM.PID) && cmd.PropertyValue.StartsWith(CONST_SHINY, true, CultureInfo.CurrentCulture)) - CommonEdits.SetShiny(pk, cmd.PropertyValue.EndsWith("0") ? Shiny.AlwaysSquare : Shiny.AlwaysStar); + CommonEdits.SetShiny(pk, cmd.PropertyValue.EndsWith("0") ? Shiny.AlwaysSquare : cmd.PropertyValue.EndsWith("1") ? Shiny.AlwaysStar : Shiny.Random); else if (cmd.PropertyName == nameof(PKM.Species) && cmd.PropertyValue == "0") Array.Clear(pk.Data, 0, pk.Data.Length); else if (cmd.PropertyName.StartsWith("IV") && cmd.PropertyValue == CONST_RAND) diff --git a/PKHeX.Core/Editing/CommonEdits.cs b/PKHeX.Core/Editing/CommonEdits.cs index 825644fc7..bde4a1c04 100644 --- a/PKHeX.Core/Editing/CommonEdits.cs +++ b/PKHeX.Core/Editing/CommonEdits.cs @@ -137,23 +137,19 @@ public static void SetRandomEC(this PKM pk) /// Returns true if the data was modified. public static bool SetShiny(PKM pk, Shiny type = Shiny.Random) { - if (pk.IsShiny) + if (pk.IsShiny && type.IsValid(pk)) return false; - if (pk.FatefulEncounter || pk.Version == (int)GameVersion.GO || type == Shiny.Random) + if (type == Shiny.Random || pk.FatefulEncounter || pk.Version == (int)GameVersion.GO || pk.Format <= 2) { pk.SetShiny(); return true; } - while (true) - { - pk.SetShiny(); + do { pk.SetShiny(); } + while (!type.IsValid(pk)); - var xor = pk.ShinyXor; - if (type == Shiny.AlwaysSquare ? xor == 0 : xor != 0) - return true; - } + return true; } /// diff --git a/PKHeX.Core/PKM/PKM.cs b/PKHeX.Core/PKM/PKM.cs index a4975f0df..b0d294cef 100644 --- a/PKHeX.Core/PKM/PKM.cs +++ b/PKHeX.Core/PKM/PKM.cs @@ -900,12 +900,20 @@ public virtual void SetShiny() /// /// Applies a shiny to the . /// - public void SetShinySID() + public void SetShinySID(Shiny shiny = Shiny.Random) { - if (IsShiny) + if (IsShiny && shiny.IsValid(this)) return; + var xor = TID ^ (PID >> 16) ^ (PID & 0xFFFF); - SID = (int)(xor & 0xFFF8) | Util.Rand.Next(8); + var bits = shiny switch + { + Shiny.AlwaysSquare => 0, + Shiny.AlwaysStar => 1, + _ => Util.Rand.Next(8) + }; + + SID = (int)xor ^ bits; } /// diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs index 7eaaa217d..737a67e2a 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs @@ -1439,11 +1439,11 @@ private void UpdateMetAsEgg(object sender, EventArgs e) private void UpdateShinyPID(object sender, EventArgs e) { - var ShinyPID = Entity.Format <= 2 || ModifierKeys != Keys.Control; - UpdateShiny(ShinyPID); + var changePID = Entity.Format >= 3 && (ModifierKeys & Keys.Alt) == 0; + UpdateShiny(changePID); } - private void UpdateShiny(bool PID) + private void UpdateShiny(bool changePID) { Entity.PID = Util.GetHexValue(TB_PID.Text); Entity.Nature = WinFormsUtil.GetIndex(CB_Nature); @@ -1453,9 +1453,15 @@ private void UpdateShiny(bool PID) if (Entity.Format > 2) { - if (PID) + var type = (ModifierKeys & ~Keys.Alt) switch { - CommonEdits.SetShiny(Entity, ModifierKeys == Keys.Shift ? Shiny.AlwaysSquare : Shiny.AlwaysStar); + Keys.Shift => Shiny.AlwaysSquare, + Keys.Control => Shiny.AlwaysStar, + _ => Shiny.Random + }; + if (changePID) + { + CommonEdits.SetShiny(Entity, type); TB_PID.Text = Entity.PID.ToString("X8"); int gen = Entity.GenNumber; @@ -1465,7 +1471,7 @@ private void UpdateShiny(bool PID) } else { - Entity.SetShinySID(); + Entity.SetShinySID(type); TID_Trainer.UpdateSID(); } } diff --git a/PKHeX.WinForms/Resources/text/shortcuts.txt b/PKHeX.WinForms/Resources/text/shortcuts.txt index b1c917956..726fef54e 100644 --- a/PKHeX.WinForms/Resources/text/shortcuts.txt +++ b/PKHeX.WinForms/Resources/text/shortcuts.txt @@ -31,6 +31,7 @@ Control + Click on... - PP Ups Label: Set all PP Ups to 0. (Click = 3) - Friendship Label: Set Friendship to 0. (Click = 255 or Base) - Level box: Set Level to 100. +- Shiny Button: Make Star Shiny (Xor1) Alt + Click on... - Preview Sprite to load from a QR url on your clipboard. @@ -39,11 +40,12 @@ Alt + Click on... - Individual IVs: Set IV to 0. - Individual AVs: Set AV to 0. - Individual EVs: Set EV to 0. +- Shiny Button: Set SID instead of PID when making shiny Shift + Click on... - Preview Sprite to bring up a QR for the viewed Pokémon. - Individual IVs: Hyper Train the IV (toggles Hyper Training in Gen7 onwards) -- Shiny Button: Make Square Shiny +- Shiny Button: Make Square Shiny (Xor0) - Moves: Apply random moveset. Hold Control when dragging to save encrypted (ekx).