Animal purchasing menu is now accessible
parent
2298d891da
commit
a7fcd45dc8
|
@ -4,11 +4,8 @@ using StardewModdingAPI.Events;
|
||||||
using StardewValley;
|
using StardewValley;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using stardew_access.Patches;
|
using stardew_access.Patches;
|
||||||
using AutoHotkey.Interop;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using stardew_access.ScreenReader;
|
using stardew_access.ScreenReader;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using StardewValley.Buildings;
|
|
||||||
|
|
||||||
namespace stardew_access
|
namespace stardew_access
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,27 +17,60 @@ namespace stardew_access.Patches
|
||||||
internal static bool isSayingBlueprintInfo = false;
|
internal static bool isSayingBlueprintInfo = false;
|
||||||
internal static string prevBlueprintInfo = "";
|
internal static string prevBlueprintInfo = "";
|
||||||
internal static bool isOnFarm = false, isUpgrading = false, isDemolishing = false, isPainting = false, isConstructing = false, isMoving = false, isMagicalConstruction = false;
|
internal static bool isOnFarm = false, isUpgrading = false, isDemolishing = false, isPainting = false, isConstructing = false, isMoving = false, isMagicalConstruction = false;
|
||||||
|
internal static bool firstTimeInNamingMenu = true;
|
||||||
internal static PurchaseAnimalsMenu? purchaseAnimalsMenu;
|
internal static PurchaseAnimalsMenu? purchaseAnimalsMenu;
|
||||||
internal static void PurchaseAnimalsMenuPatch(PurchaseAnimalsMenu __instance,
|
|
||||||
bool ___onFarm,
|
internal static void PurchaseAnimalsMenuPatch(PurchaseAnimalsMenu __instance, bool ___onFarm, bool ___namingAnimal, TextBox ___textBox)
|
||||||
bool ___namingAnimal,
|
|
||||||
FarmAnimal ___animalBeingPurchased,
|
|
||||||
Building ___newAnimalHome,
|
|
||||||
TextBox ___textBox,
|
|
||||||
TextBoxEvent ___e,
|
|
||||||
int ___priceOfAnimal)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
|
||||||
purchaseAnimalsMenu = __instance;
|
purchaseAnimalsMenu = __instance;
|
||||||
isOnFarm = ___onFarm;
|
isOnFarm = ___onFarm;
|
||||||
|
|
||||||
if (___onFarm && ___namingAnimal)
|
if (___onFarm && ___namingAnimal)
|
||||||
{
|
{
|
||||||
|
string toSpeak = "";
|
||||||
|
if (__instance.okButton != null && __instance.okButton.containsPoint(x, y))
|
||||||
|
{
|
||||||
|
toSpeak = "Cancel Button";
|
||||||
|
}
|
||||||
|
else if (__instance.doneNamingButton != null && __instance.doneNamingButton.containsPoint(x, y))
|
||||||
|
{
|
||||||
|
toSpeak = "OK Button";
|
||||||
|
}
|
||||||
|
else if (__instance.randomButton != null && __instance.randomButton.containsPoint(x, y))
|
||||||
|
{
|
||||||
|
toSpeak = "Random Name Button";
|
||||||
|
}
|
||||||
|
else if (__instance.textBoxCC != null && __instance.textBoxCC.containsPoint(x, y))
|
||||||
|
{
|
||||||
|
toSpeak = "Name Text Box";
|
||||||
|
string? value = ___textBox.Text;
|
||||||
|
if (value != "" && value != null && value != "null")
|
||||||
|
toSpeak = $"{toSpeak}, Value: {value}";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (purchaseAnimalMenuQuery != toSpeak)
|
||||||
|
{
|
||||||
|
purchaseAnimalMenuQuery = toSpeak;
|
||||||
|
|
||||||
|
if (firstTimeInNamingMenu)
|
||||||
|
{
|
||||||
|
toSpeak = $"Enter the name of animal in the name text box. {toSpeak}";
|
||||||
|
firstTimeInNamingMenu = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
MainClass.ScreenReader.Say(toSpeak, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (___onFarm && !___namingAnimal)
|
||||||
|
{
|
||||||
|
firstTimeInNamingMenu = true;
|
||||||
}
|
}
|
||||||
else if (___onFarm && !___namingAnimal) { }
|
|
||||||
else if (!___onFarm && !___namingAnimal)
|
else if (!___onFarm && !___namingAnimal)
|
||||||
{
|
{
|
||||||
|
firstTimeInNamingMenu = true;
|
||||||
if (__instance.hovered != null)
|
if (__instance.hovered != null)
|
||||||
{
|
{
|
||||||
string toSpeak = "";
|
string toSpeak = "";
|
||||||
|
@ -377,6 +410,7 @@ namespace stardew_access.Patches
|
||||||
public static string? Contstruct(Vector2 position)
|
public static string? Contstruct(Vector2 position)
|
||||||
{
|
{
|
||||||
string? response = null;
|
string? response = null;
|
||||||
|
// This code is taken from the game's code (CarpenterMenu.cs::874)
|
||||||
Game1.player.team.buildLock.RequestLock(delegate
|
Game1.player.team.buildLock.RequestLock(delegate
|
||||||
{
|
{
|
||||||
if (isOnFarm && Game1.locationRequest == null)
|
if (isOnFarm && Game1.locationRequest == null)
|
||||||
|
@ -427,6 +461,7 @@ namespace stardew_access.Patches
|
||||||
public static string? Paint(Building? toPaint)
|
public static string? Paint(Building? toPaint)
|
||||||
{
|
{
|
||||||
string? response = null;
|
string? response = null;
|
||||||
|
// This code is taken from the game's code (CarpenterMenu.cs::793)
|
||||||
Farm farm_location = Game1.getFarm();
|
Farm farm_location = Game1.getFarm();
|
||||||
if (toPaint != null)
|
if (toPaint != null)
|
||||||
{
|
{
|
||||||
|
@ -465,6 +500,7 @@ namespace stardew_access.Patches
|
||||||
public static string? Move(Building? buildingToMove, Vector2 position)
|
public static string? Move(Building? buildingToMove, Vector2 position)
|
||||||
{
|
{
|
||||||
string? response = null;
|
string? response = null;
|
||||||
|
// This code is taken from the game's code (CarpenterMenu.cs::829)
|
||||||
if (buildingToMove != null)
|
if (buildingToMove != null)
|
||||||
{
|
{
|
||||||
string? name = buildingToMove.nameOfIndoorsWithoutUnique;
|
string? name = buildingToMove.nameOfIndoorsWithoutUnique;
|
||||||
|
|
|
@ -360,11 +360,14 @@ namespace stardew_access.Patches
|
||||||
BuildingNAnimalMenuPatches.isPainting = false;
|
BuildingNAnimalMenuPatches.isPainting = false;
|
||||||
BuildingNAnimalMenuPatches.isMoving = false;
|
BuildingNAnimalMenuPatches.isMoving = false;
|
||||||
BuildingNAnimalMenuPatches.isConstructing = false;
|
BuildingNAnimalMenuPatches.isConstructing = false;
|
||||||
|
BuildingNAnimalMenuPatches.carpenterMenu = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__instance is PurchaseAnimalsMenu)
|
if (__instance is PurchaseAnimalsMenu)
|
||||||
{
|
{
|
||||||
BuildingNAnimalMenuPatches.purchaseAnimalMenuQuery = "";
|
BuildingNAnimalMenuPatches.purchaseAnimalMenuQuery = "";
|
||||||
|
BuildingNAnimalMenuPatches.firstTimeInNamingMenu = true;
|
||||||
|
BuildingNAnimalMenuPatches.purchaseAnimalsMenu = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMenuPatches.hoveredItemQueryKey = "";
|
GameMenuPatches.hoveredItemQueryKey = "";
|
||||||
|
|
|
@ -2,7 +2,6 @@ namespace stardew_access.ScreenReader
|
||||||
{
|
{
|
||||||
public interface IScreenReader
|
public interface IScreenReader
|
||||||
{
|
{
|
||||||
|
|
||||||
public string PrevTextTile
|
public string PrevTextTile
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
@ -12,7 +11,7 @@ namespace stardew_access.ScreenReader
|
||||||
/// <summary>Initializes the screen reader.</summary>
|
/// <summary>Initializes the screen reader.</summary>
|
||||||
public void InitializeScreenReader();
|
public void InitializeScreenReader();
|
||||||
|
|
||||||
// <summary>Closes the screen reader, this is important, call this function when closing the game.</summary>
|
/// <summary>Closes the screen reader, this is important, call this function when closing the game.</summary>
|
||||||
public void CloseScreenReader();
|
public void CloseScreenReader();
|
||||||
|
|
||||||
/// <summary>Speaks the text via the loaded screen reader (if any).</summary>
|
/// <summary>Speaks the text via the loaded screen reader (if any).</summary>
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"Name": "Stardew Access",
|
"Name": "Stardew Access",
|
||||||
"Author": "Mohammad Shoaib",
|
"Author": "Mohammad Shoaib",
|
||||||
"Version": "1.0.21-beta",
|
"Version": "1.0.22-beta",
|
||||||
"Description": "An accessibility mod with screen reader support!",
|
"Description": "An accessibility mod with screen reader support!",
|
||||||
"UniqueID": "shoaib.stardewaccess",
|
"UniqueID": "shoaib.stardewaccess",
|
||||||
"EntryDll": "stardew-access.dll",
|
"EntryDll": "stardew-access.dll",
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AccessibleOutput" Version="1.0.0" />
|
<PackageReference Include="AccessibleOutput" Version="1.0.0" />
|
||||||
<PackageReference Include="AutoHotkey.Interop" Version="1.0.0.1" />
|
|
||||||
<PackageReference Include="Lib.Harmony" Version="2.2.0" />
|
<PackageReference Include="Lib.Harmony" Version="2.2.0" />
|
||||||
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="4.0.0" />
|
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="4.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net452</TargetFramework>
|
|
||||||
<RootNamespace>stardew_access</RootNamespace>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<LangVersion>preview</LangVersion>
|
|
||||||
<summary>MainClass.ModEntry</summary>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="AccessibleOutput" Version="1.0.0" />
|
|
||||||
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="4.0.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
Loading…
Reference in New Issue