Exemple #1
0
        public void AddItem(uint serial, ushort graphic, ushort hue, ushort amount, uint price, string name, bool fromcliloc)
        {
            ShopItem shopItem;

            _shopScrollArea.Add(shopItem = new ShopItem(serial, graphic, hue, amount, price, name)
            {
                X = 5,
                Y = 5,
                NameFromCliloc = fromcliloc
            });

            _shopScrollArea.Add(new ResizePicLine(0x39)
            {
                X     = 10,
                Width = 190
            });
            shopItem.MouseUp          += ShopItem_MouseClick;
            shopItem.MouseDoubleClick += ShopItem_MouseDoubleClick;
            _shopItems.Add(serial, shopItem);
            if (ProfileManager.Current.AutoSellItem)
            {
                if (ProfileManager.Current.SellList == null)
                {
                    ProfileManager.Current.SellList = new List <ushort[]>();
                }
                if (ProfileManager.Current.BuyList == null)
                {
                    ProfileManager.Current.BuyList = new List <ushort[]>();
                }
                List <ushort[]> list;
                if (IsBuyGump)
                {
                    list = ProfileManager.Current.BuyList;
                }
                else
                {
                    list = ProfileManager.Current.SellList;
                }
                foreach (ushort[] tosell in list)
                {
                    if (graphic == tosell[0])
                    {
                        int total = amount;
                        int have  = 0;
                        PlayerMobile.GetAmount(World.Player.Equipment[(int)Layer.Backpack], graphic, ref have);
                        int tohave = 0;
                        if (tosell.Length < 3)
                        {
                            tohave = ProfileManager.Current.AutoBuyAmount;
                        }
                        else
                        {
                            tohave = tosell[2];
                        }
                        if (IsBuyGump)
                        {
                            total = tohave - have;
                            if (total > amount)
                            {
                                total = amount;
                            }
                        }
                        if (total > 0)
                        {
                            if (_transactionItems.TryGetValue(shopItem.LocalSerial, out TransactionItem transactionItem))
                            {
                                transactionItem.Amount += total;
                            }
                            else
                            {
                                transactionItem = new TransactionItem(shopItem.LocalSerial, shopItem.Graphic, shopItem.Hue, total, shopItem.Price, shopItem.ShopItemName);
                                transactionItem.OnIncreaseButtomClicked += TransactionItem_OnIncreaseButtomClicked;
                                transactionItem.OnDecreaseButtomClicked += TransactionItem_OnDecreaseButtomClicked;
                                _transactionScrollArea.Add(transactionItem);
                                _transactionItems.Add(shopItem.LocalSerial, transactionItem);
                            }
                            shopItem.Amount -= total;
                            _updateTotal     = true;
                        }
                    }
                }
            }
        }