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); } }
public void OnClose() { GroupedOptions.OnItemSlotRendered -= OnItemSlotRendered; GroupedOptions?.OnClose(); UngroupedOptions.OnItemSlotRendered -= OnItemSlotRendered; UngroupedOptions?.OnClose(); }
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); }
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); }
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); }
public void OnMouseButtonReleased(ButtonReleasedEventArgs e) { if (!GroupedOptions.IsEmptyMenu) { GroupedOptions.OnMouseButtonReleased(e); } if (!UngroupedOptions.IsEmptyMenu) { UngroupedOptions.OnMouseButtonReleased(e); } }
public void Update(UpdateTickedEventArgs e) { RecentlyGainedFocus = false; if (!GroupedOptions.IsEmptyMenu) { GroupedOptions.Update(e); } if (!UngroupedOptions.IsEmptyMenu) { UngroupedOptions.Update(e); } }
public void OnGamepadButtonsReleased(Buttons GamepadButtons) { if (IsGamepadFocused && !RecentlyGainedFocus) { if (!GroupedOptions.IsEmptyMenu) { GroupedOptions.OnGamepadButtonsReleased(GamepadButtons); } if (!UngroupedOptions.IsEmptyMenu) { UngroupedOptions.OnGamepadButtonsReleased(GamepadButtons); } } }
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); } } }
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); }
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); } } }
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; } }
public void DrawToolTips(SpriteBatch b) { GroupedOptions.DrawToolTips(b); UngroupedOptions.DrawToolTips(b); }