Exemple #1
0
        public WndItem(WndBag owner, Item item)
        {
            var titlebar = new IconTitle();

            titlebar.Icon(new ItemSprite(item.image, item.Glowing()));
            titlebar.Label(Utils.Capitalize(item.ToString()));
            titlebar.SetRect(0, 0, WIDTH, 0);
            Add(titlebar);

            if (item.levelKnown && item.level > 0)
            {
                titlebar.Color(ItemSlot.Upgraded);
            }
            else
            if (item.levelKnown && item.level < 0)
            {
                titlebar.Color(ItemSlot.Degraded);
            }

            var info = PixelScene.CreateMultiline(item.Info(), 6);

            info.MaxWidth = WIDTH;
            info.Measure();
            info.X = titlebar.Left();
            info.Y = titlebar.Bottom() + Gap;
            Add(info);

            var   y = info.Y + info.Height + Gap;
            float x = 0;

            if (Dungeon.Hero.IsAlive && owner != null)
            {
                foreach (var action in item.Actions(Dungeon.Hero))
                {
                    var btn = new RedButton(action);
                    btn.ClickAction = button =>
                    {
                        item.Execute(Dungeon.Hero, action);
                        Hide();
                        owner.Hide();
                    };
                    btn.SetSize(Math.Max(ButtonWidth, btn.ReqWidth()), ButtonHeight);
                    if (x + btn.Width > WIDTH)
                    {
                        x  = 0;
                        y += ButtonHeight + Gap;
                    }
                    btn.SetPos(x, y);
                    Add(btn);

                    x += btn.Width + Gap;
                }
            }

            Resize(WIDTH, (int)(y + (x > 0 ? ButtonHeight : 0)));
        }
Exemple #2
0
            public ItemButton(WndBag owner, Item item)
                : base(item)
            {
                _owner = owner;
                _item  = item;

                if (item is Gold)
                {
                    bg.Visible = false;
                }

                _Width = _Height = SLOT_SIZE;
            }
Exemple #3
0
        public WndTradeItem(Shopkeeper keeper, Item item, WndBag owner)
        {
            _keeper = keeper;
            _item   = item;
            _owner  = owner;

            var pos = CreateDescription(item, false);

            if (item.Quantity() == 1)
            {
                var btnSell = new RedButton(Utils.Format(TxtSell, item.Price()));
                btnSell.ClickAction = SellAction;
                btnSell.SetRect(0, pos + Gap, WIDTH, BtnHeight);
                Add(btnSell);

                pos = btnSell.Bottom();
            }
            else
            {
                var priceAll = item.Price();
                var btnSell1 = new RedButton(Utils.Format(TxtSell1, priceAll / item.Quantity()));
                btnSell1.ClickAction = SellOneAction;
                btnSell1.SetRect(0, pos + Gap, WIDTH, BtnHeight);
                Add(btnSell1);

                var btnSellAll = new RedButton(Utils.Format(TxtSellAll, priceAll));
                btnSellAll.ClickAction = SellAction;
                btnSellAll.SetRect(0, btnSell1.Bottom() + Gap, WIDTH, BtnHeight);
                Add(btnSellAll);

                pos = btnSellAll.Bottom();
            }

            var btnCancel = new RedButton(TxtCancel);

            btnCancel.ClickAction = CancelAction;
            btnCancel.SetRect(0, pos + Gap, WIDTH, BtnHeight);
            Add(btnCancel);

            Resize(WIDTH, (int)btnCancel.Bottom());
        }