Now it narrates tiles even if they update

master
shoaib11120 2021-12-20 23:19:49 +05:30
parent dd0889e7fb
commit 8fe6d37d4b
2 changed files with 226 additions and 221 deletions

View File

@ -251,12 +251,9 @@ namespace stardew_access
{
Dictionary<Vector2, Netcode.NetRef<TerrainFeature>> terrainFeature = Game1.currentLocation.terrainFeatures.FieldDict;
if (!Equals(gt, prevTile))
if (Game1.currentLocation.isWaterTile(x, y))
{
prevTile = gt;
if (Game1.currentLocation.isWaterTile(x, y)){
ScreenReader.say("Water", true);
ScreenReader.sayWithTileQuery("Water", x, y, true);
}
else if (Game1.currentLocation.getObjectAtTile(x, y) != null)
{
@ -273,7 +270,7 @@ namespace stardew_access
name = "Copper " + name;
}
ScreenReader.say(name, true);
ScreenReader.sayWithTileQuery(name, x, y, true);
#endregion
}
else if (terrainFeature.ContainsKey(gt))
@ -302,7 +299,7 @@ namespace stardew_access
if (isHarvestable)
toSpeak = "Harvestable " + toSpeak;
ScreenReader.say(toSpeak, true);
ScreenReader.sayWithTileQuery(toSpeak, x, y, true);
}
else
{
@ -316,13 +313,13 @@ namespace stardew_access
if (isFertilized)
toSpeak = "Fertilized " + toSpeak;
ScreenReader.say(toSpeak, true);
ScreenReader.sayWithTileQuery(toSpeak, x, y, true);
}
}
else if (terrain.Get() is Bush)
{
string toSpeak = "Bush";
ScreenReader.say(toSpeak, true);
ScreenReader.sayWithTileQuery(toSpeak, x, y, true);
}
else if (terrain.Get() is CosmeticPlant)
{
@ -335,7 +332,7 @@ namespace stardew_access
if (toSpeak.Contains("feature"))
toSpeak.Replace("feature", "");
ScreenReader.say(toSpeak, true);
ScreenReader.sayWithTileQuery(toSpeak, x, y, true);
}
else if (terrain.Get() is Flooring)
{
@ -351,29 +348,21 @@ namespace stardew_access
if (isSteppingStone)
toSpeak = "Stepping Stone";
ScreenReader.say(toSpeak, true);
ScreenReader.sayWithTileQuery(toSpeak, x, y, true);
}
else if (terrain.Get() is FruitTree)
{
FruitTree fruitTree = (FruitTree)terrain.Get();
string toSpeak = Game1.objectInformation[fruitTree.treeType].Split('/')[0];
ScreenReader.say(toSpeak, true);
}
else if (terrain.Get() is ResourceClump)
{
ResourceClump resourceClump = (ResourceClump)terrain.Get();
monitor.Log(Game1.objectInformation[resourceClump.parentSheetIndex], LogLevel.Debug);
string toSpeak = Game1.objectInformation[resourceClump.parentSheetIndex].Split('/')[0];
ScreenReader.say(toSpeak, true);
ScreenReader.sayWithTileQuery(toSpeak, x, y, true);
}
else if (terrain.Get() is Grass)
{
Grass grass = (Grass)terrain.Get();
string toSpeak = "Grass";
ScreenReader.say(toSpeak, true);
ScreenReader.sayWithTileQuery(toSpeak, x, y, true);
}
else if (terrain.Get() is Tree)
{
@ -397,17 +386,17 @@ namespace stardew_access
toSpeak += $", {stage} stage";
ScreenReader.say(toSpeak, true);
ScreenReader.sayWithTileQuery(toSpeak, x, y, true);
}
else if (terrain.Get() is Quartz)
{
string toSpeak = "Quartz";
ScreenReader.say(toSpeak, true);
ScreenReader.sayWithTileQuery(toSpeak, x, y, true);
}
else if (terrain.Get() is Leaf)
{
string toSpeak = "Leaf";
ScreenReader.say(toSpeak, true);
ScreenReader.sayWithTileQuery(toSpeak, x, y, true);
}
#endregion
}
@ -446,7 +435,7 @@ namespace stardew_access
break;
}
ScreenReader.say(toSpeak, true);
ScreenReader.sayWithTileQuery(toSpeak, x, y, true);
return;
}
});
@ -459,21 +448,23 @@ namespace stardew_access
{
if (Equals(x, ydoor.X) && Equals(y, ydoor.Y))
{
ScreenReader.say("Door", true);
ScreenReader.sayWithTileQuery("Door", x, y, true);
}
});
});
#endregion
#region Ladder
if (Game1.inMine || Game1.currentLocation is Mine)
{
int index = Game1.currentLocation.Map.GetLayer("Buildings").Tiles[x, y].TileIndex;
if (index == 173 || index == 174)
ScreenReader.say("Ladder", true);
}
ScreenReader.sayWithTileQuery("Ladder", x, y, true);
}
#endregion
}
}
}
catch (Exception e)

View File

@ -73,5 +73,19 @@ namespace stardew_access
screenReader.Speak(text, interrupt);
}
}
public static void sayWithTileQuery(string text, int x, int y, bool interrupt)
{
if (screenReader == null)
return;
string query = $"{text} x:{x} y:{y}";
if (prevText != query)
{
prevText = query;
screenReader.Speak(text, interrupt);
}
}
}
}