Added an api for the ScreenReader.cs
parent
94ca19f3bb
commit
ce5e85c9b9
|
@ -107,7 +107,7 @@ namespace stardew_access
|
|||
|
||||
helper.ConsoleCommands.Add("refsr", "Refresh screen reader", (string commmand, string[] args) =>
|
||||
{
|
||||
ScreenReader.initializeScreenReader();
|
||||
MainClass.screenReader.InitializeScreenReader();
|
||||
|
||||
MainClass.monitor.Log("Screen Reader refreshed!", LogLevel.Info);
|
||||
});
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace stardew_access.Game
|
|||
return;
|
||||
|
||||
previousSlotItem = currentSlotItem;
|
||||
ScreenReader.say($"{currentSlotItem.DisplayName} Selected", true);
|
||||
MainClass.screenReader.Say($"{currentSlotItem.DisplayName} Selected", true);
|
||||
}
|
||||
|
||||
// Narrates current location's name
|
||||
|
@ -38,7 +38,7 @@ namespace stardew_access.Game
|
|||
return;
|
||||
|
||||
previousLocation = currentLocation;
|
||||
ScreenReader.say($"{currentLocation.Name} Entered",true);
|
||||
MainClass.screenReader.Say($"{currentLocation.Name} Entered",true);
|
||||
}
|
||||
|
||||
public static void SnapMouseToPlayer()
|
||||
|
@ -89,7 +89,7 @@ namespace stardew_access.Game
|
|||
{
|
||||
MainClass.hudMessageQueryKey = searchQuery;
|
||||
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace stardew_access.Game
|
|||
{
|
||||
if (!manuallyTriggered && prevTile != gt)
|
||||
{
|
||||
ScreenReader.prevTextTile = " ";
|
||||
MainClass.screenReader.prevTextTile = " ";
|
||||
}
|
||||
|
||||
Dictionary<Vector2, Netcode.NetRef<TerrainFeature>> terrainFeature = Game1.currentLocation.terrainFeatures.FieldDict;
|
||||
|
@ -45,7 +45,7 @@ namespace stardew_access.Game
|
|||
NPC npc = Game1.currentLocation.isCharacterAtTile(gt);
|
||||
toSpeak = npc.displayName;
|
||||
}
|
||||
else if(getFarmAnimalAt(Game1.currentLocation, x, y) != null)
|
||||
else if (getFarmAnimalAt(Game1.currentLocation, x, y) != null)
|
||||
{
|
||||
toSpeak = getFarmAnimalAt(Game1.currentLocation, x, y);
|
||||
}
|
||||
|
@ -77,11 +77,11 @@ namespace stardew_access.Game
|
|||
{
|
||||
toSpeak = "Ladder";
|
||||
}
|
||||
else if(getBuildingAtTile(x, y) != null)
|
||||
else if (getBuildingAtTile(x, y) != null)
|
||||
{
|
||||
toSpeak = getBuildingAtTile(x, y);
|
||||
}
|
||||
else if(getJunimoBundleAt(x, y) != null)
|
||||
else if (getJunimoBundleAt(x, y) != null)
|
||||
{
|
||||
toSpeak = getJunimoBundleAt(x, y);
|
||||
}
|
||||
|
@ -89,17 +89,17 @@ namespace stardew_access.Game
|
|||
|
||||
#region Narrate toSpeak
|
||||
if (toSpeak != " ")
|
||||
if (manuallyTriggered)
|
||||
ScreenReader.say(toSpeak, true);
|
||||
else
|
||||
ScreenReader.sayWithTileQuery(toSpeak, x, y, true);
|
||||
if (manuallyTriggered)
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
else
|
||||
MainClass.screenReader.SayWithTileQuery(toSpeak, x, y, true);
|
||||
#endregion
|
||||
|
||||
#region Play colliding sound effect
|
||||
if (isCollidingAtTile(x, y) && prevTile != gt)
|
||||
{
|
||||
Game1.playSound("colliding");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
prevTile = gt;
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace stardew_access
|
|||
AutoHotkeyEngine ahk;
|
||||
public static string hudMessageQueryKey = "";
|
||||
public static Radar radarFeature;
|
||||
public static ScreenReader screenReader;
|
||||
|
||||
/*********
|
||||
** Public methods
|
||||
|
@ -50,7 +51,8 @@ namespace stardew_access
|
|||
monitor.Log($"Unable to initialize AutoHotKey:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
|
||||
}
|
||||
|
||||
ScreenReader.initializeScreenReader();
|
||||
screenReader = new ScreenReader();
|
||||
screenReader.InitializeScreenReader();
|
||||
|
||||
CustomSoundEffects.Initialize(helper);
|
||||
|
||||
|
@ -67,6 +69,12 @@ namespace stardew_access
|
|||
helper.Events.GameLoop.UpdateTicked += this.onUpdateTicked;
|
||||
}
|
||||
|
||||
/// <summary>Returns the Screen Reader class for other mods to use.</summary>
|
||||
public override object GetApi()
|
||||
{
|
||||
return new ScreenReader();
|
||||
}
|
||||
|
||||
private void onUpdateTicked(object sender, UpdateTickedEventArgs e)
|
||||
{
|
||||
if (!Context.IsPlayerFree)
|
||||
|
@ -104,28 +112,28 @@ namespace stardew_access
|
|||
if (Equals(e.Button, SButton.H))
|
||||
{
|
||||
string toSpeak = $"Health is {CurrentPlayer.getHealth()} and Stamina is {CurrentPlayer.getStamina()}";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
|
||||
// Narrate Position
|
||||
if (Equals(e.Button, SButton.K))
|
||||
{
|
||||
string toSpeak = $"X: {CurrentPlayer.getPositionX()} , Y: {CurrentPlayer.getPositionY()}";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
|
||||
// Narrate money at hand
|
||||
if (Equals(e.Button, SButton.R))
|
||||
{
|
||||
string toSpeak = $"You have {CurrentPlayer.getMoney()}g";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
|
||||
// Narrate time and season
|
||||
if (Equals(e.Button, SButton.Q))
|
||||
{
|
||||
string toSpeak = $"Time is {CurrentPlayer.getTimeOfDay()} and it is {CurrentPlayer.getDay()} {CurrentPlayer.getDate()} of {CurrentPlayer.getSeason()}";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
|
||||
// Manual read tile
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace stardew_access.Patches
|
|||
toSpeak += $"{message.message}, ";
|
||||
});
|
||||
if (toSpeak != " ")
|
||||
ScreenReader.sayWithChatChecker(toSpeak, false);
|
||||
MainClass.screenReader.SayWithChatChecker(toSpeak, false);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ namespace stardew_access.Patches
|
|||
toSpeak += $"{message.message}, ";
|
||||
});
|
||||
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
isChatRunning = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,9 +49,9 @@ namespace stardew_access.Patches
|
|||
if (toSpeak != " ")
|
||||
{
|
||||
if (hasResponses)
|
||||
ScreenReader.sayWithChecker(toSpeak, false);
|
||||
MainClass.screenReader.SayWithChecker(toSpeak, false);
|
||||
else
|
||||
ScreenReader.sayWithChecker(toSpeak, true);
|
||||
MainClass.screenReader.SayWithChecker(toSpeak, true);
|
||||
}
|
||||
}
|
||||
else if (__instance.isQuestion)
|
||||
|
@ -80,9 +80,9 @@ namespace stardew_access.Patches
|
|||
if (toSpeak != " ")
|
||||
{
|
||||
if (hasResponses)
|
||||
ScreenReader.sayWithChecker(toSpeak, false);
|
||||
MainClass.screenReader.SayWithChecker(toSpeak, false);
|
||||
else
|
||||
ScreenReader.sayWithChecker(toSpeak, true);
|
||||
MainClass.screenReader.SayWithChecker(toSpeak, true);
|
||||
}
|
||||
}
|
||||
else if (Game1.activeClickableMenu is DialogueBox)
|
||||
|
@ -91,7 +91,7 @@ namespace stardew_access.Patches
|
|||
if (currentDialogue != __instance.getCurrentString())
|
||||
{
|
||||
currentDialogue = __instance.getCurrentString();
|
||||
ScreenReader.say(__instance.getCurrentString(), true);
|
||||
MainClass.screenReader.Say(__instance.getCurrentString(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -261,9 +261,9 @@ namespace stardew_access.Patches
|
|||
if (toSpeak.ToString() != " ")
|
||||
{
|
||||
if (Context.IsPlayerFree)
|
||||
ScreenReader.sayWithChecker(toSpeak.ToString(), true); // Normal Checker
|
||||
MainClass.screenReader.SayWithChecker(toSpeak.ToString(), true); // Normal Checker
|
||||
else
|
||||
ScreenReader.sayWithMenuChecker(toSpeak.ToString(), true); // Menu Checker
|
||||
MainClass.screenReader.SayWithMenuChecker(toSpeak.ToString(), true); // Menu Checker
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
shopMenuQueryKey = toSpeak;
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
Game1.playSound("drop_item");
|
||||
}
|
||||
return;
|
||||
|
@ -59,7 +59,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
shopMenuQueryKey = toSpeak;
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
shopMenuQueryKey = toSpeak;
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
shopMenuQueryKey = toSpeak;
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
@ -146,7 +146,7 @@ namespace stardew_access.Patches
|
|||
if (gameMenuQueryKey != toSpeak)
|
||||
{
|
||||
gameMenuQueryKey = toSpeak;
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ namespace stardew_access.Patches
|
|||
if (geodeMenuQueryKey != toSpeak)
|
||||
{
|
||||
geodeMenuQueryKey = toSpeak;
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ namespace stardew_access.Patches
|
|||
if (geodeMenuQueryKey != toSpeak)
|
||||
{
|
||||
geodeMenuQueryKey = toSpeak;
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ namespace stardew_access.Patches
|
|||
if (geodeMenuQueryKey != toSpeak)
|
||||
{
|
||||
geodeMenuQueryKey = toSpeak;
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
Game1.playSound("drop_item");
|
||||
}
|
||||
return;
|
||||
|
@ -213,7 +213,7 @@ namespace stardew_access.Patches
|
|||
if (geodeMenuQueryKey != toSpeak)
|
||||
{
|
||||
geodeMenuQueryKey = toSpeak;
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ namespace stardew_access.Patches
|
|||
if (geodeMenuQueryKey != toSpeak)
|
||||
{
|
||||
geodeMenuQueryKey = toSpeak;
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ namespace stardew_access.Patches
|
|||
itemGrabMenuQueryKey = toSpeak;
|
||||
hoveredItemQueryKey = "";
|
||||
gameMenuQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ namespace stardew_access.Patches
|
|||
itemGrabMenuQueryKey = toSpeak;
|
||||
gameMenuQueryKey = "";
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ namespace stardew_access.Patches
|
|||
itemGrabMenuQueryKey = toSpeak;
|
||||
gameMenuQueryKey = "";
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ namespace stardew_access.Patches
|
|||
itemGrabMenuQueryKey = toSpeak;
|
||||
gameMenuQueryKey = "";
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ namespace stardew_access.Patches
|
|||
itemGrabMenuQueryKey = toSpeak;
|
||||
gameMenuQueryKey = "";
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ namespace stardew_access.Patches
|
|||
itemGrabMenuQueryKey = toSpeak;
|
||||
gameMenuQueryKey = "";
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -349,7 +349,7 @@ namespace stardew_access.Patches
|
|||
itemGrabMenuQueryKey = toSpeak;
|
||||
gameMenuQueryKey = "";
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -362,7 +362,7 @@ namespace stardew_access.Patches
|
|||
itemGrabMenuQueryKey = toSpeak;
|
||||
gameMenuQueryKey = "";
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
Game1.playSound("drop_item");
|
||||
}
|
||||
return;
|
||||
|
@ -404,7 +404,7 @@ namespace stardew_access.Patches
|
|||
itemGrabMenuQueryKey = toSpeak;
|
||||
gameMenuQueryKey = "";
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -542,7 +542,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
craftingPageQueryKey = toSpeak;
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -554,7 +554,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
craftingPageQueryKey = toSpeak;
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -566,7 +566,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
craftingPageQueryKey = toSpeak;
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -578,7 +578,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
craftingPageQueryKey = toSpeak;
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
Game1.playSound("drop_item");
|
||||
}
|
||||
return;
|
||||
|
@ -655,7 +655,7 @@ namespace stardew_access.Patches
|
|||
craftingPageQueryKey = toSpeak;
|
||||
gameMenuQueryKey = "";
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -722,7 +722,7 @@ namespace stardew_access.Patches
|
|||
inventoryPageQueryKey = toSpeak;
|
||||
gameMenuQueryKey = "";
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
Game1.playSound("drop_item");
|
||||
}
|
||||
return;
|
||||
|
@ -736,7 +736,7 @@ namespace stardew_access.Patches
|
|||
inventoryPageQueryKey = toSpeak;
|
||||
gameMenuQueryKey = "";
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -749,7 +749,7 @@ namespace stardew_access.Patches
|
|||
inventoryPageQueryKey = toSpeak;
|
||||
gameMenuQueryKey = "";
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -762,7 +762,7 @@ namespace stardew_access.Patches
|
|||
itemGrabMenuQueryKey = toSpeak;
|
||||
gameMenuQueryKey = "";
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -776,7 +776,7 @@ namespace stardew_access.Patches
|
|||
itemGrabMenuQueryKey = toSpeak;
|
||||
gameMenuQueryKey = "";
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -872,7 +872,7 @@ namespace stardew_access.Patches
|
|||
inventoryPageQueryKey = toSpeak;
|
||||
gameMenuQueryKey = "";
|
||||
hoveredItemQueryKey = "";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -935,7 +935,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
gameMenuQueryKey = "";
|
||||
optionsPageQueryKey = toSpeak;
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -959,7 +959,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
gameMenuQueryKey = "";
|
||||
exitPageQueryKey = toSpeak;
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -971,7 +971,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
gameMenuQueryKey = "";
|
||||
exitPageQueryKey = toSpeak;
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1110,7 +1110,7 @@ namespace stardew_access.Patches
|
|||
if (hoveredItemQueryKey != $"{toSpeak}:{i}")
|
||||
{
|
||||
hoveredItemQueryKey = $"{toSpeak}:{i}";
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -52,13 +52,13 @@ namespace stardew_access.Patches
|
|||
|
||||
if(__instance.nextPageButton != null && __instance.nextPageButton.containsPoint(x, y))
|
||||
{
|
||||
ScreenReader.sayWithMenuChecker($"Next Page Button", true);
|
||||
MainClass.screenReader.SayWithMenuChecker($"Next Page Button", true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (__instance.previousPageButton != null && __instance.previousPageButton.containsPoint(x, y))
|
||||
{
|
||||
ScreenReader.sayWithMenuChecker($"Previous Page Button", true);
|
||||
MainClass.screenReader.SayWithMenuChecker($"Previous Page Button", true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
if(__instance.languages[i].containsPoint(x, y))
|
||||
{
|
||||
ScreenReader.sayWithMenuChecker($"{__instance.languageList[i]} Button", true);
|
||||
MainClass.screenReader.SayWithMenuChecker($"{__instance.languageList[i]} Button", true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
if(___elevators[i].containsPoint(x, y))
|
||||
{
|
||||
ScreenReader.sayWithMenuChecker($"{___elevators[i].name} level", true);
|
||||
MainClass.screenReader.SayWithMenuChecker($"{___elevators[i].name} level", true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ namespace stardew_access.Patches
|
|||
___textBox.SelectMe();
|
||||
string toSpeak = $"{title}";
|
||||
|
||||
ScreenReader.sayWithChecker(toSpeak, true);
|
||||
MainClass.screenReader.SayWithChecker(toSpeak, true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -119,13 +119,13 @@ namespace stardew_access.Patches
|
|||
{
|
||||
int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y;
|
||||
|
||||
ScreenReader.sayWithMenuChecker(___message, true);
|
||||
MainClass.screenReader.SayWithMenuChecker(___message, true);
|
||||
if(__instance.okButton.containsPoint(x, y))
|
||||
{
|
||||
ScreenReader.sayWithMenuChecker("Ok Button", false);
|
||||
MainClass.screenReader.SayWithMenuChecker("Ok Button", false);
|
||||
} else if (__instance.cancelButton.containsPoint(x, y))
|
||||
{
|
||||
ScreenReader.sayWithMenuChecker("Cancel Button", false);
|
||||
MainClass.screenReader.SayWithMenuChecker("Cancel Button", false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -187,10 +187,10 @@ namespace stardew_access.Patches
|
|||
}
|
||||
|
||||
if (toSpeak != " ")
|
||||
ScreenReader.sayWithMenuChecker(toSpeak, true);
|
||||
MainClass.screenReader.SayWithMenuChecker(toSpeak, true);
|
||||
else if (__instance.isProfessionChooser && currentLevelUpTitle != $"{___title}. Select a new profession.")
|
||||
{
|
||||
ScreenReader.sayWithMenuChecker($"{___title}. Select a new profession.", true);
|
||||
MainClass.screenReader.SayWithMenuChecker($"{___title}. Select a new profession.", true);
|
||||
currentLevelUpTitle = $"{___title}. Select a new profession.";
|
||||
}
|
||||
}
|
||||
|
@ -211,14 +211,14 @@ namespace stardew_access.Patches
|
|||
if (__instance.okButton.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y))
|
||||
{
|
||||
toSpeak = $"{total}g in total. Press left mouse button to save.";
|
||||
ScreenReader.sayWithChecker(toSpeak, true);
|
||||
MainClass.screenReader.SayWithChecker(toSpeak, true);
|
||||
}
|
||||
for (int i = 0; i < __instance.categories.Count; i++)
|
||||
{
|
||||
if (__instance.categories[i].containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y))
|
||||
{
|
||||
toSpeak = $"Money recieved from {__instance.getCategoryName(i)}: {___categoryTotals[i]}g.";
|
||||
ScreenReader.sayWithChecker(toSpeak, true);
|
||||
MainClass.screenReader.SayWithChecker(toSpeak, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ namespace stardew_access.Patches
|
|||
toSpeak += "\t\n Left click to accept quest.";
|
||||
__instance.acceptQuestButton.snapMouseCursorToCenter();
|
||||
}
|
||||
ScreenReader.say(toSpeak, false);
|
||||
MainClass.screenReader.Say(toSpeak, false);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -278,7 +278,7 @@ namespace stardew_access.Patches
|
|||
string label = c.label;
|
||||
|
||||
if (c.containsPoint(Game1.getMousePosition().X, Game1.getMousePosition().Y))
|
||||
ScreenReader.sayWithChecker($"Grab: {name} \t\n {label}", false);
|
||||
MainClass.screenReader.SayWithChecker($"Grab: {name} \t\n {label}", false);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace stardew_access.Patches
|
|||
|
||||
toSpeak = $"Left Quest:\n\t{toSpeak}\n\tPress left click to accept this quest.";
|
||||
|
||||
ScreenReader.sayWithMenuChecker(toSpeak, true);
|
||||
MainClass.screenReader.SayWithMenuChecker(toSpeak, true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace stardew_access.Patches
|
|||
|
||||
toSpeak = $"Right Quest:\n\t{toSpeak}\n\tPress left click to accept this quest.";
|
||||
|
||||
ScreenReader.sayWithMenuChecker(toSpeak, true);
|
||||
MainClass.screenReader.SayWithMenuChecker(toSpeak, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ namespace stardew_access.Patches
|
|||
if (Game1.dayOfMonth == i + 1)
|
||||
toSpeak += $", Current";
|
||||
|
||||
ScreenReader.sayWithChecker(toSpeak, true);
|
||||
MainClass.screenReader.SayWithChecker(toSpeak, true);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
@ -114,7 +114,7 @@ namespace stardew_access.Patches
|
|||
if (currentDailyQuestText != toSpeak)
|
||||
{
|
||||
currentDailyQuestText = toSpeak;
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -134,7 +134,7 @@ namespace stardew_access.Patches
|
|||
__instance.acceptQuestButton.snapMouseCursorToCenter();
|
||||
}
|
||||
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
@ -171,7 +171,7 @@ namespace stardew_access.Patches
|
|||
toSpeak += ___pages[___currentPage][i].ShouldDisplayAsComplete() ? " completed!" : "";
|
||||
if (__instance.questLogButtons[i].containsPoint(Game1.getOldMouseX(), Game1.getOldMouseY()))
|
||||
{
|
||||
ScreenReader.sayWithChecker(toSpeak, true);
|
||||
MainClass.screenReader.SayWithChecker(toSpeak, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ namespace stardew_access.Patches
|
|||
if (snapMouseToRewardBox)
|
||||
__instance.rewardBox.snapMouseCursorToCenter();
|
||||
|
||||
ScreenReader.sayWithChecker(toSpeak, true);
|
||||
MainClass.screenReader.SayWithChecker(toSpeak, true);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace stardew_access.Patches
|
|||
#endregion
|
||||
|
||||
if (toSpeak != " ")
|
||||
ScreenReader.sayWithChecker(toSpeak, true);
|
||||
MainClass.screenReader.SayWithChecker(toSpeak, true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -95,11 +95,11 @@ namespace stardew_access.Patches
|
|||
if (TitleMenu.subMenu != null && __instance.backButton.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y))
|
||||
{
|
||||
string text = "Back Button";
|
||||
ScreenReader.sayWithChecker(text, true);
|
||||
MainClass.screenReader.SayWithChecker(text, true);
|
||||
}
|
||||
|
||||
if (TitleMenu.subMenu == null && toSpeak != "")
|
||||
ScreenReader.sayWithChecker(toSpeak, true);
|
||||
MainClass.screenReader.SayWithChecker(toSpeak, true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -119,7 +119,7 @@ namespace stardew_access.Patches
|
|||
#region Farms
|
||||
if (___menu.deleteButtons.Count > 0 && ___menu.deleteButtons[i].containsPoint(x, y))
|
||||
{
|
||||
ScreenReader.sayWithChecker($"Delete {__instance.Farmer.farmName} Farm", true);
|
||||
MainClass.screenReader.SayWithChecker($"Delete {__instance.Farmer.farmName} Farm", true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -128,14 +128,14 @@ namespace stardew_access.Patches
|
|||
// Used diff. functions to narrate to prevent it from speaking the message again on selecting another button.
|
||||
string message = "Really delete farm?";
|
||||
|
||||
ScreenReader.sayWithChecker(message, true);
|
||||
MainClass.screenReader.SayWithChecker(message, true);
|
||||
if (___menu.okDeleteButton.containsPoint(x, y))
|
||||
{
|
||||
ScreenReader.sayWithMenuChecker("Ok Button", false);
|
||||
MainClass.screenReader.SayWithMenuChecker("Ok Button", false);
|
||||
}
|
||||
else if (___menu.cancelDeleteButton.containsPoint(x, y))
|
||||
{
|
||||
ScreenReader.sayWithMenuChecker("Cancel Button", false);
|
||||
MainClass.screenReader.SayWithMenuChecker("Cancel Button", false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ namespace stardew_access.Patches
|
|||
|
||||
string toSpeak = $"{farmName} Farm Selected, \t\n Farmer:{farmerName}, \t\nMoney:{money}, \t\nHours Played:{hoursPlayed}, \t\nDate:{dateStringForSaveGame}";
|
||||
|
||||
ScreenReader.sayWithChecker(toSpeak, true);
|
||||
MainClass.screenReader.SayWithChecker(toSpeak, true);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -640,7 +640,7 @@ namespace stardew_access.Patches
|
|||
|
||||
if(toSpeak!=" ")
|
||||
{
|
||||
ScreenReader.say(toSpeak, true);
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
|
||||
await Task.Delay(200);
|
||||
|
|
|
@ -3,12 +3,13 @@ using StardewModdingAPI;
|
|||
|
||||
namespace stardew_access
|
||||
{
|
||||
internal class ScreenReader
|
||||
public class ScreenReader
|
||||
{
|
||||
public static IAccessibleOutput? screenReader = null;
|
||||
internal static string prevText = "", prevTextTile = " ", prevChatText = "", prevMenuText = "";
|
||||
public IAccessibleOutput? screenReader = null;
|
||||
public string prevText = "", prevTextTile = " ", prevChatText = "", prevMenuText = "";
|
||||
|
||||
public static void initializeScreenReader()
|
||||
/// <summary>Initializes the screen reader.</summary>
|
||||
public void InitializeScreenReader()
|
||||
{
|
||||
NvdaOutput? nvdaOutput = null;
|
||||
JawsOutput? jawsOutput = null;
|
||||
|
@ -45,7 +46,10 @@ namespace stardew_access
|
|||
MainClass.monitor.Log($"Unable to load any screen reader!", LogLevel.Error);
|
||||
}
|
||||
|
||||
public static void say(string text, bool interrupt)
|
||||
/// <summary>Speaks the text via the loaded screen reader (if any).</summary>
|
||||
/// <param name="text">The text to be narrated.</param>
|
||||
/// <param name="interrupt">Whether to skip the currently speaking text or not.</param>
|
||||
public void Say(string text, bool interrupt)
|
||||
{
|
||||
if (screenReader == null)
|
||||
return;
|
||||
|
@ -53,7 +57,11 @@ namespace stardew_access
|
|||
screenReader.Speak(text, interrupt);
|
||||
}
|
||||
|
||||
public static void sayWithChecker(string text, bool interrupt)
|
||||
/// <summary>Speaks the text via the loaded screen reader (if any).
|
||||
/// <br/>Skips the text narration if the previously narrated text was the same as the one provided.</summary>
|
||||
/// <param name="text">The text to be narrated.</param>
|
||||
/// <param name="interrupt">Whether to skip the currently speaking text or not.</param>
|
||||
public void SayWithChecker(string text, bool interrupt)
|
||||
{
|
||||
if (screenReader == null)
|
||||
return;
|
||||
|
@ -65,7 +73,12 @@ namespace stardew_access
|
|||
}
|
||||
}
|
||||
|
||||
public static void sayWithMenuChecker(string text, bool interrupt)
|
||||
/// <summary>Speaks the text via the loaded screen reader (if any).
|
||||
/// <br/>Skips the text narration if the previously narrated text was the same as the one provided.
|
||||
/// <br/><br/>Use this when narrating hovered component in menus to avoid interference.</summary>
|
||||
/// <param name="text">The text to be narrated.</param>
|
||||
/// <param name="interrupt">Whether to skip the currently speaking text or not.</param>
|
||||
public void SayWithMenuChecker(string text, bool interrupt)
|
||||
{
|
||||
if (screenReader == null)
|
||||
return;
|
||||
|
@ -77,7 +90,12 @@ namespace stardew_access
|
|||
}
|
||||
}
|
||||
|
||||
public static void sayWithChatChecker(string text, bool interrupt)
|
||||
/// <summary>Speaks the text via the loaded screen reader (if any).
|
||||
/// <br/>Skips the text narration if the previously narrated text was the same as the one provided.
|
||||
/// <br/><br/>Use this when narrating chat messages to avoid interference.</summary>
|
||||
/// <param name="text">The text to be narrated.</param>
|
||||
/// <param name="interrupt">Whether to skip the currently speaking text or not.</param>
|
||||
public void SayWithChatChecker(string text, bool interrupt)
|
||||
{
|
||||
if (screenReader == null)
|
||||
return;
|
||||
|
@ -89,7 +107,14 @@ namespace stardew_access
|
|||
}
|
||||
}
|
||||
|
||||
public static void sayWithTileQuery(string text, int x, int y, bool interrupt)
|
||||
/// <summary>Speaks the text via the loaded screen reader (if any).
|
||||
/// <br/>Skips the text narration if the previously narrated text was the same as the one provided.
|
||||
/// <br/><br/>Use this when narrating texts based on tile position to avoid interference.</summary>
|
||||
/// <param name="text">The text to be narrated.</param>
|
||||
/// <param name="x">The X location of tile.</param>
|
||||
/// <param name="y">The Y location of tile.</param>
|
||||
/// <param name="interrupt">Whether to skip the currently speaking text or not.</param>
|
||||
public void SayWithTileQuery(string text, int x, int y, bool interrupt)
|
||||
{
|
||||
if (screenReader == null)
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue