mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-09-29 06:54:48 -05:00
ZA: Fix item edit IsNewNotify
Behavior might be wrong in S/V but nobody reported? Either way, this fixes the behavior of old things seeming new again in Z-A.
This commit is contained in:
@@ -210,7 +210,7 @@ public static InventoryType GetInventoryPouch(ushort itemIndex)
|
||||
Feraligatr when form == 1 => 2564,
|
||||
Skarmory when form == 1 => 2565,
|
||||
Froslass when form == 1 => 2566,
|
||||
Emboar when form == 1 => 2569,
|
||||
Emboar when form == 1 => 2569,
|
||||
Excadrill when form == 1 => 2570,
|
||||
Scolipede when form == 1 => 2571,
|
||||
Scrafty when form == 1 => 2572,
|
||||
@@ -228,6 +228,24 @@ public static InventoryType GetInventoryPouch(ushort itemIndex)
|
||||
Zygarde when form == 5 => 2584,
|
||||
Drampa when form == 1 => 2585,
|
||||
Falinks when form == 1 => 2587,
|
||||
|
||||
// DLC Mega Stones
|
||||
Raichu when form == 1 => 2635, // X
|
||||
Raichu when form == 2 => 2636, // Y
|
||||
Chimecho when form == 1 => 2637,
|
||||
Absol when form == 2 => 2638, // ZA
|
||||
Staraptor when form == 1 => 2639,
|
||||
Garchomp when form == 2 => 2640, // ZA
|
||||
Lucario when form == 2 => 2641, // ZA
|
||||
Golurk when form == 1 => 2642,
|
||||
Meowstic when form == 2 => 2643,
|
||||
Crabominable when form == 1 => 2644,
|
||||
Golisopod when form == 1 => 2645,
|
||||
Magearna when form == 2 => 2646,
|
||||
Scovillain when form == 1 => 2647,
|
||||
Baxcalibur when form == 1 => 2648,
|
||||
Tatsugiri when form >= 3 => 2649,
|
||||
Glimmora when form == 1 => 2650,
|
||||
_ => 0,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -41,7 +41,14 @@ public void SetItemQuantity(ushort itemIndex, int quantity)
|
||||
var item = InventoryItem9a.Read(itemIndex, span);
|
||||
item.Count = quantity;
|
||||
item.Pouch = GetPouchIndex(GetType(itemIndex));
|
||||
item.IsUpdated = true;
|
||||
|
||||
if (item.IsNewNotify && quantity != 0)
|
||||
{
|
||||
// Show popup, treat as new.
|
||||
item.IsNewNotify = false;
|
||||
item.IsNew = true;
|
||||
}
|
||||
|
||||
item.Write(span);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,13 +21,23 @@ public sealed record InventoryItem9a : InventoryItem, IItemFavorite, IItemNewFla
|
||||
public uint Flags { get; set; }
|
||||
public uint Padding { get; set; }
|
||||
|
||||
public bool IsNew { get => (Flags & 0x1) != 0; set => Flags = (Flags & ~0x1u) | (value ? 0x1u : 0x0u); } // red dot
|
||||
public bool IsFavorite { get => (Flags & 0x2) != 0; set => Flags = (Flags & ~0x2u) | (value ? 0x2u : 0x0u); }
|
||||
public bool IsUpdated { get => (Flags & 0x4) != 0; set => Flags = (Flags & ~0x4u) | (value ? 0x4u : 0x0u); } // always true if pouch is set
|
||||
public bool IsNewShop { get => (Flags & 0x8) != 0; set => Flags = (Flags & ~0x8u) | (value ? 0x8u : 0x0u); }
|
||||
public bool IsHeld { get => (Flags & 0x10) != 0; set => Flags = (Flags & ~0x10u) | (value ? 0x10u : 0x0u); } // only for Mega Stones currently held by a Pokémon
|
||||
/// <summary> Indicates the red dot in the inventory pouch list that the item hasn't been looked at yet by the player. </summary>
|
||||
public bool IsNew { get => (Flags & 0x1) != 0; set => Flags = (Flags & ~0x1u) | (value ? 0x1u : 0x0u); }
|
||||
|
||||
private const byte DefaultFlagValue = 0b0_1101;
|
||||
/// <summary> The player has marked it as a favorite item (for sorting). </summary>
|
||||
public bool IsFavorite { get => (Flags & 0x2) != 0; set => Flags = (Flags & ~0x2u) | (value ? 0x2u : 0x0u); }
|
||||
|
||||
/// <summary> Flyout notification will show "NEW" when item is picked up. When clearing this flag, the <see cref="IsNew"/> flag is set, however, the initial flag value already has it set. </summary>
|
||||
/// <remarks> Will always <c>false</c> if any quantity of the item has been acquired. </remarks>
|
||||
public bool IsNewNotify { get => (Flags & 0x4) != 0; set => Flags = (Flags & ~0x4u) | (value ? 0x4u : 0x0u); }
|
||||
|
||||
/// <summary> Indicates the item is newly available for purchase in shops. Similar to <see cref="IsNew"/>, but for shop inventory listing. </summary>
|
||||
public bool IsNewShop { get => (Flags & 0x8) != 0; set => Flags = (Flags & ~0x8u) | (value ? 0x8u : 0x0u); }
|
||||
|
||||
/// <summary> Indicates the item is currently being held by a Pokémon. Only applicable to Mega Stones in this game. </summary>
|
||||
public bool IsHeld { get => (Flags & 0x10) != 0; set => Flags = (Flags & ~0x10u) | (value ? 0x10u : 0x0u); }
|
||||
|
||||
private const byte DefaultFlagValue = 0b0_1101; // New in Shop, Not Notified yet, Not Favorite, New in Inventory (redundant)
|
||||
|
||||
public override string ToString() => $"{Index:000} x{Count}{(IsNew ? "*" : "")}{(IsFavorite ? "F" : "")} - {Flags:X8}";
|
||||
|
||||
@@ -54,7 +64,9 @@ public static InventoryItem9a Read(ushort index, ReadOnlySpan<byte> data) => new
|
||||
|
||||
public void Write(Span<byte> data)
|
||||
{
|
||||
IsUpdated = Pouch != PouchNone;
|
||||
// Ensure the updated flag state is as expected.
|
||||
if (Pouch == PouchNone)
|
||||
Flags = DefaultFlagValue;
|
||||
|
||||
// Index is not saved.
|
||||
WriteUInt32LittleEndian(data, Pouch);
|
||||
|
||||
@@ -77,22 +77,10 @@ private void EnsureFlagsConsistent(InventoryItem9a item, InventoryItem9a origina
|
||||
if (item.Count != 0)
|
||||
{
|
||||
// Ensure the flag is set; 0->X and Y->Z
|
||||
item.IsUpdated = true;
|
||||
if (!original.IsUpdated && SetNew)
|
||||
if (original.IsNewNotify && SetNew)
|
||||
item.IsNew = true;
|
||||
item.IsNewNotify = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!item.IsUpdated)
|
||||
{
|
||||
item.IsNew = item.IsFavorite = false;
|
||||
if (item.Pouch is not (0 or uint.MaxValue))
|
||||
item.Pouch = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.IsUpdated)
|
||||
item.Pouch = PouchIndex; // ensure the pouch is set
|
||||
}
|
||||
|
||||
public static void SetQuantityZero(Span<byte> block, ushort index)
|
||||
@@ -102,7 +90,10 @@ public static void SetQuantityZero(Span<byte> block, ushort index)
|
||||
if (exist.Count == 0)
|
||||
return;
|
||||
exist.Count = 0;
|
||||
exist.IsUpdated = true;
|
||||
if (exist.IsValidPouch)
|
||||
exist.IsNewNotify = false; // exist was nonzero, must not have the flag.
|
||||
else
|
||||
exist.Clear();
|
||||
exist.Write(span);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user