Issue#25 Added command to toggle speaking in percentage for health n stamina

master
Mohammad Shoaib Khan 2022-08-13 13:06:24 +05:30
parent 949e5c5bfc
commit 408a40121d
17 changed files with 85 additions and 25 deletions

View File

@ -494,6 +494,14 @@ namespace stardew_access
MainClass.DebugLog("Static tiles refreshed!"); MainClass.DebugLog("Static tiles refreshed!");
}); });
helper.ConsoleCommands.Add("hnspercent", "Toggle between speaking in percentage or full health and stamina.", (string commmand, string[] args) =>
{
MainClass.Config.HealthNStaminaInPercentage = !MainClass.Config.HealthNStaminaInPercentage;
helper.WriteConfig(MainClass.Config);
MainClass.DebugLog("Speaking in percentage is " + (MainClass.Config.HealthNStaminaInPercentage ? "on" : "off"));
});
} }
} }
} }

View File

@ -9,37 +9,56 @@ namespace stardew_access.Features
/// <summary> /// <summary>
/// Returns the percentage health remaining of player. /// Returns the percentage health remaining of player.
/// </summary> /// </summary>
public static int Health public static int PercentHealth
{ {
get get
{ {
if (Game1.player == null) if (Game1.player == null)
return 0; return 0;
int maxHealth = Game1.player.maxHealth; return (CurrentHealth * 100) / Game1.player.maxHealth; ;
int currentHealth = Game1.player.health; }
}
int healthPercentage = (int)(currentHealth * 100) / maxHealth; /// <summary>
return healthPercentage; /// Returns the total health player has currently
/// </summary>
public static int CurrentHealth
{
get
{
if (Game1.player == null)
return 0;
return Game1.player.health;
} }
} }
/// <summary> /// <summary>
/// Returns the percentage stamine/energy remaining of player. /// Returns the percentage stamine/energy remaining of player.
/// </summary> /// </summary>
public static int Stamina public static int PercentStamina
{ {
get get
{ {
if (Game1.player == null) if (Game1.player == null)
return 0; return 0;
int maxStamina = Game1.player.maxStamina.Value; return (CurrentStamina * 100) / Game1.player.maxStamina.Value;
int currentStamine = (int)Game1.player.stamina; }
}
int staminaPercentage = (int)(currentStamine * 100) / maxStamina; /// <summary>
/// Returns the total stamina player has currently
/// </summary>
public static int CurrentStamina
{
get
{
if (Game1.player == null)
return 0;
return staminaPercentage; return (int)Game1.player.stamina;
} }
} }

View File

@ -53,7 +53,7 @@ namespace stardew_access.Features
if (MainClass.ModHelper == null) if (MainClass.ModHelper == null)
return; return;
int stamina = CurrentPlayer.Stamina; int stamina = CurrentPlayer.PercentStamina;
string toSpeak = MainClass.ModHelper.Translation.Get("warnings.stamina", new { value = stamina }); string toSpeak = MainClass.ModHelper.Translation.Get("warnings.stamina", new { value = stamina });
if ((stamina <= 50 && prevStamina > 50) || (stamina <= 25 && prevStamina > 25) || (stamina <= 10 && prevStamina > 10)) if ((stamina <= 50 && prevStamina > 50) || (stamina <= 25 && prevStamina > 25) || (stamina <= 10 && prevStamina > 10))
@ -74,7 +74,7 @@ namespace stardew_access.Features
if (MainClass.ModHelper == null) if (MainClass.ModHelper == null)
return; return;
int health = CurrentPlayer.Health; int health = CurrentPlayer.PercentHealth;
string toSpeak = MainClass.ModHelper.Translation.Get("warnings.health", new { value = health }); string toSpeak = MainClass.ModHelper.Translation.Get("warnings.health", new { value = health });
if ((health <= 50 && prevHealth > 50) || (health <= 25 && prevHealth > 25) || (health <= 10 && prevHealth > 10)) if ((health <= 50 && prevHealth > 50) || (health <= 25 && prevHealth > 25) || (health <= 10 && prevHealth > 10))

View File

@ -69,6 +69,7 @@ namespace stardew_access
#region Others #region Others
public KeybindList HealthNStaminaKey { get; set; } = KeybindList.Parse("H"); // Narrate health and stamina. public KeybindList HealthNStaminaKey { get; set; } = KeybindList.Parse("H"); // Narrate health and stamina.
public bool HealthNStaminaInPercentage { get; set; } = true;
public KeybindList PositionKey { get; set; } = KeybindList.Parse("K"); // Narrate player position. public KeybindList PositionKey { get; set; } = KeybindList.Parse("K"); // Narrate player position.
public KeybindList LocationKey { get; set; } = KeybindList.Parse("LeftAlt + K"); // Narrate current location name. public KeybindList LocationKey { get; set; } = KeybindList.Parse("LeftAlt + K"); // Narrate current location name.
public KeybindList MoneyKey { get; set; } = KeybindList.Parse("R"); // Narrate the money the player has currently. public KeybindList MoneyKey { get; set; } = KeybindList.Parse("R"); // Narrate the money the player has currently.

View File

@ -289,7 +289,15 @@ namespace stardew_access
// Narrate health and stamina // Narrate health and stamina
if (Config.HealthNStaminaKey.JustPressed()) if (Config.HealthNStaminaKey.JustPressed())
{ {
string toSpeak = $"Health is {CurrentPlayer.Health} and Stamina is {CurrentPlayer.Stamina}"; if (ModHelper == null)
return;
string toSpeak;
if (Config.HealthNStaminaInPercentage)
toSpeak = ModHelper.Translation.Get("manuallytriggered.healthnstamina.percent", new { health = CurrentPlayer.PercentHealth, stamina = CurrentPlayer.PercentStamina });
else
toSpeak = ModHelper.Translation.Get("manuallytriggered.healthnstamina.normal", new { health = CurrentPlayer.CurrentHealth, stamina = CurrentPlayer.CurrentStamina });
MainClass.ScreenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
return; return;
} }

View File

@ -8,5 +8,7 @@
"grandpastory.scene6":"Du erreichst deinen Schreibtisch und findest Opas Brief.", "grandpastory.scene6":"Du erreichst deinen Schreibtisch und findest Opas Brief.",
"grandpastory.letteropen":"Linksklick, um Opas Brief zu öffnen", "grandpastory.letteropen":"Linksklick, um Opas Brief zu öffnen",
"intro.scene3":"Fahrt zur Bushaltestelle Stardew Valley", "intro.scene3":"Fahrt zur Bushaltestelle Stardew Valley",
"intro.scene4":"Stardew Valley 0.5 Meilen entfernt" "intro.scene4":"Stardew Valley 0.5 Meilen entfernt",
"manuallytriggered.healthnstamina.percent":"Gesundheit ist {{health}} % und Ausdauer ist {{stamina}} %",
"manuallytriggered.healthnstamina.normal":"Gesundheit ist {{health}} und Ausdauer ist {{stamina}}"
} }

View File

@ -8,5 +8,7 @@
"grandpastory.scene6":"You reach your desk finding grandpa's letter.", "grandpastory.scene6":"You reach your desk finding grandpa's letter.",
"grandpastory.letteropen":"Left click to open grandpa's letter", "grandpastory.letteropen":"Left click to open grandpa's letter",
"intro.scene3":"Travelling to Stardew Valley bus stop", "intro.scene3":"Travelling to Stardew Valley bus stop",
"intro.scene4":"Stardew valley 0.5 miles away" "intro.scene4":"Stardew valley 0.5 miles away",
"manuallytriggered.healthnstamina.percent":"Health is {{health}} % and Stamina is {{stamina}} %",
"manuallytriggered.healthnstamina.normal":"Health is {{health}} and Stamina is {{stamina}}"
} }

View File

@ -8,5 +8,7 @@
"grandpastory.scene6":"Llegas a tu escritorio y encuentras la carta del abuelo.", "grandpastory.scene6":"Llegas a tu escritorio y encuentras la carta del abuelo.",
"grandpastory.letteropen":"Haz clic izquierdo para abrir la carta del abuelo.", "grandpastory.letteropen":"Haz clic izquierdo para abrir la carta del abuelo.",
"intro.scene3":"Viajando a la parada de autobús de Stardew Valley", "intro.scene3":"Viajando a la parada de autobús de Stardew Valley",
"intro.scene4":"Valle de Stardew a 0.5 millas de distancia" "intro.scene4":"Valle de Stardew a 0.5 millas de distancia",
"manuallytriggered.healthnstamina.percent":"La salud es {{health}} % y la resistencia es {{stamina}} %",
"manuallytriggered.healthnstamina.normal":"La salud es {{health}} y la resistencia es {{stamina}}"
} }

View File

@ -8,5 +8,7 @@
"grandpastory.scene6":"Vous atteignez votre bureau en trouvant la lettre de grand-père.", "grandpastory.scene6":"Vous atteignez votre bureau en trouvant la lettre de grand-père.",
"grandpastory.letteropen":"Clic gauche pour ouvrir la lettre de grand-père", "grandpastory.letteropen":"Clic gauche pour ouvrir la lettre de grand-père",
"intro.scene3":"Se rendre à l'arrêt de bus Stardew Valley", "intro.scene3":"Se rendre à l'arrêt de bus Stardew Valley",
"intro.scene4":"Vallée de Stardew à 0.5 miles" "intro.scene4":"Vallée de Stardew à 0.5 miles",
"manuallytriggered.healthnstamina.percent":"La santé est de {{health}} % et l'endurance est de {{stamina}} %",
"manuallytriggered.healthnstamina.normal":"La santé est {{health}} et l'endurance est {{stamina}}"
} }

View File

@ -8,5 +8,7 @@
"grandpastory.scene6":"Az asztalodhoz érve megtalálod a nagypapa levelét.", "grandpastory.scene6":"Az asztalodhoz érve megtalálod a nagypapa levelét.",
"grandpastory.letteropen":"Kattintson a bal gombbal a nagypapa levelének megnyitásához", "grandpastory.letteropen":"Kattintson a bal gombbal a nagypapa levelének megnyitásához",
"intro.scene3":"Utazás a Stardew Valley buszmegállóhoz", "intro.scene3":"Utazás a Stardew Valley buszmegállóhoz",
"intro.scene4":"Stardew-völgy 0.5 mérföldre van" "intro.scene4":"Stardew-völgy 0.5 mérföldre van",
"manuallytriggered.healthnstamina.percent":"Az egészségi állapot {{health}} %, az állóképesség pedig {{stamina}} %",
"manuallytriggered.healthnstamina.normal":"Az egészség {{health}}, az állóképesség pedig {{stamina}}"
} }

View File

@ -8,5 +8,7 @@
"grandpastory.scene6":"Raggiungi la tua scrivania e trovi la lettera del nonno.", "grandpastory.scene6":"Raggiungi la tua scrivania e trovi la lettera del nonno.",
"grandpastory.letteropen":"Fare clic con il tasto sinistro per aprire la lettera del nonno", "grandpastory.letteropen":"Fare clic con il tasto sinistro per aprire la lettera del nonno",
"intro.scene3":"In viaggio verso la fermata dell'autobus di Stardew Valley", "intro.scene3":"In viaggio verso la fermata dell'autobus di Stardew Valley",
"intro.scene4":"Stardew Valley 0.5 miglia di distanza" "intro.scene4":"Stardew Valley 0.5 miglia di distanza",
"manuallytriggered.healthnstamina.percent":"La salute è {{health}} % e la resistenza è {{stamina}} %",
"manuallytriggered.healthnstamina.normal":"La salute è {{health}} e la resistenza è {{stamina}}"
} }

View File

@ -8,5 +8,7 @@
"grandpastory.scene6":"おじいちゃんの手紙を見つけて机に着きます。", "grandpastory.scene6":"おじいちゃんの手紙を見つけて机に着きます。",
"grandpastory.letteropen":"左クリックしておじいちゃんの手紙を開く", "grandpastory.letteropen":"左クリックしておじいちゃんの手紙を開く",
"intro.scene3":"スターデューバレーバス停への移動", "intro.scene3":"スターデューバレーバス停への移動",
"intro.scene4":"0.5マイル離れたスターデューバレー" "intro.scene4":"0.5マイル離れたスターデューバレー",
"manuallytriggered.healthnstamina.percent":"体力は {{health}} %、スタミナは {{stamina}} %",
"manuallytriggered.healthnstamina.normal":"体力は{{health}}、スタミナは{{stamina}}です"
} }

View File

@ -8,5 +8,7 @@
"grandpastory.scene6":"책상에 다가가 할아버지의 편지를 찾습니다.", "grandpastory.scene6":"책상에 다가가 할아버지의 편지를 찾습니다.",
"grandpastory.letteropen":"할아버지의 편지를 열려면 왼쪽 클릭", "grandpastory.letteropen":"할아버지의 편지를 열려면 왼쪽 클릭",
"intro.scene3":"스타듀밸리 버스정류장으로 이동", "intro.scene3":"스타듀밸리 버스정류장으로 이동",
"intro.scene4":"스타듀 밸리에서 0.8km 떨어짐" "intro.scene4":"스타듀 밸리에서 0.8km 떨어짐",
"manuallytriggered.healthnstamina.percent":"체력은 {{health}} %이고 체력은 {{stamina}} %입니다.",
"manuallytriggered.healthnstamina.normal":"체력은 {{health}}이고 체력은 {{stamina}}입니다."
} }

View File

@ -8,5 +8,7 @@
"grandpastory.scene6":"Você chega à sua mesa encontrando a carta do vovô.", "grandpastory.scene6":"Você chega à sua mesa encontrando a carta do vovô.",
"grandpastory.letteropen":"Clique com o botão esquerdo para abrir a carta do vovô", "grandpastory.letteropen":"Clique com o botão esquerdo para abrir a carta do vovô",
"intro.scene3":"Viajar para o ponto de ônibus Stardew Valley", "intro.scene3":"Viajar para o ponto de ônibus Stardew Valley",
"intro.scene4":"Vale Stardew a 0.5 km de distância" "intro.scene4":"Vale Stardew a 0.5 km de distância",
"manuallytriggered.healthnstamina.percent":"Saúde é {{health}} % e Stamina é {{stamina}} %",
"manuallytriggered.healthnstamina.normal":"Saúde é {{health}} e Stamina é {{stamina}}"
} }

View File

@ -8,5 +8,7 @@
"grandpastory.scene6":"Вы подходите к своему столу и находите дедушкино письмо.", "grandpastory.scene6":"Вы подходите к своему столу и находите дедушкино письмо.",
"grandpastory.letteropen":"Щелкните левой кнопкой мыши, чтобы открыть письмо дедушки", "grandpastory.letteropen":"Щелкните левой кнопкой мыши, чтобы открыть письмо дедушки",
"intro.scene3":"Поездка на автобусную остановку Stardew Valley", "intro.scene3":"Поездка на автобусную остановку Stardew Valley",
"intro.scene4":"Долина Стардью: 0.8 км" "intro.scene4":"Долина Стардью: 0.8 км",
"manuallytriggered.healthnstamina.percent":"Здоровье составляет {{health}}%, а выносливость - {{stamina}}%",
"manuallytriggered.healthnstamina.normal":"Здоровье – {{health}}, а выносливость – {{stamina}}."
} }

View File

@ -8,5 +8,7 @@
"grandpastory.scene6":"Dedenizin mektubunu bulmak için masanıza ulaşıyorsunuz.", "grandpastory.scene6":"Dedenizin mektubunu bulmak için masanıza ulaşıyorsunuz.",
"grandpastory.letteropen":"Büyükbabanın mektubunu açmak için sol tıklayın", "grandpastory.letteropen":"Büyükbabanın mektubunu açmak için sol tıklayın",
"intro.scene3":"Stardew Valley otobüs durağına seyahat", "intro.scene3":"Stardew Valley otobüs durağına seyahat",
"intro.scene4":"Stardew vadisi 0.5 mil uzakta" "intro.scene4":"Stardew vadisi 0.5 mil uzakta",
"manuallytriggered.healthnstamina.percent":"Sağlık %{{health}} ve Dayanıklılık %{{stamina}}",
"manuallytriggered.healthnstamina.normal":"Sağlık {{health}} ve Dayanıklılık {{stamina}}"
} }

View File

@ -8,5 +8,7 @@
"grandpastory.scene6":"你走到办公桌前,找到了爷爷的信。", "grandpastory.scene6":"你走到办公桌前,找到了爷爷的信。",
"grandpastory.letteropen":"左方括号打开爷爷的信", "grandpastory.letteropen":"左方括号打开爷爷的信",
"intro.scene3":"前往星露谷物语巴士站", "intro.scene3":"前往星露谷物语巴士站",
"intro.scene4":"星露谷物语 0.5 英里外" "intro.scene4":"星露谷物语 0.5 英里外",
"manuallytriggered.healthnstamina.percent":"健康为 {{health}} %,耐力为 {{stamina}} %",
"manuallytriggered.healthnstamina.normal":"健康为 {{health}},耐力为 {{stamina}}"
} }