public bool UpdateInventoryItem(int inventoryId, int itemId)
        {
            FieldInfo myPropInfo = typeof(GameOffsets).GetField($"INVENTORY_ITEM_ID_{inventoryId}");
            Offset    offset     = (Offset)myPropInfo.GetValue(GameItems.Instance);
            Item?     item       = GameItems.GetItemById(itemId);

            return(item.HasValue && WriteOffset(offset, item.Value.Id));
        }
Exemple #2
0
 private void SetupInventoryClicked()
 {
     foreach (var children in GridInventory.Children)
     {
         Border element = (Border)children;
         element.MouseLeftButtonUp += (sender, e) =>
         {
             int             inventoryId     = int.Parse(new Regex(@"\d+").Match(element.Name).Value);
             Item?           currentItem     = GameItems.GetItemById(_windWaker.GetInventoryItem(inventoryId));
             InventoryDialog inventoryDialog = new InventoryDialog(currentItem.HasValue ? currentItem.Value.Name : "")
             {
                 Owner = this
             };
             if (inventoryDialog.ShowDialog() == true)
             {
                 _windWaker.UpdateInventoryItem(inventoryId, inventoryDialog.GetResult().ItemId);
             }
         };
     }
 }
Exemple #3
0
        public InventoryDialog(string currentItem, int currentQuantity = -1, bool quantity = false)
        {
            InitializeComponent();

            LabelCurrentItem.Content = currentItem;

            ComboNewItem.SelectedValuePath = "Id";
            ComboNewItem.DisplayMemberPath = "Name";
            ComboNewItem.ItemsSource       = GameItems.GetAllItems();

            Item?matchingItem = GameItems.GetAllItems().FirstOrDefault(item => item.Name == currentItem);

            if (matchingItem.HasValue)
            {
                ComboNewItem.SelectedValue = matchingItem.Value.Id;
            }

            TxtQuantity.Text      = currentQuantity.ToString();
            LabelQuantity.Content = currentQuantity.ToString();

            PanelQuantity.Visibility = quantity ? Visibility.Visible : Visibility.Hidden;
        }