Пример #1
0
        internal static void QuestLogPatch(QuestLog __instance, int ___questPage, List <List <IQuest> > ___pages, int ___currentPage, IQuest ____shownQuest, List <string> ____objectiveText)
        {
            try
            {
                bool   isCPressed = MainClass.Config.PrimaryInfoKey.JustPressed();
                int    x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
                string toSpeak = " ", extra = "";

                if (___questPage == -1)
                {
                    #region Quest Lists
                    if (!firstTimeInIndividualQuest)
                    {
                        firstTimeInIndividualQuest = true;
                    }

                    for (int i = 0; i < __instance.questLogButtons.Count; i++)
                    {
                        if (___pages.Count() > 0 && ___pages[___currentPage].Count() > i)
                        {
                            if (!__instance.questLogButtons[i].containsPoint(x, y))
                            {
                                continue;
                            }

                            string name     = ___pages[___currentPage][i].GetName();
                            int    daysLeft = ___pages[___currentPage][i].GetDaysLeft();
                            toSpeak = $"{name}";

                            if (daysLeft > 0 && ___pages[___currentPage][i].ShouldDisplayAsComplete())
                            {
                                toSpeak += $"\t\n {daysLeft} days left";
                            }

                            toSpeak += ___pages[___currentPage][i].ShouldDisplayAsComplete() ? " completed!" : "";
                            break;
                        }
                    }

                    if (__instance.backButton != null && __instance.backButton.visible && __instance.backButton.containsPoint(x, y))
                    {
                        toSpeak = "Previous page button";
                    }
                    else if (__instance.forwardButton != null && __instance.forwardButton.visible && __instance.forwardButton.containsPoint(x, y))
                    {
                        toSpeak = "Next page button";
                    }
                    else if (__instance.upperRightCloseButton != null && __instance.upperRightCloseButton.visible && __instance.upperRightCloseButton.containsPoint(x, y))
                    {
                        toSpeak = "Close menu button";
                    }

                    if (questLogQuery != toSpeak)
                    {
                        questLogQuery = toSpeak;
                        MainClass.ScreenReader.Say(toSpeak, true);
                    }
                    #endregion
                }
                else
                {
                    #region Individual quest
                    bool   containsReward = __instance.HasReward() || __instance.HasMoneyReward();
                    string description    = Game1.parseText(____shownQuest.GetDescription(), Game1.dialogueFont, __instance.width - 128);
                    string title          = ____shownQuest.GetName();

                    if (firstTimeInIndividualQuest || (isCPressed && !isNarratingQuestInfo))
                    {
                        if (firstTimeInIndividualQuest)
                        {
                            toSpeak = "Back button";
                        }

                        if (____shownQuest.ShouldDisplayAsComplete())
                        {
                            #region Quest completed menu

                            extra = $"Quest: {title} Completed!";

                            if (__instance.HasMoneyReward())
                            {
                                extra += $"you recieved {____shownQuest.GetMoneyReward()}g";
                            }

                            #endregion
                        }
                        else
                        {
                            #region Quest in-complete menu
                            extra = $"Title: {title}. \t\n Description: {description}";

                            for (int j = 0; j < ____objectiveText.Count; j++)
                            {
                                string parsed_text = Game1.parseText(____objectiveText[j], width: __instance.width - 192, whichFont: Game1.dialogueFont);
                                if (____shownQuest != null && ____shownQuest is SpecialOrder)
                                {
                                    OrderObjective order_objective = ((SpecialOrder)____shownQuest).objectives[j];
                                    if (order_objective.GetMaxCount() > 1 && order_objective.ShouldShowProgress())
                                    {
                                        parsed_text += "\n\t" + order_objective.GetCount() + " of " + order_objective.GetMaxCount() + " completed";
                                    }
                                }

                                extra += $"\t\nOrder {j + 1}: {parsed_text} \t\n";
                            }

                            if (____shownQuest != null)
                            {
                                int daysLeft = ____shownQuest.GetDaysLeft();

                                if (daysLeft > 0)
                                {
                                    extra += $"\t\n{daysLeft} days left.";
                                }
                            }
                            #endregion
                        }

                        isNarratingQuestInfo = true;
                        Task.Delay(200).ContinueWith(_ => { isNarratingQuestInfo = false; });
                        questLogQuery = " ";
                    }

                    if (!firstTimeInIndividualQuest)
                    {
                        if (__instance.backButton != null && __instance.backButton.visible && __instance.backButton.containsPoint(x, y))
                        {
                            toSpeak = (___currentPage > 0) ? "Previous page button" : "Back button";
                        }
                        else if (__instance.forwardButton != null && __instance.forwardButton.visible && __instance.forwardButton.containsPoint(x, y))
                        {
                            toSpeak = "Next page button";
                        }
                        else if (__instance.cancelQuestButton != null && __instance.cancelQuestButton.visible && __instance.cancelQuestButton.containsPoint(x, y))
                        {
                            toSpeak = "Cancel quest button";
                        }
                        else if (__instance.upperRightCloseButton != null && __instance.upperRightCloseButton.visible && __instance.upperRightCloseButton.containsPoint(x, y))
                        {
                            toSpeak = "Close menu button";
                        }
                        else if (containsReward && __instance.rewardBox.containsPoint(x, y))
                        {
                            toSpeak = "Left click to collect reward";
                        }
                    }

                    if (firstTimeInIndividualQuest || (questLogQuery != toSpeak))
                    {
                        questLogQuery = toSpeak;
                        MainClass.ScreenReader.Say(extra + " \n\t" + toSpeak, true);

                        if (firstTimeInIndividualQuest)
                        {
                            firstTimeInIndividualQuest = false;
                        }
                    }

                    #endregion
                }
            }
            catch (Exception e)
            {
                MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
            }
        }
Пример #2
0
        public override void receiveLeftClick(int x, int y, bool playSound = true)
        {
            base.receiveLeftClick(x, y, playSound);
            if (Game1.activeClickableMenu == null)
            {
                return;
            }
            if (questPage == -1)
            {
                for (int i = 0; i < questLogButtons.Count; i++)
                {
                    if (pages.Count > 0 && pages[currentPage].Count > i && questLogButtons[i].containsPoint(x, y))
                    {
                        Game1.playSound("smallSelect");
                        questPage      = i;
                        _shownQuest    = pages[currentPage][i];
                        _objectiveText = _shownQuest.GetObjectiveDescriptions();
                        _shownQuest.MarkAsViewed();
                        scrollAmount = 0f;
                        SetScrollBarFromAmount();
                        if (Game1.options.SnappyMenus)
                        {
                            currentlySnappedComponent = getComponentWithID(102);
                            currentlySnappedComponent.rightNeighborID = -7777;
                            currentlySnappedComponent.downNeighborID  = (HasMoneyReward() ? 103 : (_shownQuest.CanBeCancelled() ? 104 : (-1)));
                            snapCursorToCurrentSnappedComponent();
                        }
                        return;
                    }
                }
                if (currentPage < pages.Count - 1 && forwardButton.containsPoint(x, y))
                {
                    nonQuestPageForwardButton();
                    return;
                }
                if (currentPage > 0 && backButton.containsPoint(x, y))
                {
                    nonQuestPageBackButton();
                    return;
                }
                Game1.playSound("bigDeSelect");
                exitThisMenu();
                return;
            }
            Quest quest = _shownQuest as Quest;

            if (questPage != -1 && _shownQuest.ShouldDisplayAsComplete() && _shownQuest.HasMoneyReward() && rewardBox.containsPoint(x, y))
            {
                Game1.player.Money += _shownQuest.GetMoneyReward();
                Game1.playSound("purchaseRepeat");
                _shownQuest.OnMoneyRewardClaimed();
            }
            else if (questPage != -1 && quest != null && !quest.completed && (bool)quest.canBeCancelled && cancelQuestButton.containsPoint(x, y))
            {
                quest.accepted.Value = false;
                if (quest.dailyQuest.Value && quest.dayQuestAccepted.Value == Game1.Date.TotalDays)
                {
                    Game1.player.acceptedDailyQuest.Set(newValue: false);
                }
                Game1.player.questLog.Remove(quest);
                pages[currentPage].RemoveAt(questPage);
                questPage = -1;
                Game1.playSound("trashcan");
                if (Game1.options.SnappyMenus && currentPage == 0)
                {
                    currentlySnappedComponent = getComponentWithID(0);
                    snapCursorToCurrentSnappedComponent();
                }
            }
            else if (!NeedsScroll() || backButton.containsPoint(x, y))
            {
                exitQuestPage();
            }
            if (NeedsScroll())
            {
                if (downArrow.containsPoint(x, y) && scrollAmount < _contentHeight - _scissorRectHeight)
                {
                    DownArrowPressed();
                    Game1.playSound("shwip");
                }
                else if (upArrow.containsPoint(x, y) && scrollAmount > 0f)
                {
                    UpArrowPressed();
                    Game1.playSound("shwip");
                }
                else if (scrollBar.containsPoint(x, y))
                {
                    scrolling = true;
                }
                else if (scrollBarBounds.Contains(x, y))
                {
                    scrolling = true;
                }
                else if (!downArrow.containsPoint(x, y) && x > xPositionOnScreen + width && x < xPositionOnScreen + width + 128 && y > yPositionOnScreen && y < yPositionOnScreen + height)
                {
                    scrolling = true;
                    leftClickHeld(x, y);
                    releaseLeftClick(x, y);
                }
            }
        }