Code cleanup
parent
5d8912ae7c
commit
d24c224d1d
|
@ -67,9 +67,8 @@ namespace stardew_access.Features
|
|||
Game1.setMousePosition(x, y);
|
||||
}
|
||||
|
||||
public static async void narrateHudMessages()
|
||||
public static void narrateHudMessages()
|
||||
{
|
||||
MainClass.isNarratingHudMessage = true;
|
||||
try
|
||||
{
|
||||
if (Game1.hudMessages.Count > 0)
|
||||
|
@ -99,8 +98,6 @@ namespace stardew_access.Features
|
|||
MainClass.ErrorLog($"Unable to narrate hud messages:\n{e.Message}\n{e.StackTrace}");
|
||||
}
|
||||
|
||||
await Task.Delay(300);
|
||||
MainClass.isNarratingHudMessage = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,12 +96,11 @@ namespace stardew_access.Features
|
|||
*/
|
||||
}
|
||||
|
||||
public async void Run()
|
||||
public void Run()
|
||||
{
|
||||
if (MainClass.radarDebug)
|
||||
MainClass.DebugLog($"\n\nRead Tile started");
|
||||
|
||||
isRunning = true;
|
||||
Vector2 currPosition = Game1.player.getTileLocation();
|
||||
|
||||
closed.Clear();
|
||||
|
@ -112,9 +111,6 @@ namespace stardew_access.Features
|
|||
|
||||
if (MainClass.radarDebug)
|
||||
MainClass.DebugLog($"\nRead Tile stopped\n\n");
|
||||
|
||||
await Task.Delay(delay);
|
||||
isRunning = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -22,10 +22,8 @@ namespace stardew_access.Features
|
|||
isReadingTile = false;
|
||||
}
|
||||
|
||||
public static async void run(bool manuallyTriggered = false, bool playersPosition = false)
|
||||
public static void run(bool manuallyTriggered = false, bool playersPosition = false)
|
||||
{
|
||||
isReadingTile = true;
|
||||
|
||||
try
|
||||
{
|
||||
Vector2 tile;
|
||||
|
@ -82,9 +80,6 @@ namespace stardew_access.Features
|
|||
{
|
||||
MainClass.ErrorLog($"Error in Read Tile:\n{e.Message}\n{e.StackTrace}");
|
||||
}
|
||||
|
||||
await Task.Delay(100);
|
||||
isReadingTile = false;
|
||||
}
|
||||
|
||||
///<summary>Returns the name of the object at tile alongwith it's category's name</summary>
|
||||
|
|
|
@ -170,7 +170,7 @@ namespace stardew_access
|
|||
#region Chat Menu Patches
|
||||
harmony.Patch(
|
||||
original: AccessTools.Method(typeof(ChatBox), nameof(ChatBox.update), new Type[] { typeof(GameTime) }),
|
||||
postfix: new HarmonyMethod(typeof(ChatManuPatches), nameof(ChatManuPatches.ChatBoxPatch))
|
||||
postfix: new HarmonyMethod(typeof(ChatMenuPatches), nameof(ChatMenuPatches.ChatBoxPatch))
|
||||
);
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -120,14 +120,24 @@ namespace stardew_access
|
|||
Other.SnapMouseToPlayer();
|
||||
|
||||
if (!ReadTile.isReadingTile && Config.ReadTile)
|
||||
{
|
||||
ReadTile.isReadingTile = true;
|
||||
ReadTile.run();
|
||||
Task.Delay(100).ContinueWith(_ => { ReadTile.isReadingTile = false; });
|
||||
}
|
||||
|
||||
if (!RadarFeature.isRunning && Config.Radar)
|
||||
{
|
||||
RadarFeature.isRunning = true;
|
||||
RadarFeature.Run();
|
||||
Task.Delay(RadarFeature.delay).ContinueWith(_ => { RadarFeature.isRunning = false; });
|
||||
}
|
||||
|
||||
if (!isNarratingHudMessage)
|
||||
{
|
||||
isNarratingHudMessage = true;
|
||||
Other.narrateHudMessages();
|
||||
Task.Delay(300).ContinueWith(_ => { isNarratingHudMessage = false; });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
using StardewModdingAPI;
|
||||
using StardewValley;
|
||||
using StardewValley;
|
||||
using StardewValley.Menus;
|
||||
|
||||
namespace stardew_access.Patches
|
||||
{
|
||||
internal class ChatManuPatches
|
||||
internal class ChatMenuPatches
|
||||
{
|
||||
private static int currentChatMessageIndex = 0;
|
||||
private static bool isChatRunning = false;
|
||||
|
@ -25,11 +24,15 @@ namespace stardew_access.Patches
|
|||
#region To narrate previous and next chat messages
|
||||
if (isNextArrowPressed && !isChatRunning)
|
||||
{
|
||||
isChatRunning = true;
|
||||
CycleThroughChatMessages(true, ___messages);
|
||||
Task.Delay(200).ContinueWith(_ => { isChatRunning = false; });
|
||||
}
|
||||
else if (isPrevArrowPressed && !isChatRunning)
|
||||
{
|
||||
isChatRunning = true;
|
||||
CycleThroughChatMessages(false, ___messages);
|
||||
Task.Delay(200).ContinueWith(_ => { isChatRunning = false; });
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
@ -52,9 +55,8 @@ namespace stardew_access.Patches
|
|||
}
|
||||
}
|
||||
|
||||
private static async void CycleThroughChatMessages(bool increase, List<ChatMessage> ___messages)
|
||||
private static void CycleThroughChatMessages(bool increase, List<ChatMessage> ___messages)
|
||||
{
|
||||
isChatRunning = true;
|
||||
string toSpeak = " ";
|
||||
if (increase)
|
||||
{
|
||||
|
@ -78,8 +80,6 @@ namespace stardew_access.Patches
|
|||
});
|
||||
|
||||
MainClass.GetScreenReader().Say(toSpeak, true);
|
||||
await Task.Delay(200);
|
||||
isChatRunning = false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
using StardewModdingAPI;
|
||||
using StardewValley;
|
||||
using StardewValley;
|
||||
using StardewValley.Locations;
|
||||
using StardewValley.Menus;
|
||||
using StardewValley.Objects;
|
||||
|
@ -104,15 +103,21 @@ namespace stardew_access.Patches
|
|||
|
||||
if (isIPressed && !isUsingCustomButtons)
|
||||
{
|
||||
isUsingCustomButtons = true;
|
||||
JunimoNoteCustomButtons(__instance, ___currentPageBundle, 0, isLeftShiftPressed);
|
||||
Task.Delay(200).ContinueWith(_ => { isUsingCustomButtons = false; });
|
||||
}
|
||||
else if (isVPressed && !isUsingCustomButtons)
|
||||
{
|
||||
isUsingCustomButtons = true;
|
||||
JunimoNoteCustomButtons(__instance, ___currentPageBundle, 1, isLeftShiftPressed);
|
||||
Task.Delay(200).ContinueWith(_ => { isUsingCustomButtons = false; });
|
||||
}
|
||||
else if (isCPressed && !isUsingCustomButtons)
|
||||
{
|
||||
isUsingCustomButtons = true;
|
||||
JunimoNoteCustomButtons(__instance, ___currentPageBundle, 2, isLeftShiftPressed);
|
||||
Task.Delay(200).ContinueWith(_ => { isUsingCustomButtons = false; });
|
||||
}
|
||||
else if (isBackPressed && __instance.backButton != null && !__instance.backButton.containsPoint(x, y))
|
||||
{
|
||||
|
@ -133,9 +138,8 @@ namespace stardew_access.Patches
|
|||
}
|
||||
}
|
||||
|
||||
private static async void JunimoNoteCustomButtons(JunimoNoteMenu __instance, Bundle ___currentPageBundle, int signal, bool isLeftShiftPressed = false)
|
||||
private static void JunimoNoteCustomButtons(JunimoNoteMenu __instance, Bundle ___currentPageBundle, int signal, bool isLeftShiftPressed = false)
|
||||
{
|
||||
isUsingCustomButtons = true;
|
||||
try
|
||||
{
|
||||
|
||||
|
@ -291,9 +295,6 @@ namespace stardew_access.Patches
|
|||
{
|
||||
MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
|
||||
}
|
||||
|
||||
await Task.Delay(200);
|
||||
isUsingCustomButtons = false;
|
||||
}
|
||||
|
||||
internal static void SocialPagePatch(SocialPage __instance, List<ClickableTextureComponent> ___sprites, int ___slotPosition, List<string> ___kidsNames)
|
||||
|
@ -955,7 +956,9 @@ namespace stardew_access.Patches
|
|||
}
|
||||
else if (isCPressed && !isSelectingRecipe)
|
||||
{
|
||||
_ = CycleThroughRecipies(__instance.pagesOfCraftingRecipes, ___currentCraftingPage, __instance);
|
||||
isSelectingRecipe = true;
|
||||
CycleThroughRecipies(__instance.pagesOfCraftingRecipes, ___currentCraftingPage, __instance);
|
||||
Task.Delay(200).ContinueWith(_ => { isSelectingRecipe = false; });
|
||||
}
|
||||
|
||||
#region Narrate buttons in the menu
|
||||
|
@ -1103,19 +1106,14 @@ namespace stardew_access.Patches
|
|||
}
|
||||
}
|
||||
|
||||
private static async Task CycleThroughRecipies(List<Dictionary<ClickableTextureComponent, CraftingRecipe>> pagesOfCraftingRecipes, int ___currentCraftingPage, CraftingPage __instance)
|
||||
private static void CycleThroughRecipies(List<Dictionary<ClickableTextureComponent, CraftingRecipe>> pagesOfCraftingRecipes, int ___currentCraftingPage, CraftingPage __instance)
|
||||
{
|
||||
isSelectingRecipe = true;
|
||||
|
||||
currentSelectedCraftingRecipe++;
|
||||
if (currentSelectedCraftingRecipe < 0 || currentSelectedCraftingRecipe >= pagesOfCraftingRecipes[0].Count)
|
||||
currentSelectedCraftingRecipe = 0;
|
||||
|
||||
__instance.setCurrentlySnappedComponentTo(pagesOfCraftingRecipes[___currentCraftingPage].ElementAt(currentSelectedCraftingRecipe).Key.myID);
|
||||
pagesOfCraftingRecipes[___currentCraftingPage].ElementAt(currentSelectedCraftingRecipe).Key.snapMouseCursorToCenter();
|
||||
|
||||
await Task.Delay(200);
|
||||
isSelectingRecipe = false;
|
||||
}
|
||||
|
||||
// This method is used to get the inventory items to check if the player has enough ingredients for a recipe
|
||||
|
|
|
@ -481,41 +481,12 @@ namespace stardew_access.Patches
|
|||
}
|
||||
}
|
||||
|
||||
#region Cleanup on exitting a menu
|
||||
internal static void Game1ExitActiveMenuPatch()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Game1.activeClickableMenu is GameMenu)
|
||||
{
|
||||
GameMenuPatches.gameMenuQueryKey = "";
|
||||
GameMenuPatches.craftingPageQueryKey = "";
|
||||
GameMenuPatches.inventoryPageQueryKey = "";
|
||||
GameMenuPatches.exitPageQueryKey = "";
|
||||
GameMenuPatches.optionsPageQueryKey = "";
|
||||
GameMenuPatches.socialPageQuery = "";
|
||||
GameMenuPatches.currentSelectedCraftingRecipe = -1;
|
||||
GameMenuPatches.isSelectingRecipe = false;
|
||||
}
|
||||
|
||||
if (Game1.activeClickableMenu is JunimoNoteMenu)
|
||||
{
|
||||
GameMenuPatches.currentIngredientListItem = -1;
|
||||
GameMenuPatches.currentIngredientInputSlot = -1;
|
||||
GameMenuPatches.currentInventorySlot = -1;
|
||||
GameMenuPatches.junimoNoteMenuQuery = "";
|
||||
}
|
||||
|
||||
if (Game1.activeClickableMenu is ShopMenu)
|
||||
{
|
||||
GameMenuPatches.shopMenuQueryKey = "";
|
||||
}
|
||||
|
||||
if (Game1.activeClickableMenu is ItemGrabMenu)
|
||||
{
|
||||
GameMenuPatches.itemGrabMenuQueryKey = "";
|
||||
}
|
||||
|
||||
GameMenuPatches.hoveredItemQueryKey = "";
|
||||
Cleanup(Game1.activeClickableMenu);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -527,46 +498,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
try
|
||||
{
|
||||
if (__instance is GeodeMenu)
|
||||
{
|
||||
GameMenuPatches.geodeMenuQueryKey = "";
|
||||
}
|
||||
|
||||
if (__instance is ItemGrabMenu)
|
||||
{
|
||||
GameMenuPatches.itemGrabMenuQueryKey = "";
|
||||
}
|
||||
|
||||
if (__instance is ShopMenu)
|
||||
{
|
||||
GameMenuPatches.shopMenuQueryKey = "";
|
||||
}
|
||||
|
||||
if (__instance is CarpenterMenu)
|
||||
{
|
||||
BuildingNAnimalMenuPatches.carpenterMenuQuery = "";
|
||||
BuildingNAnimalMenuPatches.isUpgrading = false;
|
||||
BuildingNAnimalMenuPatches.isDemolishing = false;
|
||||
BuildingNAnimalMenuPatches.isPainting = false;
|
||||
BuildingNAnimalMenuPatches.isMoving = false;
|
||||
BuildingNAnimalMenuPatches.isConstructing = false;
|
||||
BuildingNAnimalMenuPatches.carpenterMenu = null;
|
||||
}
|
||||
|
||||
if (__instance is PurchaseAnimalsMenu)
|
||||
{
|
||||
BuildingNAnimalMenuPatches.purchaseAnimalMenuQuery = "";
|
||||
BuildingNAnimalMenuPatches.firstTimeInNamingMenu = true;
|
||||
BuildingNAnimalMenuPatches.purchaseAnimalsMenu = null;
|
||||
}
|
||||
|
||||
if (__instance is DialogueBox)
|
||||
{
|
||||
DialoguePatches.isDialogueAppearingFirstTime = true;
|
||||
DialoguePatches.currentDialogue = " ";
|
||||
}
|
||||
|
||||
GameMenuPatches.hoveredItemQueryKey = "";
|
||||
Cleanup(__instance);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -574,6 +506,71 @@ namespace stardew_access.Patches
|
|||
}
|
||||
}
|
||||
|
||||
private static void Cleanup(IClickableMenu menu)
|
||||
{
|
||||
if (menu is GameMenu)
|
||||
{
|
||||
GameMenuPatches.gameMenuQueryKey = "";
|
||||
GameMenuPatches.craftingPageQueryKey = "";
|
||||
GameMenuPatches.inventoryPageQueryKey = "";
|
||||
GameMenuPatches.exitPageQueryKey = "";
|
||||
GameMenuPatches.optionsPageQueryKey = "";
|
||||
GameMenuPatches.socialPageQuery = "";
|
||||
GameMenuPatches.currentSelectedCraftingRecipe = -1;
|
||||
GameMenuPatches.isSelectingRecipe = false;
|
||||
}
|
||||
|
||||
if (menu is JunimoNoteMenu)
|
||||
{
|
||||
GameMenuPatches.currentIngredientListItem = -1;
|
||||
GameMenuPatches.currentIngredientInputSlot = -1;
|
||||
GameMenuPatches.currentInventorySlot = -1;
|
||||
GameMenuPatches.junimoNoteMenuQuery = "";
|
||||
}
|
||||
|
||||
if (menu is ShopMenu)
|
||||
{
|
||||
GameMenuPatches.shopMenuQueryKey = "";
|
||||
}
|
||||
|
||||
if (menu is ItemGrabMenu)
|
||||
{
|
||||
GameMenuPatches.itemGrabMenuQueryKey = "";
|
||||
}
|
||||
|
||||
if (menu is GeodeMenu)
|
||||
{
|
||||
GameMenuPatches.geodeMenuQueryKey = "";
|
||||
}
|
||||
|
||||
if (menu is CarpenterMenu)
|
||||
{
|
||||
BuildingNAnimalMenuPatches.carpenterMenuQuery = "";
|
||||
BuildingNAnimalMenuPatches.isUpgrading = false;
|
||||
BuildingNAnimalMenuPatches.isDemolishing = false;
|
||||
BuildingNAnimalMenuPatches.isPainting = false;
|
||||
BuildingNAnimalMenuPatches.isMoving = false;
|
||||
BuildingNAnimalMenuPatches.isConstructing = false;
|
||||
BuildingNAnimalMenuPatches.carpenterMenu = null;
|
||||
}
|
||||
|
||||
if (menu is PurchaseAnimalsMenu)
|
||||
{
|
||||
BuildingNAnimalMenuPatches.purchaseAnimalMenuQuery = "";
|
||||
BuildingNAnimalMenuPatches.firstTimeInNamingMenu = true;
|
||||
BuildingNAnimalMenuPatches.purchaseAnimalsMenu = null;
|
||||
}
|
||||
|
||||
if (menu is DialogueBox)
|
||||
{
|
||||
DialoguePatches.isDialogueAppearingFirstTime = true;
|
||||
DialoguePatches.currentDialogue = " ";
|
||||
}
|
||||
|
||||
GameMenuPatches.hoveredItemQueryKey = "";
|
||||
}
|
||||
#endregion
|
||||
|
||||
internal static void ExitEventPatch()
|
||||
{
|
||||
if (MainClass.GetScreenReader() != null)
|
||||
|
|
|
@ -178,11 +178,15 @@ namespace stardew_access.Patches
|
|||
|
||||
if (isNextArrowPressed && !isRunning)
|
||||
{
|
||||
_ = CycleThroughItems(true, __instance, ___skipIntro);
|
||||
isRunning = true;
|
||||
CycleThroughItems(true, __instance, ___skipIntro);
|
||||
Task.Delay(200).ContinueWith(_ => { isRunning = false; });
|
||||
}
|
||||
else if (isPrevArrowPressed && !isRunning)
|
||||
{
|
||||
_ = CycleThroughItems(false, __instance, ___skipIntro);
|
||||
isRunning = true;
|
||||
CycleThroughItems(false, __instance, ___skipIntro);
|
||||
Task.Delay(200).ContinueWith(_ => { isRunning = false; });
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -191,9 +195,8 @@ namespace stardew_access.Patches
|
|||
}
|
||||
}
|
||||
|
||||
private static async Task CycleThroughItems(bool increase, CharacterCustomization __instance, bool ___skipIntro)
|
||||
private static void CycleThroughItems(bool increase, CharacterCustomization __instance, bool ___skipIntro)
|
||||
{
|
||||
isRunning = true;
|
||||
string toSpeak = " ";
|
||||
|
||||
if (increase)
|
||||
|
@ -650,9 +653,6 @@ namespace stardew_access.Patches
|
|||
{
|
||||
MainClass.GetScreenReader().Say(toSpeak, true);
|
||||
}
|
||||
|
||||
await Task.Delay(200);
|
||||
isRunning = false;
|
||||
}
|
||||
|
||||
private static string getFarmHoverText(ClickableTextureComponent farm)
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
Linux speech dispatcher library used:
|
||||
https://github.com/shoaib11120/libspeechdwrapper
|
||||
*/
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace stardew_access.ScreenReader
|
||||
|
|
Loading…
Reference in New Issue