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 OnPocketSelectionChanged(object sender, SelectionChangedEventArgs e) { if (gameIndex != -2 && comboBoxPocket.SelectedItem != null) { pocket = PokeManager.GetGameSaveAt(gameIndex).Inventory.Items[(ItemTypes)((ComboBoxItem)comboBoxPocket.SelectedItem).Tag]; UpdateItemList(); } }
public async Task GetItemPocketResourceAsyncIntegrationTest() { // assemble PokeApiClient client = new PokeApiClient(); // act ItemPocket itemPocket = await client.GetResourceAsync <ItemPocket>(1); // assert Assert.True(itemPocket.Id != default(int)); }
// Constructor public ItemData(string ID, string baseID = null, string itemName = null, ItemPocket pocket = ItemPocket.None, ItemBattlePocket battlePocket = ItemBattlePocket.None, bool useBaseAesthetic = false, string displayID = null, string bagDisplayID = null, bool combineBaseTags = false, IEnumerable <ItemTag> tags = null, ItemEffect[] effects = null, bool combineBaseEffects = false, EffectDatabase.ItemEff.ItemEffect[] effectsNew = null) { this.ID = ID; this.baseID = baseID; this.itemName = itemName; this.pocket = pocket; this.battlePocket = battlePocket; this.useBaseAesthetic = useBaseAesthetic; this.displayID = displayID; this.bagDisplayID = bagDisplayID; this.combineBaseTags = combineBaseTags; this.tags = new HashSet <ItemTag>(); if (tags != null) { this.tags.UnionWith(tags); } this.effects = (effects == null) ? new ItemEffect[0] : new ItemEffect[effects.Length]; if (effects != null) { for (int i = 0; i < effects.Length; i++) { this.effects[i] = ItemEffect.Clone(effects[i]); } } this.combineBaseEffects = combineBaseEffects; this.effectsNew = new List <EffectDatabase.ItemEff.ItemEffect>(); if (effectsNew != null) { List <EffectDatabase.ItemEff.ItemEffect> addableEffects = new List <EffectDatabase.ItemEff.ItemEffect>(); for (int i = 0; i < effectsNew.Length; i++) { addableEffects.Add(effectsNew[i].Clone()); } this.effectsNew = addableEffects; } }
private void OnBallSelectionChanged(object sender, SelectionChangedEventArgs e) { selectedIndex = listViewBalls.SelectedIndex; if (selectedIndex != -1) { ItemPocket pocket = PokeManager.GetGameSaveAt(gameIndex).Inventory.Items[ItemTypes.PokeBalls]; selectedItem = pocket[selectedIndex]; } else { selectedItem = null; } }
private void OnPocketSelectionChanged(object sender, SelectionChangedEventArgs e) { if (!loaded) { return; } if (gameIndex != -2 && comboBoxPocket.SelectedIndex != -1) { IGameSave gameSave = PokeManager.GetGameSaveAt(gameIndex); pocket = gameSave.Inventory.Items[(ItemTypes)(comboBoxPocket.SelectedItem as ComboBoxItem).Tag]; UpdateItemList(); } }
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) ); } }
public List <Item> GetItemsByPocket(ItemPocket pocket) { List <Item> pocketItems = new List <Item>(); HashSet <string> accountedItems = new HashSet <string>(); for (int i = 0; i < items.Count; i++) { if (items[i].data.pocket == pocket && !accountedItems.Contains(items[i].itemID)) { pocketItems.Add(items[i]); } } return(pocketItems); }
private byte[] SaveItemPocket(ItemTypes pocketType) { ItemPocket pocket = inventory.Items[pocketType]; List <byte> data = new List <byte>(); data.AddRange(BitConverter.GetBytes(pocket.SlotsUsed)); for (int i = 0; i < pocket.SlotsUsed; i++) { data.AddRange(BitConverter.GetBytes(pocket[i].ID)); data.AddRange(BitConverter.GetBytes(pocket[i].Count)); } return(data.ToArray()); }
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); } } }
public void LoadPocket(ItemPocket pocket) { this.pocket = pocket; pocket.AddListViewItem += OnAddListViewItem; pocket.UpdateListViewItem += OnUpdateListViewItem; pocket.RemoveListViewItem += OnRemoveListViewItem; pocket.MoveListViewItem += OnMoveListViewItem; listViewItems.ItemsSource = pocket.ListViewItems; dropManager = new ListViewDragDropManager <ListViewItem>(listViewItems); dropManager.ProcessDrop += OnProcessDrop; UpdateDetails(); buySellInfo.UnloadBuySellInfo(); pocket.RepopulateListView(); gridSortButton.Visibility = (pocket.IsOrdered || pocket.PocketType == ItemTypes.KeyItems ? Visibility.Hidden : Visibility.Visible); }
private void SavePocket(ItemTypes pocketType, int index) { ItemPocket pocket = parent.Inventory.Items[pocketType]; uint pocketSize = pocket.TotalSlots; ushort securityKey = (ushort)(pocketType == ItemTypes.PC ? 0 : parent.UInt16SecurityKey); for (int i = 0; i < (int)pocketSize; i++) { if (i < (int)pocket.SlotsUsed) { LittleEndian.WriteUInt16(pocket[i].ID, raw, index + i * 4); LittleEndian.WriteUInt16((ushort)(pocket[i].Count ^ securityKey), raw, index + i * 4 + 2); } else { LittleEndian.WriteUInt16(0, raw, index + i * 4); LittleEndian.WriteUInt16(securityKey, raw, index + i * 4 + 2); } } }
private void SavePocket(ItemTypes pocketType, int index) { ItemPocket pocket = parent.Inventory.Items[pocketType]; uint pocketSize = pocket.TotalSlots; for (int i = 0; i < (int)pocketSize; i++) { if (i < (int)pocket.SlotsUsed) { ushort id = pocket[i].ID; if (gameSave.GameType == GameTypes.XD) { // Share Colognes and cologne case between games so make sure we use one of the game's ID's, We're using Colosseum's IDs if (id >= 542 && id <= 545) { id += 970; } // Two Key items that are shared between Colosseum and XD if (id == 501) { id += 1000; } if (id == 530) { id += 975; } // Because XD and Colosseum share the same item IDs with different items, XD items are 1000 higher. (I chose 1000 for easy reading) if (id >= 1500) { id -= 1000; } } BigEndian.WriteUInt16(id, raw, index + i * 4); BigEndian.WriteUInt16((ushort)pocket[i].Count, raw, index + i * 4 + 2); } else { BigEndian.WriteUInt32(0, raw, index + i * 4); } } }
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 SavePCPocket(int index) { ItemPocket pocket = parent.Inventory.Items[ItemTypes.PC]; uint pocketSize = pocket.TotalSlots; for (int i = 0; i < (int)pocketSize; i++) { if (i < (int)pocket.SlotsUsed) { ushort id = pocket[i].ID; // Because XD and Colosseum share the same item IDs with different items, XD items are 1000 higher. (I chose 1000 for easy reading) if (id >= 1500 && gameSave.GameType == GameTypes.XD) { id -= 1000; } BigEndian.WriteUInt16(id, raw, index + i * 4); BigEndian.WriteUInt16((ushort)pocket[i].Count, raw, index + i * 4 + 2); } else { BigEndian.WriteUInt32(0, raw, index + i * 4); } } }
private void UpdateItemList() { listViewItems.Items.Clear(); selectedIndex = -1; selectedItem = null; ItemPocket[] pockets = { pocket }; if (pocket.PocketType == ItemTypes.Items && pocket.Inventory.ContainsPocket(ItemTypes.InBattle)) { pockets = new ItemPocket[] { pocket.Inventory[ItemTypes.InBattle], pocket.Inventory[ItemTypes.Valuables], pocket.Inventory[ItemTypes.Misc], pocket.Inventory[ItemTypes.Hold] }; } foreach (ItemPocket itemPocket in pockets) { for (int i = 0; i < itemPocket.SlotsUsed; i++) { Item item = itemPocket[i]; bool isValid = false; foreach (ushort id in validItemIDs) { if (item.ID == id) { isValid = true; break; } } if (isValid) { ListViewItem listViewItem = new ListViewItem(); listViewItem.Tag = item; listViewItem.SnapsToDevicePixels = true; listViewItem.UseLayoutRounding = true; DockPanel dockPanel = new DockPanel(); dockPanel.Width = 170; Image image = new Image(); image.Width = 12; image.Height = 12; image.Source = ItemDatabase.GetItemImageFromID(item.ID); image.Stretch = Stretch.Uniform; image.SnapsToDevicePixels = true; image.UseLayoutRounding = true; image.HorizontalAlignment = HorizontalAlignment.Center; image.VerticalAlignment = VerticalAlignment.Center; TextBlock itemName = new TextBlock(); itemName.VerticalAlignment = VerticalAlignment.Center; itemName.Text = ItemDatabase.GetItemFromID(item.ID).Name; itemName.TextTrimming = TextTrimming.CharacterEllipsis; itemName.Margin = new Thickness(4, 0, 0, 0); TextBlock itemX = new TextBlock(); itemX.VerticalAlignment = VerticalAlignment.Center; itemX.HorizontalAlignment = HorizontalAlignment.Right; itemX.TextAlignment = TextAlignment.Right; itemX.Text = "x"; itemX.Width = Double.NaN; itemX.MinWidth = 10; TextBlock itemCount = new TextBlock(); itemCount.VerticalAlignment = VerticalAlignment.Center; itemCount.HorizontalAlignment = HorizontalAlignment.Right; itemCount.TextAlignment = TextAlignment.Right; itemCount.Width = 30; itemCount.Text = item.Count.ToString(); listViewItem.ToolTip = item.ItemData.Description; listViewItem.Content = dockPanel; listViewItems.Items.Add(listViewItem); dockPanel.Children.Add(image); dockPanel.Children.Add(itemName); if (!item.ItemData.IsImportant) { dockPanel.Children.Add(itemCount); dockPanel.Children.Add(itemX); DockPanel.SetDock(itemCount, Dock.Right); } DockPanel.SetDock(image, Dock.Left); } } } }
public void OnMoveListViewItem(object sender, ItemPocketEventArgs e) { ItemPocket pocket = sender as ItemPocket; pocket.ListViewItems.Move(e.OldIndex, e.NewIndex); }
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"); } } } }
private void OnGameSelectionChanged(object sender, SelectionChangedEventArgs e) { if (!loaded) { return; } gameIndex = comboBoxGame.SelectedGameIndex; ItemPocket pocket = PokeManager.GetGameSaveAt(gameIndex).Inventory.Items[ItemTypes.PokeBalls]; listViewBalls.Items.Clear(); selectedIndex = -1; selectedItem = null; for (int i = 0; i < pocket.SlotsUsed; i++) { Item item = pocket[i]; ListViewItem listViewItem = new ListViewItem(); listViewItem.SnapsToDevicePixels = true; listViewItem.UseLayoutRounding = true; DockPanel dockPanel = new DockPanel(); dockPanel.Width = 170; Image image = new Image(); image.Source = PokemonDatabase.GetBallCaughtImageFromID((byte)item.ID); image.Stretch = Stretch.None; image.SnapsToDevicePixels = true; image.UseLayoutRounding = true; image.HorizontalAlignment = HorizontalAlignment.Center; image.VerticalAlignment = VerticalAlignment.Center; TextBlock itemName = new TextBlock(); itemName.VerticalAlignment = VerticalAlignment.Center; itemName.Text = ItemDatabase.GetItemFromID(item.ID).Name; itemName.TextTrimming = TextTrimming.CharacterEllipsis; itemName.Margin = new Thickness(4, 0, 0, 0); TextBlock itemX = new TextBlock(); itemX.VerticalAlignment = VerticalAlignment.Center; itemX.HorizontalAlignment = HorizontalAlignment.Right; itemX.TextAlignment = TextAlignment.Right; itemX.Text = "x"; itemX.Width = Double.NaN; itemX.MinWidth = 10; TextBlock itemCount = new TextBlock(); itemCount.VerticalAlignment = VerticalAlignment.Center; itemCount.HorizontalAlignment = HorizontalAlignment.Right; itemCount.TextAlignment = TextAlignment.Right; itemCount.Width = 30; itemCount.Text = item.Count.ToString(); listViewItem.Content = dockPanel; listViewBalls.Items.Add(listViewItem); dockPanel.Children.Add(image); dockPanel.Children.Add(itemName); dockPanel.Children.Add(itemCount); dockPanel.Children.Add(itemX); DockPanel.SetDock(image, Dock.Left); DockPanel.SetDock(itemCount, Dock.Right); } }