Fix snap mouse and read tile bug

master
shoaib11120 2021-12-15 22:58:49 +05:30
parent 63540393b7
commit 6c6c7bdecf
2 changed files with 88 additions and 28 deletions

View File

@ -176,16 +176,64 @@ namespace stardew_access
int x = Game1.player.GetBoundingBox().Center.X - Game1.viewport.X; int x = Game1.player.GetBoundingBox().Center.X - Game1.viewport.X;
int y = Game1.player.GetBoundingBox().Center.Y - Game1.viewport.Y; int y = Game1.player.GetBoundingBox().Center.Y - Game1.viewport.Y;
int offset = 64;
switch (Game1.player.FacingDirection)
{
case 0:
y -= offset;
break;
case 1:
x += offset;
break;
case 2:
y += offset;
break;
case 3:
x -= offset;
break;
}
Game1.setMousePosition(x, y); Game1.setMousePosition(x, y);
} }
private static async void ReadTile() private static async void ReadTile()
{ {
isReadingTile = true; isReadingTile = true;
try
{
#region Get Correct Grab Tile
int x = Game1.player.GetBoundingBox().Center.X;
int y = Game1.player.GetBoundingBox().Center.Y;
int offset = 64;
switch (Game1.player.FacingDirection)
{
case 0:
y -= offset;
break;
case 1:
x += offset;
break;
case 2:
y += offset;
break;
case 3:
x -= offset;
break;
}
x /= Game1.tileSize;
y /= Game1.tileSize;
Vector2 gt = new Vector2(x, y);
#endregion
if (Context.IsPlayerFree) if (Context.IsPlayerFree)
{ {
Dictionary<Vector2, Netcode.NetRef<TerrainFeature>> terrainFeature = Game1.currentLocation.terrainFeatures.FieldDict; Dictionary<Vector2, Netcode.NetRef<TerrainFeature>> terrainFeature = Game1.currentLocation.terrainFeatures.FieldDict;
Vector2 gt = Game1.player.GetGrabTile();
StardewValley.Object obj = Game1.currentLocation.getObjectAtTile((int)gt.X, (int)gt.Y); StardewValley.Object obj = Game1.currentLocation.getObjectAtTile((int)gt.X, (int)gt.Y);
if (!Equals(gt, prevTile)) if (!Equals(gt, prevTile))
@ -195,8 +243,6 @@ namespace stardew_access
{ {
string name = obj.name; string name = obj.name;
string checkQuery = $"x:{gt.X} y:{gt.Y}";
ScreenReader.say(name, true); ScreenReader.say(name, true);
} }
@ -211,8 +257,17 @@ namespace stardew_access
{ {
string cropName = Game1.objectInformation[dirt.crop.indexOfHarvest]; string cropName = Game1.objectInformation[dirt.crop.indexOfHarvest];
cropName = cropName.Substring(0, cropName.IndexOf("/")); cropName = cropName.Substring(0, cropName.IndexOf("/"));
string toSpeak = $"{cropName}"; string toSpeak = $"{cropName}";
bool isWatered = dirt.state.Value == HoeDirt.watered;
bool isHarvestable = dirt.crop.fullyGrown.Get();
if(isWatered)
toSpeak = "Watered " + toSpeak;
if (isHarvestable)
toSpeak = "Harvestable " + toSpeak;
ScreenReader.say(toSpeak, true); ScreenReader.say(toSpeak, true);
} }
} }
@ -220,6 +275,11 @@ namespace stardew_access
} }
} }
} }
}
catch (Exception e)
{
monitor.Log($"Error in Read Tile:\n{e.Message}\n{e.StackTrace}");
}
await Task.Delay(100); await Task.Delay(100);
isReadingTile = false; isReadingTile = false;

View File

@ -1,7 +1,7 @@
{ {
"Name": "Stardew Access", "Name": "Stardew Access",
"Author": "Mohammad Shoaib", "Author": "Mohammad Shoaib",
"Version": "1.0.3-beta", "Version": "1.0.4-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",