예제 #1
0
 public void GainedGamepadFocus()
 {
     RecentlyGainedFocus     = true;
     HoveredSlot             = SlotBounds.First();
     HoveredContentsButton   = null;
     IsNavigatingWithGamepad = true;
 }
예제 #2
0
        public bool TryNavigateEnter(NavigationDirection StartingSide, Rectangle?ClosestTo)
        {
            IsGamepadFocused        = true;
            IsNavigatingWithGamepad = true;

            if (ClosestTo.HasValue)
            {
                HoveredSlot = SlotBounds.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);
        }
예제 #3
0
 internal Object GetHoveredItem()
 {
     if (HoveredSlot.HasValue)
     {
         int Index = SlotBounds.IndexOf(HoveredSlot.Value);
         if (Index >= 0 && Index < PlaceholderItems.Count)
         {
             return(PlaceholderItems[Index]);
         }
         else
         {
             return(null);
         }
     }
     else
     {
         return(null);
     }
 }
예제 #4
0
 public bool TryNavigate(NavigationDirection Direction, NavigationWrappingMode HorizontalWrapping, NavigationWrappingMode VerticalWrapping)
 {
     if (IsGamepadFocused && HoveredSlot == null)
     {
         HoveredSlot             = SlotBounds.First();
         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);
     }
 }
예제 #5
0
        public void DrawToolTips(SpriteBatch b)
        {
            //  Draw tooltips on the hovered item inside the bag
            if (HoveredSlot.HasValue)
            {
                ItemBag HoveredBag = GetHoveredBag();
                if (HoveredBag == null)
                {
                    int Index = SlotBounds.IndexOf(HoveredSlot.Value);
                    if (Index >= 0 && Index < Placeholders.Count)
                    {
                        HoveredBag = Placeholders[Index];
                    }
                }

                if (HoveredBag != null)
                {
                    Rectangle Location;
                    if (IsNavigatingWithGamepad)
                    {
                        Location = HoveredSlot.Value; //new Rectangle(HoveredSlot.Value.Right, HoveredSlot.Value.Bottom, 1, 1);
                    }
                    else
                    {
                        Location = new Rectangle(Game1.getMouseX() - 8, Game1.getMouseY() + 36, 8 + 36, 1);
                    }

                    //if (HoveredBag is Rucksack RS)
                    //{
                    //    int XPos = Location.Right;
                    //    int YPos = Location.Bottom;
                    //    RS.drawTooltip(b, ref XPos, ref YPos, Game1.smallFont, 1f, RS.Description);
                    //}
                    //else
                    //{
                    //    DrawHelpers.DrawToolTipInfo(b, Location, HoveredBag, true, true, true, true, true, Bag.MaxStackSize);
                    //}

                    DrawHelpers.DrawToolTipInfo(b, Location, HoveredBag, true, true, true, true, true, true, Bag.MaxStackSize);
                }
            }
        }
예제 #6
0
 internal ItemBag GetHoveredBag()
 {
     if (HoveredSlot.HasValue)
     {
         int Index = SlotBounds.IndexOf(HoveredSlot.Value);
         if (Index >= 0 && Index < Placeholders.Count)
         {
             return(ActualContents[Index]);
             //string TypeId = Placeholders[Index].GetTypeId();
             //return OmniBag.NestedBags.FirstOrDefault(x => x.GetTypeId() == TypeId);
         }
         else
         {
             return(null);
         }
     }
     else
     {
         return(null);
     }
 }
예제 #7
0
        public void OnMouseMoved(CursorMovedEventArgs e)
        {
            Rectangle?PreviouslyHovered = HoveredSlot;

            this.HoveredSlot = null;
            if (SlotBounds != null)
            {
                foreach (Rectangle Rect in SlotBounds.SelectMany(x => x.Value.Values))
                {
                    if (Rect.Contains(e.NewPosition.ScreenPixels.AsPoint()))
                    {
                        if (PreviouslyHovered.HasValue && Rect != PreviouslyHovered.Value)
                        {
                            SecondaryActionButtonPressedLocation = null;
                        }
                        this.HoveredSlot        = Rect;
                        IsNavigatingWithGamepad = false;
                        break;
                    }
                }
            }

            UpdateHoveredItem(e);
        }
예제 #8
0
        public bool TryGetSlotNeighbor(Rectangle?ItemSlot, NavigationDirection Direction, NavigationWrappingMode HorizontalWrapping, NavigationWrappingMode VerticalWrapping, out Rectangle?Neighbor)
        {
            List <Rectangle> AllSlots = SlotBounds.Union(LockedSlotBounds).OrderBy(x => x.Top).ThenBy(x => x.Left).ToList();

            return(GamepadControls.TryGetSlotNeighbor(AllSlots, ItemSlot, ColumnCount, Direction, HorizontalWrapping, VerticalWrapping, out Neighbor));
        }
예제 #9
0
        public bool TryGetSlotNeighbor(Rectangle?ItemSlot, NavigationDirection Direction, NavigationWrappingMode HorizontalWrapping, NavigationWrappingMode VerticalWrapping, out Rectangle?Neighbor)
        {
            List <Rectangle> AllSlots = SlotBounds.Select(x => x.Value).SelectMany(x => x.OrderBy(y => y.Key).Select(z => z.Value)).ToList();

            return(GamepadControls.TryGetSlotNeighbor(AllSlots, ItemSlot, GroupsPerRow * ColumnsPerGroup, Direction, HorizontalWrapping, VerticalWrapping, out Neighbor));
        }
예제 #10
0
 public void GainedGamepadFocus()
 {
     RecentlyGainedFocus     = true;
     HoveredSlot             = SlotBounds.First().Value[ColumnType.RegularQuality];
     IsNavigatingWithGamepad = true;
 }