Added current slot and location narration
parent
6fb4cea854
commit
069769b2d6
|
@ -5,24 +5,14 @@ namespace stardew_access.Game
|
||||||
{
|
{
|
||||||
internal class CurrentPlayer
|
internal class CurrentPlayer
|
||||||
{
|
{
|
||||||
private static Farmer? player = null;
|
|
||||||
|
|
||||||
CurrentPlayer()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void initPlayer()
|
|
||||||
{
|
|
||||||
player = Game1.player;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static int getHealth()
|
internal static int getHealth()
|
||||||
{
|
{
|
||||||
if(player == null)
|
if(Game1.player == null)
|
||||||
initPlayer();
|
return 0;
|
||||||
|
|
||||||
int maxHealth = player.maxHealth;
|
int maxHealth = Game1.player.maxHealth;
|
||||||
int currentHealth = player.health;
|
int currentHealth = Game1.player.health;
|
||||||
|
|
||||||
int healthPercentage = (int) (currentHealth * 100)/maxHealth;
|
int healthPercentage = (int) (currentHealth * 100)/maxHealth;
|
||||||
return healthPercentage;
|
return healthPercentage;
|
||||||
|
@ -30,11 +20,11 @@ namespace stardew_access.Game
|
||||||
|
|
||||||
internal static int getStamina()
|
internal static int getStamina()
|
||||||
{
|
{
|
||||||
if (player == null)
|
if (Game1.player == null)
|
||||||
initPlayer();
|
return 0;
|
||||||
|
|
||||||
int maxStamina = player.maxStamina;
|
int maxStamina = Game1.player.maxStamina;
|
||||||
int currentStamine = (int)player.stamina;
|
int currentStamine = (int)Game1.player.stamina;
|
||||||
|
|
||||||
int staminaPercentage = (int)(currentStamine * 100) / maxStamina;
|
int staminaPercentage = (int)(currentStamine * 100) / maxStamina;
|
||||||
|
|
||||||
|
@ -43,37 +33,19 @@ namespace stardew_access.Game
|
||||||
|
|
||||||
internal static int getPositionX()
|
internal static int getPositionX()
|
||||||
{
|
{
|
||||||
if (player == null)
|
if (Game1.player == null)
|
||||||
initPlayer();
|
return 0;
|
||||||
|
|
||||||
int x = (int)player.getTileLocation().X;
|
int x = (int)Game1.player.getTileLocation().X;
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static int getPositionY()
|
internal static int getPositionY()
|
||||||
{
|
{
|
||||||
if (player == null)
|
if (Game1.player == null)
|
||||||
initPlayer();
|
return 0;
|
||||||
|
|
||||||
int y = (int)player.getTileLocation().Y;
|
int y = (int)Game1.player.getTileLocation().Y;
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static int getToolHItPositionX()
|
|
||||||
{
|
|
||||||
if (player == null)
|
|
||||||
initPlayer();
|
|
||||||
|
|
||||||
int x = (int)player.GetGrabTile().X;
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static int getToolHItPositionY()
|
|
||||||
{
|
|
||||||
if (player == null)
|
|
||||||
initPlayer();
|
|
||||||
|
|
||||||
int y = (int)player.GetGrabTile().Y;
|
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
|
||||||
|
using StardewModdingAPI;
|
||||||
|
using StardewValley;
|
||||||
|
|
||||||
|
namespace stardew_access.Game
|
||||||
|
{
|
||||||
|
internal class SlotAndLocation
|
||||||
|
{
|
||||||
|
private static Item? currentSlotItem;
|
||||||
|
private static Item? previousSlotItem;
|
||||||
|
|
||||||
|
private static GameLocation? currentLocation;
|
||||||
|
private static GameLocation? previousLocation;
|
||||||
|
|
||||||
|
// Narrates current slected slot name
|
||||||
|
public static void narrateCurrentSlot()
|
||||||
|
{
|
||||||
|
currentSlotItem = Game1.player.CurrentItem;
|
||||||
|
|
||||||
|
if (currentSlotItem == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (previousSlotItem == currentSlotItem)
|
||||||
|
return;
|
||||||
|
|
||||||
|
previousSlotItem = currentSlotItem;
|
||||||
|
ScreenReader.say(currentSlotItem.Name, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Narrates current location's name
|
||||||
|
public static void narrateCurrentLocation()
|
||||||
|
{
|
||||||
|
currentLocation = Game1.currentLocation;
|
||||||
|
|
||||||
|
if (currentLocation == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (previousLocation == currentLocation)
|
||||||
|
return;
|
||||||
|
|
||||||
|
previousLocation = currentLocation;
|
||||||
|
ScreenReader.say(currentLocation.Name,true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,8 @@ using stardew_access.Patches;
|
||||||
using AutoHotkey.Interop;
|
using AutoHotkey.Interop;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using StardewValley.TerrainFeatures;
|
using StardewValley.TerrainFeatures;
|
||||||
|
using StardewValley.Locations;
|
||||||
|
using StardewValley.Objects;
|
||||||
|
|
||||||
namespace stardew_access
|
namespace stardew_access
|
||||||
{
|
{
|
||||||
|
@ -119,11 +121,25 @@ namespace stardew_access
|
||||||
snapMouse = !snapMouse;
|
snapMouse = !snapMouse;
|
||||||
|
|
||||||
monitor.Log("Snap Mouse is " + (snapMouse ? "on" : "off"), LogLevel.Info);
|
monitor.Log("Snap Mouse is " + (snapMouse ? "on" : "off"), LogLevel.Info);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
helper.ConsoleCommands.Add("ref_sr", "Refresh screen reader", (string arg1, string[] arg2) =>
|
||||||
|
{
|
||||||
|
ScreenReader.initializeScreenReader();
|
||||||
|
|
||||||
|
monitor.Log("Screen Reader refreshed!", LogLevel.Info);
|
||||||
|
});
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
|
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
|
||||||
helper.Events.GameLoop.UpdateTicked += this.onUpdateTicked;
|
helper.Events.GameLoop.UpdateTicked += this.onUpdateTicked;
|
||||||
|
helper.Events.GameLoop.OneSecondUpdateTicked += this.onOneSecondUpdateTicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onOneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
|
||||||
|
{
|
||||||
|
if (!Context.IsPlayerFree)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onUpdateTicked(object sender, UpdateTickedEventArgs e)
|
private void onUpdateTicked(object sender, UpdateTickedEventArgs e)
|
||||||
|
@ -133,7 +149,11 @@ namespace stardew_access
|
||||||
|
|
||||||
MenuPatch.resetGlobalVars();
|
MenuPatch.resetGlobalVars();
|
||||||
|
|
||||||
if(snapMouse)
|
SlotAndLocation.narrateCurrentSlot();
|
||||||
|
|
||||||
|
SlotAndLocation.narrateCurrentLocation();
|
||||||
|
|
||||||
|
if (snapMouse)
|
||||||
SnapMouseToPlayer();
|
SnapMouseToPlayer();
|
||||||
|
|
||||||
if(!isReadingTile && readTile)
|
if(!isReadingTile && readTile)
|
||||||
|
@ -203,7 +223,6 @@ namespace stardew_access
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
#region Get Correct Grab Tile
|
#region Get Correct Grab Tile
|
||||||
int x = Game1.player.GetBoundingBox().Center.X;
|
int x = Game1.player.GetBoundingBox().Center.X;
|
||||||
int y = Game1.player.GetBoundingBox().Center.Y;
|
int y = Game1.player.GetBoundingBox().Center.Y;
|
||||||
|
@ -236,6 +255,11 @@ namespace stardew_access
|
||||||
Dictionary<Vector2, Netcode.NetRef<TerrainFeature>> terrainFeature = Game1.currentLocation.terrainFeatures.FieldDict;
|
Dictionary<Vector2, Netcode.NetRef<TerrainFeature>> terrainFeature = Game1.currentLocation.terrainFeatures.FieldDict;
|
||||||
|
|
||||||
StardewValley.Object obj = Game1.currentLocation.getObjectAtTile((int)gt.X, (int)gt.Y);
|
StardewValley.Object obj = Game1.currentLocation.getObjectAtTile((int)gt.X, (int)gt.Y);
|
||||||
|
// Mine loc x49 y14
|
||||||
|
// x41 y7 allyway
|
||||||
|
// x40 y7
|
||||||
|
// x41 y0 entrance
|
||||||
|
// x40 y0
|
||||||
if (!Equals(gt, prevTile))
|
if (!Equals(gt, prevTile))
|
||||||
{
|
{
|
||||||
prevTile = gt;
|
prevTile = gt;
|
||||||
|
@ -243,6 +267,17 @@ namespace stardew_access
|
||||||
{
|
{
|
||||||
string name = obj.name;
|
string name = obj.name;
|
||||||
|
|
||||||
|
monitor.Log(obj.parentSheetIndex.ToString(), LogLevel.Debug);
|
||||||
|
if (Game1.objectInformation.ContainsKey(obj.ParentSheetIndex) && name.ToLower().Equals("stone"))
|
||||||
|
{
|
||||||
|
string info = Game1.objectInformation[obj.parentSheetIndex];
|
||||||
|
if (info.ToLower().Contains("copper"))
|
||||||
|
name = "Copper " + name;
|
||||||
|
else if (info.ToLower().Contains("iron"))
|
||||||
|
name = "Iron " + name;
|
||||||
|
monitor.Log(info, LogLevel.Debug);
|
||||||
|
}
|
||||||
|
|
||||||
ScreenReader.say(name, true);
|
ScreenReader.say(name, true);
|
||||||
}
|
}
|
||||||
else if (terrainFeature.ContainsKey(gt))
|
else if (terrainFeature.ContainsKey(gt))
|
||||||
|
@ -270,7 +305,6 @@ namespace stardew_access
|
||||||
if (isHarvestable)
|
if (isHarvestable)
|
||||||
toSpeak = "Harvestable " + toSpeak;
|
toSpeak = "Harvestable " + toSpeak;
|
||||||
|
|
||||||
monitor.Log(toSpeak, LogLevel.Debug);
|
|
||||||
ScreenReader.say(toSpeak, true);
|
ScreenReader.say(toSpeak, true);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
|
@ -377,10 +411,28 @@ namespace stardew_access
|
||||||
string toSpeak = "Leaf";
|
string toSpeak = "Leaf";
|
||||||
ScreenReader.say(toSpeak, true);
|
ScreenReader.say(toSpeak, true);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Game1.currentLocation.resourceClumps.ToList().ForEach(x =>
|
||||||
{
|
{
|
||||||
monitor.Log($"LTF {terrain.Get() is ResourceClump}", LogLevel.Debug);
|
if(x.occupiesTile((int)gt.X, (int)gt.Y))
|
||||||
}
|
{
|
||||||
|
monitor.Log("here", LogLevel.Debug);
|
||||||
|
string toSpeak = " ";
|
||||||
|
|
||||||
|
if (Game1.objectInformation.ContainsKey(obj.ParentSheetIndex))
|
||||||
|
{
|
||||||
|
toSpeak = Game1.objectInformation[x.parentSheetIndex];
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
toSpeak = x.parentSheetIndex.ToString();
|
||||||
|
}
|
||||||
|
monitor.Log(toSpeak, LogLevel.Debug);
|
||||||
|
ScreenReader.say(toSpeak, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue