diff --git a/stardew-access/CustomCommands.cs b/stardew-access/CustomCommands.cs index 026a193..9f28d13 100644 --- a/stardew-access/CustomCommands.cs +++ b/stardew-access/CustomCommands.cs @@ -494,6 +494,14 @@ namespace stardew_access 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")); + }); } } } diff --git a/stardew-access/Features/CurrentPlayer.cs b/stardew-access/Features/CurrentPlayer.cs index 5331576..9424ea9 100644 --- a/stardew-access/Features/CurrentPlayer.cs +++ b/stardew-access/Features/CurrentPlayer.cs @@ -9,37 +9,56 @@ namespace stardew_access.Features /// /// Returns the percentage health remaining of player. /// - public static int Health + public static int PercentHealth { get { if (Game1.player == null) return 0; - int maxHealth = Game1.player.maxHealth; - int currentHealth = Game1.player.health; + return (CurrentHealth * 100) / Game1.player.maxHealth; ; + } + } - int healthPercentage = (int)(currentHealth * 100) / maxHealth; - return healthPercentage; + /// + /// Returns the total health player has currently + /// + public static int CurrentHealth + { + get + { + if (Game1.player == null) + return 0; + + return Game1.player.health; } } /// /// Returns the percentage stamine/energy remaining of player. /// - public static int Stamina + public static int PercentStamina { get { if (Game1.player == null) return 0; - int maxStamina = Game1.player.maxStamina.Value; - int currentStamine = (int)Game1.player.stamina; + return (CurrentStamina * 100) / Game1.player.maxStamina.Value; + } + } - int staminaPercentage = (int)(currentStamine * 100) / maxStamina; + /// + /// Returns the total stamina player has currently + /// + public static int CurrentStamina + { + get + { + if (Game1.player == null) + return 0; - return staminaPercentage; + return (int)Game1.player.stamina; } } diff --git a/stardew-access/Features/Warnings.cs b/stardew-access/Features/Warnings.cs index 328f78d..a43f151 100644 --- a/stardew-access/Features/Warnings.cs +++ b/stardew-access/Features/Warnings.cs @@ -53,7 +53,7 @@ namespace stardew_access.Features if (MainClass.ModHelper == null) return; - int stamina = CurrentPlayer.Stamina; + int stamina = CurrentPlayer.PercentStamina; string toSpeak = MainClass.ModHelper.Translation.Get("warnings.stamina", new { value = stamina }); 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) return; - int health = CurrentPlayer.Health; + int health = CurrentPlayer.PercentHealth; string toSpeak = MainClass.ModHelper.Translation.Get("warnings.health", new { value = health }); if ((health <= 50 && prevHealth > 50) || (health <= 25 && prevHealth > 25) || (health <= 10 && prevHealth > 10)) diff --git a/stardew-access/ModConfig.cs b/stardew-access/ModConfig.cs index d323e27..c77e9df 100644 --- a/stardew-access/ModConfig.cs +++ b/stardew-access/ModConfig.cs @@ -69,6 +69,7 @@ namespace stardew_access #region Others 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 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. diff --git a/stardew-access/ModEntry.cs b/stardew-access/ModEntry.cs index f564ed6..f9de5d3 100644 --- a/stardew-access/ModEntry.cs +++ b/stardew-access/ModEntry.cs @@ -289,7 +289,15 @@ namespace stardew_access // Narrate health and stamina 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); return; } diff --git a/stardew-access/i18n/de.json b/stardew-access/i18n/de.json index 8c66154..6887ac2 100644 --- a/stardew-access/i18n/de.json +++ b/stardew-access/i18n/de.json @@ -8,5 +8,7 @@ "grandpastory.scene6":"Du erreichst deinen Schreibtisch und findest Opas Brief.", "grandpastory.letteropen":"Linksklick, um Opas Brief zu öffnen", "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}}" } \ No newline at end of file diff --git a/stardew-access/i18n/default.json b/stardew-access/i18n/default.json index cf1b780..6eb682c 100644 --- a/stardew-access/i18n/default.json +++ b/stardew-access/i18n/default.json @@ -8,5 +8,7 @@ "grandpastory.scene6":"You reach your desk finding grandpa's letter.", "grandpastory.letteropen":"Left click to open grandpa's letter", "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}}" } \ No newline at end of file diff --git a/stardew-access/i18n/es.json b/stardew-access/i18n/es.json index 2c0a7fb..9c4b92f 100644 --- a/stardew-access/i18n/es.json +++ b/stardew-access/i18n/es.json @@ -8,5 +8,7 @@ "grandpastory.scene6":"Llegas a tu escritorio y encuentras 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.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}}" } \ No newline at end of file diff --git a/stardew-access/i18n/fr.json b/stardew-access/i18n/fr.json index ad36680..4bdac41 100644 --- a/stardew-access/i18n/fr.json +++ b/stardew-access/i18n/fr.json @@ -8,5 +8,7 @@ "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", "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}}" } \ No newline at end of file diff --git a/stardew-access/i18n/hu.json b/stardew-access/i18n/hu.json index 8421e95..4873aa1 100644 --- a/stardew-access/i18n/hu.json +++ b/stardew-access/i18n/hu.json @@ -8,5 +8,7 @@ "grandpastory.scene6":"Az asztalodhoz érve megtalálod a nagypapa levelét.", "grandpastory.letteropen":"Kattintson a bal gombbal a nagypapa levelének megnyitásá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}}" } \ No newline at end of file diff --git a/stardew-access/i18n/it.json b/stardew-access/i18n/it.json index 1b54896..46f6f7d 100644 --- a/stardew-access/i18n/it.json +++ b/stardew-access/i18n/it.json @@ -8,5 +8,7 @@ "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", "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}}" } \ No newline at end of file diff --git a/stardew-access/i18n/ja.json b/stardew-access/i18n/ja.json index c667345..4a8fcee 100644 --- a/stardew-access/i18n/ja.json +++ b/stardew-access/i18n/ja.json @@ -8,5 +8,7 @@ "grandpastory.scene6":"おじいちゃんの手紙を見つけて机に着きます。", "grandpastory.letteropen":"左クリックしておじいちゃんの手紙を開く", "intro.scene3":"スターデューバレーバス停への移動", - "intro.scene4":"0.5マイル離れたスターデューバレー" + "intro.scene4":"0.5マイル離れたスターデューバレー", + "manuallytriggered.healthnstamina.percent":"体力は {{health}} %、スタミナは {{stamina}} %", + "manuallytriggered.healthnstamina.normal":"体力は{{health}}、スタミナは{{stamina}}です" } \ No newline at end of file diff --git a/stardew-access/i18n/ko.json b/stardew-access/i18n/ko.json index 2261eb5..fc6c953 100644 --- a/stardew-access/i18n/ko.json +++ b/stardew-access/i18n/ko.json @@ -8,5 +8,7 @@ "grandpastory.scene6":"책상에 다가가 할아버지의 편지를 찾습니다.", "grandpastory.letteropen":"할아버지의 편지를 열려면 왼쪽 클릭", "intro.scene3":"스타듀밸리 버스정류장으로 이동", - "intro.scene4":"스타듀 밸리에서 0.8km 떨어짐" + "intro.scene4":"스타듀 밸리에서 0.8km 떨어짐", + "manuallytriggered.healthnstamina.percent":"체력은 {{health}} %이고 체력은 {{stamina}} %입니다.", + "manuallytriggered.healthnstamina.normal":"체력은 {{health}}이고 체력은 {{stamina}}입니다." } \ No newline at end of file diff --git a/stardew-access/i18n/pt.json b/stardew-access/i18n/pt.json index edd1ed5..737798c 100644 --- a/stardew-access/i18n/pt.json +++ b/stardew-access/i18n/pt.json @@ -8,5 +8,7 @@ "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ô", "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}}" } \ No newline at end of file diff --git a/stardew-access/i18n/ru.json b/stardew-access/i18n/ru.json index 61b2023..149503f 100644 --- a/stardew-access/i18n/ru.json +++ b/stardew-access/i18n/ru.json @@ -8,5 +8,7 @@ "grandpastory.scene6":"Вы подходите к своему столу и находите дедушкино письмо.", "grandpastory.letteropen":"Щелкните левой кнопкой мыши, чтобы открыть письмо дедушки", "intro.scene3":"Поездка на автобусную остановку Stardew Valley", - "intro.scene4":"Долина Стардью: 0.8 км" + "intro.scene4":"Долина Стардью: 0.8 км", + "manuallytriggered.healthnstamina.percent":"Здоровье составляет {{health}}%, а выносливость - {{stamina}}%", + "manuallytriggered.healthnstamina.normal":"Здоровье – {{health}}, а выносливость – {{stamina}}." } \ No newline at end of file diff --git a/stardew-access/i18n/tr.json b/stardew-access/i18n/tr.json index ebcdb31..db02ffd 100644 --- a/stardew-access/i18n/tr.json +++ b/stardew-access/i18n/tr.json @@ -8,5 +8,7 @@ "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", "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}}" } \ No newline at end of file diff --git a/stardew-access/i18n/zh.json b/stardew-access/i18n/zh.json index 49037b9..0d42090 100644 --- a/stardew-access/i18n/zh.json +++ b/stardew-access/i18n/zh.json @@ -8,5 +8,7 @@ "grandpastory.scene6":"你走到办公桌前,找到了爷爷的信。", "grandpastory.letteropen":"左方括号打开爷爷的信", "intro.scene3":"前往星露谷物语巴士站", - "intro.scene4":"星露谷物语 0.5 英里外" + "intro.scene4":"星露谷物语 0.5 英里外", + "manuallytriggered.healthnstamina.percent":"健康为 {{health}} %,耐力为 {{stamina}} %", + "manuallytriggered.healthnstamina.normal":"健康为 {{health}},耐力为 {{stamina}}" }