Пример #1
0
        public override void receiveLeftClick(int x, int y, bool playSound = true)
        {
            if (Game1.activeClickableMenu == null)
            {
                return;
            }

            if (_questOnPage == -1)
            {
                for (int i = 0; i < questButtons.Count; ++i)
                {
                    if (_pages.Count > 0 & _pages[_currentPage].Count > i && questButtons[i].containsPoint(x, y))
                    {
                        Game1.playSound("smallSelect");

                        _questOnPage   = i;
                        shownQuest     = _pages[_currentPage][i];
                        _objectiveText = shownQuest.GetObjectiveDescriptions();
                        shownQuest.MarkAsViewed();

                        scrollComponent.ScrollAmount = 0;

                        if (Game1.options.SnappyMenus)
                        {
                            currentlySnappedComponent = backButton;
                            currentlySnappedComponent.rightNeighborID = CUSTOM_SNAP_BEHAVIOR;
                            snapCursorToCurrentSnappedComponent();
                        }

                        return;
                    }
                }

                if (_currentPage > 0 && backButton.containsPoint(x, y))
                {
                    PreviousPage();
                }
                else if (_currentPage < _pages.Count - 1 && forwardButton.containsPoint(x, y))
                {
                    NextPage();
                }
                else
                {
                    Game1.activeClickableMenu?.exitThisMenu();
                }

                return;
            }
            else if (shownQuest != null)
            {
                if (shownQuest.ShouldDisplayAsComplete() && shownQuest.HasMoneyReward() && rewardBox.containsPoint(x, y))
                {
                    Game1.player.Money += shownQuest.GetMoneyReward();
                    Game1.playSound("purchaseRepeat");
                    shownQuest.OnMoneyRewardClaimed();
                }
                else if (shownQuest is Quest quest && !quest.completed.Get() && quest.canBeCancelled.Get() && cancelQuestButton.containsPoint(x, y))
                {
                    quest.accepted.Value = false;

                    if (quest.dailyQuest.Get() && quest.dayQuestAccepted.Get() == Game1.Date.TotalDays)
                    {
                        Game1.player.acceptedDailyQuest.Set(newValue: false);
                    }

                    Game1.player.questLog.Remove(quest);
                    Game1.playSound("trashcan");
                    _pages[_currentPage].RemoveAt(_questOnPage);
                    _questOnPage = -1;

                    if (Game1.options.SnappyMenus && _currentPage == 0)
                    {
                        currentlySnappedComponent = getComponentWithID(0);
                        snapCursorToCurrentSnappedComponent();
                    }
                }
                else if (!scrollComponent.CanScroll() || backButton.containsPoint(x, y))
                {
                    ExitQuestPage();
                }
            }
Пример #2
0
        public override void receiveLeftClick(int x, int y, bool playSound = true)
        {
            if (ChildHasFocus())
            {
                _childMenu.receiveLeftClick(x, y, playSound);
                return;
            }

            if (_dragging)
            {
                return;
            }
            else if (addTaskButton.containsPoint(x, y))
            {
                OpenAddTaskMenu();
                return;
            }
            else if (moneyButton.containsPoint(x, y))
            {
                _config.MoneyViewNetWealth = !_config.MoneyViewNetWealth;
                RefreshMoneyDial();
            }
            else
            {
                IReadOnlyList <ITask> tasks = _taskManager.Tasks;
                int scrollOffset            = scrollComponent.ScrollAmount / scrollComponent.ScrollDistance;

                for (int i = 0; i < taskEntries.Count && i + scrollOffset < tasks.Count; i++)
                {
                    TaskEntryComponent entry = taskEntries[i];
                    ITask task = tasks[i + scrollOffset];

                    if (entry.containsPoint(x, y))
                    {
                        if (entry.checkbox.containsPoint(x, y))
                        {
                            if (task.Active)
                            {
                                task.Complete = !task.Complete;
                                task.MarkAsViewed();
                                Game1.playSoundPitched("tinyWhip", task.Complete ? 2000 : 1000);
                            }
                            else
                            {
                                task.Active = true;
                                Game1.playSound("newRecipe");
                            }
                        }
                        else if (entry.removeButton.containsPoint(x, y))
                        {
                            RemoveTaskAt(i + scrollOffset);
                            Game1.playSound("trashcan");
                        }
                        else
                        {
                            _selectedTaskIndex = i + scrollOffset;
                        }

                        return;
                    }
                }

                if (!scrollComponent.CanScroll() || !_boundsWithScrollBar.Contains(x, y))
                {
                    Game1.activeClickableMenu?.exitThisMenu();
                }
            }

            scrollComponent.ReceiveLeftClick(x, y, playSound);
        }