Added keybind for money and time narration

master
shoaib11120 2021-12-20 23:43:24 +05:30
parent 8fe6d37d4b
commit 329154bea6
3 changed files with 58 additions and 24 deletions

View File

@ -52,7 +52,28 @@ namespace stardew_access.Game
public static string getTimeOfDay() public static string getTimeOfDay()
{ {
int timeOfDay = Game1.timeOfDay; int timeOfDay = Game1.timeOfDay;
return timeOfDay.ToString();
int minutes = timeOfDay % 100;
int hours = timeOfDay / 100;
string amOrpm = "A M";
if(hours>=12)
{
amOrpm = "P M";
if (hours > 12)
hours -= 12;
}
return $"{hours}:{minutes} {amOrpm}";
}
public static string getSeason()
{
return Game1.CurrentSeasonDisplayName;
}
public static int getDay()
{
return Game1.dayOfMonth;
} }
public static int getMoney() public static int getMoney()

View File

@ -159,32 +159,45 @@ namespace stardew_access
private void OnButtonPressed(object sender, ButtonPressedEventArgs e) private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
{ {
if (Game1.activeClickableMenu == null) if (!Context.IsPlayerFree)
return;
// Narrate health and stamina
if (Equals(e.Button, SButton.H))
{ {
// Narrate health and stamina string toSpeak = $"Health is {CurrentPlayer.getHealth()} and Stamina is {CurrentPlayer.getStamina()}";
if (Equals(e.Button, SButton.H)) ScreenReader.say(toSpeak, true);
{ }
string toSpeak = $"Health is {CurrentPlayer.getHealth()} and Stamina is {CurrentPlayer.getStamina()}";
ScreenReader.say(toSpeak, true);
}
// Narrate Position // Narrate Position
if (Equals(e.Button, SButton.K)) if (Equals(e.Button, SButton.K))
{ {
string toSpeak = $"X: {CurrentPlayer.getPositionX()} , Y: {CurrentPlayer.getPositionY()}"; string toSpeak = $"X: {CurrentPlayer.getPositionX()} , Y: {CurrentPlayer.getPositionY()}";
ScreenReader.say(toSpeak, true); ScreenReader.say(toSpeak, true);
} }
if (Equals(e.Button, SButton.J)) // Narrate money at hand
{ if (Equals(e.Button, SButton.R))
Game1.pressActionButton(Game1.input.GetKeyboardState(), Game1.input.GetMouseState(), Game1.input.GetGamePadState()); {
} string toSpeak = $"You have {CurrentPlayer.getMoney()}g";
ScreenReader.say(toSpeak, true);
}
if (Equals(e.Button, SButton.L)) // Narrate time and season
{ if (Equals(e.Button, SButton.Q))
Game1.pressUseToolButton(); {
} string toSpeak = $"Time is {CurrentPlayer.getTimeOfDay()} and season is {CurrentPlayer.getSeason()}";
ScreenReader.say(toSpeak, true);
}
if (Equals(e.Button, SButton.J))
{
Game1.pressActionButton(Game1.input.GetKeyboardState(), Game1.input.GetMouseState(), Game1.input.GetGamePadState());
}
if (Equals(e.Button, SButton.L))
{
Game1.pressUseToolButton();
} }
} }

View File

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