Made coop menu accessible

master
shoaib11120 2021-12-28 20:43:07 +05:30
parent d16f53723a
commit 51dd77d9fc
2 changed files with 135 additions and 62 deletions

View File

@ -117,6 +117,12 @@ namespace stardew_access
postfix: new HarmonyMethod(typeof(MenuPatch), nameof(MenuPatch.OptionsPagePatch)) postfix: new HarmonyMethod(typeof(MenuPatch), nameof(MenuPatch.OptionsPagePatch))
); );
harmony.Patch(
original: AccessTools.Method(typeof(CoopMenu), nameof(CoopMenu.update), new Type[] { typeof(GameTime) }),
postfix: new HarmonyMethod(typeof(MenuPatch), nameof(MenuPatch.CoopMenuPatch))
);
#endregion #endregion
#region Custom Commands #region Custom Commands

View File

@ -4,6 +4,7 @@ using StardewModdingAPI;
using StardewValley; using StardewValley;
using StardewValley.Menus; using StardewValley.Menus;
using StardewValley.Quests; using StardewValley.Quests;
using static StardewValley.Menus.LoadGameMenu;
namespace stardew_access.Patches namespace stardew_access.Patches
{ {
@ -13,8 +14,56 @@ namespace stardew_access.Patches
private static bool isRunning = false; private static bool isRunning = false;
private static string currentLetterText = " "; private static string currentLetterText = " ";
private static string currentDailyQuestText = " "; private static string currentDailyQuestText = " ";
public static bool isJoinTabSelected = false;
public static bool isHostTabSelected = false;
internal static void CoopMenuPatch(CoopMenu __instance, CoopMenu.Tab ___currentTab)
{
try
{
int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y;
string toSpeak = " ";
#region Join/Host Button (Important! This should be checked before checking other buttons)
if (__instance.slotButtons[0].containsPoint(x, y))
{
MainClass.monitor.Log($"here", LogLevel.Debug);
if (___currentTab == CoopMenu.Tab.JOIN_TAB)
toSpeak = "Join lan game";
if (___currentTab == CoopMenu.Tab.HOST_TAB)
toSpeak = "Host new farm";
}
#endregion
#region Other Buttons
if (__instance.joinTab.containsPoint(x, y))
{
toSpeak = "Join Tab Button";
}
else if (__instance.hostTab.containsPoint(x, y))
{
toSpeak = "Host Tab Button";
}
else if (__instance.refreshButton.containsPoint(x, y))
{
toSpeak = "Refresh Button";
}
#endregion
if (toSpeak != " ")
ScreenReader.sayWithChecker(toSpeak, true);
}
catch (Exception e)
{
throw;
}
}
internal static void OptionsPagePatch(OptionsPage __instance) internal static void OptionsPagePatch(OptionsPage __instance)
{
try
{ {
int currentItemIndex = Math.Max(0, Math.Min(__instance.options.Count - 7, __instance.currentItemIndex)); int currentItemIndex = Math.Max(0, Math.Min(__instance.options.Count - 7, __instance.currentItemIndex));
int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y;
@ -43,8 +92,8 @@ namespace stardew_access.Patches
} }
else else
{ {
if(toSpeak.Contains(':')) if (toSpeak.Contains(":"))
toSpeak = toSpeak.Remove(':'); toSpeak = toSpeak.Replace(":", "");
toSpeak = $"{toSpeak} Options:"; toSpeak = $"{toSpeak} Options:";
} }
@ -54,8 +103,16 @@ namespace stardew_access.Patches
} }
} }
} }
catch (Exception e)
{
throw;
}
}
internal static void ShippingMenuPatch(ShippingMenu __instance, List<int> ___categoryTotals) internal static void ShippingMenuPatch(ShippingMenu __instance, List<int> ___categoryTotals)
{
try
{ {
if (__instance.currentPage == -1) if (__instance.currentPage == -1)
{ {
@ -76,6 +133,12 @@ namespace stardew_access.Patches
} }
} }
} }
catch (Exception e)
{
throw;
}
}
internal static void BillboardPatch(Billboard __instance, bool ___dailyQuestBoard) internal static void BillboardPatch(Billboard __instance, bool ___dailyQuestBoard)
{ {
@ -296,10 +359,13 @@ namespace stardew_access.Patches
} }
} }
internal static void TitleMenuPatch(TitleMenu __instance) internal static void TitleMenuPatch(TitleMenu __instance, bool ___isTransitioningButtons)
{ {
try try
{ {
if (___isTransitioningButtons)
return;
string toSpeak = ""; string toSpeak = "";
__instance.buttons.ForEach(component => __instance.buttons.ForEach(component =>
@ -347,18 +413,17 @@ namespace stardew_access.Patches
} }
} }
internal static void LoadGameMenuPatch(LoadGameMenu.SaveFileSlot __instance, LoadGameMenu ___menu, int i) internal static void LoadGameMenuPatch(SaveFileSlot __instance, LoadGameMenu ___menu, int i)
{ {
try try
{ {
if (___menu.slotButtons[i].containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y)) if (___menu.slotButtons[i].containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y))
{ {
if (__instance.Farmer == null) if (__instance.Farmer != null)
return; {
#region Farms
if (___menu.deleteButtons[i].containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y)) if (Game1.activeClickableMenu is LoadGameMenu && ___menu.deleteButtons[i].containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y))
{ {
// Fix for delete button hover text not narrating
ScreenReader.sayWithChecker($"Delete {__instance.Farmer.farmName} Farm", true); ScreenReader.sayWithChecker($"Delete {__instance.Farmer.farmName} Farm", true);
return; return;
} }
@ -374,6 +439,8 @@ 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}";
ScreenReader.sayWithChecker(toSpeak, true); ScreenReader.sayWithChecker(toSpeak, true);
#endregion
}
} }
} }
catch (Exception e) catch (Exception e)