Perserve & Display Favorite flag for items

Also clamp give all for TMs to 1 instead of whatever the giveall value is, like for prior games' HMs

reuse the "free space" bool; no real benefit in increasing the amount of abstraction (even though that's my current urge for legality)
This commit is contained in:
Kurt 2020-07-18 20:15:41 -05:00
parent 65ecd3ca9a
commit a21bb09c37
3 changed files with 21 additions and 14 deletions

View file

@ -204,6 +204,8 @@ namespace PKHeX.Core
{
if (sav is SAV7b) // mixed pouch count caps
return InventoryPouch7b.GetSuggestedCount(Type, item, requestVal);
if (sav is SAV8SWSH)
return InventoryPouch8.GetSuggestedCount(Type, item, requestVal);
if (ItemConverter.IsItemHM((ushort)item, sav.Generation))
return 1;
return Math.Min(MaxCount, requestVal);

View file

@ -45,12 +45,13 @@ namespace PKHeX.Core
// 15bit itemID
// 15bit count
// 1 bit new flag
// 1 bit reserved
// 1 bit favorite flag
return new InventoryItem
{
Index = (int)(val & 0x7FF),
Count = (int)(val >> 15 & 0x3FF), // clamp to sane values
New = (val & 0x40000000) != 0, // 30th bit is "NEW"
FreeSpace = (val & 0x80000000) != 0, // 31th bit is "FAVORITE"
};
}
@ -59,7 +60,7 @@ namespace PKHeX.Core
// 15bit itemID
// 15bit count
// 1 bit new flag
// 1 bit reserved
// 1 bit favorite flag
uint val = 0;
val |= (uint)(item.Index & 0x7FF);
val |= (uint)(item.Count & 0x3FF) << 15; // clamped to sane limit
@ -67,6 +68,8 @@ namespace PKHeX.Core
item.New |= OriginalItems.All(z => z.Index != item.Index);
if (item.New)
val |= 0x40000000;
if (item.FreeSpace)
val |= 0x80000000;
return val;
}
@ -86,6 +89,8 @@ namespace PKHeX.Core
{
return t switch
{
// TMs are clamped to 1, let TRs be whatever
InventoryType.TMHMs => 1130 <= item && item <= 1229 ? requestVal : 1,
_ => requestVal
};
}

View file

@ -26,7 +26,7 @@ namespace PKHeX.WinForms
itemlist[i] = $"(Item #{i:000})";
}
HasFreeSpace = SAV.Generation == 7 && !(SAV is SAV7b);
HasFreeSpace = SAV.Generation >= 7 && !(SAV is SAV7b);
HasNew = CHK_NEW.Visible = SAV.Generation == 7;
Pouches = SAV.Inventory;
CreateBagViews();
@ -84,7 +84,7 @@ namespace PKHeX.WinForms
dgv.Columns.Add(item);
dgv.Columns.Add(GetCountColumn(pouch, Main.HaX, ColumnCount = dgv.Columns.Count));
if (HasFreeSpace)
dgv.Columns.Add(GetFreeSpaceColumn(ColumnFreeSpace = dgv.Columns.Count));
dgv.Columns.Add(GetFreeSpaceColumn(ColumnFreeSpace = dgv.Columns.Count, SAV.Generation >= 8 ? "Fav" : "Free"));
if (HasNew)
dgv.Columns.Add(GetNewColumn(ColumnNEW = dgv.Columns.Count));
@ -122,11 +122,11 @@ namespace PKHeX.WinForms
};
}
private static DataGridViewComboBoxColumn GetItemColumn(int c)
private static DataGridViewComboBoxColumn GetItemColumn(int c, string name = "Item")
{
return new DataGridViewComboBoxColumn
{
HeaderText = "Item",
HeaderText = name,
DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing,
DisplayIndex = c,
Width = 135,
@ -134,11 +134,11 @@ namespace PKHeX.WinForms
};
}
private static DataGridViewColumn GetCountColumn(InventoryPouch pouch, bool HaX, int c)
private static DataGridViewColumn GetCountColumn(InventoryPouch pouch, bool HaX, int c, string name = "Count")
{
var dgvIndex = new DataGridViewTextBoxColumn
{
HeaderText = "Count",
HeaderText = name,
DisplayIndex = c,
Width = 45,
DefaultCellStyle = {Alignment = DataGridViewContentAlignment.MiddleCenter},
@ -148,22 +148,22 @@ namespace PKHeX.WinForms
return dgvIndex;
}
private static DataGridViewColumn GetFreeSpaceColumn(int c)
private static DataGridViewColumn GetFreeSpaceColumn(int c, string name = "Free")
{
return new DataGridViewCheckBoxColumn
{
HeaderText = "Free",
HeaderText = name,
DisplayIndex = c,
Width = 40,
FlatStyle = FlatStyle.Flat
};
}
private static DataGridViewColumn GetNewColumn(int c)
private static DataGridViewColumn GetNewColumn(int c, string name = "NEW")
{
return new DataGridViewCheckBoxColumn
{
HeaderText = "NEW",
HeaderText = name,
DisplayIndex = c,
Width = 40,
FlatStyle = FlatStyle.Flat
@ -263,9 +263,9 @@ namespace PKHeX.WinForms
NUD_Count.Value = Math.Max(1, pouch.MaxCount - 4);
}
private static int GetMax(ITrainerInfo sav, InventoryPouch pouch, bool haX)
private static int GetMax(ITrainerInfo sav, InventoryPouch pouch, bool HaX)
{
if (haX)
if (HaX)
return pouch.MaxCount;
// Cap at absolute maximum