Added social page accessibility
parent
77f9f18ecc
commit
d3d7e1c2aa
|
@ -2,7 +2,6 @@
|
|||
using StardewValley;
|
||||
using StardewValley.Objects;
|
||||
using StardewValley.TerrainFeatures;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace stardew_access.Game
|
||||
{
|
||||
|
@ -95,9 +94,6 @@ namespace stardew_access.Game
|
|||
|
||||
public async void Run()
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
||||
if (MainClass.radarDebug)
|
||||
MainClass.monitor.Log($"\n\nRead Tile started", StardewModdingAPI.LogLevel.Debug);
|
||||
|
||||
|
@ -113,8 +109,6 @@ namespace stardew_access.Game
|
|||
if (MainClass.radarDebug)
|
||||
MainClass.monitor.Log($"\nRead Tile stopped\n\n", StardewModdingAPI.LogLevel.Debug);
|
||||
|
||||
sw.Stop();
|
||||
MainClass.monitor.Log($"Time:{sw.ElapsedMilliseconds}ms", StardewModdingAPI.LogLevel.Debug);
|
||||
await Task.Delay(delay);
|
||||
isRunning = false;
|
||||
}
|
||||
|
|
|
@ -90,6 +90,11 @@ namespace stardew_access
|
|||
original: AccessTools.Method(typeof(ShopMenu), nameof(ShopMenu.draw), new Type[] { typeof(SpriteBatch) }),
|
||||
postfix: new HarmonyMethod(typeof(GameMenuPatches), nameof(GameMenuPatches.ShopMenuPatch))
|
||||
);
|
||||
|
||||
harmony.Patch(
|
||||
original: AccessTools.Method(typeof(SocialPage), nameof(SocialPage.draw), new Type[] { typeof(SpriteBatch) }),
|
||||
postfix: new HarmonyMethod(typeof(GameMenuPatches), nameof(GameMenuPatches.SocialPagePatch))
|
||||
);
|
||||
#endregion
|
||||
|
||||
#region Menu Patches
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace stardew_access
|
|||
public static bool radarDebug = false;
|
||||
public static bool radarStereoSound = true;
|
||||
public static IMonitor monitor;
|
||||
private AutoHotkeyEngine? ahk;
|
||||
private AutoHotkeyEngine ahk;
|
||||
public static string hudMessageQueryKey = "";
|
||||
public static Radar radarFeature;
|
||||
public static ScreenReaderInterface screenReader;
|
||||
|
|
|
@ -17,14 +17,151 @@ namespace stardew_access.Patches
|
|||
internal static string exitPageQueryKey = "";
|
||||
internal static string optionsPageQueryKey = "";
|
||||
internal static string shopMenuQueryKey = "";
|
||||
internal static string socialPageQuery = "";
|
||||
internal static int currentSelectedCraftingRecipe = -1;
|
||||
internal static bool isSelectingRecipe = false;
|
||||
|
||||
internal static void SocialPagePatch(SocialPage __instance, List<ClickableTextureComponent> ___sprites, int ___slotPosition, List<string> ___kidsNames)
|
||||
{
|
||||
try
|
||||
{
|
||||
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
|
||||
for (int i = ___slotPosition; i < ___slotPosition + 5; i++)
|
||||
{
|
||||
if (i < ___sprites.Count)
|
||||
{
|
||||
if (__instance.names[i] is string)
|
||||
{
|
||||
#region For NPCs
|
||||
if (__instance.characterSlots[i].bounds.Contains(Game1.getMouseX(), Game1.getMouseY()))
|
||||
{
|
||||
string name = $"{__instance.names[i] as string}";
|
||||
int heartLevel = Game1.player.getFriendshipHeartLevelForNPC(name);
|
||||
bool datable = SocialPage.isDatable(name);
|
||||
Friendship friendship = __instance.getFriendship(name);
|
||||
int giftsThisWeek = friendship.GiftsThisWeek;
|
||||
bool hasTalked = Game1.player.hasPlayerTalkedToNPC(name);
|
||||
bool spouse = friendship.IsMarried();
|
||||
bool housemate = spouse && SocialPage.isRoommateOfAnyone(name);
|
||||
|
||||
string toSpeak = $"{name}";
|
||||
|
||||
if (!hasTalked)
|
||||
{
|
||||
toSpeak = $"{toSpeak}, not talked yet";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (datable | housemate)
|
||||
{
|
||||
string text2 = (LocalizedContentManager.CurrentLanguageCode != LocalizedContentManager.LanguageCode.pt) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635") : ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').First() : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').Last());
|
||||
if (housemate)
|
||||
{
|
||||
text2 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Housemate");
|
||||
}
|
||||
else if (spouse)
|
||||
{
|
||||
text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11636") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11637"));
|
||||
}
|
||||
else if (__instance.isMarriedToAnyone(name))
|
||||
{
|
||||
text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_MaleNPC") : Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_FemaleNPC"));
|
||||
}
|
||||
else if (!Game1.player.isMarried() && friendship.IsDating())
|
||||
{
|
||||
text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11639") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11640"));
|
||||
}
|
||||
else if (__instance.getFriendship(name).IsDivorced())
|
||||
{
|
||||
text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11642") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11643"));
|
||||
}
|
||||
|
||||
toSpeak = $"{toSpeak}, {text2}";
|
||||
}
|
||||
if (!__instance.getFriendship(name).IsMarried() && !___kidsNames.Contains(name))
|
||||
{
|
||||
toSpeak = $"{toSpeak}, married";
|
||||
}
|
||||
if (spouse)
|
||||
{
|
||||
toSpeak = $"{toSpeak}, spouse";
|
||||
}
|
||||
else if (friendship.IsDating())
|
||||
{
|
||||
toSpeak = $"{toSpeak}, dating";
|
||||
}
|
||||
|
||||
toSpeak = $"{toSpeak}, {heartLevel} hearts, {giftsThisWeek} gifts given this week.";
|
||||
}
|
||||
|
||||
if (socialPageQuery != toSpeak)
|
||||
{
|
||||
socialPageQuery = toSpeak;
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
else if (__instance.names[i] is long)
|
||||
{
|
||||
#region For Farmers
|
||||
|
||||
long farmerID = (long)__instance.names[i];
|
||||
Farmer farmer = Game1.getFarmerMaybeOffline(farmerID);
|
||||
if (farmer != null)
|
||||
{
|
||||
int gender = (!farmer.IsMale) ? 1 : 0;
|
||||
ClickableTextureComponent clickableTextureComponent = ___sprites[i];
|
||||
if (clickableTextureComponent.containsPoint(x, y))
|
||||
{
|
||||
Friendship friendship = Game1.player.team.GetFriendship(Game1.player.UniqueMultiplayerID, farmerID);
|
||||
bool spouse = friendship.IsMarried();
|
||||
string toSpeak = "";
|
||||
|
||||
string text2 = (LocalizedContentManager.CurrentLanguageCode != LocalizedContentManager.LanguageCode.pt) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635") : ((gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').First() : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').Last());
|
||||
if (spouse)
|
||||
{
|
||||
text2 = ((gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11636") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11637"));
|
||||
}
|
||||
else if (farmer.isMarried() && !farmer.hasRoommate())
|
||||
{
|
||||
text2 = ((gender == 0) ? Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_MaleNPC") : Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_FemaleNPC"));
|
||||
}
|
||||
else if (!Game1.player.isMarried() && friendship.IsDating())
|
||||
{
|
||||
text2 = ((gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11639") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11640"));
|
||||
}
|
||||
else if (friendship.IsDivorced())
|
||||
{
|
||||
text2 = ((gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11642") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11643"));
|
||||
}
|
||||
|
||||
toSpeak = $"{farmer.displayName}, {text2}";
|
||||
|
||||
if (socialPageQuery != toSpeak)
|
||||
{
|
||||
socialPageQuery = toSpeak;
|
||||
MainClass.screenReader.Say(toSpeak, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MainClass.monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void ShopMenuPatch(ShopMenu __instance)
|
||||
{
|
||||
try
|
||||
{
|
||||
int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; // Mouse x and y position
|
||||
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
|
||||
bool isIPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.I);
|
||||
bool isLeftShiftPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift);
|
||||
|
||||
|
@ -136,7 +273,7 @@ namespace stardew_access.Patches
|
|||
if (__instance.currentTab != 0 && __instance.currentTab != 4 && __instance.currentTab != 6 && __instance.currentTab != 7)
|
||||
return;
|
||||
|
||||
int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; // Mouse x and y position
|
||||
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
|
||||
|
||||
for (int i = 0; i < __instance.tabs.Count; i++)
|
||||
{
|
||||
|
@ -162,7 +299,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
try
|
||||
{
|
||||
int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; // Mouse x and y position
|
||||
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
|
||||
|
||||
#region Narrate the treasure recieved on breaking the geode
|
||||
if (__instance.geodeTreasure != null)
|
||||
|
@ -246,7 +383,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
try
|
||||
{
|
||||
int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; // Mouse x and y position
|
||||
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
|
||||
bool isIPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.I);
|
||||
bool isLeftShiftPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift);
|
||||
|
||||
|
@ -510,7 +647,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
try
|
||||
{
|
||||
int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; // Mouse x and y position
|
||||
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
|
||||
bool isIPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.I);
|
||||
bool isCPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.C);
|
||||
bool isLeftShiftPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift);
|
||||
|
@ -711,7 +848,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
try
|
||||
{
|
||||
int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; // Mouse x and y position
|
||||
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
|
||||
|
||||
#region Narrate buttons in the menu
|
||||
if (__instance.inventory.dropItemInvisibleButton != null && __instance.inventory.dropItemInvisibleButton.containsPoint(x, y))
|
||||
|
@ -899,7 +1036,7 @@ namespace stardew_access.Patches
|
|||
try
|
||||
{
|
||||
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.getMouseX(), y = Game1.getMouseY();
|
||||
for (int i = 0; i < __instance.optionSlots.Count; i++)
|
||||
{
|
||||
if (__instance.optionSlots[i].bounds.Contains(x, y) && currentItemIndex + i < __instance.options.Count && __instance.options[currentItemIndex + i].bounds.Contains(x - __instance.optionSlots[i].bounds.X, y - __instance.optionSlots[i].bounds.Y))
|
||||
|
@ -952,7 +1089,7 @@ namespace stardew_access.Patches
|
|||
try
|
||||
{
|
||||
if (__instance.exitToTitle.visible &&
|
||||
__instance.exitToTitle.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y))
|
||||
__instance.exitToTitle.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
|
||||
{
|
||||
string toSpeak = "Exit to Title Button";
|
||||
if (exitPageQueryKey != toSpeak)
|
||||
|
@ -964,7 +1101,7 @@ namespace stardew_access.Patches
|
|||
return;
|
||||
}
|
||||
if (__instance.exitToDesktop.visible &&
|
||||
__instance.exitToDesktop.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y))
|
||||
__instance.exitToDesktop.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
|
||||
{
|
||||
string toSpeak = "Exit to Desktop Button";
|
||||
if (exitPageQueryKey != toSpeak)
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
try
|
||||
{
|
||||
int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; // Mouse x and y position
|
||||
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
|
||||
|
||||
if (__instance.nextPageButton != null && __instance.nextPageButton.containsPoint(x, y))
|
||||
{
|
||||
|
@ -81,7 +81,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
try
|
||||
{
|
||||
int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; // Mouse x and y position
|
||||
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
|
||||
for (int i = 0; i < ___elevators.Count; i++)
|
||||
{
|
||||
if (___elevators[i].containsPoint(x, y))
|
||||
|
@ -117,13 +117,14 @@ namespace stardew_access.Patches
|
|||
{
|
||||
try
|
||||
{
|
||||
int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y;
|
||||
int x = Game1.getMouseX(), y = Game1.getMouseY();
|
||||
|
||||
MainClass.screenReader.SayWithMenuChecker(___message, true);
|
||||
if (__instance.okButton.containsPoint(x, y))
|
||||
{
|
||||
MainClass.screenReader.SayWithMenuChecker("Ok Button", false);
|
||||
} else if (__instance.cancelButton.containsPoint(x, y))
|
||||
}
|
||||
else if (__instance.cancelButton.containsPoint(x, y))
|
||||
{
|
||||
MainClass.screenReader.SayWithMenuChecker("Cancel Button", false);
|
||||
}
|
||||
|
@ -138,7 +139,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
try
|
||||
{
|
||||
int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y;
|
||||
int x = Game1.getMouseX(), y = Game1.getMouseY();
|
||||
string leftProfession = " ", rightProfession = " ", extraInfo = " ", newCraftingRecipe = " ", toSpeak = " ";
|
||||
|
||||
if (!__instance.informationUp)
|
||||
|
@ -208,14 +209,14 @@ namespace stardew_access.Patches
|
|||
{
|
||||
int total = ___categoryTotals[5];
|
||||
string toSpeak;
|
||||
if (__instance.okButton.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y))
|
||||
if (__instance.okButton.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
|
||||
{
|
||||
toSpeak = $"{total}g in total. Press left mouse button to save.";
|
||||
MainClass.screenReader.SayWithChecker(toSpeak, true);
|
||||
}
|
||||
for (int i = 0; i < __instance.categories.Count; i++)
|
||||
{
|
||||
if (__instance.categories[i].containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y))
|
||||
if (__instance.categories[i].containsPoint(Game1.getMouseX(), Game1.getMouseY()))
|
||||
{
|
||||
toSpeak = $"Money recieved from {__instance.getCategoryName(i)}: {___categoryTotals[i]}g.";
|
||||
MainClass.screenReader.SayWithChecker(toSpeak, true);
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
try
|
||||
{
|
||||
int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; // Mouse x and y position
|
||||
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
|
||||
|
||||
if (__instance.acceptLeftQuestButton.visible && __instance.acceptLeftQuestButton.containsPoint(x, y))
|
||||
{
|
||||
|
@ -83,7 +83,7 @@ namespace stardew_access.Patches
|
|||
#region Callender
|
||||
for (int i = 0; i < __instance.calendarDays.Count; i++)
|
||||
{
|
||||
if (__instance.calendarDays[i].containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y))
|
||||
if (__instance.calendarDays[i].containsPoint(Game1.getMouseX(), Game1.getMouseY()))
|
||||
{
|
||||
string toSpeak = $"Day {i + 1}";
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
try
|
||||
{
|
||||
int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y;
|
||||
int x = Game1.getMouseX(), y = Game1.getMouseY();
|
||||
string toSpeak = " ";
|
||||
|
||||
#region Join/Host Button (Important! This should be checked before checking other buttons)
|
||||
|
@ -64,7 +64,7 @@ namespace stardew_access.Patches
|
|||
|
||||
__instance.buttons.ForEach(component =>
|
||||
{
|
||||
if (component.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y))
|
||||
if (component.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
|
||||
{
|
||||
string name = component.name;
|
||||
string label = component.label;
|
||||
|
@ -72,27 +72,27 @@ namespace stardew_access.Patches
|
|||
}
|
||||
});
|
||||
|
||||
if (__instance.muteMusicButton.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y))
|
||||
if (__instance.muteMusicButton.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
|
||||
{
|
||||
toSpeak = "Mute Music Button";
|
||||
}
|
||||
|
||||
if (__instance.aboutButton.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y))
|
||||
if (__instance.aboutButton.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
|
||||
{
|
||||
toSpeak = "About Button";
|
||||
}
|
||||
|
||||
if (__instance.languageButton.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y))
|
||||
if (__instance.languageButton.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
|
||||
{
|
||||
toSpeak = "Language Button";
|
||||
}
|
||||
|
||||
if (__instance.windowedButton.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y))
|
||||
if (__instance.windowedButton.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
|
||||
{
|
||||
toSpeak = "Fullscreen toggle Button";
|
||||
}
|
||||
|
||||
if (TitleMenu.subMenu != null && __instance.backButton.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y))
|
||||
if (TitleMenu.subMenu != null && __instance.backButton.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
|
||||
{
|
||||
string text = "Back Button";
|
||||
MainClass.screenReader.SayWithChecker(text, true);
|
||||
|
@ -111,7 +111,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
try
|
||||
{
|
||||
int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y;
|
||||
int x = Game1.getMouseX(), y = Game1.getMouseY();
|
||||
if (___menu.slotButtons[i].containsPoint(x, y))
|
||||
{
|
||||
if (__instance.Farmer != null)
|
||||
|
|
Loading…
Reference in New Issue