Refactored code
parent
8059e09089
commit
8b0350497b
|
@ -225,7 +225,7 @@ namespace stardew_access
|
|||
#region On Menu CLose Patch
|
||||
harmony.Patch(
|
||||
original: AccessTools.Method(typeof(IClickableMenu), nameof(IClickableMenu.exitThisMenu)),
|
||||
postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.IClickableMenuOnExitPatch))
|
||||
postfix: new HarmonyMethod(typeof(IClickableMenuPatch), nameof(IClickableMenuPatch.ExitThisMenuPatch))
|
||||
);
|
||||
harmony.Patch(
|
||||
original: AccessTools.Method(typeof(Game1), nameof(Game1.exitActiveMenu)),
|
||||
|
@ -290,6 +290,11 @@ namespace stardew_access
|
|||
original: AccessTools.Method(typeof(TextBox), nameof(TextBox.Draw)),
|
||||
prefix: new HarmonyMethod(typeof(TextBoxPatch), nameof(TextBoxPatch.DrawPatch))
|
||||
);
|
||||
|
||||
harmony.Patch(
|
||||
original: AccessTools.Method(typeof(IClickableMenu), nameof(IClickableMenu.draw)),
|
||||
prefix: new HarmonyMethod(typeof(IClickableMenuPatch), nameof(IClickableMenuPatch.DrawPatch))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,123 @@
|
|||
using StardewValley.Menus;
|
||||
|
||||
namespace stardew_access.Patches
|
||||
{
|
||||
// These patches are global, i.e. work on every menus
|
||||
internal class IClickableMenuPatch
|
||||
{
|
||||
internal static void ExitThisMenuPatch(IClickableMenu __instance)
|
||||
{
|
||||
try
|
||||
{
|
||||
Cleanup(__instance);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
|
||||
}
|
||||
}
|
||||
|
||||
internal static void Cleanup(IClickableMenu menu)
|
||||
{
|
||||
if (menu is LetterViewerMenu)
|
||||
{
|
||||
DialoguePatches.currentLetterText = " ";
|
||||
}
|
||||
else if (menu is LevelUpMenu)
|
||||
{
|
||||
MenuPatches.currentLevelUpTitle = " ";
|
||||
}
|
||||
else if (menu is Billboard)
|
||||
{
|
||||
QuestPatches.currentDailyQuestText = " ";
|
||||
}
|
||||
else if (menu is GameMenu)
|
||||
{
|
||||
GameMenuPatches.gameMenuQueryKey = "";
|
||||
GameMenuPatches.craftingPageQueryKey = "";
|
||||
GameMenuPatches.inventoryPageQueryKey = "";
|
||||
GameMenuPatches.exitPageQueryKey = "";
|
||||
GameMenuPatches.optionsPageQueryKey = "";
|
||||
GameMenuPatches.socialPageQuery = "";
|
||||
GameMenuPatches.currentSelectedCraftingRecipe = -1;
|
||||
GameMenuPatches.isSelectingRecipe = false;
|
||||
}
|
||||
else if (menu is JunimoNoteMenu)
|
||||
{
|
||||
BundleMenuPatches.currentIngredientListItem = -1;
|
||||
BundleMenuPatches.currentIngredientInputSlot = -1;
|
||||
BundleMenuPatches.currentInventorySlot = -1;
|
||||
BundleMenuPatches.junimoNoteMenuQuery = "";
|
||||
}
|
||||
else if (menu is ShopMenu)
|
||||
{
|
||||
GameMenuPatches.shopMenuQueryKey = "";
|
||||
}
|
||||
else if (menu is ItemGrabMenu)
|
||||
{
|
||||
GameMenuPatches.itemGrabMenuQueryKey = "";
|
||||
}
|
||||
else if (menu is GeodeMenu)
|
||||
{
|
||||
GameMenuPatches.geodeMenuQueryKey = "";
|
||||
}
|
||||
else if (menu is CarpenterMenu)
|
||||
{
|
||||
BuildingNAnimalMenuPatches.carpenterMenuQuery = "";
|
||||
BuildingNAnimalMenuPatches.isUpgrading = false;
|
||||
BuildingNAnimalMenuPatches.isDemolishing = false;
|
||||
BuildingNAnimalMenuPatches.isPainting = false;
|
||||
BuildingNAnimalMenuPatches.isMoving = false;
|
||||
BuildingNAnimalMenuPatches.isConstructing = false;
|
||||
BuildingNAnimalMenuPatches.carpenterMenu = null;
|
||||
}
|
||||
else if (menu is PurchaseAnimalsMenu)
|
||||
{
|
||||
BuildingNAnimalMenuPatches.purchaseAnimalMenuQuery = "";
|
||||
BuildingNAnimalMenuPatches.firstTimeInNamingMenu = true;
|
||||
BuildingNAnimalMenuPatches.purchaseAnimalsMenu = null;
|
||||
}
|
||||
else if (menu is DialogueBox)
|
||||
{
|
||||
DialoguePatches.isDialogueAppearingFirstTime = true;
|
||||
DialoguePatches.currentDialogue = " ";
|
||||
}
|
||||
else if (menu is JojaCDMenu)
|
||||
{
|
||||
BundleMenuPatches.jojaCDMenuQuery = "";
|
||||
}
|
||||
else if (menu is QuestLog)
|
||||
{
|
||||
QuestPatches.questLogQuery = " ";
|
||||
}
|
||||
else if (menu is TailoringMenu)
|
||||
{
|
||||
MenuPatches.tailoringMenuQuery = " ";
|
||||
}
|
||||
else if (menu is ForgeMenu)
|
||||
{
|
||||
MenuPatches.forgeMenuQuery = " ";
|
||||
}
|
||||
else if (menu is ItemListMenu)
|
||||
{
|
||||
MenuPatches.itemListMenuQuery = " ";
|
||||
}
|
||||
else if (menu is FieldOfficeMenu)
|
||||
{
|
||||
DonationMenuPatches.fieldOfficeMenuQuery = " ";
|
||||
}
|
||||
else if (menu is MuseumMenu)
|
||||
{
|
||||
DonationMenuPatches.museumQueryKey = " ";
|
||||
}
|
||||
else if (menu is PondQueryMenu)
|
||||
{
|
||||
MenuPatches.pondQueryMenuQuery = " ";
|
||||
}
|
||||
|
||||
InventoryUtils.hoveredItemQueryKey = "";
|
||||
InventoryUtils.prevSlotIndex = -999;
|
||||
TextBoxPatch.activeTextBoxes = "";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -604,12 +604,11 @@ namespace stardew_access.Patches
|
|||
}
|
||||
}
|
||||
|
||||
#region Cleanup on exitting a menu
|
||||
internal static void Game1ExitActiveMenuPatch()
|
||||
{
|
||||
try
|
||||
{
|
||||
Cleanup(Game1.activeClickableMenu);
|
||||
IClickableMenuPatch.Cleanup(Game1.activeClickableMenu);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -617,122 +616,6 @@ namespace stardew_access.Patches
|
|||
}
|
||||
}
|
||||
|
||||
internal static void IClickableMenuOnExitPatch(IClickableMenu __instance)
|
||||
{
|
||||
try
|
||||
{
|
||||
Cleanup(__instance);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
|
||||
}
|
||||
}
|
||||
|
||||
private static void Cleanup(IClickableMenu menu)
|
||||
{
|
||||
if (menu is LetterViewerMenu)
|
||||
{
|
||||
DialoguePatches.currentLetterText = " ";
|
||||
}
|
||||
else if (menu is LevelUpMenu)
|
||||
{
|
||||
currentLevelUpTitle = " ";
|
||||
}
|
||||
else if (menu is Billboard)
|
||||
{
|
||||
QuestPatches.currentDailyQuestText = " ";
|
||||
}
|
||||
else if (menu is GameMenu)
|
||||
{
|
||||
GameMenuPatches.gameMenuQueryKey = "";
|
||||
GameMenuPatches.craftingPageQueryKey = "";
|
||||
GameMenuPatches.inventoryPageQueryKey = "";
|
||||
GameMenuPatches.exitPageQueryKey = "";
|
||||
GameMenuPatches.optionsPageQueryKey = "";
|
||||
GameMenuPatches.socialPageQuery = "";
|
||||
GameMenuPatches.currentSelectedCraftingRecipe = -1;
|
||||
GameMenuPatches.isSelectingRecipe = false;
|
||||
}
|
||||
else if (menu is JunimoNoteMenu)
|
||||
{
|
||||
BundleMenuPatches.currentIngredientListItem = -1;
|
||||
BundleMenuPatches.currentIngredientInputSlot = -1;
|
||||
BundleMenuPatches.currentInventorySlot = -1;
|
||||
BundleMenuPatches.junimoNoteMenuQuery = "";
|
||||
}
|
||||
else if (menu is ShopMenu)
|
||||
{
|
||||
GameMenuPatches.shopMenuQueryKey = "";
|
||||
}
|
||||
else if (menu is ItemGrabMenu)
|
||||
{
|
||||
GameMenuPatches.itemGrabMenuQueryKey = "";
|
||||
}
|
||||
else if (menu is GeodeMenu)
|
||||
{
|
||||
GameMenuPatches.geodeMenuQueryKey = "";
|
||||
}
|
||||
else if (menu is CarpenterMenu)
|
||||
{
|
||||
BuildingNAnimalMenuPatches.carpenterMenuQuery = "";
|
||||
BuildingNAnimalMenuPatches.isUpgrading = false;
|
||||
BuildingNAnimalMenuPatches.isDemolishing = false;
|
||||
BuildingNAnimalMenuPatches.isPainting = false;
|
||||
BuildingNAnimalMenuPatches.isMoving = false;
|
||||
BuildingNAnimalMenuPatches.isConstructing = false;
|
||||
BuildingNAnimalMenuPatches.carpenterMenu = null;
|
||||
}
|
||||
else if (menu is PurchaseAnimalsMenu)
|
||||
{
|
||||
BuildingNAnimalMenuPatches.purchaseAnimalMenuQuery = "";
|
||||
BuildingNAnimalMenuPatches.firstTimeInNamingMenu = true;
|
||||
BuildingNAnimalMenuPatches.purchaseAnimalsMenu = null;
|
||||
}
|
||||
else if (menu is DialogueBox)
|
||||
{
|
||||
DialoguePatches.isDialogueAppearingFirstTime = true;
|
||||
DialoguePatches.currentDialogue = " ";
|
||||
}
|
||||
else if (menu is JojaCDMenu)
|
||||
{
|
||||
BundleMenuPatches.jojaCDMenuQuery = "";
|
||||
}
|
||||
else if (menu is QuestLog)
|
||||
{
|
||||
QuestPatches.questLogQuery = " ";
|
||||
}
|
||||
else if (menu is TailoringMenu)
|
||||
{
|
||||
tailoringMenuQuery = " ";
|
||||
}
|
||||
else if (menu is ForgeMenu)
|
||||
{
|
||||
forgeMenuQuery = " ";
|
||||
}
|
||||
else if (menu is ItemListMenu)
|
||||
{
|
||||
itemListMenuQuery = " ";
|
||||
}
|
||||
else if (menu is FieldOfficeMenu)
|
||||
{
|
||||
DonationMenuPatches.fieldOfficeMenuQuery = " ";
|
||||
}
|
||||
else if (menu is MuseumMenu)
|
||||
{
|
||||
DonationMenuPatches.museumQueryKey = " ";
|
||||
}
|
||||
else if (menu is PondQueryMenu)
|
||||
{
|
||||
pondQueryMenuQuery = " ";
|
||||
}
|
||||
|
||||
InventoryUtils.hoveredItemQueryKey = "";
|
||||
InventoryUtils.prevSlotIndex = -999;
|
||||
TextBoxPatch.activeTextBoxes = "";
|
||||
}
|
||||
#endregion
|
||||
|
||||
internal static void ExitEventPatch()
|
||||
{
|
||||
if (MainClass.ScreenReader != null)
|
||||
|
|
Loading…
Reference in New Issue