diff --git a/client/text.cpp b/client/text.cpp index 9c153bd025..245fd393e5 100644 --- a/client/text.cpp +++ b/client/text.cpp @@ -1318,24 +1318,73 @@ const QString act_sel_action_tool_tip(const struct action *paction, } /** - Describing buildings that affect happiness. + * Describe buildings that affect happiness (or rather, anything with a + * Make_Content effect). */ QString text_happiness_buildings(const struct city *pcity) { - struct effect_list *plist = effect_list_new(); - QString effects; - QString str; + if (const auto effects = get_effects(EFT_MAKE_CONTENT); + effect_list_size(effects) == 0) { + effect_list_destroy(effects); + return QString(); // Disabled in the ruleset. + } - get_city_bonus_effects(plist, pcity, nullptr, EFT_MAKE_CONTENT); - if (0 < effect_list_size(plist)) { - effects = get_effect_list_req_text(plist); - str = QString(_("Buildings: %1.")).arg(effects); - } else { - str = _("Buildings: None."); + auto str = QStringLiteral("

"); + str += _("Infrastructure can have an effect on citizen happiness."); + str += QStringLiteral(" "); + + int bonus = get_city_bonus(pcity, EFT_MAKE_CONTENT); + if (bonus <= 0) { + // TRANS: Comes after "Infrastructure can have an effect on citizen + // happiness" + str += _("This city doesn't receive any such bonus."); + return str + QStringLiteral("

"); } - effect_list_destroy(plist); - return str.trimmed(); + // TRANS: Comes after "Infrastructure can have an effect on citizen + // happiness" + str += + QString( + PL_("In this city, it can make up to %1 citizen content.", + "In this city, it can make up to %1 citizens content.", + bonus)) + .arg(bonus); + + // Add a list of active effects + auto effects = effect_list_new(); + get_city_bonus_effects(effects, pcity, nullptr, EFT_MAKE_CONTENT); + + str += QStringLiteral("

"); + // TRANS: Precedes a list of active effects, pluralized on its length. + str += PL_( + "The following contribution is active:", + "The following contributions are active:", effect_list_size(effects)); + str += QStringLiteral("

    "); + + char help_text_buffer[MAX_LEN_PACKET]; + + effect_list_iterate(effects, peffect) + { + str += QStringLiteral("
  • "); + if (requirement_vector_size(&peffect->reqs) == 0) { + // TRANS: Describes an effect without requirements; %1 is its value + str += QString(_("%1 by default")) + .arg(effect_type_unit_text(peffect->type, peffect->value)); + } else { + help_text_buffer[0] = '\0'; + get_effect_req_text(peffect, help_text_buffer, + sizeof(help_text_buffer)); + // TRANS: Describes an effect; %1 is its value and %2 the requirements + str += QString(_("%1 from %2")) + .arg(effect_type_unit_text(peffect->type, peffect->value)) + .arg(help_text_buffer); + } + str += QStringLiteral("
  • "); + } + effect_list_iterate_end; + effect_list_destroy(effects); + + return str + QStringLiteral("

"); } /** @@ -1745,9 +1794,10 @@ QString text_happiness_luxuries(const struct city *pcity) } } else { str += - QString(PL_("All available luxury is used to %1 citizen happier.", - "All available luxury is used to %1 citizens happier.", - citizens_affected)) + QString( + PL_("All available luxury is used to make %1 citizen happier.", + "All available luxury is used to make %1 citizens happier.", + citizens_affected)) .arg(citizens_affected); }