Added door name narration and fixed warnings

master
Mohammad Shoaib 2022-02-13 16:57:06 +05:30
parent a2d2f2e63a
commit 2a059ffc29
18 changed files with 532 additions and 491 deletions

View File

@ -0,0 +1,51 @@
namespace stardew_access.ScreenReader
{
public class API
{
public API()
{
}
public void Say(String text, Boolean interrupt)
{
if (MainClass.GetScreenReader() == null)
return;
MainClass.GetScreenReader().Say(text, interrupt);
}
public void SayWithChecker(String text, Boolean interrupt)
{
if (MainClass.GetScreenReader() == null)
return;
MainClass.GetScreenReader().SayWithChecker(text, interrupt);
}
public void SayWithMenuChecker(String text, Boolean interrupt)
{
if (MainClass.GetScreenReader() == null)
return;
MainClass.GetScreenReader().SayWithMenuChecker(text, interrupt);
}
public void SayWithChatChecker(String text, Boolean interrupt)
{
if (MainClass.GetScreenReader() == null)
return;
MainClass.GetScreenReader().SayWithChatChecker(text, interrupt);
}
public void SayWithTileQuery(String text, int x, int y, Boolean interrupt)
{
if (MainClass.GetScreenReader() == null)
return;
MainClass.GetScreenReader().SayWithTileQuery(text, x, y, interrupt);
}
}
}

View File

@ -17,21 +17,21 @@ namespace stardew_access
{ {
MainClass.readTile = !MainClass.readTile; MainClass.readTile = !MainClass.readTile;
MainClass.Monitor.Log("Read Tile is " + (MainClass.readTile ? "on" : "off"), LogLevel.Info); MainClass.GetMonitor().Log("Read Tile is " + (MainClass.readTile ? "on" : "off"), LogLevel.Info);
}); });
helper.ConsoleCommands.Add("snapmouse", "Toggle snap mouse feature.", (string commmand, string[] args) => helper.ConsoleCommands.Add("snapmouse", "Toggle snap mouse feature.", (string commmand, string[] args) =>
{ {
MainClass.snapMouse = !MainClass.snapMouse; MainClass.snapMouse = !MainClass.snapMouse;
MainClass.Monitor.Log("Snap Mouse is " + (MainClass.snapMouse ? "on" : "off"), LogLevel.Info); MainClass.GetMonitor().Log("Snap Mouse is " + (MainClass.snapMouse ? "on" : "off"), LogLevel.Info);
}); });
helper.ConsoleCommands.Add("radar", "Toggle radar feature.", (string commmand, string[] args) => helper.ConsoleCommands.Add("radar", "Toggle radar feature.", (string commmand, string[] args) =>
{ {
MainClass.radar = !MainClass.radar; MainClass.radar = !MainClass.radar;
MainClass.Monitor.Log("Radar " + (MainClass.radar ? "on" : "off"), LogLevel.Info); MainClass.GetMonitor().Log("Radar " + (MainClass.radar ? "on" : "off"), LogLevel.Info);
}); });
#region Radar Feature #region Radar Feature
@ -39,21 +39,21 @@ namespace stardew_access
{ {
MainClass.radarDebug = !MainClass.radarDebug; MainClass.radarDebug = !MainClass.radarDebug;
MainClass.Monitor.Log("Radar debugging " + (MainClass.radarDebug ? "on" : "off"), LogLevel.Info); MainClass.GetMonitor().Log("Radar debugging " + (MainClass.radarDebug ? "on" : "off"), LogLevel.Info);
}); });
helper.ConsoleCommands.Add("rstereo", "Toggle stereo sound in radar feature.", (string commmand, string[] args) => helper.ConsoleCommands.Add("rstereo", "Toggle stereo sound in radar feature.", (string commmand, string[] args) =>
{ {
MainClass.radarStereoSound = !MainClass.radarStereoSound; MainClass.radarStereoSound = !MainClass.radarStereoSound;
MainClass.Monitor.Log("Stereo sound is " + (MainClass.radarStereoSound ? "on" : "off"), LogLevel.Info); MainClass.GetMonitor().Log("Stereo sound is " + (MainClass.radarStereoSound ? "on" : "off"), LogLevel.Info);
}); });
helper.ConsoleCommands.Add("rfocus", "Toggle focus mode in radar feature.", (string commmand, string[] args) => helper.ConsoleCommands.Add("rfocus", "Toggle focus mode in radar feature.", (string commmand, string[] args) =>
{ {
bool focus = MainClass.RadarFeature.ToggleFocus(); bool focus = MainClass.RadarFeature.ToggleFocus();
MainClass.Monitor.Log("Focus mode is " + (focus ? "on" : "off"), LogLevel.Info); MainClass.GetMonitor().Log("Focus mode is " + (focus ? "on" : "off"), LogLevel.Info);
}); });
helper.ConsoleCommands.Add("rdelay", "Set the delay of radar feature in milliseconds.", (string commmand, string[] args) => helper.ConsoleCommands.Add("rdelay", "Set the delay of radar feature in milliseconds.", (string commmand, string[] args) =>
@ -72,19 +72,19 @@ namespace stardew_access
{ {
MainClass.RadarFeature.delay = delay; MainClass.RadarFeature.delay = delay;
if (delay >= 1000) if (delay >= 1000)
MainClass.Monitor.Log($"Delay set to {MainClass.RadarFeature.delay} milliseconds.", LogLevel.Info); MainClass.GetMonitor().Log($"Delay set to {MainClass.RadarFeature.delay} milliseconds.", LogLevel.Info);
else else
MainClass.Monitor.Log($"Delay should be atleast 1 second or 1000 millisecond long.", LogLevel.Info); MainClass.GetMonitor().Log($"Delay should be atleast 1 second or 1000 millisecond long.", LogLevel.Info);
} }
else else
{ {
MainClass.Monitor.Log("Invalid delay amount, it can only be in numeric form.", LogLevel.Info); MainClass.GetMonitor().Log("Invalid delay amount, it can only be in numeric form.", LogLevel.Info);
} }
} }
else else
{ {
MainClass.Monitor.Log("Enter the delay amount (in milliseconds)!", LogLevel.Info); MainClass.GetMonitor().Log("Enter the delay amount (in milliseconds)!", LogLevel.Info);
} }
}); });
@ -105,19 +105,19 @@ namespace stardew_access
{ {
MainClass.RadarFeature.range = range; MainClass.RadarFeature.range = range;
if (range >= 2 && range <= 10) if (range >= 2 && range <= 10)
MainClass.Monitor.Log($"Range set to {MainClass.RadarFeature.range}.", LogLevel.Info); MainClass.GetMonitor().Log($"Range set to {MainClass.RadarFeature.range}.", LogLevel.Info);
else else
MainClass.Monitor.Log($"Range should be atleast 2 and maximum 10.", LogLevel.Info); MainClass.GetMonitor().Log($"Range should be atleast 2 and maximum 10.", LogLevel.Info);
} }
else else
{ {
MainClass.Monitor.Log("Invalid range amount, it can only be in numeric form.", LogLevel.Info); MainClass.GetMonitor().Log("Invalid range amount, it can only be in numeric form.", LogLevel.Info);
} }
} }
else else
{ {
MainClass.Monitor.Log("Enter the range amount!", LogLevel.Info); MainClass.GetMonitor().Log("Enter the range amount!", LogLevel.Info);
} }
}); });
@ -136,16 +136,16 @@ namespace stardew_access
if (!MainClass.RadarFeature.exclusions.Contains(keyToAdd)) if (!MainClass.RadarFeature.exclusions.Contains(keyToAdd))
{ {
MainClass.RadarFeature.exclusions.Add(keyToAdd); MainClass.RadarFeature.exclusions.Add(keyToAdd);
MainClass.Monitor.Log($"Added {keyToAdd} key to exclusions list.", LogLevel.Info); MainClass.GetMonitor().Log($"Added {keyToAdd} key to exclusions list.", LogLevel.Info);
} }
else else
{ {
MainClass.Monitor.Log($"{keyToAdd} key already present in the list.", LogLevel.Info); MainClass.GetMonitor().Log($"{keyToAdd} key already present in the list.", LogLevel.Info);
} }
} }
else else
{ {
MainClass.Monitor.Log("Unable to add the key to exclusions list.", LogLevel.Info); MainClass.GetMonitor().Log("Unable to add the key to exclusions list.", LogLevel.Info);
} }
}); });
@ -161,16 +161,16 @@ namespace stardew_access
if (MainClass.RadarFeature.exclusions.Contains(keyToAdd)) if (MainClass.RadarFeature.exclusions.Contains(keyToAdd))
{ {
MainClass.RadarFeature.exclusions.Remove(keyToAdd); MainClass.RadarFeature.exclusions.Remove(keyToAdd);
MainClass.Monitor.Log($"Removed {keyToAdd} key from exclusions list.", LogLevel.Info); MainClass.GetMonitor().Log($"Removed {keyToAdd} key from exclusions list.", LogLevel.Info);
} }
else else
{ {
MainClass.Monitor.Log($"Cannot find {keyToAdd} key in exclusions list.", LogLevel.Info); MainClass.GetMonitor().Log($"Cannot find {keyToAdd} key in exclusions list.", LogLevel.Info);
} }
} }
else else
{ {
MainClass.Monitor.Log("Unable to remove the key from exclusions list.", LogLevel.Info); MainClass.GetMonitor().Log("Unable to remove the key from exclusions list.", LogLevel.Info);
} }
}); });
@ -183,23 +183,23 @@ namespace stardew_access
{ {
toPrint = $"{toPrint}\t{i + 1}: {MainClass.RadarFeature.exclusions[i]}"; toPrint = $"{toPrint}\t{i + 1}: {MainClass.RadarFeature.exclusions[i]}";
} }
MainClass.Monitor.Log(toPrint, LogLevel.Info); MainClass.GetMonitor().Log(toPrint, LogLevel.Info);
} }
else else
{ {
MainClass.Monitor.Log("No exclusions found.", LogLevel.Info); MainClass.GetMonitor().Log("No exclusions found.", LogLevel.Info);
} }
}); });
helper.ConsoleCommands.Add("reclear", "Clear the focus exclusions in the radar featrure.", (string commmand, string[] args) => helper.ConsoleCommands.Add("reclear", "Clear the focus exclusions in the radar featrure.", (string commmand, string[] args) =>
{ {
MainClass.RadarFeature.exclusions.Clear(); MainClass.RadarFeature.exclusions.Clear();
MainClass.Monitor.Log($"Cleared the focus list in the exclusions feature.", LogLevel.Info); MainClass.GetMonitor().Log($"Cleared the focus list in the exclusions feature.", LogLevel.Info);
}); });
helper.ConsoleCommands.Add("recount", "Number of exclusions in the radar feature.", (string commmand, string[] args) => helper.ConsoleCommands.Add("recount", "Number of exclusions in the radar feature.", (string commmand, string[] args) =>
{ {
MainClass.Monitor.Log($"There are {MainClass.RadarFeature.exclusions.Count} exclusiond in the radar feature.", LogLevel.Info); MainClass.GetMonitor().Log($"There are {MainClass.RadarFeature.exclusions.Count} exclusiond in the radar feature.", LogLevel.Info);
}); });
#endregion #endregion
@ -216,16 +216,16 @@ namespace stardew_access
if (!MainClass.RadarFeature.focus.Contains(keyToAdd)) if (!MainClass.RadarFeature.focus.Contains(keyToAdd))
{ {
MainClass.RadarFeature.focus.Add(keyToAdd); MainClass.RadarFeature.focus.Add(keyToAdd);
MainClass.Monitor.Log($"Added {keyToAdd} key to focus list.", LogLevel.Info); MainClass.GetMonitor().Log($"Added {keyToAdd} key to focus list.", LogLevel.Info);
} }
else else
{ {
MainClass.Monitor.Log($"{keyToAdd} key already present in the list.", LogLevel.Info); MainClass.GetMonitor().Log($"{keyToAdd} key already present in the list.", LogLevel.Info);
} }
} }
else else
{ {
MainClass.Monitor.Log("Unable to add the key to focus list.", LogLevel.Info); MainClass.GetMonitor().Log("Unable to add the key to focus list.", LogLevel.Info);
} }
}); });
@ -241,16 +241,16 @@ namespace stardew_access
if (MainClass.RadarFeature.focus.Contains(keyToAdd)) if (MainClass.RadarFeature.focus.Contains(keyToAdd))
{ {
MainClass.RadarFeature.focus.Remove(keyToAdd); MainClass.RadarFeature.focus.Remove(keyToAdd);
MainClass.Monitor.Log($"Removed {keyToAdd} key from focus list.", LogLevel.Info); MainClass.GetMonitor().Log($"Removed {keyToAdd} key from focus list.", LogLevel.Info);
} }
else else
{ {
MainClass.Monitor.Log($"Cannot find {keyToAdd} key in focus list.", LogLevel.Info); MainClass.GetMonitor().Log($"Cannot find {keyToAdd} key in focus list.", LogLevel.Info);
} }
} }
else else
{ {
MainClass.Monitor.Log("Unable to remove the key from focus list.", LogLevel.Info); MainClass.GetMonitor().Log("Unable to remove the key from focus list.", LogLevel.Info);
} }
}); });
@ -263,23 +263,23 @@ namespace stardew_access
{ {
toPrint = $"{toPrint}\t{i + 1}): {MainClass.RadarFeature.focus[i]}"; toPrint = $"{toPrint}\t{i + 1}): {MainClass.RadarFeature.focus[i]}";
} }
MainClass.Monitor.Log(toPrint, LogLevel.Info); MainClass.GetMonitor().Log(toPrint, LogLevel.Info);
} }
else else
{ {
MainClass.Monitor.Log("No objects found in the focus list.", LogLevel.Info); MainClass.GetMonitor().Log("No objects found in the focus list.", LogLevel.Info);
} }
}); });
helper.ConsoleCommands.Add("rfclear", "Clear the focus list in the radar featrure.", (string commmand, string[] args) => helper.ConsoleCommands.Add("rfclear", "Clear the focus list in the radar featrure.", (string commmand, string[] args) =>
{ {
MainClass.RadarFeature.focus.Clear(); MainClass.RadarFeature.focus.Clear();
MainClass.Monitor.Log($"Cleared the focus list in the radar feature.", LogLevel.Info); MainClass.GetMonitor().Log($"Cleared the focus list in the radar feature.", LogLevel.Info);
}); });
helper.ConsoleCommands.Add("rfcount", "Number of list in the radar feature.", (string commmand, string[] args) => helper.ConsoleCommands.Add("rfcount", "Number of list in the radar feature.", (string commmand, string[] args) =>
{ {
MainClass.Monitor.Log($"There are {MainClass.RadarFeature.focus.Count} objects in the focus list in the radar feature.", LogLevel.Info); MainClass.GetMonitor().Log($"There are {MainClass.RadarFeature.focus.Count} objects in the focus list in the radar feature.", LogLevel.Info);
}); });
#endregion #endregion
@ -290,14 +290,14 @@ namespace stardew_access
{ {
if (Game1.currentLocation is not Farm) if (Game1.currentLocation is not Farm)
{ {
MainClass.Monitor.Log("Can only use this command in the farm", LogLevel.Info); MainClass.GetMonitor().Log("Can only use this command in the farm", LogLevel.Info);
return; return;
} }
string? indexInString = args.ElementAtOrDefault(0); string? indexInString = args.ElementAtOrDefault(0);
if (indexInString == null) if (indexInString == null)
{ {
MainClass.Monitor.Log("Enter the index too!", LogLevel.Info); MainClass.GetMonitor().Log("Enter the index too!", LogLevel.Info);
return; return;
} }
@ -306,12 +306,12 @@ namespace stardew_access
if (!isParsable || !(index >= 0 && index <= 9)) if (!isParsable || !(index >= 0 && index <= 9))
{ {
MainClass.Monitor.Log("Index can only be a number and from 0 to 9 only", LogLevel.Info); MainClass.GetMonitor().Log("Index can only be a number and from 0 to 9 only", LogLevel.Info);
return; return;
} }
BuildingNAnimalMenuPatches.marked[index] = new Vector2((int)Game1.player.getTileX(), (int)Game1.player.getTileY()); BuildingNAnimalMenuPatches.marked[index] = new Vector2((int)Game1.player.getTileX(), (int)Game1.player.getTileY());
MainClass.Monitor.Log($"Location {(int)Game1.player.getTileX()}x {(int)Game1.player.getTileY()}y added at {index} index.", LogLevel.Info); MainClass.GetMonitor().Log($"Location {(int)Game1.player.getTileX()}x {(int)Game1.player.getTileY()}y added at {index} index.", LogLevel.Info);
}); });
helper.ConsoleCommands.Add("marklist", "List all marked positions.", (string commmand, string[] args) => helper.ConsoleCommands.Add("marklist", "List all marked positions.", (string commmand, string[] args) =>
@ -326,16 +326,16 @@ namespace stardew_access
} }
if (toPrint == "") if (toPrint == "")
MainClass.Monitor.Log("No positions marked!", LogLevel.Info); MainClass.GetMonitor().Log("No positions marked!", LogLevel.Info);
else else
MainClass.Monitor.Log($"Marked positions:{toPrint}\nOpen command menu and use pageup and pagedown to check the list", LogLevel.Info); MainClass.GetMonitor().Log($"Marked positions:{toPrint}\nOpen command menu and use pageup and pagedown to check the list", LogLevel.Info);
}); });
helper.ConsoleCommands.Add("buildlist", "List all buildings for selection for upgrading/demolishing/painting", (string commmand, string[] args) => helper.ConsoleCommands.Add("buildlist", "List all buildings for selection for upgrading/demolishing/painting", (string commmand, string[] args) =>
{ {
if ((Game1.activeClickableMenu is not CarpenterMenu && Game1.activeClickableMenu is not PurchaseAnimalsMenu) || !BuildingNAnimalMenuPatches.isOnFarm) if ((Game1.activeClickableMenu is not CarpenterMenu && Game1.activeClickableMenu is not PurchaseAnimalsMenu) || !BuildingNAnimalMenuPatches.isOnFarm)
{ {
MainClass.Monitor.Log($"Cannot list buildings.", LogLevel.Info); MainClass.GetMonitor().Log($"Cannot list buildings.", LogLevel.Info);
return; return;
} }
@ -356,11 +356,11 @@ namespace stardew_access
if (toPrint == "") if (toPrint == "")
{ {
MainClass.Monitor.Log("No appropriate buildings to list", LogLevel.Info); MainClass.GetMonitor().Log("No appropriate buildings to list", LogLevel.Info);
} }
else else
{ {
MainClass.Monitor.Log($"Available buildings:{toPrint}\nOpen command menu and use pageup and pagedown to check the list", LogLevel.Info); MainClass.GetMonitor().Log($"Available buildings:{toPrint}\nOpen command menu and use pageup and pagedown to check the list", LogLevel.Info);
} }
}); });
@ -368,14 +368,14 @@ namespace stardew_access
{ {
if ((Game1.activeClickableMenu is not CarpenterMenu && Game1.activeClickableMenu is not PurchaseAnimalsMenu) || !BuildingNAnimalMenuPatches.isOnFarm) if ((Game1.activeClickableMenu is not CarpenterMenu && Game1.activeClickableMenu is not PurchaseAnimalsMenu) || !BuildingNAnimalMenuPatches.isOnFarm)
{ {
MainClass.Monitor.Log($"Cannot select building.", LogLevel.Info); MainClass.GetMonitor().Log($"Cannot select building.", LogLevel.Info);
return; return;
} }
string? indexInString = args.ElementAtOrDefault(0); string? indexInString = args.ElementAtOrDefault(0);
if (indexInString == null) if (indexInString == null)
{ {
MainClass.Monitor.Log("Enter the index of the building too! Use buildlist", LogLevel.Info); MainClass.GetMonitor().Log("Enter the index of the building too! Use buildlist", LogLevel.Info);
return; return;
} }
@ -384,11 +384,11 @@ namespace stardew_access
if (!isParsable) if (!isParsable)
{ {
MainClass.Monitor.Log("Index can only be a number.", LogLevel.Info); MainClass.GetMonitor().Log("Index can only be a number.", LogLevel.Info);
return; return;
} }
string positionIndexInString = args.ElementAtOrDefault(1); string? positionIndexInString = args.ElementAtOrDefault(1);
int positionIndex = 0; int positionIndex = 0;
if (BuildingNAnimalMenuPatches.isMoving) if (BuildingNAnimalMenuPatches.isMoving)
@ -398,13 +398,13 @@ namespace stardew_access
{ {
if (BuildingNAnimalMenuPatches.availableBuildings[index] == null) if (BuildingNAnimalMenuPatches.availableBuildings[index] == null)
{ {
MainClass.Monitor.Log($"No building found with index {index}. Use buildlist.", LogLevel.Info); MainClass.GetMonitor().Log($"No building found with index {index}. Use buildlist.", LogLevel.Info);
return; return;
} }
if (positionIndexInString == null) if (positionIndexInString == null)
{ {
MainClass.Monitor.Log("Enter the index of marked place too! Use marklist.", LogLevel.Info); MainClass.GetMonitor().Log("Enter the index of marked place too! Use marklist.", LogLevel.Info);
return; return;
} }
@ -412,7 +412,7 @@ namespace stardew_access
if (!isParsable) if (!isParsable)
{ {
MainClass.Monitor.Log("Index can only be a number.", LogLevel.Info); MainClass.GetMonitor().Log("Index can only be a number.", LogLevel.Info);
return; return;
} }
} }
@ -421,7 +421,7 @@ namespace stardew_access
{ {
if (BuildingNAnimalMenuPatches.marked[index] == Vector2.Zero) if (BuildingNAnimalMenuPatches.marked[index] == Vector2.Zero)
{ {
MainClass.Monitor.Log($"No marked position found at {index} index.", LogLevel.Info); MainClass.GetMonitor().Log($"No marked position found at {index} index.", LogLevel.Info);
return; return;
} }
} }
@ -429,7 +429,7 @@ namespace stardew_access
{ {
if (BuildingNAnimalMenuPatches.availableBuildings[index] == null) if (BuildingNAnimalMenuPatches.availableBuildings[index] == null)
{ {
MainClass.Monitor.Log($"No building found with index {index}. Use buildlist.", LogLevel.Info); MainClass.GetMonitor().Log($"No building found with index {index}. Use buildlist.", LogLevel.Info);
return; return;
} }
} }
@ -448,16 +448,16 @@ namespace stardew_access
if (response != null) if (response != null)
{ {
MainClass.Monitor.Log(response, LogLevel.Info); MainClass.GetMonitor().Log(response, LogLevel.Info);
} }
}); });
#endregion #endregion
helper.ConsoleCommands.Add("refsr", "Refresh screen reader", (string commmand, string[] args) => helper.ConsoleCommands.Add("refsr", "Refresh screen reader", (string commmand, string[] args) =>
{ {
MainClass.ScreenReader.InitializeScreenReader(); MainClass.GetScreenReader().InitializeScreenReader();
MainClass.Monitor.Log("Screen Reader refreshed!", LogLevel.Info); MainClass.GetMonitor().Log("Screen Reader refreshed!", LogLevel.Info);
}); });
} }
} }

View File

@ -71,7 +71,7 @@ namespace stardew_access
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to initialize custom sounds:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to initialize custom sounds:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
} }

View File

@ -23,7 +23,7 @@ namespace stardew_access.Game
return; return;
previousSlotItem = currentSlotItem; previousSlotItem = currentSlotItem;
MainClass.ScreenReader.Say($"{currentSlotItem.DisplayName} Selected", true); MainClass.GetScreenReader().Say($"{currentSlotItem.DisplayName} Selected", true);
} }
// Narrates current location's name // Narrates current location's name
@ -38,7 +38,7 @@ namespace stardew_access.Game
return; return;
previousLocation = currentLocation; previousLocation = currentLocation;
MainClass.ScreenReader.Say($"{currentLocation.Name} Entered", true); MainClass.GetScreenReader().Say($"{currentLocation.Name} Entered", true);
} }
public static void SnapMouseToPlayer() public static void SnapMouseToPlayer()
@ -89,14 +89,14 @@ namespace stardew_access.Game
{ {
MainClass.hudMessageQueryKey = searchQuery; MainClass.hudMessageQueryKey = searchQuery;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
} }
} }
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate hud messages:\n{e.Message}\n{e.StackTrace}", StardewModdingAPI.LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate hud messages:\n{e.Message}\n{e.StackTrace}", StardewModdingAPI.LogLevel.Error);
} }
await Task.Delay(300); await Task.Delay(300);

View File

@ -95,7 +95,7 @@ namespace stardew_access.Game
public async void Run() public async void Run()
{ {
if (MainClass.radarDebug) if (MainClass.radarDebug)
MainClass.Monitor.Log($"\n\nRead Tile started", StardewModdingAPI.LogLevel.Debug); MainClass.GetMonitor().Log($"\n\nRead Tile started", StardewModdingAPI.LogLevel.Debug);
isRunning = true; isRunning = true;
Vector2 currPosition = Game1.player.getTileLocation(); Vector2 currPosition = Game1.player.getTileLocation();
@ -107,7 +107,7 @@ namespace stardew_access.Game
BFS(currPosition, range); BFS(currPosition, range);
if (MainClass.radarDebug) if (MainClass.radarDebug)
MainClass.Monitor.Log($"\nRead Tile stopped\n\n", StardewModdingAPI.LogLevel.Debug); MainClass.GetMonitor().Log($"\nRead Tile stopped\n\n", StardewModdingAPI.LogLevel.Debug);
await Task.Delay(delay); await Task.Delay(delay);
isRunning = false; isRunning = false;
@ -241,7 +241,7 @@ namespace stardew_access.Game
else if (terrainFeature.ContainsKey(position)) else if (terrainFeature.ContainsKey(position))
{ {
Netcode.NetRef<TerrainFeature> tr = terrainFeature[position]; Netcode.NetRef<TerrainFeature> tr = terrainFeature[position];
string? terrain = ReadTile.getTerrainFeatureAtTile(tr).ToLower(); string? terrain = ReadTile.getTerrainFeatureAtTile(tr);
if (terrain != null) if (terrain != null)
{ {
if (tr.Get() is HoeDirt) if (tr.Get() is HoeDirt)
@ -296,7 +296,7 @@ namespace stardew_access.Game
PlaySoundAt(position, "ladder", CATEGORY.Buildings); PlaySoundAt(position, "ladder", CATEGORY.Buildings);
} }
// Check for doors // Check for doors
else if (ReadTile.isDoorAtTile((int)position.X, (int)position.Y)) else if (ReadTile.isDoorAtTile((int)position.X, (int)position.Y).Item1)
{ {
PlaySoundAt(position, "door", CATEGORY.Buildings); PlaySoundAt(position, "door", CATEGORY.Buildings);
} }
@ -304,7 +304,8 @@ namespace stardew_access.Game
else if (ReadTile.getTileInfo((int)position.X, (int)position.Y).Item2 != null) else if (ReadTile.getTileInfo((int)position.X, (int)position.Y).Item2 != null)
{ {
(CATEGORY?, string?) item = ReadTile.getTileInfo((int)position.X, (int)position.Y); (CATEGORY?, string?) item = ReadTile.getTileInfo((int)position.X, (int)position.Y);
PlaySoundAt(position, item.Item2, item.Item1); if (item.Item2 != null && item.Item1 != null)
PlaySoundAt(position, item.Item2, item.Item1);
} }
// Check for resource clumps // Check for resource clumps
else if (ReadTile.getResourceClumpAtTile((int)position.X, (int)position.Y) != null) else if (ReadTile.getResourceClumpAtTile((int)position.X, (int)position.Y) != null)
@ -319,7 +320,7 @@ namespace stardew_access.Game
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"{e.Message}\n{e.StackTrace}\n{e.Source}", StardewModdingAPI.LogLevel.Error); MainClass.GetMonitor().Log($"{e.Message}\n{e.StackTrace}\n{e.Source}", StardewModdingAPI.LogLevel.Error);
} }
} }
@ -371,7 +372,7 @@ namespace stardew_access.Game
#endregion #endregion
if (MainClass.radarDebug) if (MainClass.radarDebug)
MainClass.Monitor.Log($"{radarFocus}\tObject:{searchQuery.ToLower().Trim()}\tPosition: X={position.X} Y={position.Y}", StardewModdingAPI.LogLevel.Debug); MainClass.GetMonitor().Log($"{radarFocus}\tObject:{searchQuery.ToLower().Trim()}\tPosition: X={position.X} Y={position.Y}", StardewModdingAPI.LogLevel.Debug);
int px = (int)Game1.player.getTileX(); // Player's X postion int px = (int)Game1.player.getTileX(); // Player's X postion
int py = (int)Game1.player.getTileY(); // Player's Y postion int py = (int)Game1.player.getTileY(); // Player's Y postion

View File

@ -25,163 +25,184 @@ namespace stardew_access.Game
try try
{ {
#region Get Next Grab Tile #region Get Next Grab Tile
Vector2 gt = CurrentPlayer.getNextTile(); Vector2 tile = CurrentPlayer.getNextTile();
int x = (int)gt.X; int x = (int)tile.X;
int y = (int)gt.Y; int y = (int)tile.Y;
#endregion #endregion
if (Context.IsPlayerFree) if (Context.IsPlayerFree)
{ {
if (!manuallyTriggered && prevTile != gt) if (!manuallyTriggered && prevTile != tile)
{ {
if (MainClass.ScreenReader != null) if (MainClass.GetScreenReader() != null)
MainClass.ScreenReader.PrevTextTile = " "; MainClass.GetScreenReader().PrevTextTile = " ";
} }
bool isColliding = isCollidingAtTile(x, y); bool isColliding = isCollidingAtTile(x, y);
Dictionary<Vector2, Netcode.NetRef<TerrainFeature>> terrainFeature = Game1.currentLocation.terrainFeatures.FieldDict; string? toSpeak = getNameAtTile(tile);
string? toSpeak = " ";
#region Get objects, crops, resource clumps, etc.
if (Game1.currentLocation.isCharacterAtTile(gt) != null)
{
NPC npc = Game1.currentLocation.isCharacterAtTile(gt);
toSpeak = npc.displayName;
}
else if (getFarmAnimalAt(Game1.currentLocation, x, y) != null)
{
toSpeak = getFarmAnimalAt(Game1.currentLocation, x, y);
}
else if (Game1.currentLocation.isWaterTile(x, y) && isColliding)
{
toSpeak = "Water";
}
else if (Game1.currentLocation.isObjectAtTile(x, y))
{
string? objectName = getObjectNameAtTile(x, y);
if (objectName != null)
toSpeak = objectName;
}
else if (terrainFeature.ContainsKey(gt))
{
string? terrain = getTerrainFeatureAtTile(terrainFeature[gt]);
if (terrain != null)
toSpeak = terrain;
}
else if (Game1.currentLocation.getLargeTerrainFeatureAt(x, y) != null)
{
Bush bush = (Bush)Game1.currentLocation.getLargeTerrainFeatureAt(x, y);
int size = bush.size;
#region Check if bush is harvestable or not
if (!bush.townBush && (int)bush.tileSheetOffset == 1 && bush.inBloom(Game1.GetSeasonForLocation(Game1.currentLocation), Game1.dayOfMonth))
{
// Taken from the game's code
string season = ((int)bush.overrideSeason == -1) ? Game1.GetSeasonForLocation(Game1.currentLocation) : Utility.getSeasonNameFromNumber(bush.overrideSeason);
int shakeOff = -1;
if (!(season == "spring"))
{
if (season == "fall")
{
shakeOff = 410;
}
}
else
{
shakeOff = 296;
}
if ((int)size == 3)
{
shakeOff = 815;
}
if ((int)size == 4)
{
shakeOff = 73;
}
if (shakeOff == -1)
{
return;
}
toSpeak = "Harvestable";
}
#endregion
if (bush.townBush)
toSpeak = $"{toSpeak} Town Bush";
else if (bush.greenhouseBush)
toSpeak = $"{toSpeak} Greenhouse Bush";
else
toSpeak = $"{toSpeak} Bush";
}
else if (getResourceClumpAtTile(x, y) != null)
{
toSpeak = getResourceClumpAtTile(x, y);
}
else if (isDoorAtTile(x, y))
{
toSpeak = "Door";
}
else if (isMineDownLadderAtTile(x, y))
{
toSpeak = "Ladder";
}
else if (isMineUpLadderAtTile(x, y))
{
toSpeak = "Up Ladder";
}
else if (isElevatorAtTile(x, y))
{
toSpeak = "Elevator";
}
else if (getTileInfo(x, y).Item2 != null)
{
toSpeak = getTileInfo(x, y).Item2;
}
else if (getJunimoBundleAt(x, y) != null)
{
toSpeak = getJunimoBundleAt(x, y);
}
else if (getStumpsInWoods(x, y) != null)
{
toSpeak = getStumpsInWoods(x, y);
}
#endregion
#region Narrate toSpeak #region Narrate toSpeak
if (toSpeak != " ") if (toSpeak != null)
if (manuallyTriggered) if (MainClass.GetScreenReader() != null)
MainClass.ScreenReader.Say(toSpeak, true); if (manuallyTriggered)
else MainClass.GetScreenReader().Say(toSpeak, true);
MainClass.ScreenReader.SayWithTileQuery(toSpeak, x, y, true); else
MainClass.GetScreenReader().SayWithTileQuery(toSpeak, x, y, true);
#endregion #endregion
#region Play colliding sound effect #region Play colliding sound effect
if (isColliding && prevTile != gt) if (isColliding && prevTile != tile)
{ {
Game1.playSound("colliding"); Game1.playSound("colliding");
} }
#endregion #endregion
prevTile = gt; prevTile = tile;
} }
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Error in Read Tile:\n{e.Message}\n{e.StackTrace}", LogLevel.Debug); MainClass.GetMonitor().Log($"Error in Read Tile:\n{e.Message}\n{e.StackTrace}", LogLevel.Debug);
} }
await Task.Delay(100); await Task.Delay(100);
isReadingTile = false; isReadingTile = false;
} }
public static string? getNameAtTile(Vector2 tile)
{
int x = (int)tile.X;
int y = (int)tile.Y;
string? toReturn = "";
bool isColliding = isCollidingAtTile(x, y);
Dictionary<Vector2, Netcode.NetRef<TerrainFeature>> terrainFeature = Game1.currentLocation.terrainFeatures.FieldDict;
(bool, string?) door = isDoorAtTile(x, y);
(CATEGORY?, string?) tileInfo = getTileInfo(x, y);
string? junimoBundle = getJunimoBundleAt(x, y);
string? resourceClump = getResourceClumpAtTile(x, y);
string? farmAnimal = getFarmAnimalAt(Game1.currentLocation, x, y);
if (Game1.currentLocation.isCharacterAtTile(tile) != null)
{
NPC npc = Game1.currentLocation.isCharacterAtTile(tile);
toReturn = npc.displayName;
}
else if (farmAnimal != null)
{
toReturn = farmAnimal;
}
else if (Game1.currentLocation.isWaterTile(x, y) && isColliding)
{
toReturn = "Water";
}
else if (Game1.currentLocation.isObjectAtTile(x, y))
{
toReturn = getObjectNameAtTile(x, y);
}
else if (terrainFeature.ContainsKey(tile))
{
string? terrain = getTerrainFeatureAtTile(terrainFeature[tile]);
if (terrain != null)
toReturn = terrain;
}
else if (Game1.currentLocation.getLargeTerrainFeatureAt(x, y) != null)
{
toReturn = getBushAtTile(x, y);
}
else if (resourceClump != null)
{
toReturn = resourceClump;
}
else if (door.Item1)
{
toReturn = (door.Item2 == null) ? "door" : door.Item2;
}
else if (isMineDownLadderAtTile(x, y))
{
toReturn = "Ladder";
}
else if (isMineUpLadderAtTile(x, y))
{
toReturn = "Up Ladder";
}
else if (isElevatorAtTile(x, y))
{
toReturn = "Elevator";
}
else if (tileInfo.Item2 != null)
{
toReturn = tileInfo.Item2;
}
else if (junimoBundle != null)
{
toReturn = junimoBundle;
}
if (toReturn == "")
return null;
return toReturn;
}
public static string? getBushAtTile(int x, int y)
{
string? toReturn = null;
Bush bush = (Bush)Game1.currentLocation.getLargeTerrainFeatureAt(x, y);
int size = bush.size;
#region Check if bush is harvestable or not
if (!bush.townBush && (int)bush.tileSheetOffset == 1 && bush.inBloom(Game1.GetSeasonForLocation(Game1.currentLocation), Game1.dayOfMonth))
{
// Taken from the game's code
string season = ((int)bush.overrideSeason == -1) ? Game1.GetSeasonForLocation(Game1.currentLocation) : Utility.getSeasonNameFromNumber(bush.overrideSeason);
int shakeOff = -1;
if (!(season == "spring"))
{
if (season == "fall")
{
shakeOff = 410;
}
}
else
{
shakeOff = 296;
}
if ((int)size == 3)
{
shakeOff = 815;
}
if ((int)size == 4)
{
shakeOff = 73;
}
if (shakeOff == -1)
{
return null;
}
toReturn = "Harvestable";
}
#endregion
if (bush.townBush)
toReturn = $"{toReturn} Town Bush";
else if (bush.greenhouseBush)
toReturn = $"{toReturn} Greenhouse Bush";
else
toReturn = $"{toReturn} Bush";
return toReturn;
}
public static string? getJunimoBundleAt(int x, int y) public static string? getJunimoBundleAt(int x, int y)
{ {
if (Game1.currentLocation is not CommunityCenter) if (Game1.currentLocation is not CommunityCenter)
return null; return null;
CommunityCenter communityCenter = (Game1.currentLocation as CommunityCenter);
CommunityCenter communityCenter = ((CommunityCenter)Game1.currentLocation);
string? name = (x, y) switch string? name = (x, y) switch
{ {
@ -223,9 +244,9 @@ CommunityCenter communityCenter = (Game1.currentLocation as CommunityCenter);
List<FarmAnimal>? farmAnimals = null; List<FarmAnimal>? farmAnimals = null;
if (location is Farm) if (location is Farm)
farmAnimals = (location as Farm).getAllFarmAnimals(); farmAnimals = ((Farm)location).getAllFarmAnimals();
else if (location is AnimalHouse) else if (location is AnimalHouse)
farmAnimals = (location as AnimalHouse).animals.Values.ToList(); farmAnimals = ((AnimalHouse)location).animals.Values.ToList();
if (farmAnimals == null || farmAnimals.Count <= 0) if (farmAnimals == null || farmAnimals.Count <= 0)
return null; return null;
@ -314,7 +335,7 @@ CommunityCenter communityCenter = (Game1.currentLocation as CommunityCenter);
return (null, null); return (null, null);
} }
public static string getTerrainFeatureAtTile(Netcode.NetRef<TerrainFeature> terrain) public static string? getTerrainFeatureAtTile(Netcode.NetRef<TerrainFeature> terrain)
{ {
string? toReturn = null; string? toReturn = null;
if (terrain.Get() is HoeDirt) if (terrain.Get() is HoeDirt)
@ -353,7 +374,7 @@ CommunityCenter communityCenter = (Game1.currentLocation as CommunityCenter);
} }
else if (terrain.Get() is GiantCrop) else if (terrain.Get() is GiantCrop)
{ {
int whichCrop = (terrain.Get() as GiantCrop).which.Value; int whichCrop = ((GiantCrop)terrain.Get()).which.Value;
switch (whichCrop) switch (whichCrop)
{ {
case 0: case 0:
@ -367,10 +388,6 @@ CommunityCenter communityCenter = (Game1.currentLocation as CommunityCenter);
break; break;
} }
} }
else if (terrain.Get() is Bush)
{
toReturn = "Bush";
}
else if (terrain.Get() is CosmeticPlant) else if (terrain.Get() is CosmeticPlant)
{ {
CosmeticPlant cosmeticPlant = (CosmeticPlant)terrain.Get(); CosmeticPlant cosmeticPlant = (CosmeticPlant)terrain.Get();
@ -412,10 +429,6 @@ CommunityCenter communityCenter = (Game1.currentLocation as CommunityCenter);
{ {
toReturn = "Quartz"; toReturn = "Quartz";
} }
else if (terrain.Get() is Leaf)
{
toReturn = "Leaf";
}
return toReturn; return toReturn;
} }
@ -565,8 +578,6 @@ CommunityCenter communityCenter = (Game1.currentLocation as CommunityCenter);
case 816: case 816:
case 817: case 817:
return "Fossil stone"; return "Fossil stone";
case 25:
return "Stone";
case 118: case 118:
case 120: case 120:
case 122: case 122:
@ -701,25 +712,29 @@ CommunityCenter communityCenter = (Game1.currentLocation as CommunityCenter);
return false; return false;
} }
public static bool isDoorAtTile(int x, int y) public static (bool, string?) isDoorAtTile(int x, int y)
{ {
Point tilePoint = new Point(x, y); Point tilePoint = new Point(x, y);
List<SerializableDictionary<Point, string>> doorList = Game1.currentLocation.doors.ToList(); StardewValley.Network.NetPointDictionary<string, Netcode.NetString> doorList = Game1.currentLocation.doors;
for (int i = 0; i < doorList.Count; i++) for (int i = 0; i < doorList.Count(); i++)
{ {
for (int j = 0; j < doorList[i].Keys.Count; j++) if (doorList.ContainsKey(tilePoint))
{ {
if (doorList[i].Keys.Contains(tilePoint)) string? doorName;
return true; doorList.TryGetValue(tilePoint, out doorName);
return (true, doorName);
} }
} }
return false; return (false, null);
} }
public static string? getResourceClumpAtTile(int x, int y) public static string? getResourceClumpAtTile(int x, int y)
{ {
if (Game1.currentLocation is Woods)
return getStumpsInWoods(x, y);
for (int i = 0; i < Game1.currentLocation.resourceClumps.Count; i++) for (int i = 0; i < Game1.currentLocation.resourceClumps.Count; i++)
{ {
@ -750,10 +765,9 @@ CommunityCenter communityCenter = (Game1.currentLocation as CommunityCenter);
return null; return null;
} }
public static string? getStumpsInWoods(int x, int y) public static string? getStumpsInWoods(int x, int y)
{ {
string strIndex = null;
if (Game1.currentLocation is not Woods) if (Game1.currentLocation is not Woods)
{ {
return null; return null;
@ -767,7 +781,7 @@ CommunityCenter communityCenter = (Game1.currentLocation as CommunityCenter);
} }
} }
return null; return null;
} }
} }
} }

View File

@ -21,13 +21,32 @@ namespace stardew_access
private static IMonitor monitor; private static IMonitor monitor;
public static string hudMessageQueryKey = ""; public static string hudMessageQueryKey = "";
private static Radar radarFeature; private static Radar radarFeature;
private static IScreenReader screenReader; private static IScreenReader? screenReader;
private static IModHelper modHelper; private static IModHelper modHelper;
public static IModHelper ModHelper { get => modHelper; } public static IModHelper ModHelper { get => modHelper; }
public static Radar RadarFeature { get => radarFeature; set => radarFeature = value; } public static Radar RadarFeature { get => radarFeature; set => radarFeature = value; }
public static IScreenReader ScreenReader { get => screenReader; set => screenReader = value; }
public static IMonitor Monitor { get => monitor; set => monitor = value; } public static IScreenReader GetScreenReader()
{
screenReader = new ScreenReaderController().Initialize();
return screenReader;
}
public static void SetScreenReader(IScreenReader value)
{
screenReader = value;
}
public static IMonitor GetMonitor()
{
return monitor;
}
public static void SetMonitor(IMonitor value)
{
monitor = value;
}
/********* /*********
** Public methods ** Public methods
@ -38,12 +57,12 @@ namespace stardew_access
{ {
#region Initializations #region Initializations
Monitor = base.Monitor; // Inititalize monitor SetMonitor(base.Monitor); // Inititalize monitor
modHelper = helper; modHelper = helper;
Game1.options.setGamepadMode("force_on"); Game1.options.setGamepadMode("force_on");
ScreenReader = new ScreenReaderController().Initialize(); SetScreenReader(new ScreenReaderController().Initialize());
CustomSoundEffects.Initialize(); CustomSoundEffects.Initialize();
@ -75,14 +94,14 @@ namespace stardew_access
public void OnExit(object? sender, EventArgs? e) public void OnExit(object? sender, EventArgs? e)
{ {
// Don't if this ever gets called or not but, just in case if it does. // Don't if this ever gets called or not but, just in case if it does.
if (ScreenReader != null) if (GetScreenReader() != null)
ScreenReader.CloseScreenReader(); GetScreenReader().CloseScreenReader();
} }
/// <summary>Returns the Screen Reader class for other mods to use.</summary> /// <summary>Returns the Screen Reader class for other mods to use.</summary>
public override object GetApi() public override object GetApi()
{ {
return new ScreenReaderAPI(); return new API();
} }
private void onUpdateTicked(object? sender, UpdateTickedEventArgs? e) private void onUpdateTicked(object? sender, UpdateTickedEventArgs? e)
@ -151,28 +170,28 @@ namespace stardew_access
if (Equals(e.Button, SButton.H)) if (Equals(e.Button, SButton.H))
{ {
string toSpeak = $"Health is {CurrentPlayer.getHealth()} and Stamina is {CurrentPlayer.getStamina()}"; string toSpeak = $"Health is {CurrentPlayer.getHealth()} and Stamina is {CurrentPlayer.getStamina()}";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
// Narrate Position // Narrate Position
if (Equals(e.Button, SButton.K)) if (Equals(e.Button, SButton.K))
{ {
string toSpeak = $"X: {CurrentPlayer.getPositionX()} , Y: {CurrentPlayer.getPositionY()}"; string toSpeak = $"X: {CurrentPlayer.getPositionX()} , Y: {CurrentPlayer.getPositionY()}";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
// Narrate money at hand // Narrate money at hand
if (Equals(e.Button, SButton.R)) if (Equals(e.Button, SButton.R))
{ {
string toSpeak = $"You have {CurrentPlayer.getMoney()}g"; string toSpeak = $"You have {CurrentPlayer.getMoney()}g";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
// Narrate time and season // Narrate time and season
if (Equals(e.Button, SButton.Q)) if (Equals(e.Button, SButton.Q))
{ {
string toSpeak = $"Time is {CurrentPlayer.getTimeOfDay()} and it is {CurrentPlayer.getDay()} {CurrentPlayer.getDate()} of {CurrentPlayer.getSeason()}"; string toSpeak = $"Time is {CurrentPlayer.getTimeOfDay()} and it is {CurrentPlayer.getDay()} {CurrentPlayer.getDate()} of {CurrentPlayer.getSeason()}";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
// Manual read tile // Manual read tile

View File

@ -61,7 +61,7 @@ namespace stardew_access.Patches
firstTimeInNamingMenu = false; firstTimeInNamingMenu = false;
} }
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
} }
else if (___onFarm && !___namingAnimal) else if (___onFarm && !___namingAnimal)
@ -90,7 +90,7 @@ namespace stardew_access.Patches
if (purchaseAnimalMenuQuery != toSpeak) if (purchaseAnimalMenuQuery != toSpeak)
{ {
purchaseAnimalMenuQuery = toSpeak; purchaseAnimalMenuQuery = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -98,7 +98,7 @@ namespace stardew_access.Patches
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -180,7 +180,7 @@ namespace stardew_access.Patches
if (carpenterMenuQuery != toSpeak) if (carpenterMenuQuery != toSpeak)
{ {
carpenterMenuQuery = toSpeak; carpenterMenuQuery = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -191,7 +191,7 @@ namespace stardew_access.Patches
if (carpenterMenuQuery != toSpeak) if (carpenterMenuQuery != toSpeak)
{ {
carpenterMenuQuery = toSpeak; carpenterMenuQuery = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -202,7 +202,7 @@ namespace stardew_access.Patches
if (carpenterMenuQuery != toSpeak) if (carpenterMenuQuery != toSpeak)
{ {
carpenterMenuQuery = toSpeak; carpenterMenuQuery = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -213,7 +213,7 @@ namespace stardew_access.Patches
if (carpenterMenuQuery != toSpeak) if (carpenterMenuQuery != toSpeak)
{ {
carpenterMenuQuery = toSpeak; carpenterMenuQuery = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -224,7 +224,7 @@ namespace stardew_access.Patches
if (carpenterMenuQuery != toSpeak) if (carpenterMenuQuery != toSpeak)
{ {
carpenterMenuQuery = toSpeak; carpenterMenuQuery = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -235,7 +235,7 @@ namespace stardew_access.Patches
if (carpenterMenuQuery != toSpeak) if (carpenterMenuQuery != toSpeak)
{ {
carpenterMenuQuery = toSpeak; carpenterMenuQuery = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -246,7 +246,7 @@ namespace stardew_access.Patches
if (carpenterMenuQuery != toSpeak) if (carpenterMenuQuery != toSpeak)
{ {
carpenterMenuQuery = toSpeak; carpenterMenuQuery = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -269,14 +269,14 @@ namespace stardew_access.Patches
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
private static async void SayBlueprintInfo(string info) private static async void SayBlueprintInfo(string info)
{ {
isSayingBlueprintInfo = true; isSayingBlueprintInfo = true;
MainClass.ScreenReader.Say(info, true); MainClass.GetScreenReader().Say(info, true);
await Task.Delay(300); await Task.Delay(300);
isSayingBlueprintInfo = false; isSayingBlueprintInfo = false;
} }
@ -288,7 +288,7 @@ namespace stardew_access.Patches
string? response = null; string? response = null;
// This code is taken from the game's code (CarpenterMenu.cs::654) // This code is taken from the game's code (CarpenterMenu.cs::654)
Farm farm = Game1.getLocationFromName("Farm") as Farm; Farm farm = (Farm)Game1.getLocationFromName("Farm");
Action buildingLockFailed = delegate Action buildingLockFailed = delegate
{ {
if (isDemolishing) if (isDemolishing)
@ -304,7 +304,7 @@ namespace stardew_access.Patches
{ {
response = Game1.content.LoadString("Strings\\UI:Carpenter_CantDemolish_DuringConstruction"); response = Game1.content.LoadString("Strings\\UI:Carpenter_CantDemolish_DuringConstruction");
} }
else if (toDemolish.indoors.Value != null && toDemolish.indoors.Value is AnimalHouse && (toDemolish.indoors.Value as AnimalHouse).animalsThatLiveHere.Count > 0) else if (toDemolish.indoors.Value != null && toDemolish.indoors.Value is AnimalHouse && ((AnimalHouse)toDemolish.indoors.Value).animalsThatLiveHere.Count > 0)
{ {
response = Game1.content.LoadString("Strings\\UI:Carpenter_CantDemolish_AnimalsHere"); response = Game1.content.LoadString("Strings\\UI:Carpenter_CantDemolish_AnimalsHere");
} }
@ -318,24 +318,24 @@ namespace stardew_access.Patches
{ {
foreach (Farmer current in Game1.getAllFarmers()) foreach (Farmer current in Game1.getAllFarmers())
{ {
if (current.currentLocation != null && current.currentLocation.Name == (toDemolish.indoors.Value as Cabin).GetCellarName()) if (current.currentLocation != null && current.currentLocation.Name == ((Cabin)toDemolish.indoors.Value).GetCellarName())
{ {
response = Game1.content.LoadString("Strings\\UI:Carpenter_CantDemolish_PlayerHere"); response = Game1.content.LoadString("Strings\\UI:Carpenter_CantDemolish_PlayerHere");
return; return;
} }
} }
} }
if (toDemolish.indoors.Value is Cabin && (toDemolish.indoors.Value as Cabin).farmhand.Value.isActive()) if (toDemolish.indoors.Value is Cabin && ((Cabin)toDemolish.indoors.Value).farmhand.Value.isActive())
{ {
response = Game1.content.LoadString("Strings\\UI:Carpenter_CantDemolish_FarmhandOnline"); response = Game1.content.LoadString("Strings\\UI:Carpenter_CantDemolish_FarmhandOnline");
} }
else else
{ {
toDemolish.BeforeDemolish(); toDemolish.BeforeDemolish();
Chest chest = null; Chest? chest = null;
if (toDemolish.indoors.Value is Cabin) if (toDemolish.indoors.Value is Cabin)
{ {
List<Item> list = (toDemolish.indoors.Value as Cabin).demolish(); List<Item> list = ((Cabin)toDemolish.indoors.Value).demolish();
if (list.Count > 0) if (list.Count > 0)
{ {
chest = new Chest(playerChest: true); chest = new Chest(playerChest: true);
@ -351,7 +351,8 @@ namespace stardew_access.Patches
toDemolish.showDestroyedAnimation(Game1.getFarm()); toDemolish.showDestroyedAnimation(Game1.getFarm());
Game1.playSound("explosion"); Game1.playSound("explosion");
Utility.spreadAnimalsAround(toDemolish, farm); Utility.spreadAnimalsAround(toDemolish, farm);
DelayedAction.functionAfterDelay(carpenterMenu.returnToCarpentryMenu, 1500); if (carpenterMenu != null)
DelayedAction.functionAfterDelay(carpenterMenu.returnToCarpentryMenu, 1500);
// freeze = true; // freeze = true;
if (chest != null) if (chest != null)
{ {
@ -370,12 +371,12 @@ namespace stardew_access.Patches
toDemolish = null; toDemolish = null;
return response; return response;
} }
if (!carpenterMenu.CanDemolishThis(toDemolish)) if (carpenterMenu != null && !carpenterMenu.CanDemolishThis(toDemolish))
{ {
toDemolish = null; toDemolish = null;
return response; return response;
} }
if (!Game1.IsMasterGame && !carpenterMenu.hasPermissionsToDemolish(toDemolish)) if (carpenterMenu != null && !Game1.IsMasterGame && !carpenterMenu.hasPermissionsToDemolish(toDemolish))
{ {
toDemolish = null; toDemolish = null;
return response; return response;
@ -383,7 +384,7 @@ namespace stardew_access.Patches
} }
if (toDemolish != null && toDemolish.indoors.Value is Cabin) if (toDemolish != null && toDemolish.indoors.Value is Cabin)
{ {
Cabin cabin = toDemolish.indoors.Value as Cabin; Cabin cabin = (Cabin)toDemolish.indoors.Value;
if (cabin.farmhand.Value != null && (bool)cabin.farmhand.Value.isCustomized) if (cabin.farmhand.Value != null && (bool)cabin.farmhand.Value.isCustomized)
{ {
Game1.currentLocation.createQuestionDialogue(Game1.content.LoadString("Strings\\UI:Carpenter_DemolishCabinConfirm", cabin.farmhand.Value.Name), Game1.currentLocation.createYesNoResponses(), delegate (Farmer f, string answer) Game1.currentLocation.createQuestionDialogue(Game1.content.LoadString("Strings\\UI:Carpenter_DemolishCabinConfirm", cabin.farmhand.Value.Name), Game1.currentLocation.createYesNoResponses(), delegate (Farmer f, string answer)
@ -395,7 +396,8 @@ namespace stardew_access.Patches
} }
else else
{ {
DelayedAction.functionAfterDelay(carpenterMenu.returnToCarpentryMenu, 1000); if (carpenterMenu != null)
DelayedAction.functionAfterDelay(carpenterMenu.returnToCarpentryMenu, 1000);
} }
}); });
return response; return response;
@ -419,8 +421,11 @@ namespace stardew_access.Patches
{ {
if (tryToBuild(position)) if (tryToBuild(position))
{ {
carpenterMenu.CurrentBlueprint.consumeResources(); if (carpenterMenu != null)
DelayedAction.functionAfterDelay(carpenterMenu.returnToCarpentryMenuAfterSuccessfulBuild, 2000); {
carpenterMenu.CurrentBlueprint.consumeResources();
DelayedAction.functionAfterDelay(carpenterMenu.returnToCarpentryMenuAfterSuccessfulBuild, 2000);
}
// freeze = true; // freeze = true;
} }
else else
@ -436,6 +441,8 @@ namespace stardew_access.Patches
public static bool tryToBuild(Vector2 position) public static bool tryToBuild(Vector2 position)
{ {
if (carpenterMenu == null)
return false;
return ((Farm)Game1.getLocationFromName("Farm")).buildStructure(carpenterMenu.CurrentBlueprint, position, Game1.player, isMagicalConstruction); return ((Farm)Game1.getLocationFromName("Farm")).buildStructure(carpenterMenu.CurrentBlueprint, position, Game1.player, isMagicalConstruction);
} }
@ -443,7 +450,7 @@ namespace stardew_access.Patches
{ {
string? response = null; string? response = null;
// This code is taken from the game's code (CarpenterMenu.cs::775) // This code is taken from the game's code (CarpenterMenu.cs::775)
if (toUpgrade != null && carpenterMenu.CurrentBlueprint.name != null && toUpgrade.buildingType.Equals(carpenterMenu.CurrentBlueprint.nameOfBuildingToUpgrade)) if (carpenterMenu != null && toUpgrade != null && carpenterMenu.CurrentBlueprint.name != null && toUpgrade.buildingType.Equals(carpenterMenu.CurrentBlueprint.nameOfBuildingToUpgrade))
{ {
carpenterMenu.CurrentBlueprint.consumeResources(); carpenterMenu.CurrentBlueprint.consumeResources();
toUpgrade.daysUntilUpgrade.Value = 2; toUpgrade.daysUntilUpgrade.Value = 2;
@ -472,13 +479,15 @@ namespace stardew_access.Patches
response = Game1.content.LoadString("Strings\\UI:Carpenter_CannotPaint"); response = Game1.content.LoadString("Strings\\UI:Carpenter_CannotPaint");
return response; return response;
} }
if (!carpenterMenu.HasPermissionsToPaint(toPaint)) if (carpenterMenu != null && !carpenterMenu.HasPermissionsToPaint(toPaint))
{ {
response = Game1.content.LoadString("Strings\\UI:Carpenter_CannotPaint_Permission"); response = Game1.content.LoadString("Strings\\UI:Carpenter_CannotPaint_Permission");
return response; return response;
} }
toPaint.color.Value = Color.White; toPaint.color.Value = Color.White;
carpenterMenu.SetChildMenu(new BuildingPaintMenu(toPaint));
if (carpenterMenu != null)
carpenterMenu.SetChildMenu(new BuildingPaintMenu(toPaint));
} }
/* TODO Add painting of farm house /* TODO Add painting of farm house
else if (farm_location.GetHouseRect().Contains(Utility.Vector2ToPoint(new Vector2(toPaint.tileX, toPaint.tileY)))) else if (farm_location.GetHouseRect().Contains(Utility.Vector2ToPoint(new Vector2(toPaint.tileX, toPaint.tileY))))
@ -513,7 +522,7 @@ namespace stardew_access.Patches
buildingToMove = null; buildingToMove = null;
return "Building under construction, cannot move"; return "Building under construction, cannot move";
} }
if (!carpenterMenu.hasPermissionsToMove(buildingToMove)) if (carpenterMenu != null && !carpenterMenu.hasPermissionsToMove(buildingToMove))
{ {
buildingToMove = null; buildingToMove = null;
return "You don't have permission to move this building"; return "You don't have permission to move this building";
@ -524,7 +533,7 @@ namespace stardew_access.Patches
{ {
if (buildingToMove is ShippingBin) if (buildingToMove is ShippingBin)
{ {
(buildingToMove as ShippingBin).initLid(); ((ShippingBin)buildingToMove).initLid();
} }
if (buildingToMove is GreenhouseBuilding) if (buildingToMove is GreenhouseBuilding)
{ {

View File

@ -42,13 +42,13 @@ namespace stardew_access.Patches
toSpeak += $"{message.message}, "; toSpeak += $"{message.message}, ";
}); });
if (toSpeak != " ") if (toSpeak != " ")
MainClass.ScreenReader.SayWithChatChecker(toSpeak, false); MainClass.GetScreenReader().SayWithChatChecker(toSpeak, false);
#endregion #endregion
} }
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -77,7 +77,7 @@ namespace stardew_access.Patches
toSpeak += $"{message.message}, "; toSpeak += $"{message.message}, ";
}); });
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
await Task.Delay(200); await Task.Delay(200);
isChatRunning = false; isChatRunning = false;
} }

View File

@ -49,9 +49,9 @@ namespace stardew_access.Patches
if (toSpeak != " ") if (toSpeak != " ")
{ {
if (hasResponses) if (hasResponses)
MainClass.ScreenReader.SayWithChecker(toSpeak, false); MainClass.GetScreenReader().SayWithChecker(toSpeak, false);
else else
MainClass.ScreenReader.SayWithChecker(toSpeak, true); MainClass.GetScreenReader().SayWithChecker(toSpeak, true);
} }
} }
else if (__instance.isQuestion) else if (__instance.isQuestion)
@ -80,9 +80,9 @@ namespace stardew_access.Patches
if (toSpeak != " ") if (toSpeak != " ")
{ {
if (hasResponses) if (hasResponses)
MainClass.ScreenReader.SayWithChecker(toSpeak, false); MainClass.GetScreenReader().SayWithChecker(toSpeak, false);
else else
MainClass.ScreenReader.SayWithChecker(toSpeak, true); MainClass.GetScreenReader().SayWithChecker(toSpeak, true);
} }
} }
else if (Game1.activeClickableMenu is DialogueBox) else if (Game1.activeClickableMenu is DialogueBox)
@ -91,13 +91,13 @@ namespace stardew_access.Patches
if (currentDialogue != __instance.getCurrentString()) if (currentDialogue != __instance.getCurrentString())
{ {
currentDialogue = __instance.getCurrentString(); currentDialogue = __instance.getCurrentString();
MainClass.ScreenReader.Say(__instance.getCurrentString(), true); MainClass.GetScreenReader().Say(__instance.getCurrentString(), true);
} }
} }
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate dialog:\n{e.StackTrace}\n{e.Message}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate dialog:\n{e.StackTrace}\n{e.Message}", LogLevel.Error);
} }
} }
@ -273,15 +273,15 @@ namespace stardew_access.Patches
if (toSpeak.ToString() != " ") if (toSpeak.ToString() != " ")
{ {
if (Context.IsPlayerFree) if (Context.IsPlayerFree)
MainClass.ScreenReader.SayWithChecker(toSpeak.ToString(), true); // Normal Checker MainClass.GetScreenReader().SayWithChecker(toSpeak.ToString(), true); // Normal Checker
else else
MainClass.ScreenReader.SayWithMenuChecker(toSpeak.ToString(), true); // Menu Checker MainClass.GetScreenReader().SayWithMenuChecker(toSpeak.ToString(), true); // Menu Checker
} }
#endregion #endregion
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate dialog:\n{e.StackTrace}\n{e.Message}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate dialog:\n{e.StackTrace}\n{e.Message}", LogLevel.Error);
} }
} }
} }

View File

@ -42,7 +42,7 @@ namespace stardew_access.Patches
if (junimoNoteMenuQuery != toSpeak) if (junimoNoteMenuQuery != toSpeak)
{ {
junimoNoteMenuQuery = toSpeak; junimoNoteMenuQuery = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -54,7 +54,7 @@ namespace stardew_access.Patches
if (junimoNoteMenuQuery != toSpeak) if (junimoNoteMenuQuery != toSpeak)
{ {
junimoNoteMenuQuery = toSpeak; junimoNoteMenuQuery = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -65,7 +65,7 @@ namespace stardew_access.Patches
if (junimoNoteMenuQuery != toSpeak) if (junimoNoteMenuQuery != toSpeak)
{ {
junimoNoteMenuQuery = toSpeak; junimoNoteMenuQuery = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -77,7 +77,7 @@ namespace stardew_access.Patches
if (junimoNoteMenuQuery != toSpeak) if (junimoNoteMenuQuery != toSpeak)
{ {
junimoNoteMenuQuery = toSpeak; junimoNoteMenuQuery = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -87,7 +87,7 @@ namespace stardew_access.Patches
if (junimoNoteMenuQuery != toSpeak) if (junimoNoteMenuQuery != toSpeak)
{ {
junimoNoteMenuQuery = toSpeak; junimoNoteMenuQuery = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -117,19 +117,19 @@ namespace stardew_access.Patches
else if (isBackPressed && __instance.backButton != null && !__instance.backButton.containsPoint(x, y)) else if (isBackPressed && __instance.backButton != null && !__instance.backButton.containsPoint(x, y))
{ {
__instance.backButton.snapMouseCursorToCenter(); __instance.backButton.snapMouseCursorToCenter();
MainClass.ScreenReader.Say("Back Button", true); MainClass.GetScreenReader().Say("Back Button", true);
} }
else if (isPPressed && __instance.purchaseButton != null && !__instance.purchaseButton.containsPoint(x, y)) else if (isPPressed && __instance.purchaseButton != null && !__instance.purchaseButton.containsPoint(x, y))
{ {
__instance.purchaseButton.snapMouseCursorToCenter(); __instance.purchaseButton.snapMouseCursorToCenter();
MainClass.ScreenReader.Say("Purchase Button", true); MainClass.GetScreenReader().Say("Purchase Button", true);
} }
} }
string reward = __instance.getRewardNameForArea(___whichArea); string reward = __instance.getRewardNameForArea(___whichArea);
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -193,7 +193,7 @@ namespace stardew_access.Patches
toSpeak = $"Completed {toSpeak}"; toSpeak = $"Completed {toSpeak}";
c.snapMouseCursorToCenter(); c.snapMouseCursorToCenter();
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
} }
break; break;
@ -228,7 +228,7 @@ namespace stardew_access.Patches
} }
c.snapMouseCursorToCenter(); c.snapMouseCursorToCenter();
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
} }
break; break;
@ -281,7 +281,7 @@ namespace stardew_access.Patches
toSpeak = "Empty Slot"; toSpeak = "Empty Slot";
} }
c.snapMouseCursorToCenter(); c.snapMouseCursorToCenter();
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
} }
break; break;
@ -289,15 +289,15 @@ namespace stardew_access.Patches
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
await Task.Delay(200); await Task.Delay(200);
isUsingCustomButtons = false; isUsingCustomButtons = false;
} }
internal static void SocialPagePatch(SocialPage __instance, List<ClickableTextureComponent> ___sprites, int ___slotPosition, List<string> ___kidsNames) internal static void SocialPagePatch(SocialPage __instance, List<ClickableTextureComponent> ___sprites, int ___slotPosition, List<string> ___kidsNames)
{ {
try try
{ {
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
@ -335,54 +335,54 @@ namespace stardew_access.Patches
{ {
toSpeak = $"{toSpeak}, not talked yet"; toSpeak = $"{toSpeak}, not talked yet";
} }
if (datable | housemate)
{
string text2 = (LocalizedContentManager.CurrentLanguageCode != LocalizedContentManager.LanguageCode.pt) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635") : ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').First() : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').Last());
if (housemate)
{
text2 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Housemate");
}
else if (spouse)
{
text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11636") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11637"));
}
else if (__instance.isMarriedToAnyone(name))
{
text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_MaleNPC") : Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_FemaleNPC"));
}
else if (!Game1.player.isMarried() && friendship.IsDating())
{
text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11639") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11640"));
}
else if (__instance.getFriendship(name).IsDivorced())
{
text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11642") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11643"));
}
toSpeak = $"{toSpeak}, {text2}";
if (datable | housemate)
{
string text2 = (LocalizedContentManager.CurrentLanguageCode != LocalizedContentManager.LanguageCode.pt) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635") : ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').First() : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').Last());
if (housemate)
{
text2 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Housemate");
} }
if (!__instance.getFriendship(name).IsMarried() && ___kidsNames.Contains(name)) else if (spouse)
{ {
toSpeak = $"{toSpeak}, married"; text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11636") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11637"));
}
if (spouse)
{
toSpeak = $"{toSpeak}, spouse";
} }
else if (friendship.IsDating()) else if (__instance.isMarriedToAnyone(name))
{ {
toSpeak = $"{toSpeak}, dating"; text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_MaleNPC") : Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_FemaleNPC"));
}
else if (!Game1.player.isMarried() && friendship.IsDating())
{
text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11639") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11640"));
}
else if (__instance.getFriendship(name).IsDivorced())
{
text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11642") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11643"));
} }
toSpeak = $"{toSpeak}, {heartLevel} hearts, {giftsThisWeek} gifts given this week."; toSpeak = $"{toSpeak}, {text2}";
}
if (!__instance.getFriendship(name).IsMarried() && ___kidsNames.Contains(name))
{
toSpeak = $"{toSpeak}, married";
}
if (spouse)
{
toSpeak = $"{toSpeak}, spouse";
}
else if (friendship.IsDating())
{
toSpeak = $"{toSpeak}, dating";
}
toSpeak = $"{toSpeak}, {heartLevel} hearts, {giftsThisWeek} gifts given this week.";
if (socialPageQuery != toSpeak) if (socialPageQuery != toSpeak)
{ {
socialPageQuery = toSpeak; socialPageQuery = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -427,7 +427,7 @@ namespace stardew_access.Patches
if (socialPageQuery != toSpeak) if (socialPageQuery != toSpeak)
{ {
socialPageQuery = toSpeak; socialPageQuery = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -440,7 +440,7 @@ namespace stardew_access.Patches
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -471,7 +471,7 @@ namespace stardew_access.Patches
{ {
shopMenuQueryKey = toSpeak; shopMenuQueryKey = toSpeak;
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
Game1.playSound("drop_item"); Game1.playSound("drop_item");
} }
return; return;
@ -483,7 +483,7 @@ namespace stardew_access.Patches
{ {
shopMenuQueryKey = toSpeak; shopMenuQueryKey = toSpeak;
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -494,7 +494,7 @@ namespace stardew_access.Patches
{ {
shopMenuQueryKey = toSpeak; shopMenuQueryKey = toSpeak;
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -541,14 +541,14 @@ namespace stardew_access.Patches
{ {
shopMenuQueryKey = toSpeak; shopMenuQueryKey = toSpeak;
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
} }
#endregion #endregion
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -570,7 +570,7 @@ namespace stardew_access.Patches
if (gameMenuQueryKey != toSpeak) if (gameMenuQueryKey != toSpeak)
{ {
gameMenuQueryKey = toSpeak; gameMenuQueryKey = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -578,7 +578,7 @@ namespace stardew_access.Patches
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -599,7 +599,7 @@ namespace stardew_access.Patches
if (geodeMenuQueryKey != toSpeak) if (geodeMenuQueryKey != toSpeak)
{ {
geodeMenuQueryKey = toSpeak; geodeMenuQueryKey = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -612,7 +612,7 @@ namespace stardew_access.Patches
if (geodeMenuQueryKey != toSpeak) if (geodeMenuQueryKey != toSpeak)
{ {
geodeMenuQueryKey = toSpeak; geodeMenuQueryKey = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -624,7 +624,7 @@ namespace stardew_access.Patches
if (geodeMenuQueryKey != toSpeak) if (geodeMenuQueryKey != toSpeak)
{ {
geodeMenuQueryKey = toSpeak; geodeMenuQueryKey = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
Game1.playSound("drop_item"); Game1.playSound("drop_item");
} }
return; return;
@ -637,7 +637,7 @@ namespace stardew_access.Patches
if (geodeMenuQueryKey != toSpeak) if (geodeMenuQueryKey != toSpeak)
{ {
geodeMenuQueryKey = toSpeak; geodeMenuQueryKey = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -649,7 +649,7 @@ namespace stardew_access.Patches
if (geodeMenuQueryKey != toSpeak) if (geodeMenuQueryKey != toSpeak)
{ {
geodeMenuQueryKey = toSpeak; geodeMenuQueryKey = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -662,7 +662,7 @@ namespace stardew_access.Patches
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -694,7 +694,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
gameMenuQueryKey = ""; gameMenuQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -706,7 +706,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -719,7 +719,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -732,7 +732,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -745,7 +745,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -759,7 +759,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -773,7 +773,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -786,7 +786,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
Game1.playSound("drop_item"); Game1.playSound("drop_item");
} }
return; return;
@ -828,7 +828,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -853,7 +853,7 @@ namespace stardew_access.Patches
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -966,7 +966,7 @@ namespace stardew_access.Patches
{ {
craftingPageQueryKey = toSpeak; craftingPageQueryKey = toSpeak;
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -978,7 +978,7 @@ namespace stardew_access.Patches
{ {
craftingPageQueryKey = toSpeak; craftingPageQueryKey = toSpeak;
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -990,7 +990,7 @@ namespace stardew_access.Patches
{ {
craftingPageQueryKey = toSpeak; craftingPageQueryKey = toSpeak;
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -1002,7 +1002,7 @@ namespace stardew_access.Patches
{ {
craftingPageQueryKey = toSpeak; craftingPageQueryKey = toSpeak;
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
Game1.playSound("drop_item"); Game1.playSound("drop_item");
} }
return; return;
@ -1082,7 +1082,7 @@ namespace stardew_access.Patches
craftingPageQueryKey = toSpeak; craftingPageQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -1099,7 +1099,7 @@ namespace stardew_access.Patches
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -1120,7 +1120,7 @@ namespace stardew_access.Patches
// This method is used to get the inventory items to check if the player has enough ingredients for a recipe // This method is used to get the inventory items to check if the player has enough ingredients for a recipe
// Taken from CraftingPage.cs -> 169 line // Taken from CraftingPage.cs -> 169 line
internal static IList<Item> getContainerContents(List<Chest> materialContainers) internal static IList<Item>? getContainerContents(List<Chest> materialContainers)
{ {
if (materialContainers == null) if (materialContainers == null)
{ {
@ -1149,7 +1149,7 @@ namespace stardew_access.Patches
inventoryPageQueryKey = toSpeak; inventoryPageQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
Game1.playSound("drop_item"); Game1.playSound("drop_item");
} }
return; return;
@ -1163,7 +1163,7 @@ namespace stardew_access.Patches
inventoryPageQueryKey = toSpeak; inventoryPageQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -1176,7 +1176,7 @@ namespace stardew_access.Patches
inventoryPageQueryKey = toSpeak; inventoryPageQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -1189,7 +1189,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -1203,7 +1203,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -1299,7 +1299,7 @@ namespace stardew_access.Patches
inventoryPageQueryKey = toSpeak; inventoryPageQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -1317,7 +1317,7 @@ namespace stardew_access.Patches
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -1337,17 +1337,17 @@ namespace stardew_access.Patches
if (optionsElement is OptionsButton) if (optionsElement is OptionsButton)
toSpeak = $" {toSpeak} Button"; toSpeak = $" {toSpeak} Button";
else if (optionsElement is OptionsCheckbox) else if (optionsElement is OptionsCheckbox)
toSpeak = ((optionsElement as OptionsCheckbox).isChecked ? "Enabled" : "Disabled") + $" {toSpeak} Checkbox"; toSpeak = (((OptionsCheckbox)optionsElement).isChecked ? "Enabled" : "Disabled") + $" {toSpeak} Checkbox";
else if (optionsElement is OptionsDropDown) else if (optionsElement is OptionsDropDown)
toSpeak = $"{toSpeak} Dropdown, option {(optionsElement as OptionsDropDown).dropDownDisplayOptions[(optionsElement as OptionsDropDown).selectedOption]} selected"; toSpeak = $"{toSpeak} Dropdown, option {((OptionsDropDown)optionsElement).dropDownDisplayOptions[((OptionsDropDown)optionsElement).selectedOption]} selected";
else if (optionsElement is OptionsSlider) else if (optionsElement is OptionsSlider)
toSpeak = $"{(optionsElement as OptionsSlider).value}% {toSpeak} Slider"; toSpeak = $"{((OptionsSlider)optionsElement).value}% {toSpeak} Slider";
else if (optionsElement is OptionsPlusMinus) else if (optionsElement is OptionsPlusMinus)
toSpeak = $"{(optionsElement as OptionsPlusMinus).displayOptions[(optionsElement as OptionsPlusMinus).selected]} selected of {toSpeak}"; toSpeak = $"{((OptionsPlusMinus)optionsElement).displayOptions[((OptionsPlusMinus)optionsElement).selected]} selected of {toSpeak}";
else if (optionsElement is OptionsInputListener) else if (optionsElement is OptionsInputListener)
{ {
string buttons = ""; string buttons = "";
(optionsElement as OptionsInputListener).buttonNames.ForEach(name => { buttons += $", {name}"; }); ((OptionsInputListener)optionsElement).buttonNames.ForEach(name => { buttons += $", {name}"; });
toSpeak = $"{toSpeak} is bound to {buttons}. Left click to change."; toSpeak = $"{toSpeak} is bound to {buttons}. Left click to change.";
} }
else else
@ -1362,7 +1362,7 @@ namespace stardew_access.Patches
{ {
gameMenuQueryKey = ""; gameMenuQueryKey = "";
optionsPageQueryKey = toSpeak; optionsPageQueryKey = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -1370,7 +1370,7 @@ namespace stardew_access.Patches
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -1386,7 +1386,7 @@ namespace stardew_access.Patches
{ {
gameMenuQueryKey = ""; gameMenuQueryKey = "";
exitPageQueryKey = toSpeak; exitPageQueryKey = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
@ -1398,14 +1398,14 @@ namespace stardew_access.Patches
{ {
gameMenuQueryKey = ""; gameMenuQueryKey = "";
exitPageQueryKey = toSpeak; exitPageQueryKey = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return; return;
} }
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -1431,9 +1431,9 @@ namespace stardew_access.Patches
string requirements = ""; string requirements = "";
#region Add quality of item #region Add quality of item
if (actualInventory[i] is StardewValley.Object && (actualInventory[i] as StardewValley.Object).quality > 0) if (actualInventory[i] is StardewValley.Object && ((StardewValley.Object)actualInventory[i]).quality > 0)
{ {
int qualityIndex = (actualInventory[i] as StardewValley.Object).quality; int qualityIndex = ((StardewValley.Object)actualInventory[i]).quality;
if (qualityIndex == 1) if (qualityIndex == 1)
{ {
quality = "Silver quality"; quality = "Silver quality";
@ -1453,13 +1453,13 @@ namespace stardew_access.Patches
{ {
description = actualInventory[i].getDescription(); description = actualInventory[i].getDescription();
#region Add health & stamina provided by the item #region Add health & stamina provided by the item
if (actualInventory[i] is StardewValley.Object && (actualInventory[i] as StardewValley.Object).Edibility != -300) if (actualInventory[i] is StardewValley.Object && ((StardewValley.Object)actualInventory[i]).Edibility != -300)
{ {
int stamina_recovery = (actualInventory[i] as StardewValley.Object).staminaRecoveredOnConsumption(); int stamina_recovery = ((StardewValley.Object)actualInventory[i]).staminaRecoveredOnConsumption();
healthNStamine += $"{stamina_recovery} Energy"; healthNStamine += $"{stamina_recovery} Energy";
if (stamina_recovery >= 0) if (stamina_recovery >= 0)
{ {
int health_recovery = (actualInventory[i] as StardewValley.Object).healthRecoveredOnConsumption(); int health_recovery = ((StardewValley.Object)actualInventory[i]).healthRecoveredOnConsumption();
healthNStamine += $"\n\t{health_recovery} Health"; healthNStamine += $"\n\t{health_recovery} Health";
} }
} }
@ -1467,8 +1467,8 @@ namespace stardew_access.Patches
#region Add buff items (effects like +1 walking speed) #region Add buff items (effects like +1 walking speed)
// These variables are taken from the game's code itself (IClickableMenu.cs -> 1016 line) // These variables are taken from the game's code itself (IClickableMenu.cs -> 1016 line)
bool edibleItem = actualInventory[i] != null && actualInventory[i] is StardewValley.Object && (int)(actualInventory[i] as StardewValley.Object).edibility != -300; bool edibleItem = actualInventory[i] != null && actualInventory[i] is StardewValley.Object && (int)((StardewValley.Object)actualInventory[i]).edibility != -300;
string[] buffIconsToDisplay = (edibleItem && Game1.objectInformation[(actualInventory[i] as StardewValley.Object).parentSheetIndex].Split('/').Length > 7) ? actualInventory[i].ModifyItemBuffs(Game1.objectInformation[(actualInventory[i] as StardewValley.Object).parentSheetIndex].Split('/')[7].Split(' ')) : null; string[]? buffIconsToDisplay = (edibleItem && Game1.objectInformation[((StardewValley.Object)actualInventory[i]).parentSheetIndex].Split('/').Length > 7) ? actualInventory[i].ModifyItemBuffs(Game1.objectInformation[((StardewValley.Object)actualInventory[i]).parentSheetIndex].Split('/')[7].Split(' ')) : null;
if (buffIconsToDisplay != null) if (buffIconsToDisplay != null)
{ {
for (int j = 0; j < buffIconsToDisplay.Length; j++) for (int j = 0; j < buffIconsToDisplay.Length; j++)
@ -1537,7 +1537,7 @@ namespace stardew_access.Patches
if (hoveredItemQueryKey != $"{toSpeak}:{i}") if (hoveredItemQueryKey != $"{toSpeak}:{i}")
{ {
hoveredItemQueryKey = $"{toSpeak}:{i}"; hoveredItemQueryKey = $"{toSpeak}:{i}";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
return true; return true;
} }

View File

@ -38,7 +38,7 @@ namespace stardew_access.Patches
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
return true; return true;
@ -52,13 +52,13 @@ namespace stardew_access.Patches
if (__instance.nextPageButton != null && __instance.nextPageButton.containsPoint(x, y)) if (__instance.nextPageButton != null && __instance.nextPageButton.containsPoint(x, y))
{ {
MainClass.ScreenReader.SayWithMenuChecker($"Next Page Button", true); MainClass.GetScreenReader().SayWithMenuChecker($"Next Page Button", true);
return; return;
} }
if (__instance.previousPageButton != null && __instance.previousPageButton.containsPoint(x, y)) if (__instance.previousPageButton != null && __instance.previousPageButton.containsPoint(x, y))
{ {
MainClass.ScreenReader.SayWithMenuChecker($"Previous Page Button", true); MainClass.GetScreenReader().SayWithMenuChecker($"Previous Page Button", true);
return; return;
} }
@ -66,14 +66,14 @@ namespace stardew_access.Patches
{ {
if (__instance.languages[i].containsPoint(x, y)) if (__instance.languages[i].containsPoint(x, y))
{ {
MainClass.ScreenReader.SayWithMenuChecker($"{__instance.languageList[i]} Button", true); MainClass.GetScreenReader().SayWithMenuChecker($"{__instance.languageList[i]} Button", true);
break; break;
} }
} }
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -86,14 +86,14 @@ namespace stardew_access.Patches
{ {
if (___elevators[i].containsPoint(x, y)) if (___elevators[i].containsPoint(x, y))
{ {
MainClass.ScreenReader.SayWithMenuChecker($"{___elevators[i].name} level", true); MainClass.GetScreenReader().SayWithMenuChecker($"{___elevators[i].name} level", true);
break; break;
} }
} }
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -105,11 +105,11 @@ namespace stardew_access.Patches
___textBox.SelectMe(); ___textBox.SelectMe();
string toSpeak = $"{title}"; string toSpeak = $"{title}";
MainClass.ScreenReader.SayWithChecker(toSpeak, true); MainClass.GetScreenReader().SayWithChecker(toSpeak, true);
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -119,19 +119,19 @@ namespace stardew_access.Patches
{ {
int x = Game1.getMouseX(), y = Game1.getMouseY(); int x = Game1.getMouseX(), y = Game1.getMouseY();
MainClass.ScreenReader.SayWithMenuChecker(___message, true); MainClass.GetScreenReader().SayWithMenuChecker(___message, true);
if (__instance.okButton.containsPoint(x, y)) if (__instance.okButton.containsPoint(x, y))
{ {
MainClass.ScreenReader.SayWithMenuChecker("Ok Button", false); MainClass.GetScreenReader().SayWithMenuChecker("Ok Button", false);
} }
else if (__instance.cancelButton.containsPoint(x, y)) else if (__instance.cancelButton.containsPoint(x, y))
{ {
MainClass.ScreenReader.SayWithMenuChecker("Cancel Button", false); MainClass.GetScreenReader().SayWithMenuChecker("Cancel Button", false);
} }
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -223,16 +223,16 @@ namespace stardew_access.Patches
} }
if (toSpeak != " ") if (toSpeak != " ")
MainClass.ScreenReader.SayWithMenuChecker(toSpeak, true); MainClass.GetScreenReader().SayWithMenuChecker(toSpeak, true);
else if (__instance.isProfessionChooser && currentLevelUpTitle != $"{___title}. Select a new profession.") else if (__instance.isProfessionChooser && currentLevelUpTitle != $"{___title}. Select a new profession.")
{ {
MainClass.ScreenReader.SayWithMenuChecker($"{___title}. Select a new profession.", true); MainClass.GetScreenReader().SayWithMenuChecker($"{___title}. Select a new profession.", true);
currentLevelUpTitle = $"{___title}. Select a new profession."; currentLevelUpTitle = $"{___title}. Select a new profession.";
} }
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -256,21 +256,21 @@ namespace stardew_access.Patches
Game1.activeClickableMenu.receiveLeftClick(Game1.getMouseX(true), Game1.getMouseY(true)); Game1.activeClickableMenu.receiveLeftClick(Game1.getMouseX(true), Game1.getMouseY(true));
} }
toSpeak = $"{total}g in total. Press left mouse button to save."; toSpeak = $"{total}g in total. Press left mouse button to save.";
MainClass.ScreenReader.SayWithChecker(toSpeak, true); MainClass.GetScreenReader().SayWithChecker(toSpeak, true);
} }
for (int i = 0; i < __instance.categories.Count; i++) for (int i = 0; i < __instance.categories.Count; i++)
{ {
if (__instance.categories[i].containsPoint(Game1.getMouseX(), Game1.getMouseY())) if (__instance.categories[i].containsPoint(Game1.getMouseX(), Game1.getMouseY()))
{ {
toSpeak = $"Money recieved from {__instance.getCategoryName(i)}: {___categoryTotals[i]}g."; toSpeak = $"Money recieved from {__instance.getCategoryName(i)}: {___categoryTotals[i]}g.";
MainClass.ScreenReader.SayWithChecker(toSpeak, true); MainClass.GetScreenReader().SayWithChecker(toSpeak, true);
} }
} }
} }
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -310,7 +310,7 @@ namespace stardew_access.Patches
toSpeak += "\t\n Left click to accept quest."; toSpeak += "\t\n Left click to accept quest.";
__instance.acceptQuestButton.snapMouseCursorToCenter(); __instance.acceptQuestButton.snapMouseCursorToCenter();
} }
MainClass.ScreenReader.Say(toSpeak, false); MainClass.GetScreenReader().Say(toSpeak, false);
} }
#endregion #endregion
@ -323,7 +323,7 @@ namespace stardew_access.Patches
string label = c.label; string label = c.label;
if (c.containsPoint(Game1.getMousePosition().X, Game1.getMousePosition().Y)) if (c.containsPoint(Game1.getMousePosition().X, Game1.getMousePosition().Y))
MainClass.ScreenReader.SayWithChecker($"Grab: {name} \t\n {label}", false); MainClass.GetScreenReader().SayWithChecker($"Grab: {name} \t\n {label}", false);
} }
} }
#endregion #endregion
@ -331,7 +331,7 @@ namespace stardew_access.Patches
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -373,7 +373,7 @@ namespace stardew_access.Patches
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -418,14 +418,14 @@ namespace stardew_access.Patches
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
internal static void ExitEventPatch() internal static void ExitEventPatch()
{ {
if (MainClass.ScreenReader != null) if (MainClass.GetScreenReader() != null)
MainClass.ScreenReader.CloseScreenReader(); MainClass.GetScreenReader().CloseScreenReader();
} }
internal static void resetGlobalVars() internal static void resetGlobalVars()
{ {

View File

@ -23,7 +23,7 @@ namespace stardew_access.Patches
toSpeak = $"Left Quest:\n\t{toSpeak}\n\tPress left click to accept this quest."; toSpeak = $"Left Quest:\n\t{toSpeak}\n\tPress left click to accept this quest.";
MainClass.ScreenReader.SayWithMenuChecker(toSpeak, true); MainClass.GetScreenReader().SayWithMenuChecker(toSpeak, true);
return; return;
} }
@ -33,13 +33,13 @@ namespace stardew_access.Patches
toSpeak = $"Right Quest:\n\t{toSpeak}\n\tPress left click to accept this quest."; toSpeak = $"Right Quest:\n\t{toSpeak}\n\tPress left click to accept this quest.";
MainClass.ScreenReader.SayWithMenuChecker(toSpeak, true); MainClass.GetScreenReader().SayWithMenuChecker(toSpeak, true);
return; return;
} }
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -99,7 +99,7 @@ namespace stardew_access.Patches
if (Game1.dayOfMonth == i + 1) if (Game1.dayOfMonth == i + 1)
toSpeak += $", Current"; toSpeak += $", Current";
MainClass.ScreenReader.SayWithChecker(toSpeak, true); MainClass.GetScreenReader().SayWithChecker(toSpeak, true);
} }
} }
#endregion #endregion
@ -114,7 +114,7 @@ namespace stardew_access.Patches
if (currentDailyQuestText != toSpeak) if (currentDailyQuestText != toSpeak)
{ {
currentDailyQuestText = toSpeak; currentDailyQuestText = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
} }
else else
@ -134,7 +134,7 @@ namespace stardew_access.Patches
__instance.acceptQuestButton.snapMouseCursorToCenter(); __instance.acceptQuestButton.snapMouseCursorToCenter();
} }
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
} }
#endregion #endregion
@ -142,7 +142,7 @@ namespace stardew_access.Patches
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
#endregion #endregion
@ -171,7 +171,7 @@ namespace stardew_access.Patches
toSpeak += ___pages[___currentPage][i].ShouldDisplayAsComplete() ? " completed!" : ""; toSpeak += ___pages[___currentPage][i].ShouldDisplayAsComplete() ? " completed!" : "";
if (__instance.questLogButtons[i].containsPoint(Game1.getOldMouseX(), Game1.getOldMouseY())) if (__instance.questLogButtons[i].containsPoint(Game1.getOldMouseX(), Game1.getOldMouseY()))
{ {
MainClass.ScreenReader.SayWithChecker(toSpeak, true); MainClass.GetScreenReader().SayWithChecker(toSpeak, true);
} }
} }
} }
@ -232,13 +232,13 @@ namespace stardew_access.Patches
if (snapMouseToRewardBox) if (snapMouseToRewardBox)
__instance.rewardBox.snapMouseCursorToCenter(); __instance.rewardBox.snapMouseCursorToCenter();
MainClass.ScreenReader.SayWithChecker(toSpeak, true); MainClass.GetScreenReader().SayWithChecker(toSpeak, true);
#endregion #endregion
} }
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
#endregion #endregion

View File

@ -45,11 +45,11 @@ namespace stardew_access.Patches
#endregion #endregion
if (toSpeak != " ") if (toSpeak != " ")
MainClass.ScreenReader.SayWithChecker(toSpeak, true); MainClass.GetScreenReader().SayWithChecker(toSpeak, true);
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -95,15 +95,15 @@ namespace stardew_access.Patches
if (TitleMenu.subMenu != null && __instance.backButton.containsPoint(Game1.getMouseX(), Game1.getMouseY())) if (TitleMenu.subMenu != null && __instance.backButton.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
{ {
string text = "Back Button"; string text = "Back Button";
MainClass.ScreenReader.SayWithChecker(text, true); MainClass.GetScreenReader().SayWithChecker(text, true);
} }
if (TitleMenu.subMenu == null && toSpeak != "") if (TitleMenu.subMenu == null && toSpeak != "")
MainClass.ScreenReader.SayWithChecker(toSpeak, true); MainClass.GetScreenReader().SayWithChecker(toSpeak, true);
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -119,7 +119,7 @@ namespace stardew_access.Patches
#region Farms #region Farms
if (___menu.deleteButtons.Count > 0 && ___menu.deleteButtons[i].containsPoint(x, y)) if (___menu.deleteButtons.Count > 0 && ___menu.deleteButtons[i].containsPoint(x, y))
{ {
MainClass.ScreenReader.SayWithChecker($"Delete {__instance.Farmer.farmName} Farm", true); MainClass.GetScreenReader().SayWithChecker($"Delete {__instance.Farmer.farmName} Farm", true);
return; 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. // Used diff. functions to narrate to prevent it from speaking the message again on selecting another button.
string message = "Really delete farm?"; string message = "Really delete farm?";
MainClass.ScreenReader.SayWithChecker(message, true); MainClass.GetScreenReader().SayWithChecker(message, true);
if (___menu.okDeleteButton.containsPoint(x, y)) if (___menu.okDeleteButton.containsPoint(x, y))
{ {
MainClass.ScreenReader.SayWithMenuChecker("Ok Button", false); MainClass.GetScreenReader().SayWithMenuChecker("Ok Button", false);
} }
else if (___menu.cancelDeleteButton.containsPoint(x, y)) else if (___menu.cancelDeleteButton.containsPoint(x, y))
{ {
MainClass.ScreenReader.SayWithMenuChecker("Cancel Button", false); MainClass.GetScreenReader().SayWithMenuChecker("Cancel Button", false);
} }
return; return;
} }
@ -150,14 +150,14 @@ namespace stardew_access.Patches
string toSpeak = $"{farmName} Farm Selected, \t\n Farmer:{farmerName}, \t\nMoney:{money}, \t\nHours Played:{hoursPlayed}, \t\nDate:{dateStringForSaveGame}"; string toSpeak = $"{farmName} Farm Selected, \t\n Farmer:{farmerName}, \t\nMoney:{money}, \t\nHours Played:{hoursPlayed}, \t\nDate:{dateStringForSaveGame}";
MainClass.ScreenReader.SayWithChecker(toSpeak, true); MainClass.GetScreenReader().SayWithChecker(toSpeak, true);
#endregion #endregion
} }
} }
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -179,7 +179,7 @@ namespace stardew_access.Patches
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); MainClass.GetMonitor().Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -640,7 +640,7 @@ namespace stardew_access.Patches
if (toSpeak != " ") if (toSpeak != " ")
{ {
MainClass.ScreenReader.Say(toSpeak, true); MainClass.GetScreenReader().Say(toSpeak, true);
} }
await Task.Delay(200); await Task.Delay(200);

View File

@ -1,51 +0,0 @@
namespace stardew_access.ScreenReader
{
public class ScreenReaderAPI
{
public ScreenReaderAPI()
{
}
public void Say(String text, Boolean interrupt)
{
if (MainClass.ScreenReader == null)
return;
MainClass.ScreenReader.Say(text, interrupt);
}
public void SayWithChecker(String text, Boolean interrupt)
{
if (MainClass.ScreenReader == null)
return;
MainClass.ScreenReader.SayWithChecker(text, interrupt);
}
public void SayWithMenuChecker(String text, Boolean interrupt)
{
if (MainClass.ScreenReader == null)
return;
MainClass.ScreenReader.SayWithMenuChecker(text, interrupt);
}
public void SayWithChatChecker(String text, Boolean interrupt)
{
if (MainClass.ScreenReader == null)
return;
MainClass.ScreenReader.SayWithChatChecker(text, interrupt);
}
public void SayWithTileQuery(String text, int x, int y, Boolean interrupt)
{
if (MainClass.ScreenReader == null)
return;
MainClass.ScreenReader.SayWithTileQuery(text, x, y, interrupt);
}
}
}

View File

@ -4,9 +4,9 @@ namespace stardew_access.ScreenReader
{ {
public class ScreenReaderController public class ScreenReaderController
{ {
public IScreenReader? Initialize() public IScreenReader Initialize()
{ {
IScreenReader? ScreenReader = null; IScreenReader ScreenReader = new ScreenReaderWindows(); // Default is windows
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{ {
@ -22,6 +22,10 @@ namespace stardew_access.ScreenReader
ScreenReader = screenReaderLinux; ScreenReader = screenReaderLinux;
} }
else
{
ScreenReader.InitializeScreenReader();
}
return ScreenReader; return ScreenReader;
} }

View File

@ -54,6 +54,9 @@ namespace stardew_access.ScreenReader
public void Say(string text, bool interrupt) public void Say(string text, bool interrupt)
{ {
if (text == null)
return;
if (initialized) if (initialized)
{ {
GoString str = new GoString(text, text.Length); GoString str = new GoString(text, text.Length);

View File

@ -56,6 +56,9 @@ namespace stardew_access.ScreenReader
public void Say(string text, bool interrupt) public void Say(string text, bool interrupt)
{ {
if (text == null)
return;
if (screenReader == null) if (screenReader == null)
return; return;
@ -64,9 +67,6 @@ namespace stardew_access.ScreenReader
public void SayWithChecker(string text, bool interrupt) public void SayWithChecker(string text, bool interrupt)
{ {
if (screenReader == null)
return;
if (prevText != text) if (prevText != text)
{ {
prevText = text; prevText = text;
@ -76,9 +76,6 @@ namespace stardew_access.ScreenReader
public void SayWithMenuChecker(string text, bool interrupt) public void SayWithMenuChecker(string text, bool interrupt)
{ {
if (screenReader == null)
return;
if (prevMenuText != text) if (prevMenuText != text)
{ {
prevMenuText = text; prevMenuText = text;
@ -88,9 +85,6 @@ namespace stardew_access.ScreenReader
public void SayWithChatChecker(string text, bool interrupt) public void SayWithChatChecker(string text, bool interrupt)
{ {
if (screenReader == null)
return;
if (prevChatText != text) if (prevChatText != text)
{ {
prevChatText = text; prevChatText = text;
@ -100,9 +94,6 @@ namespace stardew_access.ScreenReader
public void SayWithTileQuery(string text, int x, int y, bool interrupt) public void SayWithTileQuery(string text, int x, int y, bool interrupt)
{ {
if (screenReader == null)
return;
string query = $"{text} x:{x} y:{y}"; string query = $"{text} x:{x} y:{y}";
if (prevTextTile != query) if (prevTextTile != query)