예제 #1
0
        public bool TryNavigateEnter(NavigationDirection StartingSide, Rectangle?ClosestTo)
        {
            if (!GroupedOptions.IsEmptyMenu && !UngroupedOptions.IsEmptyMenu)
            {
                if (StartingSide == NavigationDirection.Down)
                {
                    return(UngroupedOptions.TryNavigateEnter(StartingSide, ClosestTo));
                }
                else if (StartingSide == NavigationDirection.Up)
                {
                    return(GroupedOptions.TryNavigateEnter(StartingSide, ClosestTo));
                }
            }

            if (!GroupedOptions.IsEmptyMenu)
            {
                return(GroupedOptions.TryNavigateEnter(StartingSide, ClosestTo));
            }
            else if (!UngroupedOptions.IsEmptyMenu)
            {
                return(UngroupedOptions.TryNavigateEnter(StartingSide, ClosestTo));
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
 public void OnClose()
 {
     GroupedOptions.OnItemSlotRendered -= OnItemSlotRendered;
     GroupedOptions?.OnClose();
     UngroupedOptions.OnItemSlotRendered -= OnItemSlotRendered;
     UngroupedOptions?.OnClose();
 }
예제 #3
0
        private bool TryHandlePrimaryAction(bool IsMouseInput)
        {
            if (BoundedBag.Autofill && !IBM.IsTransferMultipleModifierHeld && !IBM.IsTransferHalfModifierHeld)
            {
                if (!GroupedOptions.IsEmptyMenu && GroupedOptions.HoveredSlot.HasValue)
                {
                    if (!IsMouseInput || GetAutofillToggleClickableRegion(GroupedOptions.HoveredSlot.Value).Contains(CurrentMousePosition))
                    {
                        BoundedBag.ToggleItemAutofill(GroupedOptions.GetHoveredItem());
                        return(true);
                    }
                }

                if (!UngroupedOptions.IsEmptyMenu && UngroupedOptions.HoveredSlot.HasValue)
                {
                    if (!IsMouseInput || GetAutofillToggleClickableRegion(UngroupedOptions.HoveredSlot.Value).Contains(CurrentMousePosition))
                    {
                        BoundedBag.ToggleItemAutofill(UngroupedOptions.GetHoveredItem());
                        return(true);
                    }
                }
            }

            return(false);
        }
예제 #4
0
        public void InitializeLayout(int ResizeIteration)
        {
            if (GroupedOptions == null || UngroupedOptions == null)
            {
                return;
            }

            GroupedOptions.InitializeLayout(ResizeIteration);
            UngroupedOptions.InitializeLayout(ResizeIteration);

            int RequiredWidth;
            int RequiredHeight;

            if (UngroupedOptions.IsEmptyMenu)
            {
                RequiredWidth  = GroupedOptions.RelativeBounds.Width + Padding * 2;
                RequiredHeight = GroupedOptions.RelativeBounds.Height + Padding * 2;

                Point GroupedOptionsPos = new Point(TopLeftScreenPosition.X + Padding, TopLeftScreenPosition.Y + Padding);
                GroupedOptions.SetTopLeft(GroupedOptionsPos);
                Point UngroupedOptionsPos = new Point(0, 0);
                UngroupedOptions.SetTopLeft(UngroupedOptionsPos);
                HorizontalSeparatorPosition = null;
            }
            else if (GroupedOptions.IsEmptyMenu)
            {
                RequiredWidth  = UngroupedOptions.RelativeBounds.Width + Padding * 2;
                RequiredHeight = UngroupedOptions.RelativeBounds.Height + Padding * 2;

                Point GroupedOptionsPos = new Point(0, 0);
                GroupedOptions.SetTopLeft(GroupedOptionsPos);
                Point UngroupedOptionsPos = new Point(TopLeftScreenPosition.X + Padding, TopLeftScreenPosition.Y + Padding);
                UngroupedOptions.SetTopLeft(UngroupedOptionsPos);
                HorizontalSeparatorPosition = null;
            }
            else
            {
                int SeparatorHeight = 12;
                RequiredWidth  = Math.Max(GroupedOptions.RelativeBounds.Width, UngroupedOptions.RelativeBounds.Width) + Padding * 2;
                RequiredHeight = Padding + GroupedOptions.RelativeBounds.Height + SeparatorHeight + UngroupedOptions.RelativeBounds.Height + Padding;

                Point GroupedOptionsPos = new Point(TopLeftScreenPosition.X + (RequiredWidth - GroupedOptions.RelativeBounds.Width) / 2, TopLeftScreenPosition.Y + Padding);
                GroupedOptions.SetTopLeft(GroupedOptionsPos);
                Point UngroupedOptionsPos = new Point(TopLeftScreenPosition.X + (RequiredWidth - UngroupedOptions.RelativeBounds.Width) / 2, TopLeftScreenPosition.Y + Padding + GroupedOptions.RelativeBounds.Height + SeparatorHeight);
                UngroupedOptions.SetTopLeft(UngroupedOptionsPos);

                //  Add a horizontal separator
                int SeparatorXPosition = TopLeftScreenPosition.X + Padding;
                int SeparatorYPosition = TopLeftScreenPosition.Y + Padding + GroupedOptions.RelativeBounds.Height;
                int SeparatorWidth     = Math.Max(GroupedOptions.RelativeBounds.Width, UngroupedOptions.RelativeBounds.Width);
                HorizontalSeparatorPosition = new Rectangle(SeparatorXPosition, SeparatorYPosition, SeparatorWidth, SeparatorHeight);
            }

            this.RelativeBounds = new Rectangle(0, 0, RequiredWidth, RequiredHeight);
        }
예제 #5
0
        public void Draw(SpriteBatch b)
        {
            //b.Draw(TextureHelpers.GetSolidColorTexture(Game1.graphics.GraphicsDevice, Color.Red), ContentsBounds, Color.White);

            if (HorizontalSeparatorPosition.HasValue)
            {
                DrawHelpers.DrawHorizontalSeparator(b, HorizontalSeparatorPosition.Value);
            }
            GroupedOptions.Draw(b);
            UngroupedOptions.Draw(b);
        }
예제 #6
0
 public void OnMouseButtonReleased(ButtonReleasedEventArgs e)
 {
     if (!GroupedOptions.IsEmptyMenu)
     {
         GroupedOptions.OnMouseButtonReleased(e);
     }
     if (!UngroupedOptions.IsEmptyMenu)
     {
         UngroupedOptions.OnMouseButtonReleased(e);
     }
 }
예제 #7
0
        public void Update(UpdateTickedEventArgs e)
        {
            RecentlyGainedFocus = false;

            if (!GroupedOptions.IsEmptyMenu)
            {
                GroupedOptions.Update(e);
            }
            if (!UngroupedOptions.IsEmptyMenu)
            {
                UngroupedOptions.Update(e);
            }
        }
예제 #8
0
 public void OnGamepadButtonsReleased(Buttons GamepadButtons)
 {
     if (IsGamepadFocused && !RecentlyGainedFocus)
     {
         if (!GroupedOptions.IsEmptyMenu)
         {
             GroupedOptions.OnGamepadButtonsReleased(GamepadButtons);
         }
         if (!UngroupedOptions.IsEmptyMenu)
         {
             UngroupedOptions.OnGamepadButtonsReleased(GamepadButtons);
         }
     }
 }
예제 #9
0
        public void OnGamepadButtonsPressed(Buttons GamepadButtons)
        {
            if (IsGamepadFocused && !RecentlyGainedFocus)
            {
                if (GamepadControls.IsMatch(GamepadButtons, GamepadControls.Current.BoundedBagToggleAutofill))
                {
                    TryHandlePrimaryAction(false);
                }

                if (!GroupedOptions.IsEmptyMenu)
                {
                    GroupedOptions.OnGamepadButtonsPressed(GamepadButtons);
                }
                if (!UngroupedOptions.IsEmptyMenu)
                {
                    UngroupedOptions.OnGamepadButtonsPressed(GamepadButtons);
                }
            }
        }
예제 #10
0
        public void OnMouseMoved(CursorMovedEventArgs e)
        {
            CurrentMousePosition = e.NewPosition.LegacyScreenPixels().AsPoint();

            if (Bounds.Contains(e.OldPosition.LegacyScreenPixels().AsPoint()) || Bounds.Contains(e.NewPosition.LegacyScreenPixels().AsPoint()))
            {
                if (!GroupedOptions.IsEmptyMenu && (GroupedOptions.Bounds.Contains(e.OldPosition.LegacyScreenPixels().AsPoint()) || GroupedOptions.Bounds.Contains(e.NewPosition.LegacyScreenPixels().AsPoint())))
                {
                    GroupedOptions.OnMouseMoved(e);
                }

                if (!UngroupedOptions.IsEmptyMenu && (UngroupedOptions.Bounds.Contains(e.OldPosition.LegacyScreenPixels().AsPoint()) || UngroupedOptions.Bounds.Contains(e.NewPosition.LegacyScreenPixels().AsPoint())))
                {
                    UngroupedOptions.OnMouseMoved(e);
                }
            }

            UpdateHoveredItem(e);
        }
예제 #11
0
        public void OnMouseButtonPressed(ButtonPressedEventArgs e)
        {
            bool Handled = false;

            if (e.Button == SButton.MouseLeft)
            {
                Handled = TryHandlePrimaryAction(true);
            }

            if (!Handled)
            {
                if (!GroupedOptions.IsEmptyMenu)
                {
                    GroupedOptions.OnMouseButtonPressed(e);
                }
                if (!UngroupedOptions.IsEmptyMenu)
                {
                    UngroupedOptions.OnMouseButtonPressed(e);
                }
            }
        }
예제 #12
0
 public void UpdateHoveredItem(CursorMovedEventArgs e)
 {
     if (Bounds.Contains(e.NewPosition.LegacyScreenPixels().AsPoint()))
     {
         if (!GroupedOptions.IsEmptyMenu && GroupedOptions.Bounds.Contains(e.NewPosition.LegacyScreenPixels().AsPoint()))
         {
             HoveredItem = GroupedOptions.GetHoveredItem();
         }
         else if (!UngroupedOptions.IsEmptyMenu && UngroupedOptions.Bounds.Contains(e.NewPosition.LegacyScreenPixels().AsPoint()))
         {
             HoveredItem = UngroupedOptions.GetHoveredItem();
         }
         else
         {
             HoveredItem = null;
         }
     }
     else
     {
         HoveredItem = null;
     }
 }
예제 #13
0
 public void DrawToolTips(SpriteBatch b)
 {
     GroupedOptions.DrawToolTips(b);
     UngroupedOptions.DrawToolTips(b);
 }