From 9e1c263cf8df9e0d6c8eb13e17d6f9dc401ec17d Mon Sep 17 00:00:00 2001 From: Mohammad Shoaib Date: Sat, 9 Apr 2022 15:48:13 +0530 Subject: [PATCH] Fixed warnings --- stardew-access/API.cs | 20 ++-- stardew-access/CustomCommands.cs | 16 +-- stardew-access/Features/CurrentPlayer.cs | 2 +- stardew-access/Features/Other.cs | 6 +- stardew-access/Features/ReadTile.cs | 24 ++-- stardew-access/ModEntry.cs | 56 +++++---- .../Patches/BuildingNAnimalMenuPatches.cs | 38 +++--- stardew-access/Patches/ChatMenuPatches.cs | 4 +- stardew-access/Patches/DialoguePatches.cs | 22 ++-- stardew-access/Patches/GameMenuPatches.cs | 108 +++++++++--------- stardew-access/Patches/MenuPatches.cs | 34 +++--- stardew-access/Patches/MuseumMenuPatches.cs | 16 +-- stardew-access/Patches/QuestPatches.cs | 14 +-- stardew-access/Patches/TitleMenuPatches.cs | 20 ++-- 14 files changed, 190 insertions(+), 190 deletions(-) diff --git a/stardew-access/API.cs b/stardew-access/API.cs index 24a6c8b..902eed7 100644 --- a/stardew-access/API.cs +++ b/stardew-access/API.cs @@ -55,10 +55,10 @@ namespace stardew_access.ScreenReader /// Whether to skip the currently speaking text or not. public void Say(String text, Boolean interrupt) { - if (MainClass.GetScreenReader() == null) + if (MainClass.ScreenReader == null) return; - MainClass.GetScreenReader().Say(text, interrupt); + MainClass.ScreenReader.Say(text, interrupt); } /// Speaks the text via the loaded screen reader (if any). @@ -67,10 +67,10 @@ namespace stardew_access.ScreenReader /// Whether to skip the currently speaking text or not. public void SayWithChecker(String text, Boolean interrupt) { - if (MainClass.GetScreenReader() == null) + if (MainClass.ScreenReader == null) return; - MainClass.GetScreenReader().SayWithChecker(text, interrupt); + MainClass.ScreenReader.SayWithChecker(text, interrupt); } /// Speaks the text via the loaded screen reader (if any). @@ -80,10 +80,10 @@ namespace stardew_access.ScreenReader /// Whether to skip the currently speaking text or not. public void SayWithMenuChecker(String text, Boolean interrupt) { - if (MainClass.GetScreenReader() == null) + if (MainClass.ScreenReader == null) return; - MainClass.GetScreenReader().SayWithMenuChecker(text, interrupt); + MainClass.ScreenReader.SayWithMenuChecker(text, interrupt); } /// Speaks the text via the loaded screen reader (if any). @@ -93,10 +93,10 @@ namespace stardew_access.ScreenReader /// Whether to skip the currently speaking text or not. public void SayWithChatChecker(String text, Boolean interrupt) { - if (MainClass.GetScreenReader() == null) + if (MainClass.ScreenReader == null) return; - MainClass.GetScreenReader().SayWithChatChecker(text, interrupt); + MainClass.ScreenReader.SayWithChatChecker(text, interrupt); } /// Speaks the text via the loaded screen reader (if any). @@ -108,10 +108,10 @@ namespace stardew_access.ScreenReader /// Whether to skip the currently speaking text or not. public void SayWithTileQuery(String text, int x, int y, Boolean interrupt) { - if (MainClass.GetScreenReader() == null) + if (MainClass.ScreenReader == null) return; - MainClass.GetScreenReader().SayWithTileQuery(text, x, y, interrupt); + MainClass.ScreenReader.SayWithTileQuery(text, x, y, interrupt); } } diff --git a/stardew-access/CustomCommands.cs b/stardew-access/CustomCommands.cs index d4b2504..fc17160 100644 --- a/stardew-access/CustomCommands.cs +++ b/stardew-access/CustomCommands.cs @@ -11,12 +11,14 @@ namespace stardew_access { internal static void Initialize() { - IModHelper helper = MainClass.ModHelper; + IModHelper? helper = MainClass.ModHelper; + if (helper == null) + return; helper.ConsoleCommands.Add("readtile", "Toggle read tile feature.", (string commmand, string[] args) => { MainClass.Config.ReadTile = !MainClass.Config.ReadTile; - MainClass.ModHelper.WriteConfig(MainClass.Config); + helper.WriteConfig(MainClass.Config); MainClass.DebugLog("Read Tile is " + (MainClass.Config.ReadTile ? "on" : "off")); }); @@ -24,7 +26,7 @@ namespace stardew_access helper.ConsoleCommands.Add("snapmouse", "Toggle snap mouse feature.", (string commmand, string[] args) => { MainClass.Config.SnapMouse = !MainClass.Config.SnapMouse; - MainClass.ModHelper.WriteConfig(MainClass.Config); + helper.WriteConfig(MainClass.Config); MainClass.DebugLog("Snap Mouse is " + (MainClass.Config.SnapMouse ? "on" : "off")); }); @@ -32,7 +34,7 @@ namespace stardew_access helper.ConsoleCommands.Add("flooring", "Toggle flooring in read tile.", (string commmand, string[] args) => { MainClass.Config.ReadFlooring = !MainClass.Config.ReadFlooring; - MainClass.ModHelper.WriteConfig(MainClass.Config); + helper.WriteConfig(MainClass.Config); MainClass.DebugLog("Flooring is " + (MainClass.Config.ReadFlooring ? "on" : "off")); }); @@ -40,7 +42,7 @@ namespace stardew_access helper.ConsoleCommands.Add("radar", "Toggle radar feature.", (string commmand, string[] args) => { MainClass.Config.Radar = !MainClass.Config.Radar; - MainClass.ModHelper.WriteConfig(MainClass.Config); + helper.WriteConfig(MainClass.Config); MainClass.DebugLog("Radar " + (MainClass.Config.Radar ? "on" : "off")); }); @@ -56,7 +58,7 @@ namespace stardew_access helper.ConsoleCommands.Add("rstereo", "Toggle stereo sound in radar feature.", (string commmand, string[] args) => { MainClass.Config.RadarStereoSound = !MainClass.Config.RadarStereoSound; - MainClass.ModHelper.WriteConfig(MainClass.Config); + helper.WriteConfig(MainClass.Config); MainClass.DebugLog("Stereo sound is " + (MainClass.Config.RadarStereoSound ? "on" : "off")); }); @@ -467,7 +469,7 @@ namespace stardew_access helper.ConsoleCommands.Add("refsr", "Refresh screen reader", (string commmand, string[] args) => { - MainClass.GetScreenReader().InitializeScreenReader(); + MainClass.ScreenReader.InitializeScreenReader(); MainClass.DebugLog("Screen Reader refreshed!"); }); diff --git a/stardew-access/Features/CurrentPlayer.cs b/stardew-access/Features/CurrentPlayer.cs index 7ea330e..3f29382 100644 --- a/stardew-access/Features/CurrentPlayer.cs +++ b/stardew-access/Features/CurrentPlayer.cs @@ -23,7 +23,7 @@ namespace stardew_access.Features if (Game1.player == null) return 0; - int maxStamina = Game1.player.maxStamina; + int maxStamina = Game1.player.maxStamina.Value; int currentStamine = (int)Game1.player.stamina; int staminaPercentage = (int)(currentStamine * 100) / maxStamina; diff --git a/stardew-access/Features/Other.cs b/stardew-access/Features/Other.cs index 6876480..a21698f 100644 --- a/stardew-access/Features/Other.cs +++ b/stardew-access/Features/Other.cs @@ -23,7 +23,7 @@ namespace stardew_access.Features return; previousSlotItem = currentSlotItem; - MainClass.GetScreenReader().Say($"{currentSlotItem.DisplayName} Selected", true); + MainClass.ScreenReader.Say($"{currentSlotItem.DisplayName} Selected", true); } // Narrates current location's name @@ -38,7 +38,7 @@ namespace stardew_access.Features return; previousLocation = currentLocation; - MainClass.GetScreenReader().Say($"{currentLocation.Name} Entered", true); + MainClass.ScreenReader.Say($"{currentLocation.Name} Entered", true); } public static void SnapMouseToPlayer() @@ -88,7 +88,7 @@ namespace stardew_access.Features { MainClass.hudMessageQueryKey = searchQuery; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } } } diff --git a/stardew-access/Features/ReadTile.cs b/stardew-access/Features/ReadTile.cs index b90919a..33c5931 100644 --- a/stardew-access/Features/ReadTile.cs +++ b/stardew-access/Features/ReadTile.cs @@ -47,8 +47,8 @@ namespace stardew_access.Features { if (!manuallyTriggered && prevTile != tile) { - if (MainClass.GetScreenReader() != null) - MainClass.GetScreenReader().PrevTextTile = " "; + if (MainClass.ScreenReader != null) + MainClass.ScreenReader.PrevTextTile = " "; } bool isColliding = isCollidingAtTile(x, y); @@ -57,11 +57,11 @@ namespace stardew_access.Features #region Narrate toSpeak if (toSpeak != null) - if (MainClass.GetScreenReader() != null) + if (MainClass.ScreenReader != null) if (manuallyTriggered) - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); else - MainClass.GetScreenReader().SayWithTileQuery(toSpeak, x, y, true); + MainClass.ScreenReader.SayWithTileQuery(toSpeak, x, y, true); #endregion #region Play colliding sound effect @@ -202,13 +202,13 @@ namespace stardew_access.Features { string? toReturn = null; Bush bush = (Bush)Game1.currentLocation.getLargeTerrainFeatureAt(x, y); - int size = bush.size; + int size = bush.size.Value; #region Check if bush is harvestable or not - if (!bush.townBush && (int)bush.tileSheetOffset == 1 && bush.inBloom(Game1.GetSeasonForLocation(Game1.currentLocation), Game1.dayOfMonth)) + if (!bush.townBush.Value && (int)bush.tileSheetOffset.Value == 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); + string season = ((int)bush.overrideSeason.Value == -1) ? Game1.GetSeasonForLocation(Game1.currentLocation) : Utility.getSeasonNameFromNumber(bush.overrideSeason.Value); int shakeOff = -1; if (!(season == "spring")) { @@ -238,9 +238,9 @@ namespace stardew_access.Features } #endregion - if (bush.townBush) + if (bush.townBush.Value) toReturn = $"{toReturn} Town Bush"; - else if (bush.greenhouseBush) + else if (bush.greenhouseBush.Value) toReturn = $"{toReturn} Greenhouse Bush"; else toReturn = $"{toReturn} Bush"; @@ -409,7 +409,7 @@ namespace stardew_access.Features HoeDirt dirt = (HoeDirt)terrain.Get(); if (dirt.crop != null) { - string cropName = Game1.objectInformation[dirt.crop.indexOfHarvest].Split('/')[0]; + string cropName = Game1.objectInformation[dirt.crop.indexOfHarvest.Value].Split('/')[0]; toReturn = $"{cropName}"; bool isWatered = dirt.state.Value == HoeDirt.watered; @@ -633,7 +633,7 @@ namespace stardew_access.Features if (machine is CrabPot crabPot) if (crabPot.bait.Value is not null && crabPot.heldObject.Value is null) return MachineState.Busy; - return GetMachineState(machine.readyForHarvest.Value, machine.MinutesUntilReady, machine.heldObject); + return GetMachineState(machine.readyForHarvest.Value, machine.MinutesUntilReady, machine.heldObject.Value); } private static MachineState GetMachineState(bool readyForHarvest, int minutesUntilReady, StardewValley.Object? heldObject) diff --git a/stardew-access/ModEntry.cs b/stardew-access/ModEntry.cs index 8c344be..1dc8136 100644 --- a/stardew-access/ModEntry.cs +++ b/stardew-access/ModEntry.cs @@ -12,16 +12,16 @@ namespace stardew_access { public class MainClass : Mod { - #region Global Vars - private static ModConfig config; + #region Global Vars & Properties + private static ModConfig? config; private Harmony? harmony; private static IMonitor? monitor; private static Radar? radarFeature; private static IScreenReader? screenReader; - private static IModHelper modHelper; + private static IModHelper? modHelper; internal static ModConfig Config { get => config; set => config = value; } - public static IModHelper ModHelper { get => modHelper; } + public static IModHelper? ModHelper { get => modHelper; } public static Radar RadarFeature { get @@ -35,25 +35,21 @@ namespace stardew_access public static string hudMessageQueryKey = ""; public static bool isNarratingHudMessage = false; public static bool radarDebug = false; + + public static IScreenReader ScreenReader + { + get + { + if (screenReader == null) + screenReader = new ScreenReaderController().Initialize(); + + return screenReader; + } + + set => screenReader = value; + } #endregion - public static IScreenReader GetScreenReader() - { - if (screenReader == null) - screenReader = new ScreenReaderController().Initialize(); - return screenReader; - } - - public static void SetScreenReader(IScreenReader value) - { - screenReader = value; - } - - public static void SetMonitor(IMonitor value) - { - monitor = value; - } - /********* ** Public methods *********/ @@ -64,12 +60,12 @@ namespace stardew_access #region Initializations Config = helper.ReadConfig(); - SetMonitor(base.Monitor); // Inititalize monitor + monitor = base.Monitor; // Inititalize monitor modHelper = helper; Game1.options.setGamepadMode("force_on"); - SetScreenReader(new ScreenReaderController().Initialize()); + ScreenReader = new ScreenReaderController().Initialize(); CustomSoundEffects.Initialize(); @@ -99,8 +95,8 @@ namespace stardew_access public void OnExit(object? sender, EventArgs? e) { // Don't if this ever gets called or not but, just in case if it does. - if (GetScreenReader() != null) - GetScreenReader().CloseScreenReader(); + if (ScreenReader != null) + ScreenReader.CloseScreenReader(); } /// Returns the Screen Reader class for other mods to use. @@ -188,7 +184,7 @@ namespace stardew_access if (Config.LocationKey.JustPressed()) { string toSpeak = $"{Game1.currentLocation.Name}"; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); return; } @@ -205,7 +201,7 @@ namespace stardew_access toSpeak = $"{CurrentPlayer.getPositionX()}, {CurrentPlayer.getPositionY()}"; } - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); return; } @@ -213,7 +209,7 @@ namespace stardew_access if (Config.HealthNStaminaKey.JustPressed()) { string toSpeak = $"Health is {CurrentPlayer.getHealth()} and Stamina is {CurrentPlayer.getStamina()}"; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); return; } @@ -221,7 +217,7 @@ namespace stardew_access if (Config.MoneyKey.JustPressed()) { string toSpeak = $"You have {CurrentPlayer.getMoney()}g"; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); return; } @@ -229,7 +225,7 @@ namespace stardew_access if (Config.TimeNSeasonKey.JustPressed()) { string toSpeak = $"Time is {CurrentPlayer.getTimeOfDay()} and it is {CurrentPlayer.getDay()} {CurrentPlayer.getDate()} of {CurrentPlayer.getSeason()}"; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); return; } diff --git a/stardew-access/Patches/BuildingNAnimalMenuPatches.cs b/stardew-access/Patches/BuildingNAnimalMenuPatches.cs index 1a90347..b172e95 100644 --- a/stardew-access/Patches/BuildingNAnimalMenuPatches.cs +++ b/stardew-access/Patches/BuildingNAnimalMenuPatches.cs @@ -61,7 +61,7 @@ namespace stardew_access.Patches firstTimeInNamingMenu = false; } - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } } else if (___onFarm && !___namingAnimal) @@ -90,7 +90,7 @@ namespace stardew_access.Patches if (purchaseAnimalMenuQuery != toSpeak) { purchaseAnimalMenuQuery = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -180,7 +180,7 @@ namespace stardew_access.Patches if (carpenterMenuQuery != toSpeak) { carpenterMenuQuery = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -191,7 +191,7 @@ namespace stardew_access.Patches if (carpenterMenuQuery != toSpeak) { carpenterMenuQuery = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -202,7 +202,7 @@ namespace stardew_access.Patches if (carpenterMenuQuery != toSpeak) { carpenterMenuQuery = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -213,7 +213,7 @@ namespace stardew_access.Patches if (carpenterMenuQuery != toSpeak) { carpenterMenuQuery = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -224,7 +224,7 @@ namespace stardew_access.Patches if (carpenterMenuQuery != toSpeak) { carpenterMenuQuery = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -235,7 +235,7 @@ namespace stardew_access.Patches if (carpenterMenuQuery != toSpeak) { carpenterMenuQuery = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -246,7 +246,7 @@ namespace stardew_access.Patches if (carpenterMenuQuery != toSpeak) { carpenterMenuQuery = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -276,7 +276,7 @@ namespace stardew_access.Patches private static async void SayBlueprintInfo(string info) { isSayingBlueprintInfo = true; - MainClass.GetScreenReader().Say(info, true); + MainClass.ScreenReader.Say(info, true); await Task.Delay(300); isSayingBlueprintInfo = false; } @@ -300,7 +300,7 @@ namespace stardew_access.Patches { if (isDemolishing && toDemolish != null && farm.buildings.Contains(toDemolish)) { - if ((int)toDemolish.daysOfConstructionLeft > 0 || (int)toDemolish.daysUntilUpgrade > 0) + if ((int)toDemolish.daysOfConstructionLeft.Value > 0 || (int)toDemolish.daysUntilUpgrade.Value > 0) { response = Game1.content.LoadString("Strings\\UI:Carpenter_CantDemolish_DuringConstruction"); } @@ -345,8 +345,8 @@ namespace stardew_access.Patches } if (farm.destroyStructure(toDemolish)) { - _ = (int)toDemolish.tileY; - _ = (int)toDemolish.tilesHigh; + _ = (int)toDemolish.tileY.Value; + _ = (int)toDemolish.tilesHigh.Value; Game1.flashAlpha = 1f; toDemolish.showDestroyedAnimation(Game1.getFarm()); Game1.playSound("explosion"); @@ -356,7 +356,7 @@ namespace stardew_access.Patches // freeze = true; if (chest != null) { - farm.objects[new Vector2((int)toDemolish.tileX + (int)toDemolish.tilesWide / 2, (int)toDemolish.tileY + (int)toDemolish.tilesHigh / 2)] = chest; + farm.objects[new Vector2((int)toDemolish.tileX.Value + (int)toDemolish.tilesWide.Value / 2, (int)toDemolish.tileY.Value + (int)toDemolish.tilesHigh.Value / 2)] = chest; } } } @@ -385,7 +385,7 @@ namespace stardew_access.Patches if (toDemolish != null && toDemolish.indoors.Value is 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.Value) { Game1.currentLocation.createQuestionDialogue(Game1.content.LoadString("Strings\\UI:Carpenter_DemolishCabinConfirm", cabin.farmhand.Value.Name), Game1.currentLocation.createYesNoResponses(), delegate (Farmer f, string answer) { @@ -458,7 +458,7 @@ namespace stardew_access.Patches Game1.playSound("axe"); DelayedAction.functionAfterDelay(carpenterMenu.returnToCarpentryMenuAfterSuccessfulBuild, 1500); // freeze = true; - // Game1.multiplayer.globalChatInfoMessage("BuildingBuild", Game1.player.Name, Utility.AOrAn(carpenterMenu.CurrentBlueprint.displayName), carpenterMenu.CurrentBlueprint.displayName, Game1.player.farmName); + // Game1.multiplayer.globalChatInfoMessage("BuildingBuild", Game1.player.Name, Utility.AOrAn(carpenterMenu.CurrentBlueprint.displayName), carpenterMenu.CurrentBlueprint.displayName, Game1.player.farmName.Value); } else if (toUpgrade != null) { @@ -517,7 +517,7 @@ namespace stardew_access.Patches string? name = buildingToMove.nameOfIndoorsWithoutUnique; name = (name == "null") ? buildingToMove.buildingType.Value : name; - if ((int)buildingToMove.daysOfConstructionLeft > 0) + if ((int)buildingToMove.daysOfConstructionLeft.Value > 0) { buildingToMove = null; return "Building under construction, cannot move"; @@ -566,8 +566,8 @@ namespace stardew_access.Patches if (purchaseAnimalsMenu == null) return; - int x = (selection.tileX * Game1.tileSize) - Game1.viewport.X; - int y = (selection.tileY * Game1.tileSize) - Game1.viewport.Y; + int x = (selection.tileX.Value * Game1.tileSize) - Game1.viewport.X; + int y = (selection.tileY.Value * Game1.tileSize) - Game1.viewport.Y; purchaseAnimalsMenu.receiveLeftClick(x, y); } } diff --git a/stardew-access/Patches/ChatMenuPatches.cs b/stardew-access/Patches/ChatMenuPatches.cs index 6b3a07a..6de3d2b 100644 --- a/stardew-access/Patches/ChatMenuPatches.cs +++ b/stardew-access/Patches/ChatMenuPatches.cs @@ -45,7 +45,7 @@ namespace stardew_access.Patches toSpeak += $"{message.message}, "; }); if (toSpeak != " ") - MainClass.GetScreenReader().SayWithChatChecker(toSpeak, false); + MainClass.ScreenReader.SayWithChatChecker(toSpeak, false); #endregion } } @@ -79,7 +79,7 @@ namespace stardew_access.Patches toSpeak += $"{message.message}, "; }); - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } } } diff --git a/stardew-access/Patches/DialoguePatches.cs b/stardew-access/Patches/DialoguePatches.cs index 9eaab5b..acdf755 100644 --- a/stardew-access/Patches/DialoguePatches.cs +++ b/stardew-access/Patches/DialoguePatches.cs @@ -57,7 +57,7 @@ namespace stardew_access.Patches else toSpeak = response; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } } else @@ -65,7 +65,7 @@ namespace stardew_access.Patches if (currentDialogue != dialogueText) { currentDialogue = dialogueText; - MainClass.GetScreenReader().Say(dialogueText, true); + MainClass.ScreenReader.Say(dialogueText, true); } } } @@ -106,7 +106,7 @@ namespace stardew_access.Patches else toSpeak = response; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } } else @@ -114,7 +114,7 @@ namespace stardew_access.Patches if (currentDialogue != dialogueText) { currentDialogue = dialogueText; - MainClass.GetScreenReader().Say(dialogueText, true); + MainClass.ScreenReader.Say(dialogueText, true); } } } @@ -124,7 +124,7 @@ namespace stardew_access.Patches if (currentDialogue != __instance.getCurrentString()) { currentDialogue = __instance.getCurrentString(); - MainClass.GetScreenReader().Say(__instance.getCurrentString(), true); + MainClass.ScreenReader.Say(__instance.getCurrentString(), true); } } } @@ -316,9 +316,9 @@ namespace stardew_access.Patches if (toSpeak.ToString() != " ") { if (Context.IsPlayerFree) - MainClass.GetScreenReader().SayWithChecker(toSpeak.ToString(), true); // Normal Checker + MainClass.ScreenReader.SayWithChecker(toSpeak.ToString(), true); // Normal Checker else - MainClass.GetScreenReader().SayWithMenuChecker(toSpeak.ToString(), true); // Menu Checker + MainClass.ScreenReader.SayWithMenuChecker(toSpeak.ToString(), true); // Menu Checker } #endregion } @@ -380,7 +380,7 @@ namespace stardew_access.Patches if (__instance.mailMessage.Count > 1) toSpeak = $"Page {__instance.page + 1} of {__instance.mailMessage.Count}:\n\t{toSpeak}"; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } #endregion @@ -393,17 +393,17 @@ namespace stardew_access.Patches string label = c.label; if (c.containsPoint(x, y)) - MainClass.GetScreenReader().SayWithChecker($"Grab: {name} \t\n {label}", false); + MainClass.ScreenReader.SayWithChecker($"Grab: {name} \t\n {label}", false); } } #endregion #region Narrate buttons if (__instance.backButton != null && __instance.backButton.visible && __instance.backButton.containsPoint(x, y)) - MainClass.GetScreenReader().SayWithChecker($"Previous page button", false); + MainClass.ScreenReader.SayWithChecker($"Previous page button", false); if (__instance.forwardButton != null && __instance.forwardButton.visible && __instance.forwardButton.containsPoint(x, y)) - MainClass.GetScreenReader().SayWithChecker($"Next page button", false); + MainClass.ScreenReader.SayWithChecker($"Next page button", false); #endregion } diff --git a/stardew-access/Patches/GameMenuPatches.cs b/stardew-access/Patches/GameMenuPatches.cs index 3c258f6..f0e72f0 100644 --- a/stardew-access/Patches/GameMenuPatches.cs +++ b/stardew-access/Patches/GameMenuPatches.cs @@ -59,7 +59,7 @@ namespace stardew_access.Patches if (junimoNoteMenuQuery != toSpeak) { junimoNoteMenuQuery = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -71,7 +71,7 @@ namespace stardew_access.Patches if (junimoNoteMenuQuery != toSpeak) { junimoNoteMenuQuery = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -82,7 +82,7 @@ namespace stardew_access.Patches if (junimoNoteMenuQuery != toSpeak) { junimoNoteMenuQuery = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -94,7 +94,7 @@ namespace stardew_access.Patches if (junimoNoteMenuQuery != toSpeak) { junimoNoteMenuQuery = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -104,7 +104,7 @@ namespace stardew_access.Patches if (junimoNoteMenuQuery != toSpeak) { junimoNoteMenuQuery = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -140,12 +140,12 @@ namespace stardew_access.Patches else if (isBackPressed && __instance.backButton != null && !__instance.backButton.containsPoint(x, y)) { __instance.backButton.snapMouseCursorToCenter(); - MainClass.GetScreenReader().Say("Back Button", true); + MainClass.ScreenReader.Say("Back Button", true); } else if (isPPressed && __instance.purchaseButton != null && !__instance.purchaseButton.containsPoint(x, y)) { __instance.purchaseButton.snapMouseCursorToCenter(); - MainClass.GetScreenReader().Say("Purchase Button", true); + MainClass.ScreenReader.Say("Purchase Button", true); } } string reward = __instance.getRewardNameForArea(___whichArea); @@ -215,7 +215,7 @@ namespace stardew_access.Patches toSpeak = $"Completed {toSpeak}"; c.snapMouseCursorToCenter(); - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } } break; @@ -250,7 +250,7 @@ namespace stardew_access.Patches } c.snapMouseCursorToCenter(); - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } } break; @@ -303,7 +303,7 @@ namespace stardew_access.Patches toSpeak = "Empty Slot"; } c.snapMouseCursorToCenter(); - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } } break; @@ -401,7 +401,7 @@ namespace stardew_access.Patches if (socialPageQuery != toSpeak) { socialPageQuery = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -446,7 +446,7 @@ namespace stardew_access.Patches if (socialPageQuery != toSpeak) { socialPageQuery = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -490,7 +490,7 @@ namespace stardew_access.Patches { shopMenuQueryKey = toSpeak; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); Game1.playSound("drop_item"); } return; @@ -502,7 +502,7 @@ namespace stardew_access.Patches { shopMenuQueryKey = toSpeak; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -513,7 +513,7 @@ namespace stardew_access.Patches { shopMenuQueryKey = toSpeak; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -560,7 +560,7 @@ namespace stardew_access.Patches { shopMenuQueryKey = toSpeak; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } } #endregion @@ -589,7 +589,7 @@ namespace stardew_access.Patches if (gameMenuQueryKey != toSpeak) { gameMenuQueryKey = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -618,7 +618,7 @@ namespace stardew_access.Patches if (geodeMenuQueryKey != toSpeak) { geodeMenuQueryKey = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -631,7 +631,7 @@ namespace stardew_access.Patches if (geodeMenuQueryKey != toSpeak) { geodeMenuQueryKey = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -643,7 +643,7 @@ namespace stardew_access.Patches if (geodeMenuQueryKey != toSpeak) { geodeMenuQueryKey = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); Game1.playSound("drop_item"); } return; @@ -656,7 +656,7 @@ namespace stardew_access.Patches if (geodeMenuQueryKey != toSpeak) { geodeMenuQueryKey = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -668,7 +668,7 @@ namespace stardew_access.Patches if (geodeMenuQueryKey != toSpeak) { geodeMenuQueryKey = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -713,7 +713,7 @@ namespace stardew_access.Patches itemGrabMenuQueryKey = toSpeak; hoveredItemQueryKey = ""; gameMenuQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -725,7 +725,7 @@ namespace stardew_access.Patches itemGrabMenuQueryKey = toSpeak; gameMenuQueryKey = ""; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -738,7 +738,7 @@ namespace stardew_access.Patches itemGrabMenuQueryKey = toSpeak; gameMenuQueryKey = ""; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -751,7 +751,7 @@ namespace stardew_access.Patches itemGrabMenuQueryKey = toSpeak; gameMenuQueryKey = ""; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -764,7 +764,7 @@ namespace stardew_access.Patches itemGrabMenuQueryKey = toSpeak; gameMenuQueryKey = ""; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -778,7 +778,7 @@ namespace stardew_access.Patches itemGrabMenuQueryKey = toSpeak; gameMenuQueryKey = ""; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -792,7 +792,7 @@ namespace stardew_access.Patches itemGrabMenuQueryKey = toSpeak; gameMenuQueryKey = ""; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -805,7 +805,7 @@ namespace stardew_access.Patches itemGrabMenuQueryKey = toSpeak; gameMenuQueryKey = ""; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); Game1.playSound("drop_item"); } return; @@ -847,7 +847,7 @@ namespace stardew_access.Patches itemGrabMenuQueryKey = toSpeak; gameMenuQueryKey = ""; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -987,7 +987,7 @@ namespace stardew_access.Patches { craftingPageQueryKey = toSpeak; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -999,7 +999,7 @@ namespace stardew_access.Patches { craftingPageQueryKey = toSpeak; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -1011,7 +1011,7 @@ namespace stardew_access.Patches { craftingPageQueryKey = toSpeak; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -1023,7 +1023,7 @@ namespace stardew_access.Patches { craftingPageQueryKey = toSpeak; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); Game1.playSound("drop_item"); } return; @@ -1057,20 +1057,22 @@ namespace stardew_access.Patches #region Health & stamina and buff items (effects like +1 walking speed) Item producesItem = ___hoverRecipe.createItem(); - if (producesItem is StardewValley.Object && ((StardewValley.Object)producesItem).Edibility != -300) + StardewValley.Object? producesItemObject = ((StardewValley.Object)producesItem); + + if (producesItem is StardewValley.Object && producesItemObject.Edibility != -300) { - int stamina_recovery = ((StardewValley.Object)producesItem).staminaRecoveredOnConsumption(); + int stamina_recovery = producesItemObject.staminaRecoveredOnConsumption(); buffs += $"{stamina_recovery} Energy"; if (stamina_recovery >= 0) { - int health_recovery = ((StardewValley.Object)producesItem).healthRecoveredOnConsumption(); + int health_recovery = producesItemObject.healthRecoveredOnConsumption(); buffs += $"\n{health_recovery} Health"; } } // These variables are taken from the game's code itself (IClickableMenu.cs -> 1016 line) - bool edibleItem = producesItem != null && producesItem is StardewValley.Object && (int)((StardewValley.Object)producesItem).Edibility != -300; - string[]? buffIconsToDisplay = (edibleItem && Game1.objectInformation[((StardewValley.Object)producesItem).ParentSheetIndex].Split('/').Length > 7) - ? producesItem.ModifyItemBuffs(Game1.objectInformation[((StardewValley.Object)producesItem).ParentSheetIndex].Split('/')[7].Split(' ')) + bool edibleItem = producesItem != null && producesItem is StardewValley.Object && (int)producesItemObject.Edibility != -300; + string[]? buffIconsToDisplay = (producesItem != null && edibleItem && Game1.objectInformation[producesItemObject.ParentSheetIndex].Split('/').Length > 7) + ? producesItem.ModifyItemBuffs(Game1.objectInformation[producesItemObject.ParentSheetIndex].Split('/')[7].Split(' ')) : null; if (buffIconsToDisplay != null) @@ -1103,7 +1105,7 @@ namespace stardew_access.Patches craftingPageQueryKey = toSpeak; gameMenuQueryKey = ""; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -1128,7 +1130,7 @@ namespace stardew_access.Patches craftingPageQueryKey = query; gameMenuQueryKey = ""; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say("unknown recipe", true); + MainClass.ScreenReader.Say("unknown recipe", true); } return; } @@ -1195,7 +1197,7 @@ namespace stardew_access.Patches inventoryPageQueryKey = toSpeak; gameMenuQueryKey = ""; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); Game1.playSound("drop_item"); } return; @@ -1209,7 +1211,7 @@ namespace stardew_access.Patches inventoryPageQueryKey = toSpeak; gameMenuQueryKey = ""; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -1222,7 +1224,7 @@ namespace stardew_access.Patches inventoryPageQueryKey = toSpeak; gameMenuQueryKey = ""; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -1235,7 +1237,7 @@ namespace stardew_access.Patches itemGrabMenuQueryKey = toSpeak; gameMenuQueryKey = ""; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -1249,7 +1251,7 @@ namespace stardew_access.Patches itemGrabMenuQueryKey = toSpeak; gameMenuQueryKey = ""; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -1345,7 +1347,7 @@ namespace stardew_access.Patches inventoryPageQueryKey = toSpeak; gameMenuQueryKey = ""; hoveredItemQueryKey = ""; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -1408,7 +1410,7 @@ namespace stardew_access.Patches { gameMenuQueryKey = ""; optionsPageQueryKey = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -1432,7 +1434,7 @@ namespace stardew_access.Patches { gameMenuQueryKey = ""; exitPageQueryKey = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -1444,7 +1446,7 @@ namespace stardew_access.Patches { gameMenuQueryKey = ""; exitPageQueryKey = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return; } @@ -1583,7 +1585,7 @@ namespace stardew_access.Patches if (hoveredItemQueryKey != $"{toSpeak}:{i}") { hoveredItemQueryKey = $"{toSpeak}:{i}"; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return true; } diff --git a/stardew-access/Patches/MenuPatches.cs b/stardew-access/Patches/MenuPatches.cs index a91f331..d929049 100644 --- a/stardew-access/Patches/MenuPatches.cs +++ b/stardew-access/Patches/MenuPatches.cs @@ -42,7 +42,7 @@ namespace stardew_access.Patches int age = (___animal.GetDaysOwned() + 1) / 28 + 1; string ageText = (age <= 1) ? Game1.content.LoadString("Strings\\UI:AnimalQuery_Age1") : Game1.content.LoadString("Strings\\UI:AnimalQuery_AgeN", age); string parent = ""; - if ((int)___animal.age < (byte)___animal.ageWhenMature) + if ((int)___animal.age.Value < (byte)___animal.ageWhenMature.Value) { ageText += Game1.content.LoadString("Strings\\UI:AnimalQuery_AgeBaby"); } @@ -74,7 +74,7 @@ namespace stardew_access.Patches if (animalQueryMenuQuery != toSpeak) { animalQueryMenuQuery = toSpeak; - MainClass.GetScreenReader().Say($"{details} {toSpeak}", true); + MainClass.ScreenReader.Say($"{details} {toSpeak}", true); } } catch (System.Exception e) @@ -123,13 +123,13 @@ namespace stardew_access.Patches if (__instance.nextPageButton != null && __instance.nextPageButton.containsPoint(x, y)) { - MainClass.GetScreenReader().SayWithMenuChecker($"Next Page Button", true); + MainClass.ScreenReader.SayWithMenuChecker($"Next Page Button", true); return; } if (__instance.previousPageButton != null && __instance.previousPageButton.containsPoint(x, y)) { - MainClass.GetScreenReader().SayWithMenuChecker($"Previous Page Button", true); + MainClass.ScreenReader.SayWithMenuChecker($"Previous Page Button", true); return; } @@ -137,7 +137,7 @@ namespace stardew_access.Patches { if (__instance.languages[i].containsPoint(x, y)) { - MainClass.GetScreenReader().SayWithMenuChecker($"{__instance.languageList[i]} Button", true); + MainClass.ScreenReader.SayWithMenuChecker($"{__instance.languageList[i]} Button", true); break; } } @@ -157,7 +157,7 @@ namespace stardew_access.Patches { if (___elevators[i].containsPoint(x, y)) { - MainClass.GetScreenReader().SayWithMenuChecker($"{___elevators[i].name} level", true); + MainClass.ScreenReader.SayWithMenuChecker($"{___elevators[i].name} level", true); break; } } @@ -179,7 +179,7 @@ namespace stardew_access.Patches toSpeak = $"Paste button"; if (toSpeak != "") - MainClass.GetScreenReader().SayWithChecker(toSpeak, true); + MainClass.ScreenReader.SayWithChecker(toSpeak, true); } catch (System.Exception e) { @@ -222,7 +222,7 @@ namespace stardew_access.Patches } if (toSpeak != "") - MainClass.GetScreenReader().SayWithChecker(toSpeak, true); + MainClass.ScreenReader.SayWithChecker(toSpeak, true); } catch (Exception e) { @@ -236,14 +236,14 @@ namespace stardew_access.Patches { int x = Game1.getMouseX(true), y = Game1.getMouseY(true); - MainClass.GetScreenReader().SayWithMenuChecker(___message, true); + MainClass.ScreenReader.SayWithMenuChecker(___message, true); if (__instance.okButton.containsPoint(x, y)) { - MainClass.GetScreenReader().SayWithMenuChecker("Ok Button", false); + MainClass.ScreenReader.SayWithMenuChecker("Ok Button", false); } else if (__instance.cancelButton.containsPoint(x, y)) { - MainClass.GetScreenReader().SayWithMenuChecker("Cancel Button", false); + MainClass.ScreenReader.SayWithMenuChecker("Cancel Button", false); } } catch (Exception e) @@ -336,10 +336,10 @@ namespace stardew_access.Patches } if (toSpeak != " ") - MainClass.GetScreenReader().SayWithMenuChecker(toSpeak, true); + MainClass.ScreenReader.SayWithMenuChecker(toSpeak, true); else if (__instance.isProfessionChooser && currentLevelUpTitle != $"{___title}. Select a new profession.") { - MainClass.GetScreenReader().SayWithMenuChecker($"{___title}. Select a new profession.", true); + MainClass.ScreenReader.SayWithMenuChecker($"{___title}. Select a new profession.", true); currentLevelUpTitle = $"{___title}. Select a new profession."; } } @@ -366,14 +366,14 @@ namespace stardew_access.Patches Game1.activeClickableMenu.receiveLeftClick(Game1.getMouseX(true), Game1.getMouseY(true)); } toSpeak = $"{total}g in total. Press left mouse button to save."; - MainClass.GetScreenReader().SayWithChecker(toSpeak, true); + MainClass.ScreenReader.SayWithChecker(toSpeak, true); } for (int i = 0; i < __instance.categories.Count; i++) { if (__instance.categories[i].containsPoint(Game1.getMouseX(true), Game1.getMouseY(true))) { toSpeak = $"Money recieved from {__instance.getCategoryName(i)}: {___categoryTotals[i]}g."; - MainClass.GetScreenReader().SayWithChecker(toSpeak, true); + MainClass.ScreenReader.SayWithChecker(toSpeak, true); } } } @@ -491,8 +491,8 @@ namespace stardew_access.Patches internal static void ExitEventPatch() { - if (MainClass.GetScreenReader() != null) - MainClass.GetScreenReader().CloseScreenReader(); + if (MainClass.ScreenReader != null) + MainClass.ScreenReader.CloseScreenReader(); } } } diff --git a/stardew-access/Patches/MuseumMenuPatches.cs b/stardew-access/Patches/MuseumMenuPatches.cs index e472b77..6a06c65 100644 --- a/stardew-access/Patches/MuseumMenuPatches.cs +++ b/stardew-access/Patches/MuseumMenuPatches.cs @@ -71,7 +71,7 @@ namespace stardew_access.Patches if (museumQueryKey != toSpeak) { museumQueryKey = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } } else @@ -92,9 +92,9 @@ namespace stardew_access.Patches if (((LibraryMuseum)Game1.currentLocation).isTileSuitableForMuseumPiece(tileX, tileY) && ((LibraryMuseum)Game1.currentLocation).isItemSuitableForDonation(__instance.inventory.actualInventory[i])) { - int objectID = __instance.inventory.actualInventory[i].parentSheetIndex; + int objectID = __instance.inventory.actualInventory[i].ParentSheetIndex; int rewardsCount = ((LibraryMuseum)Game1.currentLocation).getRewardsForPlayer(Game1.player).Count; - ((LibraryMuseum)Game1.currentLocation).museumPieces.Add(new Vector2(tileX, tileY), ((StardewValley.Object)__instance.inventory.actualInventory[i]).parentSheetIndex); + ((LibraryMuseum)Game1.currentLocation).museumPieces.Add(new Vector2(tileX, tileY), ((StardewValley.Object)__instance.inventory.actualInventory[i]).ParentSheetIndex); Game1.playSound("stoneStep"); if (((LibraryMuseum)Game1.currentLocation).getRewardsForPlayer(Game1.player).Count > rewardsCount) { @@ -115,13 +115,13 @@ namespace stardew_access.Patches switch (pieces) { case 95: - globalChatInfoMessage("MuseumComplete", Game1.player.farmName); + globalChatInfoMessage("MuseumComplete", Game1.player.farmName.Value); break; case 40: - globalChatInfoMessage("Museum40", Game1.player.farmName); + globalChatInfoMessage("Museum40", Game1.player.farmName.Value); break; default: - globalChatInfoMessage("donation", Game1.player.name, "object:" + objectID); + globalChatInfoMessage("donation", Game1.player.Name, "object:" + objectID); break; } break; @@ -135,7 +135,7 @@ namespace stardew_access.Patches if (museumQueryKey != $"ok button") { museumQueryKey = $"ok button"; - MainClass.GetScreenReader().Say("ok button", true); + MainClass.ScreenReader.Say("ok button", true); } } } @@ -205,7 +205,7 @@ namespace stardew_access.Patches if (museumQueryKey != $"{toSpeak}:{i}") { museumQueryKey = $"{toSpeak}:{i}"; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } return i; } diff --git a/stardew-access/Patches/QuestPatches.cs b/stardew-access/Patches/QuestPatches.cs index 1bd8303..b8d4a3d 100644 --- a/stardew-access/Patches/QuestPatches.cs +++ b/stardew-access/Patches/QuestPatches.cs @@ -23,7 +23,7 @@ namespace stardew_access.Patches toSpeak = $"Left Quest:\n\t{toSpeak}\n\tPress left click to accept this quest."; - MainClass.GetScreenReader().SayWithMenuChecker(toSpeak, true); + MainClass.ScreenReader.SayWithMenuChecker(toSpeak, true); return; } @@ -33,7 +33,7 @@ namespace stardew_access.Patches toSpeak = $"Right Quest:\n\t{toSpeak}\n\tPress left click to accept this quest."; - MainClass.GetScreenReader().SayWithMenuChecker(toSpeak, true); + MainClass.ScreenReader.SayWithMenuChecker(toSpeak, true); return; } } @@ -99,7 +99,7 @@ namespace stardew_access.Patches if (Game1.dayOfMonth == i + 1) toSpeak += $", Current"; - MainClass.GetScreenReader().SayWithChecker(toSpeak, true); + MainClass.ScreenReader.SayWithChecker(toSpeak, true); } } #endregion @@ -114,7 +114,7 @@ namespace stardew_access.Patches if (currentDailyQuestText != toSpeak) { currentDailyQuestText = toSpeak; - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } } else @@ -134,7 +134,7 @@ namespace stardew_access.Patches __instance.acceptQuestButton.snapMouseCursorToCenter(); } - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } } #endregion @@ -171,7 +171,7 @@ namespace stardew_access.Patches toSpeak += ___pages[___currentPage][i].ShouldDisplayAsComplete() ? " completed!" : ""; if (__instance.questLogButtons[i].containsPoint(Game1.getOldMouseX(), Game1.getOldMouseY())) { - MainClass.GetScreenReader().SayWithChecker(toSpeak, true); + MainClass.ScreenReader.SayWithChecker(toSpeak, true); } } } @@ -232,7 +232,7 @@ namespace stardew_access.Patches if (snapMouseToRewardBox) __instance.rewardBox.snapMouseCursorToCenter(); - MainClass.GetScreenReader().SayWithChecker(toSpeak, true); + MainClass.ScreenReader.SayWithChecker(toSpeak, true); #endregion } } diff --git a/stardew-access/Patches/TitleMenuPatches.cs b/stardew-access/Patches/TitleMenuPatches.cs index 38d8f8f..f8f2ec2 100644 --- a/stardew-access/Patches/TitleMenuPatches.cs +++ b/stardew-access/Patches/TitleMenuPatches.cs @@ -44,7 +44,7 @@ namespace stardew_access.Patches #endregion if (toSpeak != " ") - MainClass.GetScreenReader().SayWithChecker(toSpeak, true); + MainClass.ScreenReader.SayWithChecker(toSpeak, true); } catch (Exception e) { @@ -94,7 +94,7 @@ namespace stardew_access.Patches if (TitleMenu.subMenu != null && __instance.backButton.containsPoint(Game1.getMouseX(true), Game1.getMouseY(true))) { string text = "Back Button"; - MainClass.GetScreenReader().SayWithChecker(text, true); + MainClass.ScreenReader.SayWithChecker(text, true); } // Fix for back button not working using keyboard @@ -108,7 +108,7 @@ namespace stardew_access.Patches } if (TitleMenu.subMenu == null && toSpeak != "") - MainClass.GetScreenReader().SayWithChecker(toSpeak, true); + MainClass.ScreenReader.SayWithChecker(toSpeak, true); } catch (Exception e) { @@ -128,7 +128,7 @@ namespace stardew_access.Patches #region Farms if (___menu.deleteButtons.Count > 0 && ___menu.deleteButtons[i].containsPoint(x, y)) { - MainClass.GetScreenReader().SayWithChecker($"Delete {__instance.Farmer.farmName} Farm", true); + MainClass.ScreenReader.SayWithChecker($"Delete {__instance.Farmer.farmName.Value} Farm", true); return; } @@ -137,20 +137,20 @@ namespace stardew_access.Patches // Used diff. functions to narrate to prevent it from speaking the message again on selecting another button. string message = "Really delete farm?"; - MainClass.GetScreenReader().SayWithChecker(message, true); + MainClass.ScreenReader.SayWithChecker(message, true); if (___menu.okDeleteButton.containsPoint(x, y)) { - MainClass.GetScreenReader().SayWithMenuChecker("Ok Button", false); + MainClass.ScreenReader.SayWithMenuChecker("Ok Button", false); } else if (___menu.cancelDeleteButton.containsPoint(x, y)) { - MainClass.GetScreenReader().SayWithMenuChecker("Cancel Button", false); + MainClass.ScreenReader.SayWithMenuChecker("Cancel Button", false); } return; } String farmerName = __instance.Farmer.displayName; - String farmName = __instance.Farmer.farmName; + String farmName = __instance.Farmer.farmName.Value; String money = __instance.Farmer.Money.ToString(); String hoursPlayed = Utility.getHoursMinutesStringFromMilliseconds(__instance.Farmer.millisecondsPlayed); string dateStringForSaveGame = ((!__instance.Farmer.dayOfMonthForSaveGame.HasValue || @@ -159,7 +159,7 @@ namespace stardew_access.Patches string toSpeak = $"{farmName} Farm Selected, \t\n Farmer:{farmerName}, \t\nMoney:{money}, \t\nHours Played:{hoursPlayed}, \t\nDate:{dateStringForSaveGame}"; - MainClass.GetScreenReader().SayWithChecker(toSpeak, true); + MainClass.ScreenReader.SayWithChecker(toSpeak, true); #endregion } } @@ -318,7 +318,7 @@ namespace stardew_access.Patches if (toSpeak != " ") { - MainClass.GetScreenReader().Say(toSpeak, true); + MainClass.ScreenReader.Say(toSpeak, true); } }