public static Inventory <T> CreateGenericInventory() { // One non-specific pouch var pouch = new InventoryPouch <T>(ItemPouchType.FreeSpace); return(new Inventory <T>(pouch)); }
private DataGridView GetDGV(InventoryPouch pouch) { // Add DataGrid var dgv = GetBaseDataGrid(pouch); // Get Columns var item = GetItemColumn(ColumnItem = dgv.Columns.Count); 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)); } if (HasNew) { dgv.Columns.Add(GetNewColumn(ColumnNEW = dgv.Columns.Count)); } // Populate with rows var itemarr = Main.HaX ? itemlist : GetStringsForPouch(pouch.LegalItems); item.Items.AddRange(itemarr); dgv.Rows.Add(pouch.Items.Length); dgv.CancelEdit(); return(dgv); }
private static EncounterCount ReadCounts(InventoryPouch pouch) { var counts = new EncounterCount(); foreach (var ball in pouch.Items) { counts.SetCount(ball.Index, ball.Count); } return(counts); }
private BallPouchUtil ReadCounts(InventoryPouch pouch) { var counts = new BallPouchUtil(); foreach (var ball in pouch.Items) { counts.SetCount(ball.Index, ball.Count); } return(counts); }
private static FossilCount ReadCounts(InventoryPouch pouch) { var counts = new FossilCount(); foreach (var item in pouch.Items) { counts.SetCount(item.Index, item.Count); } return(counts); }
private void getBag(DataGridView dgv, InventoryPouch pouch) { for (int i = 0; i < dgv.Rows.Count; i++) { int c = 0; dgv.Rows[i].Cells[c++].Value = itemlist[pouch.Items[i].Index]; dgv.Rows[i].Cells[c++].Value = pouch.Items[i].Count; if (HasFreeSpace) dgv.Rows[i].Cells[c++].Value = pouch.Items[i].FreeSpace; if (HasNew) dgv.Rows[i].Cells[c].Value = pouch.Items[i].New; } }
private void setBag(DataGridView dgv, InventoryPouch pouch) { int ctr = 0; for (int i = 0; i < dgv.Rows.Count; i++) { int c = 0; string item = dgv.Rows[i].Cells[c++].Value.ToString(); int itemindex = Array.IndexOf(itemlist, item); if (itemindex <= 0) // Compression of Empty Slots { continue; } int itemcnt; int.TryParse(dgv.Rows[i].Cells[c++].Value?.ToString(), out itemcnt); if (itemcnt > pouch.MaxCount) { if (itemindex == 797 && itemcnt >= 2) // Edge case when for some reason the item count for Z-Ring was 2 in an unedited save and set 1 after using PKHeX { itemcnt = 2; } else { itemcnt = pouch.MaxCount; // Cap at pouch maximum } } else if (itemcnt <= 0) { continue; // ignore item } pouch.Items[ctr] = new InventoryItem { Index = itemindex, Count = itemcnt }; if (HasFreeSpace) { pouch.Items[ctr].FreeSpace = (bool)dgv.Rows[i].Cells[c++].Value; } if (HasNew) { pouch.Items[ctr].New = (bool)dgv.Rows[i].Cells[c].Value; } ctr++; } for (int i = ctr; i < pouch.Items.Length; i++) { pouch.Items[i] = new InventoryItem(); // Empty Slots at the end } }
private static DataGridViewColumn GetCountColumn(InventoryPouch pouch, bool HaX, int c) { var dgvIndex = new DataGridViewTextBoxColumn { HeaderText = "Count", DisplayIndex = c, Width = 45, DefaultCellStyle = { Alignment = DataGridViewContentAlignment.MiddleCenter }, }; if (!HaX) { dgvIndex.MaxInputLength = (int)(Math.Log10(Math.Max(1, pouch.MaxCount)) + 1); } return(dgvIndex); }
private void GetBag(DataGridView dgv, InventoryPouch pouch) { for (int i = 0; i < dgv.Rows.Count; i++) { var cells = dgv.Rows[i].Cells; cells[ColumnItem].Value = itemlist[pouch.Items[i].Index]; cells[ColumnCount].Value = pouch.Items[i].Count; if (HasFreeSpace) { cells[ColumnFreeSpace].Value = pouch.Items[i].FreeSpace; } if (HasNew) { cells[ColumnNEW].Value = pouch.Items[i].New; } } }
private void SetBag(DataGridView dgv, InventoryPouch pouch) { int ctr = 0; for (int i = 0; i < dgv.Rows.Count; i++) { var cells = dgv.Rows[i].Cells; var str = cells[ColumnItem].Value.ToString(); var itemindex = Array.IndexOf(itemlist, str); if (itemindex <= 0 && !HasNew) // Compression of Empty Slots { continue; } bool result = int.TryParse(cells[ColumnCount].Value?.ToString(), out int itemcnt); if (!result) { continue; } if (!pouch.IsValidItemAndCount(SAV, itemindex, HasNew, Main.HaX, ref itemcnt)) { continue; // ignore item } // create clean item data when saving var obj = new InventoryItem { Index = itemindex, Count = itemcnt }; if (HasFreeSpace) { obj.FreeSpace = (bool)cells[ColumnFreeSpace].Value; } if (HasNew) { obj.New = (bool)cells[ColumnNEW].Value; } pouch.Items[ctr] = obj; ctr++; } for (int i = ctr; i < pouch.Items.Length; i++) { pouch.Items[i] = new InventoryItem(); // Empty Slots at the end } }
private static int GetMax(ITrainerInfo sav, InventoryPouch pouch, bool haX) { if (haX) { return(pouch.MaxCount); } // Cap at absolute maximum if (sav.Generation <= 2) { return(byte.MaxValue); } if (sav.Generation >= 7) { return(pouch.MaxCount); } // if (SAV.Generation >= 3) return(ushort.MaxValue); }
private void setBag(DataGridView dgv, InventoryPouch pouch) { int ctr = 0; for (int i = 0; i < dgv.Rows.Count; i++) { int c = 0; string item = dgv.Rows[i].Cells[c++].Value.ToString(); int itemindex = Array.IndexOf(itemlist, item); if (itemindex <= 0) // Compression of Empty Slots continue; int itemcnt; int.TryParse(dgv.Rows[i].Cells[c++].Value?.ToString(), out itemcnt); if (Main.HaX && SAV.Generation != 7) // Gen7 has true cap at 1023, keep 999 cap. { // Cap at absolute maximum if (SAV.Generation <= 2 && itemcnt > byte.MaxValue) itemcnt = byte.MaxValue; else if (SAV.Generation >= 3 && itemcnt > ushort.MaxValue) itemcnt = ushort.MaxValue; } else if (itemcnt > pouch.MaxCount) { if (itemindex == 797 && itemcnt >= 2) // Edge case when for some reason the item count for Z-Ring was 2 in an unedited save and set 1 after using PKHeX itemcnt = 2; else itemcnt = pouch.MaxCount; // Cap at pouch maximum } else if (itemcnt <= 0) continue; // ignore item pouch.Items[ctr] = new InventoryItem { Index = itemindex, Count = itemcnt }; if (HasFreeSpace) pouch.Items[ctr].FreeSpace = (bool)dgv.Rows[i].Cells[c++].Value; if (HasNew) pouch.Items[ctr].New = (bool)dgv.Rows[i].Cells[c].Value; ctr++; } for (int i = ctr; i < pouch.Items.Length; i++) pouch.Items[i] = new InventoryItem(); // Empty Slots at the end }
private static DataGridView GetBaseDataGrid(InventoryPouch pouch) { return(new DataGridView { Dock = DockStyle.Fill, Text = pouch.Type.ToString(), Name = "DGV_" + pouch.Type, AllowUserToAddRows = false, AllowUserToDeleteRows = false, AllowUserToResizeRows = false, AllowUserToResizeColumns = false, RowHeadersVisible = false, MultiSelect = false, ShowEditingIcon = false, EditMode = DataGridViewEditMode.EditOnEnter, ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single, ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize, SelectionMode = DataGridViewSelectionMode.CellSelect, CellBorderStyle = DataGridViewCellBorderStyle.None, }); }
private static bool GetModifySettings(InventoryPouch pouch, out bool truncate, out bool shuffle) { truncate = false; shuffle = false; if (!pouch.IsCramped) { return(true); } var dr = WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgItemPouchSizeSmall, string.Format(MsgItemPouchRandom, Environment.NewLine)); if (dr == DialogResult.Cancel) { return(false); } truncate = true; if (dr == DialogResult.No) { shuffle = true; } return(true); }
private DataGridView GetDGV(InventoryPouch pouch) { // Add DataGrid DataGridView dgv = new DataGridView { Dock = DockStyle.Fill, Text = pouch.Type.ToString(), Name = DGVPrefix + pouch.Type, AllowUserToAddRows = false, AllowUserToDeleteRows = false, AllowUserToResizeRows = false, AllowUserToResizeColumns = false, RowHeadersVisible = false, //ColumnHeadersVisible = false, MultiSelect = false, ShowEditingIcon = false, EditMode = DataGridViewEditMode.EditOnEnter, ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single, ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize, SelectionMode = DataGridViewSelectionMode.CellSelect, CellBorderStyle = DataGridViewCellBorderStyle.None, }; int c = 0; DataGridViewComboBoxColumn dgvItemVal = new DataGridViewComboBoxColumn { HeaderText = "Item", DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing, DisplayIndex = c++, Width = 135, FlatStyle = FlatStyle.Flat }; DataGridViewColumn dgvIndex = new DataGridViewTextBoxColumn(); { dgvIndex.HeaderText = "Count"; dgvIndex.DisplayIndex = c++; dgvIndex.Width = 45; dgvIndex.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; if (!Main.HaX) { ((DataGridViewTextBoxColumn)dgvIndex).MaxInputLength = (int)(Math.Log10(Math.Max(1, pouch.MaxCount)) + 1); } } dgv.Columns.Add(dgvItemVal); dgv.Columns.Add(dgvIndex); if (HasFreeSpace) { DataGridViewCheckBoxColumn dgvFree = new DataGridViewCheckBoxColumn { HeaderText = "Free", DisplayIndex = c++, Width = 40, FlatStyle = FlatStyle.Flat }; dgv.Columns.Add(dgvFree); } if (HasNew) { DataGridViewCheckBoxColumn dgvNew = new DataGridViewCheckBoxColumn { HeaderText = "NEW", DisplayIndex = c++, Width = 40, FlatStyle = FlatStyle.Flat }; dgv.Columns.Add(dgvNew); } var itemcount = pouch.Items.Length; string[] itemarr = Main.HaX ? (string[])itemlist.Clone() : GetItems(pouch.LegalItems); var combo = dgv.Columns[0] as DataGridViewComboBoxColumn; foreach (string t in itemarr) { combo.Items.Add(t); // add only the Item Names } dgv.Rows.Add(itemcount > 0 ? itemcount : itemarr.Length); dgv.CancelEdit(); return(dgv); }
public bool TryGetPouch(ItemType item, out InventoryPouch <T> pouch) { ItemPouchType pt = ItemData.GetPouchType(item); return(_pouches.TryGetValue(pt, out pouch)); }
public bool TryGetValue(ItemPouchType key, out InventoryPouch <T> value) { return(_pouches.TryGetValue(key, out value)); }