Fixed naming menu

master
Mohammad Shoaib 2022-04-09 15:15:50 +05:30
parent 6c7b845f15
commit 416b573f43
5 changed files with 71 additions and 16 deletions

View File

@ -571,6 +571,9 @@ namespace stardew_access.Features
case "pine cone":
treeName = "Pine";
break;
default:
treeName = "Coconut";
break;
}
if (treeStage == 1)

View File

@ -130,7 +130,12 @@ namespace stardew_access
);
harmony.Patch(
original: AccessTools.Constructor(typeof(NamingMenu), new Type[] { typeof(NamingMenu.doneNamingBehavior), typeof(string), typeof(string) }),
original: AccessTools.Method(typeof(TitleTextInputMenu), nameof(TitleTextInputMenu.draw), new Type[] { typeof(SpriteBatch) }),
postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.TitleTextInputMenuPatch))
);
harmony.Patch(
original: AccessTools.Method(typeof(NamingMenu), nameof(NamingMenu.draw), new Type[] { typeof(SpriteBatch) }),
postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.NamingMenuPatch))
);

View File

@ -184,6 +184,14 @@ namespace stardew_access
if (!Context.IsPlayerFree)
return;
// Narrate Current Location
if (Config.LocationKey.JustPressed())
{
string toSpeak = $"{Game1.currentLocation.Name}";
MainClass.GetScreenReader().Say(toSpeak, true);
return;
}
// Narrate Position
if (Config.PositionKey.JustPressed())
{
@ -209,14 +217,6 @@ namespace stardew_access
return;
}
// Narrate Current Location
if (Config.LocationKey.JustPressed())
{
string toSpeak = $"{Game1.currentLocation.Name}";
MainClass.GetScreenReader().Say(toSpeak, true);
return;
}
// Narrate money at hand
if (Config.MoneyKey.JustPressed())
{

View File

@ -1068,7 +1068,7 @@ namespace stardew_access.Patches
}
}
// 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;
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(' '))
: null;
@ -1513,7 +1513,7 @@ namespace stardew_access.Patches
#region Add buff items (effects like +1 walking speed)
// These variables are taken from the game's code itself (IClickableMenu.cs -> 1016 line)
bool edibleItem = actualInventory[i] != null && actualInventory[i] is StardewValley.Object && (int)((StardewValley.Object)actualInventory[i]).edibility != -300;
bool edibleItem = actualInventory[i] != null && actualInventory[i] is StardewValley.Object && (int)((StardewValley.Object)actualInventory[i]).Edibility != -300;
string[]? buffIconsToDisplay = (edibleItem && Game1.objectInformation[((StardewValley.Object)actualInventory[i]).ParentSheetIndex].Split('/').Length > 7) ? actualInventory[i].ModifyItemBuffs(Game1.objectInformation[((StardewValley.Object)actualInventory[i]).ParentSheetIndex].Split('/')[7].Split(' ')) : null;
if (buffIconsToDisplay != null)
{

View File

@ -11,6 +11,7 @@ namespace stardew_access.Patches
internal class MenuPatches
{
private static string currentLevelUpTitle = " ";
internal static bool firstTimeInNamingMenu = true;
private static string animalQueryMenuQuery = " ";
public static Vector2? prevTile = null;
@ -167,14 +168,60 @@ namespace stardew_access.Patches
}
}
internal static void NamingMenuPatch(NamingMenu __instance, string title, TextBox ___textBox)
internal static void TitleTextInputMenuPatch(TitleTextInputMenu __instance)
{
try
{
__instance.textBoxCC.snapMouseCursor();
___textBox.SelectMe();
string toSpeak = $"{title}";
string toSpeak = "";
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
if (__instance.pasteButton != null && __instance.pasteButton.containsPoint(x, y))
toSpeak = $"Paste button";
if (toSpeak != "")
MainClass.GetScreenReader().SayWithChecker(toSpeak, true);
}
catch (System.Exception e)
{
MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
}
}
internal static void NamingMenuPatch(NamingMenu __instance, TextBox ___textBox, string ___title)
{
try
{
string toSpeak = "";
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
bool isEscPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape); // For escaping/unselecting from the animal name text box
if (firstTimeInNamingMenu)
{
firstTimeInNamingMenu = false;
___textBox.Selected = false;
}
if (___textBox.Selected)
{
___textBox.Update();
toSpeak = ___textBox.Text;
if (isEscPressed)
{
___textBox.Selected = false;
}
}
else
{
if (__instance.textBoxCC != null && __instance.textBoxCC.containsPoint(x, y))
toSpeak = $"{___title} text box";
else if (__instance.doneNamingButton != null && __instance.doneNamingButton.containsPoint(x, y))
toSpeak = $"Done naming button";
else if (__instance.randomButton != null && __instance.randomButton.containsPoint(x, y))
toSpeak = $"Random button";
}
if (toSpeak != "")
MainClass.GetScreenReader().SayWithChecker(toSpeak, true);
}
catch (Exception e)