From 6d18849f17b8e8183ce7e3a45dd49b747a5bf3e6 Mon Sep 17 00:00:00 2001 From: Mohammad Shoaib Khan Date: Thu, 18 Aug 2022 12:18:40 +0530 Subject: [PATCH] Added watered/unwatered toggle for crops --- stardew-access/CustomCommands.cs | 8 ++++++++ stardew-access/Features/TileInfo.cs | 15 ++++++++++----- stardew-access/ModConfig.cs | 1 + 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/stardew-access/CustomCommands.cs b/stardew-access/CustomCommands.cs index 9f28d13..d6d51b6 100644 --- a/stardew-access/CustomCommands.cs +++ b/stardew-access/CustomCommands.cs @@ -39,6 +39,14 @@ namespace stardew_access MainClass.DebugLog("Flooring is " + (MainClass.Config.ReadFlooring ? "on" : "off")); }); + helper.ConsoleCommands.Add("watered", "Toggle speaking watered or unwatered for crops.", (string commmand, string[] args) => + { + MainClass.Config.WateredToggle = !MainClass.Config.WateredToggle; + helper.WriteConfig(MainClass.Config); + + MainClass.DebugLog("Watered toggle is " + (MainClass.Config.WateredToggle ? "on" : "off")); + }); + #region Radar Feature helper.ConsoleCommands.Add("radar", "Toggle radar feature.", (string commmand, string[] args) => { diff --git a/stardew-access/Features/TileInfo.cs b/stardew-access/Features/TileInfo.cs index 00b0b57..ebcdd04 100644 --- a/stardew-access/Features/TileInfo.cs +++ b/stardew-access/Features/TileInfo.cs @@ -543,8 +543,9 @@ namespace stardew_access.Features /// Returns the detail about the HoeDirt i.e. soil, plant, etc. /// /// The HoeDirt to be checked + /// Ignores returning `soil` if empty /// The details about the given HoeDirt - public static string getHoeDirtDetail(HoeDirt dirt) + public static string getHoeDirtDetail(HoeDirt dirt, bool ignoreIfEmpty = false) { string detail; @@ -557,8 +558,10 @@ namespace stardew_access.Features bool isHarvestable = dirt.readyForHarvest(); bool isFertilized = dirt.fertilizer.Value != HoeDirt.noFertilizer; - if (isWatered) + if (isWatered && MainClass.Config.WateredToggle) detail = "Watered " + detail; + else if (!isWatered && !MainClass.Config.WateredToggle) + detail = "Unwatered " + detail; if (isFertilized) detail = "Fertilized " + detail; @@ -580,12 +583,14 @@ namespace stardew_access.Features } else { - detail = "Soil"; + detail = (ignoreIfEmpty) ? "" : "Soil"; bool isWatered = dirt.state.Value == HoeDirt.watered; bool isFertilized = dirt.fertilizer.Value != HoeDirt.noFertilizer; - if (isWatered) + if (isWatered && MainClass.Config.WateredToggle) detail = "Watered " + detail; + else if (!isWatered && !MainClass.Config.WateredToggle) + detail = "Unwatered " + detail; if (isFertilized) detail = "Fertilized " + detail; @@ -709,7 +714,7 @@ namespace stardew_access.Features } else if (obj is IndoorPot indoorPot) { - toReturn.name = $"{obj.DisplayName}, {getHoeDirtDetail(indoorPot.hoeDirt)}"; + toReturn.name = $"{obj.DisplayName}, {getHoeDirtDetail(indoorPot.hoeDirt, true)}"; } else if (obj is Sign sign) { diff --git a/stardew-access/ModConfig.cs b/stardew-access/ModConfig.cs index c77e9df..48e1490 100644 --- a/stardew-access/ModConfig.cs +++ b/stardew-access/ModConfig.cs @@ -23,6 +23,7 @@ namespace stardew_access public KeybindList ReadTileKey { get; set; } = KeybindList.Parse("J"); // Manually trigger read tile for the tile player is *looking at*. public KeybindList ReadStandingTileKey { get; set; } = KeybindList.Parse("LeftAlt + J"); // Manually trigger read tile for the tile player is *standing on*. public Boolean ReadFlooring { get; set; } = false; // Toggle reading floorings. + public Boolean WateredToggle { get; set; } = true; // Toggle speaking watered or unwatered for crops. #endregion #region Tile viewer