From 1d65b58e459e900dd2c6647f611b63f06fbffeb6 Mon Sep 17 00:00:00 2001 From: Ouaz Date: Tue, 30 Jan 2024 20:52:52 +0100 Subject: [PATCH] Show exact values in health overlay tooltips --- src/translation/english.c | 22 ++++++++++---------- src/widget/city_overlay_health.c | 35 +++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/src/translation/english.c b/src/translation/english.c index 22844fc7df..e2905e074a 100644 --- a/src/translation/english.c +++ b/src/translation/english.c @@ -797,17 +797,17 @@ static translation_string all_strings[] = { {TR_ADVISOR_SICKNESS_LEVEL_HIGH, "Infectious diseases spread in areas of the city having a poor level of hygiene. If the situation is not remedied soon, some buildings may be quarantined. Greater access to healthcare would effectively prevent epidemics from breaking out."}, {TR_ADVISOR_SICKNESS_LEVEL_PLAGUE, "The plague has come to some unhealthy areas in the city! Buildings have been quarantined or burned to prevent the further spread of disease. Doctors and surgeons have been requisitioned to decontaminate the afflicted places."}, {TR_TOOLTIP_OVERLAY_HEALTH_NONE, "No citizen lives here yet"}, - {TR_TOOLTIP_OVERLAY_HEALTH_0, "Health in this house is appalling (0-9)"}, - {TR_TOOLTIP_OVERLAY_HEALTH_1, "Health in this house is terrible (10-19)"}, - {TR_TOOLTIP_OVERLAY_HEALTH_2, "Health in this house is bad (20-29)"}, - {TR_TOOLTIP_OVERLAY_HEALTH_3, "Health in this house is poor (30-39)"}, - {TR_TOOLTIP_OVERLAY_HEALTH_4, "Health in this house is below average (40-49)"}, - {TR_TOOLTIP_OVERLAY_HEALTH_5, "Health in this house is average (50-59)"}, - {TR_TOOLTIP_OVERLAY_HEALTH_6, "Health in this house is good (60-69)"}, - {TR_TOOLTIP_OVERLAY_HEALTH_7, "Health in this house is very good (70-79)"}, - {TR_TOOLTIP_OVERLAY_HEALTH_8, "Health in this house is excellent (80-89)"}, - {TR_TOOLTIP_OVERLAY_HEALTH_9, "Health in this house is almost perfect (90-99)"}, - {TR_TOOLTIP_OVERLAY_HEALTH_10, "Health in this house is perfect (100)"}, + {TR_TOOLTIP_OVERLAY_HEALTH_0, " : Health in this house is appalling"}, + {TR_TOOLTIP_OVERLAY_HEALTH_1, " : Health in this house is terrible"}, + {TR_TOOLTIP_OVERLAY_HEALTH_2, " : Health in this house is bad"}, + {TR_TOOLTIP_OVERLAY_HEALTH_3, " : Health in this house is poor"}, + {TR_TOOLTIP_OVERLAY_HEALTH_4, " : Health in this house is below average"}, + {TR_TOOLTIP_OVERLAY_HEALTH_5, " : Health in this house is average"}, + {TR_TOOLTIP_OVERLAY_HEALTH_6, " : Health in this house is good"}, + {TR_TOOLTIP_OVERLAY_HEALTH_7, " : Health in this house is very good"}, + {TR_TOOLTIP_OVERLAY_HEALTH_8, " : Health in this house is excellent"}, + {TR_TOOLTIP_OVERLAY_HEALTH_9, " : Health in this house is almost perfect"}, + {TR_TOOLTIP_OVERLAY_HEALTH_10, " : Health in this house is perfect"}, {TR_TOOLTIP_OVERLAY_SICKNESS_NONE, "No disease"}, {TR_TOOLTIP_OVERLAY_SICKNESS_LOW, "Very few diseases"}, {TR_TOOLTIP_OVERLAY_SICKNESS_MEDIUM, "A few infectious diseases"}, diff --git a/src/widget/city_overlay_health.c b/src/widget/city_overlay_health.c index 7a81d44e6f..2b148ec7d3 100644 --- a/src/widget/city_overlay_health.c +++ b/src/widget/city_overlay_health.c @@ -127,34 +127,67 @@ static int get_tooltip_health(tooltip_context *c, const building *b) if (b->house_population < 1 && house_health < 1) { c->translation_key = TR_TOOLTIP_OVERLAY_HEALTH_NONE; } else if (b->house_population >= 1 && house_health < 10) { + c->has_numeric_prefix = 1; + c->numeric_prefix = house_health; c->translation_key = TR_TOOLTIP_OVERLAY_HEALTH_0; + return 1; } else if (house_health < 20) { + c->has_numeric_prefix = 1; + c->numeric_prefix = house_health; c->translation_key = TR_TOOLTIP_OVERLAY_HEALTH_1; + return 1; } else if (house_health < 30) { + c->has_numeric_prefix = 1; + c->numeric_prefix = house_health; c->translation_key = TR_TOOLTIP_OVERLAY_HEALTH_2; + return 1; } else { + c->has_numeric_prefix = 1; + c->numeric_prefix = house_health; c->translation_key = TR_TOOLTIP_OVERLAY_HEALTH_3; + return 1; } } else if (house_health < 60) { if (house_health < 50) { + c->has_numeric_prefix = 1; + c->numeric_prefix = house_health; c->translation_key = TR_TOOLTIP_OVERLAY_HEALTH_4; + return 1; } else { + c->has_numeric_prefix = 1; + c->numeric_prefix = house_health; c->translation_key = TR_TOOLTIP_OVERLAY_HEALTH_5; + return 1; } } else if (house_health < 80) { if (house_health < 70) { + c->has_numeric_prefix = 1; + c->numeric_prefix = house_health; c->translation_key = TR_TOOLTIP_OVERLAY_HEALTH_6; + return 1; } else { + c->has_numeric_prefix = 1; + c->numeric_prefix = house_health; c->translation_key = TR_TOOLTIP_OVERLAY_HEALTH_7; + return 1; } } else if (house_health < 100) { if (house_health < 90) { + c->has_numeric_prefix = 1; + c->numeric_prefix = house_health; c->translation_key = TR_TOOLTIP_OVERLAY_HEALTH_8; + return 1; } else { + c->has_numeric_prefix = 1; + c->numeric_prefix = house_health; c->translation_key = TR_TOOLTIP_OVERLAY_HEALTH_9; + return 1; } } else { - c->translation_key = TR_TOOLTIP_OVERLAY_HEALTH_10; + c->has_numeric_prefix = 1; + c->numeric_prefix = house_health; + c->translation_key = TR_TOOLTIP_OVERLAY_HEALTH_10; + return 1; } } return 0;