Example #1
0
        public string GetCurrentlyHoveredNpc(SVector2 mousePos)
        {
            int slotIndex = this.GetSlotIndex();

            if (slotIndex < 0 || slotIndex >= this.FriendSlots.Count)
            {
                Utils.DebugLog("SlotIndex is invalid", LogLevel.Error);
                return(string.Empty);
            }

            // Early out if the mouse isn't within the page bounds
            Point mousePoint = mousePos.ToPoint();

            if (!this.PageBounds.Contains(mousePoint))
            {
                return(string.Empty);
            }

            // Find the slot containing the cursor among the currently visible slots
            string hoveredFriendName = string.Empty;

            for (int i = slotIndex; i < slotIndex + SDVSocialPage.slotsOnPage; ++i)
            {
                var friend = this.FriendSlots[i];
                var bounds = this.MakeSlotBounds(friend);

                if (bounds.Contains(mousePoint) && Utils.Ensure(i < this.Names.Count, "Name index out of range"))
                {
                    hoveredFriendName = this.Names[i] as string;
                    break;
                }
            }

            return(hoveredFriendName ?? string.Empty);
        }
Example #2
0
        public int GetHoveredDayIndex(SVector2 mouse)
        {
            if (!this.Bounds.Contains(mouse.ToPoint()))
            {
                return(Calendar.InvalidDay);
            }

            for (int i = 0; i < this.CalendarDays.Count; ++i)
            {
                if (this.CalendarDays[i].bounds.Contains(mouse.ToPoint()))
                {
                    return(i);
                }
            }
            return(Calendar.InvalidDay);
        }
Example #3
0
        public string GetHoveredBirthdayNpcName(SVector2 mouse)
        {
            string name = string.Empty;

            if (!this.Bounds.Contains(mouse.ToPoint()))
            {
                return(name);
            }

            foreach (ClickableTextureComponent day in this.CalendarDays)
            {
                if (day.bounds.Contains(mouse.ToPoint()))
                {
                    if (day.hoverText.Length > 0 && day.hoverText.Contains("Birthday"))
                    {
                        name = day.hoverText;
                        break;
                    }
                }
            }
            return(name);
        }
Example #4
0
        public string GetCurrentlyHoveredNpc(SVector2 mousePos)
        {
            int slotIndex = this.GetSlotIndex();

            if (slotIndex < 0 || slotIndex >= this.FriendSlots.Count)
            {
                Utils.DebugLog("SlotIndex is invalid", LogLevel.Error);
                return(string.Empty);
            }

            // Remake the page bounds if the slot index has changed
            // TODO: we can probably just do this once on resize with slot 0
            if (slotIndex != this.LastSlotIndex)
            {
                this.PageBounds    = this.MakeBounds(slotIndex);
                this.LastSlotIndex = slotIndex;
            }

            // Early out if the mouse isn't within the page bounds
            Point mousePoint = mousePos.ToPoint();

            if (!this.PageBounds.Contains(mousePoint))
            {
                return(string.Empty);
            }

            // Find the slot containing the cursor among the currently visible slots
            string hoveredFriendName = string.Empty;

            for (int i = slotIndex; i < slotIndex + SDVSocialPage.slotsOnPage; ++i)
            {
                var friend = this.FriendSlots[i];
                var bounds = this.MakeSlotBounds(friend);

                if (bounds.Contains(mousePoint))
                {
                    hoveredFriendName = friend.name;
                    break;
                }
            }

            return(hoveredFriendName);
        }