Exemplo n.º 1
0
        protected override void MouseDown(GUIMouseButtonEventArgs args)
        {
            base.MouseDown(args);

            BottomContainer.Visible = !BottomContainer.Visible;
            args.Handle();
        }
Exemplo n.º 2
0
        protected internal override void MouseDown(GUIMouseButtonEventArgs args)
        {
            base.MouseDown(args);

            if (SelectMode == ItemListSelectMode.None || args.Button != Mouse.Button.Left)
            {
                return;
            }

            foreach (var item in _itemList)
            {
                if (item.Region == null)
                {
                    continue;
                }
                if (!item.Region.Value.Contains(args.RelativePosition))
                {
                    continue;
                }
                if (item.Selectable && !item.Disabled)
                {
                    if (item.Selected)
                    {
                        Unselect(item);
                    }
                    else
                    {
                        Select(item, SelectMode == ItemListSelectMode.Single);
                    }
                }
                break;
            }
        }
Exemplo n.º 3
0
        protected override void MouseDown(GUIMouseButtonEventArgs args)
        {
            base.MouseDown(args);

            var lefthandcontains  = handL.Contains((Vector2i)args.RelativePosition);
            var righthandcontains = handR.Contains((Vector2i)args.RelativePosition);

            if (args.Button == Mouse.Button.Left)
            {
                if (!TryGetHands(out IHandsComponent hands))
                {
                    return;
                }

                if ((hands.ActiveIndex == "left" && lefthandcontains) ||
                    (hands.ActiveIndex == "right" && righthandcontains))
                {
                    UseActiveHand();
                }
            }
            else if (args.Button == Mouse.Button.Right)
            {
                if (lefthandcontains)
                {
                    SendSwitchHandTo("left");
                }
                if (righthandcontains)
                {
                    SendSwitchHandTo("right");
                }
            }
        }
Exemplo n.º 4
0
        protected override void MouseUp(GUIMouseButtonEventArgs args)
        {
            base.MouseUp(args);

            DragOffsetTopLeft = DragOffsetBottomRight = Vector2.Zero;
            CurrentDrag       = DragMode.None;

            // If this is done in MouseDown, Godot won't fire MouseUp as you need focus to receive MouseUps.
            UserInterfaceManager.Focused?.ReleaseFocus();
        }
Exemplo n.º 5
0
        protected internal override void MouseDown(GUIMouseButtonEventArgs args)
        {
            base.MouseDown(args);

            var item = _tryFindItemAtPosition(args.RelativePosition);

            if (item != null && item.Selectable)
            {
                _selectedIndex = item.Index;
                OnItemSelected?.Invoke();
            }
        }
Exemplo n.º 6
0
        protected override void MouseDown(GUIMouseButtonEventArgs args)
        {
            base.MouseDown(args);

            CurrentDrag = GetDragModeFor(args.RelativePosition);

            if (CurrentDrag != DragMode.None)
            {
                DragOffsetTopLeft     = args.GlobalPosition - Position;
                DragOffsetBottomRight = Position + Size - args.GlobalPosition;
            }

            MoveToFront();
        }
Exemplo n.º 7
0
        protected override void MouseDown(GUIMouseButtonEventArgs args)
        {
            base.MouseDown(args);

            if (args.Button != Mouse.Button.Right)
            {
                return;
            }

            if (handL.Contains((Vector2i)args.RelativePosition))
            {
                SendSwitchHandTo("left");
            }
            if (handR.Contains((Vector2i)args.RelativePosition))
            {
                SendSwitchHandTo("right");
            }
        }
Exemplo n.º 8
0
        protected override void MouseDown(GUIMouseButtonEventArgs e)
        {
            base.MouseDown(e);

            Input.GrabKeyboardFocus();
        }
        protected override void MouseDown(GUIMouseButtonEventArgs args)
        {
            base.MouseDown(args);

            var leftHandContains  = handL.Contains((Vector2i)args.RelativePosition);
            var rightHandContains = handR.Contains((Vector2i)args.RelativePosition);

            string handIndex;

            if (leftHandContains)
            {
                handIndex = "left";
            }
            else if (rightHandContains)
            {
                handIndex = "right";
            }
            else
            {
                return;
            }

            if (args.Button == Mouse.Button.Left)
            {
                if (!TryGetHands(out var hands))
                {
                    return;
                }


                if (hands.ActiveIndex == handIndex)
                {
                    UseActiveHand();
                }
                else
                {
                    AttackByInHand(handIndex);
                }
            }

            else if (args.Button == Mouse.Button.Middle)
            {
                SendSwitchHandTo(handIndex);
            }

            else if (args.Button == Mouse.Button.Right)
            {
                if (!TryGetHands(out var hands))
                {
                    return;
                }

                var entity = hands.GetEntity(handIndex);
                if (entity == null)
                {
                    return;
                }

                var esm = IoCManager.Resolve <IEntitySystemManager>();
                esm.GetEntitySystem <VerbSystem>().OpenContextMenu(entity, new ScreenCoordinates(args.GlobalPosition));
            }
        }