private void AddPCPocket(int index, uint pocketSize, uint maxStackSize, bool allowDuplicateStacks, bool ordered) { if (parent.Inventory.Items == null) { parent.Inventory.AddItemInventory(); } parent.Inventory.Items.AddPocket(ItemTypes.PC, pocketSize, maxStackSize, allowDuplicateStacks, ordered); ItemPocket pocket = parent.Inventory.Items[ItemTypes.PC]; for (int i = 0; i < (int)pocketSize; i++) { ushort id = BigEndian.ToUInt16(raw, index + i * 4); // Because XD and Colosseum share the same item IDs with different items, XD items are 1000 higher. (I chose 1000 for easy reading) // When we save the items we'll decrement their id again. if (id >= 500 && gameSave.GameType == GameTypes.XD) { id += 1000; } ushort count = BigEndian.ToUInt16(raw, index + i * 4 + 2); if (id != 0) { pocket.AddItem(id, count); } } }
private void LoadItemPocket(ItemTypes pocketType, byte[] data) { ItemPocket pocket = inventory.Items[pocketType]; uint count = LittleEndian.ToUInt32(data, 0); for (int i = 0; i < (int)count; i++) { pocket.AddItem( LittleEndian.ToUInt16(data, 4 + i * 6), LittleEndian.ToUInt32(data, 4 + i * 6 + 2) ); } }
private void AddPocket(ItemTypes pocketType, int index, uint pocketSize, uint maxStackSize, bool allowDuplicateStacks, bool ordered) { parent.Inventory.Items.AddPocket(pocketType, pocketSize, maxStackSize, allowDuplicateStacks, ordered); ItemPocket pocket = parent.Inventory.Items[pocketType]; ushort securityKey = (ushort)(pocketType == ItemTypes.PC ? 0 : parent.UInt16SecurityKey); for (int i = 0; i < (int)pocketSize; i++) { ushort id = LittleEndian.ToUInt16(raw, index + i * 4); ushort count = (ushort)((uint)LittleEndian.ToUInt16(raw, index + i * 4 + 2) ^ securityKey); if (id != 0) { pocket.AddItem(id, count); } } }
private void AddPocket(ItemTypes pocketType, int index, uint pocketSize, uint maxStackSize, bool allowDuplicateStacks, bool ordered) { parent.Inventory.Items.AddPocket(pocketType, pocketSize, maxStackSize, allowDuplicateStacks, ordered); ItemPocket pocket = parent.Inventory.Items[pocketType]; for (int i = 0; i < (int)pocketSize; i++) { ushort id = BigEndian.ToUInt16(raw, index + i * 4); if (gameSave.GameType == GameTypes.XD) { // Because XD and Colosseum share the same item IDs with different items, XD items are 1000 higher. (I chose 1000 for easy reading) // When we save the items we'll decrement their id again. if (id >= 500) { id += 1000; } // Share Colognes amd cologne case between games so make sure we use one of the game's ID's, We're using Colosseum's IDs if (id >= 1512 && id <= 1515) { id -= 970; } // Two Key items that are shared between Colosseum and XD if (id == 1501) { id -= 1000; } if (id == 1505) { id -= 975; } } ushort count = BigEndian.ToUInt16(raw, index + i * 4 + 2); if (id != 0) { pocket.AddItem(id, count); } } }
private void OnSendTo(object sender, EventArgs e) { if (HasSelection) { if (selectionIsImportant == 1) { foreach (Item item in SelectedItems) { ItemPocket pocket = PokeManager.ManagerGameSave.Inventory.Items[item.ItemData.PocketType]; if (pocket.GetCountOfID(item.ID) == 0) { pocket.AddItem(item.ID, 1); } } } else { var results = AdvancedSendSelectionToWindow.ShowDialog(Window.GetWindow(this), pocket.GameSave.GameIndex, selectionMax, "Send Item Selection", SelectedItems[0].ItemData.PocketType, false, selectionExclusives); if (results != null) { bool noRoom = false; foreach (Item item in SelectedItems) { int finalCount = results.GetFinalCount(item.Count); if (finalCount > 0) { if (PokeManager.GetGameSaveAt(results.GameIndex).Inventory.Items[results.Pocket].HasRoomForItem(item.ID, (uint)finalCount)) { PokeManager.GetGameSaveAt(results.GameIndex).Inventory.Items[results.Pocket].AddItem(item.ID, (uint)finalCount); pocket.TossItemAt(pocket.IndexOf(item), (uint)finalCount); } else { noRoom = true; } } } if (noRoom) { TriggerMessageBox.Show(Window.GetWindow(this), "The pocket filled up before all of the selection could be sent", "No Room"); } } } } else if (selectedItem.ItemData.IsImportant) { ItemPocket pocket = PokeManager.ManagerGameSave.Inventory.Items[selectedItem.ItemData.PocketType]; if (pocket.GetCountOfID(selectedItem.ID) == 0) { pocket.AddItem(selectedItem.ID, 1); } } else { var results = AdvancedSendSingleToWindow.ShowDialog(Window.GetWindow(this), pocket.GameSave.GameIndex, (int)selectedItem.Count, "Send Item", selectedItem.ItemData.PocketType, false, selectedItem.ItemData.Exclusives); //SendItemToResult result = SendItemToWindow.ShowDialog(Window.GetWindow(this), pocket.Inventory.GameIndex, selectedItem.ID, selectedItem.Count); if (results != null) { if (PokeManager.GetGameSaveAt(results.GameIndex).Inventory.Items[results.Pocket].HasRoomForItem(selectedItem.ID, (uint)results.Count)) { PokeManager.GetGameSaveAt(results.GameIndex).Inventory.Items[results.Pocket].AddItem(selectedItem.ID, (uint)results.Count); pocket.TossItemAt(selectedIndex, (uint)results.Count); } else { // No room for item TriggerMessageBox.Show(Window.GetWindow(this), "No room for that item", "No Room"); } } } }