Added page up/down to cycle through chats
parent
b9c29f1fed
commit
aa0f36cad1
|
@ -10,8 +10,8 @@ namespace stardew_access.Patches
|
||||||
{
|
{
|
||||||
internal class MenuPatch
|
internal class MenuPatch
|
||||||
{
|
{
|
||||||
private static int saveGameIndex = -1;
|
private static int saveGameIndex = -1, currentChatMessageIndex = 0;
|
||||||
private static bool isRunning = false;
|
private static bool isRunning = false, isChatRunning = false;
|
||||||
private static string currentLetterText = " ";
|
private static string currentLetterText = " ";
|
||||||
private static string currentDailyQuestText = " ";
|
private static string currentDailyQuestText = " ";
|
||||||
|
|
||||||
|
@ -19,15 +19,38 @@ namespace stardew_access.Patches
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (___messages.Count - 1 < 0)
|
string toSpeak = " ";
|
||||||
return;
|
|
||||||
|
|
||||||
string toSpeak = "";
|
if (__instance.chatBox.Selected)
|
||||||
___messages[___messages.Count - 1].message.ForEach(message =>
|
|
||||||
{
|
{
|
||||||
toSpeak += $"{message.message}, ";
|
bool isPrevArrowPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.PageUp);
|
||||||
});
|
bool isNextArrowPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.PageDown);
|
||||||
ScreenReader.sayWithChatChecker(toSpeak, false);
|
|
||||||
|
if (___messages.Count > 0)
|
||||||
|
{
|
||||||
|
#region To narrate previous and next chat messages
|
||||||
|
if (isNextArrowPressed && !isChatRunning)
|
||||||
|
{
|
||||||
|
_ = CycleThroughChatMessages(true, ___messages);
|
||||||
|
}
|
||||||
|
else if (isPrevArrowPressed && !isChatRunning)
|
||||||
|
{
|
||||||
|
_ = CycleThroughChatMessages(false, ___messages);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (___messages.Count > 0)
|
||||||
|
{
|
||||||
|
#region To narrate latest chat message
|
||||||
|
___messages[___messages.Count - 1].message.ForEach(message =>
|
||||||
|
{
|
||||||
|
toSpeak += $"{message.message}, ";
|
||||||
|
});
|
||||||
|
if (toSpeak != " ")
|
||||||
|
ScreenReader.sayWithChatChecker(toSpeak, false);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -35,6 +58,36 @@ namespace stardew_access.Patches
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static async Task CycleThroughChatMessages(bool increase, List<ChatMessage> ___messages)
|
||||||
|
{
|
||||||
|
isChatRunning = true;
|
||||||
|
await Task.Delay(200);
|
||||||
|
string toSpeak = " ";
|
||||||
|
if (increase)
|
||||||
|
{
|
||||||
|
++currentChatMessageIndex;
|
||||||
|
if (currentChatMessageIndex > ___messages.Count - 1)
|
||||||
|
{
|
||||||
|
currentChatMessageIndex = ___messages.Count - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
--currentChatMessageIndex;
|
||||||
|
if (currentChatMessageIndex < 0)
|
||||||
|
{
|
||||||
|
currentChatMessageIndex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
___messages[currentChatMessageIndex].message.ForEach(message =>
|
||||||
|
{
|
||||||
|
toSpeak += $"{message.message}, ";
|
||||||
|
});
|
||||||
|
|
||||||
|
ScreenReader.say(toSpeak, true);
|
||||||
|
isChatRunning = false;
|
||||||
|
}
|
||||||
|
|
||||||
internal static void CoopMenuPatch(CoopMenu __instance, CoopMenu.Tab ___currentTab)
|
internal static void CoopMenuPatch(CoopMenu __instance, CoopMenu.Tab ___currentTab)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue