Esempio n. 1
0
        public ShopGump(uint serial, bool isBuyGump, int x, int y) : base
                (serial, 0) //60 is the base height, original size
        {
            int height = ProfileManager.CurrentProfile.VendorGumpHeight;

            if (_shopGumpParts == null)
            {
                GenerateVirtualTextures();
            }

            X = x;
            Y = y;
            AcceptMouseInput       = false;
            AcceptKeyboardInput    = true;
            CanMove                = true;
            CanCloseWithRightClick = true;
            IsBuyGump              = isBuyGump;

            _transactionItems = new Dictionary <uint, TransactionItem>();
            _shopItems        = new Dictionary <uint, ShopItem>();
            _updateTotal      = false;

            int add = isBuyGump ? 0 : 6;

            GumpPicTexture pic = new GumpPicTexture(0, 0, _shopGumpParts[0 + add]);

            Add(pic);

            pic = new GumpPicTexture(250, 144, _shopGumpParts[3 + add]);
            Add(pic);


            _middleGumpLeft = new GumpPicTexture(0, 64, _shopGumpParts[1 + add], true)
            {
                Width  = pic.Width,
                Height = height
            };

            Add(_middleGumpLeft);

            GumpPicTexture left_down = new GumpPicTexture
                                           (0, _middleGumpLeft.Height + _middleGumpLeft.Y, _shopGumpParts[2 + add]);

            Add(left_down);

            _shopScrollArea = new ScrollArea
                              (
                30, 60, 225, _middleGumpLeft.Height + _middleGumpLeft.Y + 50, false,
                _middleGumpLeft.Height + _middleGumpLeft.Y
                              );

            Add(_shopScrollArea);


            _middleGumpRight = new GumpPicTexture(250, 144 + 64, _shopGumpParts[4 + add], true)
            {
                Width  = pic.Width,
                Height = _middleGumpLeft.Height >> 1
            };

            Add(_middleGumpRight);


            GumpPicTexture right_down = new GumpPicTexture
                                            (250, _middleGumpRight.Height + _middleGumpRight.Y, _shopGumpParts[5 + add]);

            Add(right_down);


            HitBox boxAccept = new HitBox(280, 306 + _middleGumpRight.Height, 34, 30)
            {
                Alpha = 1
            };

            HitBox boxClear = new HitBox(452, 310 + _middleGumpRight.Height, 24, 24)
            {
                Alpha = 1
            };

            boxAccept.MouseUp += (sender, e) => { OnButtonClick((int)Buttons.Accept); };
            boxClear.MouseUp  += (sender, e) => { OnButtonClick((int)Buttons.Clear); };
            Add(boxAccept);
            Add(boxClear);


            if (isBuyGump)
            {
                Add
                (
                    _totalLabel = new Label("0", true, 0x0386, 0, 1)
                {
                    X = 318,
                    Y = 281 + _middleGumpRight.Height
                }
                );

                Add
                (
                    _playerGoldLabel = new Label(World.Player.Gold.ToString(), true, 0x0386, 0, 1)
                {
                    X = 436,
                    Y = 281 + _middleGumpRight.Height
                }
                );
            }
            else
            {
                Add
                (
                    _totalLabel = new Label("0", true, 0x0386, 0, 1)
                {
                    X = 436,
                    Y = 281 + _middleGumpRight.Height
                }
                );
            }

            Label name = new Label(World.Player.Name, false, 0x0386, font: 5)
            {
                X = 322,
                Y = 308 + _middleGumpRight.Height
            };

            Add(name);

            Add(_transactionScrollArea = new ScrollArea(260, 215, 245, 53 + _middleGumpRight.Height, false));

            _transactionDataBox = new DataBox(0, 0, 1, 1);
            _transactionDataBox.WantUpdateSize = true;

            _transactionScrollArea.Add(_transactionDataBox);

            HitBox upButton = new HitBox(233, 50, 18, 16)
            {
                Alpha = 1
            };

            upButton.MouseDown += (sender, e) => { _isUpDOWN = true; };
            upButton.MouseUp   += (sender, e) => { _isUpDOWN = false; };

            Add(upButton);

            HitBox downButton = new HitBox(233, 130 + _middleGumpLeft.Height, 18, 16)
            {
                Alpha = 1
            };

            downButton.MouseDown += (sender, e) => { _isDownDOWN = true; };
            downButton.MouseUp   += (sender, e) => { _isDownDOWN = false; };
            Add(downButton);


            HitBox upButtonT = new HitBox(483, 195, 18, 16)
            {
                Alpha = 1
            };

            upButtonT.MouseDown += (sender, e) => { _isUpDOWN_T = true; };
            upButtonT.MouseUp   += (sender, e) => { _isUpDOWN_T = false; };

            Add(upButtonT);

            HitBox downButtonT = new HitBox(483, 270 + _middleGumpRight.Height, 18, 16)
            {
                Alpha = 1
            };

            downButtonT.MouseDown += (sender, e) => { _isDownDOWN_T = true; };
            downButtonT.MouseUp   += (sender, e) => { _isDownDOWN_T = false; };
            Add(downButtonT);


            Add
            (
                _button_expander = new Button(2, 0x082E, 0x82F)
            {
                ButtonAction = ButtonAction.Activate,
                X            = _shopGumpParts[0 + add].Width / 2 - 10,
                Y            = left_down.Y + left_down.Height
            }
            );

            bool is_pressing    = false;
            int  initial_Y      = 0;
            int  initial_height = 0;

            _button_expander.MouseDown += (sender, args) =>
            {
                is_pressing    = true;
                initial_Y      = Mouse.Position.Y;
                initial_height = _middleGumpLeft.Height;
            };

            _button_expander.MouseUp += (sender, args) => { is_pressing = false; };

            _button_expander.MouseOver += (sender, args) =>
            {
                if (is_pressing && Mouse.Position.Y != initial_Y)
                {
                    _middleGumpLeft.Height = initial_height + (Mouse.Position.Y - initial_Y);

                    if (_middleGumpLeft.Height < 60)
                    {
                        _middleGumpLeft.Height = 60;
                    }
                    else if (_middleGumpLeft.Height > 450)
                    {
                        _middleGumpLeft.Height = 450;
                    }

                    ProfileManager.CurrentProfile.VendorGumpHeight = _middleGumpLeft.Height;

                    _middleGumpRight.Height = _middleGumpLeft.Height >> 1;

                    left_down.Y  = _middleGumpLeft.Y + _middleGumpLeft.Height;
                    right_down.Y = _middleGumpRight.Y + _middleGumpRight.Height;
                    boxAccept.Y  = 306 + _middleGumpRight.Height;
                    boxClear.Y   = 310 + _middleGumpRight.Height;
                    _transactionDataBox.Height      = _transactionScrollArea.Height = _middleGumpRight.Height + 53;
                    _shopScrollArea.Height          = left_down.Y + 50;
                    _shopScrollArea.ScrollMaxHeight = left_down.Y;
                    _button_expander.Y = left_down.Y + left_down.Height;
                    downButton.Y       = 130 + _middleGumpLeft.Height;
                    downButtonT.Y      = 270 + _middleGumpRight.Height;
                    name.Y             = 308 + _middleGumpRight.Height;
                    _totalLabel.Y      = 281 + _middleGumpRight.Height;

                    if (_playerGoldLabel != null)
                    {
                        _playerGoldLabel.Y = 281 + _middleGumpRight.Height;
                    }

                    WantUpdateSize = true;
                }
            };
        }
Esempio n. 2
0
        public ShopGump(uint serial, bool isBuyGump, int x, int y) : base(serial, 0) //60 is the base height, original size
        {
            int height = ProfileManager.CurrentProfile.VendorGumpHeight;

            X = x;
            Y = y;
            AcceptMouseInput       = false;
            AcceptKeyboardInput    = true;
            CanMove                = true;
            CanCloseWithRightClick = true;
            IsBuyGump              = isBuyGump;

            _transactionItems = new Dictionary <uint, TransactionItem>();
            _shopItems        = new Dictionary <uint, ShopItem>();
            _updateTotal      = false;

            WantUpdateSize = true;

            const ushort BUY_GRAPHIC_LEFT   = 0x0870;
            const ushort BUY_GRAPHIC_RIGHT  = 0x0871;
            const ushort SELL_GRAPHIC_LEFT  = 0x0872;
            const ushort SELL_GRAPHIC_RIGHT = 0x0873;


            ushort graphicLeft  = isBuyGump ? BUY_GRAPHIC_LEFT : SELL_GRAPHIC_LEFT;
            ushort graphicRight = isBuyGump ? BUY_GRAPHIC_RIGHT : SELL_GRAPHIC_RIGHT;

            _ = GumpsLoader.Instance.GetGumpTexture(graphicLeft, out var boundsLeft);
            _ = GumpsLoader.Instance.GetGumpTexture(graphicRight, out var boundsRight);



            const int LEFT_TOP_HEIGHT    = 64;
            const int LEFT_BOTTOM_HEIGHT = 116;

            Rectangle      offset  = new Rectangle(0, 0, boundsLeft.Width, LEFT_TOP_HEIGHT);
            GumpPicTexture leftTop = new GumpPicTexture(graphicLeft, 0, 0, offset, false);

            Add(leftTop);



            offset.Y     += LEFT_TOP_HEIGHT;
            offset.Height = boundsLeft.Height - (LEFT_BOTTOM_HEIGHT + LEFT_TOP_HEIGHT);
            GumpPicTexture leftmiddle = new GumpPicTexture(graphicLeft, 0, LEFT_TOP_HEIGHT, offset, true);
            int            diff       = height - leftmiddle.Height;

            leftmiddle.Height = height;
            Add(leftmiddle);


            offset.Y     += offset.Height;
            offset.Height = LEFT_BOTTOM_HEIGHT;
            GumpPicTexture leftBottom = new GumpPicTexture(graphicLeft, 0, leftmiddle.Y + leftmiddle.Height, offset, false);

            Add(leftBottom);



            const int RIGHT_OFFSET        = 32;
            const int RIGHT_BOTTOM_HEIGHT = 93;

            int rightX = boundsLeft.Width - RIGHT_OFFSET;
            int rightY = boundsLeft.Height / 2 - RIGHT_OFFSET;

            offset = new Rectangle(0, 0, boundsRight.Width, LEFT_TOP_HEIGHT);
            GumpPicTexture rightTop = new GumpPicTexture(graphicRight, rightX, rightY, offset, false);

            Add(rightTop);


            offset.Y     += LEFT_TOP_HEIGHT;
            offset.Height = boundsRight.Height - (RIGHT_BOTTOM_HEIGHT + LEFT_TOP_HEIGHT);
            GumpPicTexture rightMiddle = new GumpPicTexture(graphicRight, rightX, rightY + LEFT_TOP_HEIGHT, offset, true);

            rightMiddle.Height += diff;
            Add(rightMiddle);


            offset.Y     += offset.Height;
            offset.Height = RIGHT_BOTTOM_HEIGHT;
            GumpPicTexture rightBottom = new GumpPicTexture(graphicRight, rightX, rightMiddle.Y + rightMiddle.Height, offset, false);

            Add(rightBottom);



            _shopScrollArea = new ScrollArea
                              (
                RIGHT_OFFSET,
                leftmiddle.Y,
                boundsLeft.Width - RIGHT_OFFSET * 2 + 5,
                leftmiddle.Height + 50,
                false,
                leftmiddle.Height
                              );

            Add(_shopScrollArea);


            _transactionScrollArea = new ScrollArea
                                     (
                RIGHT_OFFSET / 2 + rightTop.X,
                LEFT_TOP_HEIGHT + rightTop.Y,
                boundsRight.Width - RIGHT_OFFSET * 2 + RIGHT_OFFSET / 2 + 5,
                rightMiddle.Height,
                false
                                     );

            Add(_transactionScrollArea);

            _transactionDataBox = new DataBox(0, 0, 1, 1);
            _transactionDataBox.WantUpdateSize = true;
            _transactionScrollArea.Add(_transactionDataBox);


            _totalLabel = new Label("0", true, 0x0386, 0, 1)
            {
                X = RIGHT_OFFSET + rightTop.X + 32 + 4,
                Y = rightBottom.Y + rightBottom.Height - 32 * 3 + 15,
            };

            Add(_totalLabel);

            if (isBuyGump)
            {
                _playerGoldLabel = new Label
                                   (
                    World.Player.Gold.ToString(),
                    true,
                    0x0386,
                    0,
                    1
                                   )
                {
                    X = _totalLabel.X + 120,
                    Y = _totalLabel.Y
                };

                Add(_playerGoldLabel);
            }
            else
            {
                _totalLabel.X = (rightTop.X + rightTop.Width) - RIGHT_OFFSET * 3;
            }



            Button expander = new Button(2, 0x082E, 0x82F)
            {
                ButtonAction = ButtonAction.Activate,
                X            = boundsLeft.Width / 2 - 10,
                Y            = leftBottom.Y + leftBottom.Height - 5
            };

            Add(expander);


            const float ALPHA_HIT_BUTTON = 0f;

            HitBox accept = new HitBox(RIGHT_OFFSET + rightTop.X, (rightBottom.Y + rightBottom.Height) - 50, 34, 30, "Accept", ALPHA_HIT_BUTTON);
            HitBox clear  = new HitBox(accept.X + 175, accept.Y, 20, 20, "Clear", ALPHA_HIT_BUTTON);

            accept.MouseUp += (sender, e) => { OnButtonClick((int)Buttons.Accept); };
            clear.MouseUp  += (sender, e) => { OnButtonClick((int)Buttons.Clear); };
            Add(accept);
            Add(clear);



            HitBox leftUp   = new HitBox((leftTop.X + leftTop.Width) - 50, (leftTop.Y + leftTop.Height) - 18, 18, 16, "Scroll Up", ALPHA_HIT_BUTTON);
            HitBox leftDown = new HitBox(leftUp.X, leftBottom.Y, 18, 16, "Scroll Down", ALPHA_HIT_BUTTON);

            HitBox rightUp   = new HitBox((rightTop.X + rightTop.Width - 50), (rightTop.Y + rightTop.Height) - 18, 18, 16, "Scroll Up", ALPHA_HIT_BUTTON);
            HitBox rightDown = new HitBox(rightUp.X, rightBottom.Y, 18, 16, "Scroll Down", ALPHA_HIT_BUTTON);

            leftUp.MouseUp      += ButtonMouseUp;
            leftDown.MouseUp    += ButtonMouseUp;
            rightUp.MouseUp     += ButtonMouseUp;
            rightDown.MouseUp   += ButtonMouseUp;
            leftUp.MouseDown    += (sender, e) => { _buttonScroll = ButtonScroll.LeftScrollUp; };
            leftDown.MouseDown  += (sender, e) => { _buttonScroll = ButtonScroll.LeftScrollDown; };
            rightUp.MouseDown   += (sender, e) => { _buttonScroll = ButtonScroll.RightScrollUp; };
            rightDown.MouseDown += (sender, e) => { _buttonScroll = ButtonScroll.RightScrollUp; };
            Add(leftUp);
            Add(leftDown);
            Add(rightUp);
            Add(rightDown);



            bool is_pressing = false;
            int  initial_height = 0, initialHeightRight = 0;
            int  minHeight      = boundsLeft.Height - (LEFT_BOTTOM_HEIGHT + LEFT_TOP_HEIGHT);
            int  minHeightRight = boundsRight.Height - (RIGHT_BOTTOM_HEIGHT + LEFT_TOP_HEIGHT);

            expander.MouseDown += (sender, args) =>
            {
                is_pressing        = true;
                initial_height     = leftmiddle.Height;
                initialHeightRight = rightMiddle.Height;
            };

            expander.MouseUp += (sender, args) => { is_pressing = false; };

            expander.MouseOver += (sender, args) =>
            {
                int steps = Mouse.LDragOffset.Y;

                if (is_pressing && steps != 0)
                {
                    leftmiddle.Height = initial_height + steps;

                    if (leftmiddle.Height < minHeight)
                    {
                        leftmiddle.Height = minHeight;
                    }
                    else if (leftmiddle.Height > 640)
                    {
                        leftmiddle.Height = 640;
                    }

                    rightMiddle.Height = initialHeightRight + steps;

                    if (rightMiddle.Height < minHeightRight)
                    {
                        rightMiddle.Height = minHeightRight;
                    }
                    else if (rightMiddle.Height > 640 - LEFT_TOP_HEIGHT)
                    {
                        rightMiddle.Height = 640 - LEFT_TOP_HEIGHT;
                    }

                    ProfileManager.CurrentProfile.VendorGumpHeight = leftmiddle.Height;

                    leftBottom.Y  = leftmiddle.Y + leftmiddle.Height;
                    expander.Y    = leftBottom.Y + leftBottom.Height - 5;
                    rightBottom.Y = rightMiddle.Y + rightMiddle.Height;

                    _shopScrollArea.Height          = leftmiddle.Height + 50;
                    _shopScrollArea.ScrollMaxHeight = leftmiddle.Height;

                    _transactionDataBox.Height = _transactionScrollArea.Height = rightMiddle.Height;
                    _totalLabel.Y = rightBottom.Y + rightBottom.Height - RIGHT_OFFSET * 3 + 15;
                    accept.Y      = clear.Y = (rightBottom.Y + rightBottom.Height) - 50;
                    leftDown.Y    = leftBottom.Y;
                    rightDown.Y   = rightBottom.Y;

                    if (_playerGoldLabel != null)
                    {
                        _playerGoldLabel.Y = _totalLabel.Y;
                    }

                    _transactionDataBox.ReArrangeChildren();
                    WantUpdateSize = true;
                }
            };


            //Label name = new Label(World.Player.Name, false, 0x0386, font: 5)
            //{
            //    X = 322,
            //    Y = 308 + _middleGumpRight.Height
            //};

            //Add(name);
        }