public bool TryNavigateEnter(NavigationDirection StartingSide, Rectangle?ClosestTo) { IsGamepadFocused = true; IsNavigatingWithGamepad = true; if (ClosestTo.HasValue) { HoveredSlot = InventorySlotBounds.OrderBy(x => x.SquaredDistanceBetweenCenters(ClosestTo.Value)).First(); } else { if (StartingSide == NavigationDirection.Right) { while (TryNavigate(NavigationDirection.Right, NavigationWrappingMode.NoWrap, NavigationWrappingMode.NoWrap)) { } } if (StartingSide == NavigationDirection.Down) { while (TryNavigate(NavigationDirection.Down, NavigationWrappingMode.NoWrap, NavigationWrappingMode.NoWrap)) { } } } return(true); }
public bool TryNavigate(NavigationDirection Direction, NavigationWrappingMode HorizontalWrapping, NavigationWrappingMode VerticalWrapping) { if (IsGamepadFocused && HoveredSlot == null) { HoveredSlot = InventorySlotBounds.FirstOrDefault(); IsNavigatingWithGamepad = HoveredSlot != null; return(HoveredSlot != null); } else if (TryGetSlotNeighbor(HoveredSlot, Direction, HorizontalWrapping, VerticalWrapping, out Rectangle? Neighbor)) { HoveredSlot = Neighbor.Value; IsNavigatingWithGamepad = true; return(true); } else { return(false); } }
public void GainedGamepadFocus() { RecentlyGainedFocus = true; HoveredSlot = InventorySlotBounds.First(); IsNavigatingWithGamepad = true; }