Beispiel #1
0
        public Belt(Widget parent) : base(parent)
        {
            slots = new List <BeltSlot>(SlotCount);

            int w = 0;
            int h = 0;

            var layout = new GridLayout();

            for (int i = 0; i < SlotCount; i++)
            {
                int index    = i;
                int keyIndex = (i + 1) % 10;

                var slot = new BeltSlot(this);
                slot.Label     = keyIndex.ToString();
                slot.Click    += OnSlotClick;
                slot.Drop     += OnSlotDrop;
                slot.ItemDrop += OnSlotItemDrop;
                slots.Add(slot);

                int column = layout.ColumnCount;
                layout.AddWidget(slot, 0, column);
                layout.SetColumnWidth(column, slot.Width - 1);

                w += slot.Width - 1;
                h  = Math.Max(h, slot.Height);

                Host.Hotkeys.Register(Key.Number1 + keyIndex - 1, () => Click.Raise(new BeltClickEvent(index, MouseButton.Left, 0)));
            }
            layout.Spacing = -1;
            layout.UpdateGeometry(0, 0, 0, 0);

            this.Resize(w, h);
        }
Beispiel #2
0
        public virtual bool Update(float deltaTime, InputDevice inputDevice)
        {
            if (!IsEnabled)
            {
                return(false);
            }

            var position          = inputDevice.Position;
            var shape             = GetBoundingRectangle();
            var previouslyPressed = IsPressed;

            IsPressed = inputDevice.IsTouching && shape.Contains(position);

            if (!previouslyPressed && IsPressed)
            {
                Pressed.Raise(this, EventArgs.Empty);
            }

            if (previouslyPressed && !IsPressed)
            {
                Released.Raise(this, EventArgs.Empty);

                if (shape.Contains(position))
                {
                    Click.Raise(this, EventArgs.Empty);
                }
            }

            return(true);
        }
Beispiel #3
0
 protected override void OnMouseButtonDown(MouseButtonEvent e)
 {
     if (e.Button == MouseButton.Left)
     {
         Click.Raise(this, EventArgs.Empty);
     }
 }
Beispiel #4
0
        private void OnSlotClick(object sender, MouseButtonEvent e)
        {
            int index = slots.IndexOf((BeltSlot)sender);

            if (index != -1)
            {
                Click.Raise(new BeltClickEvent(index, e.Button, e.Modifiers));
            }
        }
Beispiel #5
0
        protected override void OnRelease(Rectangle shape, Vector2 touchPosition)
        {
            IsPressed = false;

            if (shape.Contains(touchPosition))
            {
                Click.Raise(this, EventArgs.Empty);
            }
        }
Beispiel #6
0
 protected override void OnMouseButtonUp(MouseButtonEvent e)
 {
     if (e.Button == MouseButton.Left)
     {
         if (isPressed)
         {
             isPressed = false;
             Host.ReleaseMouse();
             Click.Raise(this, e);
         }
     }
 }
Beispiel #7
0
        protected override void OnMouseButtonUp(MouseButtonEvent e)
        {
            Host.ReleaseMouse();
            isPressed = false;

            // button released outside of borders?
            var p = MapFromScreen(e.Position);

            if (CheckHit(p.X + X, p.Y + Y))
            {
                Click.Raise();
            }

            e.Handled = true;
        }
Beispiel #8
0
 protected override void OnMouseButtonDown(MouseButtonEvent e)
 {
     if (e.Button == MouseButton.Left)
     {
         if (e.Modifiers.HasShift())
         {
             Transfer.Raise();
         }
         else
         {
             Click.Raise();
         }
         e.Handled = true;
     }
 }
Beispiel #9
0
        protected override void OnMouseButtonUp(MouseButtonEvent e)
        {
            if (e.Button != MouseButton.Left)
            {
                return;
            }

            Host.ReleaseMouse();
            isPressed = false;

            // button released outside of borders?
            var p = MapFromScreen(e.Position);

            if (Rect.FromLTRB(0, 0, Width, Height).Contains(p))
            {
                Click.Raise();
            }

            e.Handled = true;
        }
Beispiel #10
0
 private void OnAvatarClick(AvatarView sender, MouseButtonEvent e)
 {
     Click.Raise(new CombatRelationClickEvent(e.Button, this));
 }
Beispiel #11
0
 protected override void OnMouseButtonDown(MouseButtonEvent e)
 {
     Click.Raise(e);
 }
Beispiel #12
0
        private void OnButtonClick(object sender, EventArgs e)
        {
            var button = (TabButton)sender;

            Click.Raise(buttons.IndexOf(button));
        }
Beispiel #13
0
 private void OnRelationClick(CombatRelationClickEvent e)
 {
     Click.Raise(e);
 }