Removed AutoHotKey for performing clicks

master
Mohammad Shoaib 2022-02-04 14:26:19 +05:30
parent 5100b4fd89
commit 2298d891da
17 changed files with 309 additions and 294 deletions

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.Monitor.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.Monitor.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.Monitor.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.Monitor.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.Monitor.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.Monitor.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) =>
@ -70,21 +70,21 @@ namespace stardew_access
if (isParsable) if (isParsable)
{ {
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.Monitor.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.Monitor.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.Monitor.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.Monitor.Log("Enter the delay amount (in milliseconds)!", LogLevel.Info);
} }
}); });
@ -103,21 +103,21 @@ namespace stardew_access
if (isParsable) if (isParsable)
{ {
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.Monitor.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.Monitor.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.Monitor.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.Monitor.Log("Enter the range amount!", LogLevel.Info);
} }
}); });
@ -133,19 +133,19 @@ namespace stardew_access
if (keyToAdd != null) if (keyToAdd != null)
{ {
keyToAdd = keyToAdd.Trim().ToLower(); keyToAdd = keyToAdd.Trim().ToLower();
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.Monitor.Log($"Added {keyToAdd} key to exclusions list.", LogLevel.Info);
} }
else else
{ {
MainClass.monitor.Log($"{keyToAdd} key already present in the list.", LogLevel.Info); MainClass.Monitor.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.Monitor.Log("Unable to add the key to exclusions list.", LogLevel.Info);
} }
}); });
@ -158,48 +158,48 @@ namespace stardew_access
if (keyToAdd != null) if (keyToAdd != null)
{ {
keyToAdd = keyToAdd.Trim().ToLower(); keyToAdd = keyToAdd.Trim().ToLower();
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.Monitor.Log($"Removed {keyToAdd} key from exclusions list.", LogLevel.Info);
} }
else else
{ {
MainClass.monitor.Log($"Cannot find {keyToAdd} key in exclusions list.", LogLevel.Info); MainClass.Monitor.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.Monitor.Log("Unable to remove the key from exclusions list.", LogLevel.Info);
} }
}); });
helper.ConsoleCommands.Add("relist", "List all the exclusions in the radar feature.", (string commmand, string[] args) => helper.ConsoleCommands.Add("relist", "List all the exclusions in the radar feature.", (string commmand, string[] args) =>
{ {
if (MainClass.radarFeature.exclusions.Count > 0) if (MainClass.RadarFeature.exclusions.Count > 0)
{ {
string toPrint = ""; string toPrint = "";
for (int i = 0; i < MainClass.radarFeature.exclusions.Count; i++) for (int i = 0; i < MainClass.RadarFeature.exclusions.Count; i++)
{ {
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.Monitor.Log(toPrint, LogLevel.Info);
} }
else else
{ {
MainClass.monitor.Log("No exclusions found.", LogLevel.Info); MainClass.Monitor.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.Monitor.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.Monitor.Log($"There are {MainClass.RadarFeature.exclusions.Count} exclusiond in the radar feature.", LogLevel.Info);
}); });
#endregion #endregion
@ -213,19 +213,19 @@ namespace stardew_access
if (keyToAdd != null) if (keyToAdd != null)
{ {
keyToAdd = keyToAdd.Trim().ToLower(); keyToAdd = keyToAdd.Trim().ToLower();
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.Monitor.Log($"Added {keyToAdd} key to focus list.", LogLevel.Info);
} }
else else
{ {
MainClass.monitor.Log($"{keyToAdd} key already present in the list.", LogLevel.Info); MainClass.Monitor.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.Monitor.Log("Unable to add the key to focus list.", LogLevel.Info);
} }
}); });
@ -238,48 +238,48 @@ namespace stardew_access
if (keyToAdd != null) if (keyToAdd != null)
{ {
keyToAdd = keyToAdd.Trim().ToLower(); keyToAdd = keyToAdd.Trim().ToLower();
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.Monitor.Log($"Removed {keyToAdd} key from focus list.", LogLevel.Info);
} }
else else
{ {
MainClass.monitor.Log($"Cannot find {keyToAdd} key in focus list.", LogLevel.Info); MainClass.Monitor.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.Monitor.Log("Unable to remove the key from focus list.", LogLevel.Info);
} }
}); });
helper.ConsoleCommands.Add("rflist", "List all the exclusions in the radar feature.", (string commmand, string[] args) => helper.ConsoleCommands.Add("rflist", "List all the exclusions in the radar feature.", (string commmand, string[] args) =>
{ {
if (MainClass.radarFeature.focus.Count > 0) if (MainClass.RadarFeature.focus.Count > 0)
{ {
string toPrint = ""; string toPrint = "";
for (int i = 0; i < MainClass.radarFeature.focus.Count; i++) for (int i = 0; i < MainClass.RadarFeature.focus.Count; i++)
{ {
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.Monitor.Log(toPrint, LogLevel.Info);
} }
else else
{ {
MainClass.monitor.Log("No objects found in the focus list.", LogLevel.Info); MainClass.Monitor.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.Monitor.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.Monitor.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.Monitor.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! Example syntax: mark 0, here 0 is the index and it can be from 0 to 9 only", LogLevel.Info); MainClass.Monitor.Log("Enter the index too! Example syntax: mark 0, here 0 is the index and it can be from 0 to 9 only", 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.Monitor.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.Monitor.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,17 +326,17 @@ namespace stardew_access
} }
if (toPrint == "") if (toPrint == "")
MainClass.monitor.Log("No positions marked!", LogLevel.Info); MainClass.Monitor.Log("No positions marked!", LogLevel.Info);
else else
MainClass.monitor.Log($"Marked positions:\n{toPrint}\nOpen command menu and use pageup and pagedown to check the list", LogLevel.Info); MainClass.Monitor.Log($"Marked positions:\n{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) =>
{ {
MainClass.monitor.Log($"{Game1.activeClickableMenu is PurchaseAnimalsMenu}\t{BuildingNAnimalMenuPatches.isOnFarm}", LogLevel.Debug); MainClass.Monitor.Log($"{Game1.activeClickableMenu is PurchaseAnimalsMenu}\t{BuildingNAnimalMenuPatches.isOnFarm}", LogLevel.Debug);
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.Monitor.Log($"Cannot list buildings.", LogLevel.Info);
return; return;
} }
@ -357,11 +357,11 @@ namespace stardew_access
if (toPrint == "") if (toPrint == "")
{ {
MainClass.monitor.Log("No appropriate buildings to list", LogLevel.Info); MainClass.Monitor.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.Monitor.Log($"Available buildings:{toPrint}\nOpen command menu and use pageup and pagedown to check the list", LogLevel.Info);
} }
}); });
@ -370,14 +370,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.Monitor.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.Monitor.Log("Enter the index of the building too! Use buildlist", LogLevel.Info);
return; return;
} }
@ -386,7 +386,7 @@ namespace stardew_access
if (!isParsable) if (!isParsable)
{ {
MainClass.monitor.Log("Index can only be a number.", LogLevel.Info); MainClass.Monitor.Log("Index can only be a number.", LogLevel.Info);
return; return;
} }
@ -400,13 +400,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.Monitor.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.Monitor.Log("Enter the index of marked place too! Use marklist.", LogLevel.Info);
return; return;
} }
@ -414,7 +414,7 @@ namespace stardew_access
if (!isParsable) if (!isParsable)
{ {
MainClass.monitor.Log("Index can only be a number.", LogLevel.Info); MainClass.Monitor.Log("Index can only be a number.", LogLevel.Info);
return; return;
} }
} }
@ -423,7 +423,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.Monitor.Log($"No marked position found at {index} index.", LogLevel.Info);
return; return;
} }
} }
@ -431,7 +431,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.Monitor.Log($"No building found with index {index}. Use buildlist.", LogLevel.Info);
return; return;
} }
} }
@ -450,16 +450,16 @@ namespace stardew_access
if (response != null) if (response != null)
{ {
MainClass.monitor.Log(response, LogLevel.Info); MainClass.Monitor.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.ScreenReader.InitializeScreenReader();
MainClass.monitor.Log("Screen Reader refreshed!", LogLevel.Info); MainClass.Monitor.Log("Screen Reader refreshed!", LogLevel.Info);
}); });
} }
} }

View File

@ -6,7 +6,8 @@ namespace stardew_access
{ {
internal class CustomSoundEffects internal class CustomSoundEffects
{ {
internal enum TYPE{ internal enum TYPE
{
Sound, Sound,
Footstep Footstep
} }
@ -54,15 +55,15 @@ namespace stardew_access
} }
SoundEffect effect; SoundEffect effect;
string filePath = Path.Combine(MainClass.ModHelper.DirectoryPath,"sounds" , $"{soundEffect.Key}.wav"); string filePath = Path.Combine(MainClass.ModHelper.DirectoryPath, "sounds", $"{soundEffect.Key}.wav");
using (FileStream stream = new(filePath, FileMode.Open)) using (FileStream stream = new(filePath, FileMode.Open))
{ {
effect = SoundEffect.FromStream(stream); effect = SoundEffect.FromStream(stream);
} }
if(soundEffect.Value == TYPE.Sound) if (soundEffect.Value == TYPE.Sound)
cueDefinition.SetSound(effect, Game1.audioEngine.GetCategoryIndex("Sound"), false); cueDefinition.SetSound(effect, Game1.audioEngine.GetCategoryIndex("Sound"), false);
else if(soundEffect.Value == TYPE.Footstep) else if (soundEffect.Value == TYPE.Footstep)
cueDefinition.SetSound(effect, Game1.audioEngine.GetCategoryIndex("Footsteps"), false); cueDefinition.SetSound(effect, Game1.audioEngine.GetCategoryIndex("Footsteps"), false);
Game1.soundBank.AddCue(cueDefinition); Game1.soundBank.AddCue(cueDefinition);
@ -70,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.Monitor.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.ScreenReader.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.ScreenReader.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.ScreenReader.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.Monitor.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.Monitor.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.Monitor.Log($"\nRead Tile stopped\n\n", StardewModdingAPI.LogLevel.Debug);
await Task.Delay(delay); await Task.Delay(delay);
isRunning = false; isRunning = false;
@ -319,7 +319,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.Monitor.Log($"{e.Message}\n{e.StackTrace}\n{e.Source}", StardewModdingAPI.LogLevel.Error);
} }
} }
@ -371,7 +371,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.Monitor.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

@ -34,8 +34,8 @@ namespace stardew_access.Game
{ {
if (!manuallyTriggered && prevTile != gt) if (!manuallyTriggered && prevTile != gt)
{ {
if (MainClass.screenReader != null) if (MainClass.ScreenReader != null)
MainClass.screenReader.PrevTextTile = " "; MainClass.ScreenReader.PrevTextTile = " ";
} }
bool isColliding = isCollidingAtTile(x, y); bool isColliding = isCollidingAtTile(x, y);
@ -148,9 +148,9 @@ namespace stardew_access.Game
#region Narrate toSpeak #region Narrate toSpeak
if (toSpeak != " ") if (toSpeak != " ")
if (manuallyTriggered) if (manuallyTriggered)
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
else else
MainClass.screenReader.SayWithTileQuery(toSpeak, x, y, true); MainClass.ScreenReader.SayWithTileQuery(toSpeak, x, y, true);
#endregion #endregion
#region Play colliding sound effect #region Play colliding sound effect
@ -166,7 +166,7 @@ namespace stardew_access.Game
} }
catch (Exception e) catch (Exception e)
{ {
MainClass.monitor.Log($"Error in Read Tile:\n{e.Message}\n{e.StackTrace}", LogLevel.Debug); MainClass.Monitor.Log($"Error in Read Tile:\n{e.Message}\n{e.StackTrace}", LogLevel.Debug);
} }
await Task.Delay(100); await Task.Delay(100);

View File

@ -21,17 +21,16 @@ namespace stardew_access
public static bool radar = true; public static bool radar = true;
public static bool radarDebug = false; public static bool radarDebug = false;
public static bool radarStereoSound = true; public static bool radarStereoSound = true;
public static IMonitor monitor; private static IMonitor monitor;
private AutoHotkeyEngine ahk;
public static string hudMessageQueryKey = ""; public static string hudMessageQueryKey = "";
public static Radar radarFeature; private static Radar radarFeature;
public static ScreenReaderInterface screenReader; private static IScreenReader screenReader;
private static IModHelper modHelper;
private static IModHelper _modHelper; public static IModHelper ModHelper { get => modHelper; }
public static IModHelper ModHelper public static Radar RadarFeature { get => radarFeature; set => radarFeature = value; }
{ public static IScreenReader ScreenReader { get => screenReader; set => screenReader = value; }
get { return _modHelper; } public static IMonitor Monitor { get => monitor; set => monitor = value; }
}
/********* /*********
** Public methods ** Public methods
@ -42,22 +41,18 @@ namespace stardew_access
{ {
#region Initializations #region Initializations
monitor = Monitor; // Inititalize monitor Monitor = base.Monitor; // Inititalize monitor
_modHelper = helper; modHelper = helper;
Game1.options.setGamepadMode("force_on"); Game1.options.setGamepadMode("force_on");
// Initialize AutoHotKey ScreenReader = new ScreenReaderController().Initialize();
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
InitializeAutoHotKey();
screenReader = new ScreenReaderController().Initialize();
CustomSoundEffects.Initialize(); CustomSoundEffects.Initialize();
CustomCommands.Initialize(); CustomCommands.Initialize();
radarFeature = new Radar(); RadarFeature = new Radar();
harmony = new Harmony(ModManifest.UniqueID); harmony = new Harmony(ModManifest.UniqueID);
HarmonyPatches.Initialize(harmony); HarmonyPatches.Initialize(harmony);
@ -83,8 +78,8 @@ 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 (ScreenReader != null)
screenReader.CloseScreenReader(); ScreenReader.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>
@ -112,8 +107,8 @@ namespace stardew_access
if (!ReadTile.isReadingTile && readTile) if (!ReadTile.isReadingTile && readTile)
ReadTile.run(); ReadTile.run();
if (!radarFeature.isRunning && radar) if (!RadarFeature.isRunning && radar)
radarFeature.Run(); RadarFeature.Run();
if (!isNarratingHudMessage) if (!isNarratingHudMessage)
{ {
@ -128,10 +123,28 @@ namespace stardew_access
if (Game1.activeClickableMenu != null) if (Game1.activeClickableMenu != null)
{ {
bool isLeftShiftPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift);
bool isLeftControlPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftControl);
// Perform Left Click
if (Equals(e.Button, SButton.OemOpenBrackets)) if (Equals(e.Button, SButton.OemOpenBrackets))
{ {
Game1.activeClickableMenu.receiveLeftClick(Game1.getMouseX(true), Game1.getMouseY(true)); Game1.activeClickableMenu.receiveLeftClick(Game1.getMouseX(true), Game1.getMouseY(true));
} }
if (isLeftControlPressed && Equals(e.Button, SButton.Enter))
{
Game1.activeClickableMenu.receiveLeftClick(Game1.getMouseX(true), Game1.getMouseY(true));
}
// Perform Right CLick
if (Equals(e.Button, SButton.OemCloseBrackets))
{
Game1.activeClickableMenu.receiveRightClick(Game1.getMouseX(true), Game1.getMouseY(true));
}
if (isLeftShiftPressed && Equals(e.Button, SButton.Enter))
{
Game1.activeClickableMenu.receiveRightClick(Game1.getMouseX(true), Game1.getMouseY(true));
}
} }
if (!Context.IsPlayerFree) if (!Context.IsPlayerFree)
@ -141,28 +154,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.ScreenReader.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.ScreenReader.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.ScreenReader.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.ScreenReader.Say(toSpeak, true);
} }
// Manual read tile // Manual read tile
@ -177,21 +190,5 @@ namespace stardew_access
monitor.Log($"{Game1.player.controller.pathToEndPoint==null}", LogLevel.Debug); // true if path not found monitor.Log($"{Game1.player.controller.pathToEndPoint==null}", LogLevel.Debug); // true if path not found
}*/ }*/
} }
private void InitializeAutoHotKey()
{
try
{
ahk = AutoHotkeyEngine.Instance;
ahk.ExecRaw("[::\nSend {LButton}");
ahk.ExecRaw("^Enter::\nSend {LButton}");
ahk.ExecRaw("]::\nSend {RButton}");
ahk.ExecRaw("+Enter::\nSend {RButton}");
}
catch (Exception e)
{
monitor.Log($"Unable to initialize AutoHotKey:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
}
}
} }
} }

View File

@ -57,7 +57,7 @@ namespace stardew_access.Patches
if (purchaseAnimalMenuQuery != toSpeak) if (purchaseAnimalMenuQuery != toSpeak)
{ {
purchaseAnimalMenuQuery = toSpeak; purchaseAnimalMenuQuery = toSpeak;
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -65,7 +65,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.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -145,7 +145,7 @@ namespace stardew_access.Patches
if (carpenterMenuQuery != toSpeak) if (carpenterMenuQuery != toSpeak)
{ {
carpenterMenuQuery = toSpeak; carpenterMenuQuery = toSpeak;
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -156,7 +156,7 @@ namespace stardew_access.Patches
if (carpenterMenuQuery != toSpeak) if (carpenterMenuQuery != toSpeak)
{ {
carpenterMenuQuery = toSpeak; carpenterMenuQuery = toSpeak;
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -167,7 +167,7 @@ namespace stardew_access.Patches
if (carpenterMenuQuery != toSpeak) if (carpenterMenuQuery != toSpeak)
{ {
carpenterMenuQuery = toSpeak; carpenterMenuQuery = toSpeak;
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -178,7 +178,7 @@ namespace stardew_access.Patches
if (carpenterMenuQuery != toSpeak) if (carpenterMenuQuery != toSpeak)
{ {
carpenterMenuQuery = toSpeak; carpenterMenuQuery = toSpeak;
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -189,7 +189,7 @@ namespace stardew_access.Patches
if (carpenterMenuQuery != toSpeak) if (carpenterMenuQuery != toSpeak)
{ {
carpenterMenuQuery = toSpeak; carpenterMenuQuery = toSpeak;
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -200,7 +200,7 @@ namespace stardew_access.Patches
if (carpenterMenuQuery != toSpeak) if (carpenterMenuQuery != toSpeak)
{ {
carpenterMenuQuery = toSpeak; carpenterMenuQuery = toSpeak;
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -211,7 +211,7 @@ namespace stardew_access.Patches
if (carpenterMenuQuery != toSpeak) if (carpenterMenuQuery != toSpeak)
{ {
carpenterMenuQuery = toSpeak; carpenterMenuQuery = toSpeak;
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -234,14 +234,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.Monitor.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.ScreenReader.Say(info, true);
await Task.Delay(300); await Task.Delay(300);
isSayingBlueprintInfo = false; isSayingBlueprintInfo = false;
} }

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.ScreenReader.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.Monitor.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.ScreenReader.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.ScreenReader.SayWithChecker(toSpeak, false);
else else
MainClass.screenReader.SayWithChecker(toSpeak, true); MainClass.ScreenReader.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.ScreenReader.SayWithChecker(toSpeak, false);
else else
MainClass.screenReader.SayWithChecker(toSpeak, true); MainClass.ScreenReader.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.ScreenReader.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.Monitor.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.ScreenReader.SayWithChecker(toSpeak.ToString(), true); // Normal Checker
else else
MainClass.screenReader.SayWithMenuChecker(toSpeak.ToString(), true); // Menu Checker MainClass.ScreenReader.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.Monitor.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.ScreenReader.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.ScreenReader.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.ScreenReader.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.ScreenReader.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.ScreenReader.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.ScreenReader.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.ScreenReader.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.Monitor.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.ScreenReader.Say(toSpeak, true);
} }
} }
break; break;
@ -228,7 +228,7 @@ namespace stardew_access.Patches
} }
c.snapMouseCursorToCenter(); c.snapMouseCursorToCenter();
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.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.ScreenReader.Say(toSpeak, true);
} }
} }
break; break;
@ -289,7 +289,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.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
await Task.Delay(200); await Task.Delay(200);
@ -372,7 +372,7 @@ namespace stardew_access.Patches
if (socialPageQuery != toSpeak) if (socialPageQuery != toSpeak)
{ {
socialPageQuery = toSpeak; socialPageQuery = toSpeak;
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -417,7 +417,7 @@ namespace stardew_access.Patches
if (socialPageQuery != toSpeak) if (socialPageQuery != toSpeak)
{ {
socialPageQuery = toSpeak; socialPageQuery = toSpeak;
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -430,7 +430,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.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -461,7 +461,7 @@ namespace stardew_access.Patches
{ {
shopMenuQueryKey = toSpeak; shopMenuQueryKey = toSpeak;
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
Game1.playSound("drop_item"); Game1.playSound("drop_item");
} }
return; return;
@ -473,7 +473,7 @@ namespace stardew_access.Patches
{ {
shopMenuQueryKey = toSpeak; shopMenuQueryKey = toSpeak;
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -484,7 +484,7 @@ namespace stardew_access.Patches
{ {
shopMenuQueryKey = toSpeak; shopMenuQueryKey = toSpeak;
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -531,14 +531,14 @@ namespace stardew_access.Patches
{ {
shopMenuQueryKey = toSpeak; shopMenuQueryKey = toSpeak;
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.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.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -560,7 +560,7 @@ namespace stardew_access.Patches
if (gameMenuQueryKey != toSpeak) if (gameMenuQueryKey != toSpeak)
{ {
gameMenuQueryKey = toSpeak; gameMenuQueryKey = toSpeak;
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -568,7 +568,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.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -589,7 +589,7 @@ namespace stardew_access.Patches
if (geodeMenuQueryKey != toSpeak) if (geodeMenuQueryKey != toSpeak)
{ {
geodeMenuQueryKey = toSpeak; geodeMenuQueryKey = toSpeak;
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -602,7 +602,7 @@ namespace stardew_access.Patches
if (geodeMenuQueryKey != toSpeak) if (geodeMenuQueryKey != toSpeak)
{ {
geodeMenuQueryKey = toSpeak; geodeMenuQueryKey = toSpeak;
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -614,7 +614,7 @@ namespace stardew_access.Patches
if (geodeMenuQueryKey != toSpeak) if (geodeMenuQueryKey != toSpeak)
{ {
geodeMenuQueryKey = toSpeak; geodeMenuQueryKey = toSpeak;
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
Game1.playSound("drop_item"); Game1.playSound("drop_item");
} }
return; return;
@ -627,7 +627,7 @@ namespace stardew_access.Patches
if (geodeMenuQueryKey != toSpeak) if (geodeMenuQueryKey != toSpeak)
{ {
geodeMenuQueryKey = toSpeak; geodeMenuQueryKey = toSpeak;
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -639,7 +639,7 @@ namespace stardew_access.Patches
if (geodeMenuQueryKey != toSpeak) if (geodeMenuQueryKey != toSpeak)
{ {
geodeMenuQueryKey = toSpeak; geodeMenuQueryKey = toSpeak;
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -652,7 +652,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.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -684,7 +684,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
gameMenuQueryKey = ""; gameMenuQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -696,7 +696,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -709,7 +709,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -722,7 +722,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -735,7 +735,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -749,7 +749,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -763,7 +763,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -776,7 +776,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
Game1.playSound("drop_item"); Game1.playSound("drop_item");
} }
return; return;
@ -818,7 +818,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -843,7 +843,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.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -956,7 +956,7 @@ namespace stardew_access.Patches
{ {
craftingPageQueryKey = toSpeak; craftingPageQueryKey = toSpeak;
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -968,7 +968,7 @@ namespace stardew_access.Patches
{ {
craftingPageQueryKey = toSpeak; craftingPageQueryKey = toSpeak;
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -980,7 +980,7 @@ namespace stardew_access.Patches
{ {
craftingPageQueryKey = toSpeak; craftingPageQueryKey = toSpeak;
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -992,7 +992,7 @@ namespace stardew_access.Patches
{ {
craftingPageQueryKey = toSpeak; craftingPageQueryKey = toSpeak;
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
Game1.playSound("drop_item"); Game1.playSound("drop_item");
} }
return; return;
@ -1072,7 +1072,7 @@ namespace stardew_access.Patches
craftingPageQueryKey = toSpeak; craftingPageQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -1089,7 +1089,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.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -1139,7 +1139,7 @@ namespace stardew_access.Patches
inventoryPageQueryKey = toSpeak; inventoryPageQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
Game1.playSound("drop_item"); Game1.playSound("drop_item");
} }
return; return;
@ -1153,7 +1153,7 @@ namespace stardew_access.Patches
inventoryPageQueryKey = toSpeak; inventoryPageQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -1166,7 +1166,7 @@ namespace stardew_access.Patches
inventoryPageQueryKey = toSpeak; inventoryPageQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -1179,7 +1179,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -1193,7 +1193,7 @@ namespace stardew_access.Patches
itemGrabMenuQueryKey = toSpeak; itemGrabMenuQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -1289,7 +1289,7 @@ namespace stardew_access.Patches
inventoryPageQueryKey = toSpeak; inventoryPageQueryKey = toSpeak;
gameMenuQueryKey = ""; gameMenuQueryKey = "";
hoveredItemQueryKey = ""; hoveredItemQueryKey = "";
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -1307,7 +1307,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.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -1352,7 +1352,7 @@ namespace stardew_access.Patches
{ {
gameMenuQueryKey = ""; gameMenuQueryKey = "";
optionsPageQueryKey = toSpeak; optionsPageQueryKey = toSpeak;
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -1360,7 +1360,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.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -1376,7 +1376,7 @@ namespace stardew_access.Patches
{ {
gameMenuQueryKey = ""; gameMenuQueryKey = "";
exitPageQueryKey = toSpeak; exitPageQueryKey = toSpeak;
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
} }
return; return;
} }
@ -1388,14 +1388,14 @@ namespace stardew_access.Patches
{ {
gameMenuQueryKey = ""; gameMenuQueryKey = "";
exitPageQueryKey = toSpeak; exitPageQueryKey = toSpeak;
MainClass.screenReader.Say(toSpeak, true); MainClass.ScreenReader.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.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -1527,7 +1527,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.ScreenReader.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.Monitor.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.ScreenReader.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.ScreenReader.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.ScreenReader.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.Monitor.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.ScreenReader.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.Monitor.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.ScreenReader.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.Monitor.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.ScreenReader.SayWithMenuChecker(___message, true);
if (__instance.okButton.containsPoint(x, y)) if (__instance.okButton.containsPoint(x, y))
{ {
MainClass.screenReader.SayWithMenuChecker("Ok Button", false); MainClass.ScreenReader.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.ScreenReader.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.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -188,16 +188,16 @@ namespace stardew_access.Patches
} }
if (toSpeak != " ") if (toSpeak != " ")
MainClass.screenReader.SayWithMenuChecker(toSpeak, true); MainClass.ScreenReader.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.ScreenReader.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.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -212,21 +212,21 @@ namespace stardew_access.Patches
if (__instance.okButton.containsPoint(Game1.getMouseX(), Game1.getMouseY())) if (__instance.okButton.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
{ {
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.ScreenReader.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.ScreenReader.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.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -266,7 +266,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.ScreenReader.Say(toSpeak, false);
} }
#endregion #endregion
@ -279,7 +279,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.ScreenReader.SayWithChecker($"Grab: {name} \t\n {label}", false);
} }
} }
#endregion #endregion
@ -287,7 +287,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.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -329,7 +329,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.Monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
} }
} }
@ -371,14 +371,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.Monitor.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.ScreenReader != null)
MainClass.screenReader.CloseScreenReader(); MainClass.ScreenReader.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.ScreenReader.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.ScreenReader.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.Monitor.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.ScreenReader.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.ScreenReader.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.ScreenReader.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.Monitor.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.ScreenReader.SayWithChecker(toSpeak, true);
} }
} }
} }
@ -218,10 +218,13 @@ namespace stardew_access.Patches
toSpeak += $"\t\nOrder {j + 1}: {parsed_text} \t\n"; toSpeak += $"\t\nOrder {j + 1}: {parsed_text} \t\n";
} }
if (____shownQuest != null)
{
int daysLeft = ____shownQuest.GetDaysLeft(); int daysLeft = ____shownQuest.GetDaysLeft();
if (daysLeft > 0) if (daysLeft > 0)
toSpeak += $"\t\n{daysLeft} days left."; toSpeak += $"\t\n{daysLeft} days left.";
}
#endregion #endregion
} }
@ -229,13 +232,13 @@ namespace stardew_access.Patches
if (snapMouseToRewardBox) if (snapMouseToRewardBox)
__instance.rewardBox.snapMouseCursorToCenter(); __instance.rewardBox.snapMouseCursorToCenter();
MainClass.screenReader.SayWithChecker(toSpeak, true); MainClass.ScreenReader.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.Monitor.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.ScreenReader.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.Monitor.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.ScreenReader.SayWithChecker(text, true);
} }
if (TitleMenu.subMenu == null && toSpeak != "") if (TitleMenu.subMenu == null && toSpeak != "")
MainClass.screenReader.SayWithChecker(toSpeak, true); MainClass.ScreenReader.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.Monitor.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.ScreenReader.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.ScreenReader.SayWithChecker(message, true);
if (___menu.okDeleteButton.containsPoint(x, y)) if (___menu.okDeleteButton.containsPoint(x, y))
{ {
MainClass.screenReader.SayWithMenuChecker("Ok Button", false); MainClass.ScreenReader.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.ScreenReader.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.ScreenReader.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.Monitor.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.Monitor.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.ScreenReader.Say(toSpeak, true);
} }
await Task.Delay(200); await Task.Delay(200);

View File

@ -2,16 +2,21 @@ using System.Runtime.InteropServices;
namespace stardew_access.ScreenReader namespace stardew_access.ScreenReader
{ {
public class ScreenReaderController{ public class ScreenReaderController
public ScreenReaderInterface? Initialize(){ {
ScreenReaderInterface? ScreenReader = null; public IScreenReader? Initialize()
{
IScreenReader? ScreenReader = null;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)){ if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
ScreenReaderWindows screenReaderWindows = new ScreenReaderWindows(); ScreenReaderWindows screenReaderWindows = new ScreenReaderWindows();
screenReaderWindows.InitializeScreenReader(); screenReaderWindows.InitializeScreenReader();
ScreenReader = screenReaderWindows; ScreenReader = screenReaderWindows;
} else if(RuntimeInformation.IsOSPlatform(OSPlatform.Linux)){ }
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
ScreenReaderLinux screenReaderLinux = new ScreenReaderLinux(); ScreenReaderLinux screenReaderLinux = new ScreenReaderLinux();
screenReaderLinux.InitializeScreenReader(); screenReaderLinux.InitializeScreenReader();

View File

@ -1,8 +1,10 @@
namespace stardew_access.ScreenReader namespace stardew_access.ScreenReader
{ {
public interface ScreenReaderInterface{ public interface IScreenReader
{
public string PrevTextTile{ public string PrevTextTile
{
get; get;
set; set;
} }

View File

@ -14,7 +14,7 @@ namespace stardew_access.ScreenReader
} }
} }
public class ScreenReaderLinux : ScreenReaderInterface public class ScreenReaderLinux : IScreenReader
{ {
[DllImport("libspeechdwrapper.so")] [DllImport("libspeechdwrapper.so")]
private static extern int Initialize(); private static extern int Initialize();
@ -28,21 +28,25 @@ namespace stardew_access.ScreenReader
public string prevText = "", prevTextTile = " ", prevChatText = "", prevMenuText = ""; public string prevText = "", prevTextTile = " ", prevChatText = "", prevMenuText = "";
private bool initialized = false; private bool initialized = false;
public string PrevTextTile{ public string PrevTextTile
get{ return prevTextTile; } {
set{ prevTextTile=value; } get { return prevTextTile; }
set { prevTextTile = value; }
} }
public void InitializeScreenReader() public void InitializeScreenReader()
{ {
int res = Initialize(); int res = Initialize();
if(res==1){ if (res == 1)
{
initialized = true; initialized = true;
} }
} }
public void CloseScreenReader(){ public void CloseScreenReader()
if(initialized){ {
if (initialized)
{
Close(); Close();
initialized = false; initialized = false;
} }
@ -50,7 +54,8 @@ namespace stardew_access.ScreenReader
public void Say(string text, bool interrupt) public void Say(string text, bool interrupt)
{ {
if(initialized){ if (initialized)
{
GoString str = new GoString(text, text.Length); GoString str = new GoString(text, text.Length);
Speak(str, interrupt); Speak(str, interrupt);
} }

View File

@ -2,14 +2,15 @@
namespace stardew_access.ScreenReader namespace stardew_access.ScreenReader
{ {
public class ScreenReaderWindows : ScreenReaderInterface public class ScreenReaderWindows : IScreenReader
{ {
public IAccessibleOutput? screenReader = null; public IAccessibleOutput? screenReader = null;
public string prevText = "", prevTextTile = " ", prevChatText = "", prevMenuText = ""; public string prevText = "", prevTextTile = " ", prevChatText = "", prevMenuText = "";
public string PrevTextTile{ public string PrevTextTile
get{ return prevTextTile; } {
set{ prevTextTile=value; } get { return prevTextTile; }
set { prevTextTile = value; }
} }
public void InitializeScreenReader() public void InitializeScreenReader()
@ -38,7 +39,7 @@ namespace stardew_access.ScreenReader
{ {
sapiOutput = new SapiOutput(); sapiOutput = new SapiOutput();
} }
catch (Exception){ } catch (Exception) { }
if (nvdaOutput != null && nvdaOutput.IsAvailable()) if (nvdaOutput != null && nvdaOutput.IsAvailable())
screenReader = nvdaOutput; screenReader = nvdaOutput;
@ -48,7 +49,8 @@ namespace stardew_access.ScreenReader
screenReader = sapiOutput; screenReader = sapiOutput;
} }
public void CloseScreenReader(){ public void CloseScreenReader()
{
} }