Bug fix in quest log patch

master
Mohammad Shoaib 2022-04-23 16:34:53 +05:30
parent 49ec3fc85b
commit bfdb7c9f5b
1 changed files with 60 additions and 41 deletions

View File

@ -10,6 +10,7 @@ namespace stardew_access.Patches
{
internal static string currentDailyQuestText = " ";
internal static string questLogQuery = " ";
internal static bool isNarratingQuestInfo = false, firstTimeInIndividualQuest = true;
#region For Special Orders Board
internal static void SpecialOrdersBoardPatch(SpecialOrdersBoard __instance)
@ -153,18 +154,21 @@ namespace stardew_access.Patches
{
try
{
bool snapMouseToRewardBox = false;
bool isCPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.C);
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
string toSpeak = " ", extra = "";
if (___questPage == -1)
{
#region Quest Lists
string toSpeak = " ";
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))
if (!__instance.questLogButtons[i].containsPoint(x, y))
continue;
string name = ___pages[___currentPage][i].GetName();
@ -183,8 +187,6 @@ namespace stardew_access.Patches
toSpeak = "Previous page 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";
@ -198,32 +200,30 @@ namespace stardew_access.Patches
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();
string toSpeak = " ";
if (firstTimeInIndividualQuest || (isCPressed && !isNarratingQuestInfo))
{
if (firstTimeInIndividualQuest)
toSpeak = "Back button";
if (____shownQuest.ShouldDisplayAsComplete())
{
#region Quest completed menu
toSpeak = $"Quest: {title} Completed!";
extra = $"Quest: {title} Completed!";
if (__instance.HasReward())
{
snapMouseToRewardBox = true;
if (__instance.HasMoneyReward())
{
toSpeak += $"you recieved {____shownQuest.GetMoneyReward()}g";
}
toSpeak += "... left click to collect reward";
}
extra += $"you recieved {____shownQuest.GetMoneyReward()}g";
#endregion
}
else
{
#region Quest in-complete menu
toSpeak = $"Title: {title}. \t\n Description: {description}";
extra = $"Title: {title}. \t\n Description: {description}";
for (int j = 0; j < ____objectiveText.Count; j++)
{
@ -233,7 +233,7 @@ namespace stardew_access.Patches
}
string parsed_text = Game1.parseText(____objectiveText[j], width: __instance.width - 192, whichFont: Game1.dialogueFont);
toSpeak += $"\t\nOrder {j + 1}: {parsed_text} \t\n";
extra += $"\t\nOrder {j + 1}: {parsed_text} \t\n";
}
if (____shownQuest != null)
@ -241,16 +241,35 @@ namespace stardew_access.Patches
int daysLeft = ____shownQuest.GetDaysLeft();
if (daysLeft > 0)
toSpeak += $"\t\n{daysLeft} days left.";
extra += $"\t\n{daysLeft} days left.";
}
#endregion
}
// Move mouse to reward button
if (snapMouseToRewardBox)
__instance.rewardBox.snapMouseCursorToCenter();
isNarratingQuestInfo = true;
Task.Delay(200).ContinueWith(_ => { isNarratingQuestInfo = false; });
questLogQuery = " ";
}
if (!firstTimeInIndividualQuest)
if (__instance.backButton != null && __instance.backButton.visible && __instance.backButton.containsPoint(x, y))
toSpeak = "Back 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;
}
MainClass.ScreenReader.SayWithChecker(toSpeak, true);
#endregion
}
}