diff --git a/src/gui/dialogs/unit_list.cpp b/src/gui/dialogs/unit_list.cpp index 60cde6d8495e..b800be90510b 100644 --- a/src/gui/dialogs/unit_list.cpp +++ b/src/gui/dialogs/unit_list.cpp @@ -130,8 +130,13 @@ void unit_list::pre_show(window& window) row_data.emplace("unit_level", column); std::stringstream exp_str; - exp_str << font::span_color(unit->xp_color()) << unit->experience() << "/" - << (unit->can_advance() ? std::to_string(unit->max_experience()) : font::unicode_en_dash) << ""; + exp_str << font::span_color(unit->xp_color()); + if(unit->can_advance()) { + exp_str << unit->experience() << "/" << unit->max_experience(); + } else { + exp_str << font::unicode_en_dash; + } + exp_str << ""; column["label"] = exp_str.str(); row_data.emplace("unit_experience", column); diff --git a/src/gui/dialogs/unit_recall.cpp b/src/gui/dialogs/unit_recall.cpp index f24a28a68b93..0b82329908d6 100644 --- a/src/gui/dialogs/unit_recall.cpp +++ b/src/gui/dialogs/unit_recall.cpp @@ -208,8 +208,13 @@ void unit_recall::pre_show(window& window) row_data.emplace("unit_level", column); std::stringstream exp_str; - exp_str << font::span_color(unit->xp_color()) << unit->experience() << "/" - << (unit->can_advance() ? std::to_string(unit->max_experience()) : font::unicode_en_dash) << ""; + exp_str << font::span_color(unit->xp_color()); + if(unit->can_advance()) { + exp_str << unit->experience() << "/" << unit->max_experience(); + } else { + exp_str << font::unicode_en_dash; + } + exp_str << ""; column["label"] = exp_str.str(); row_data.emplace("unit_experience", column); diff --git a/src/gui/widgets/unit_preview_pane.cpp b/src/gui/widgets/unit_preview_pane.cpp index 42cb83522c4e..8227f3ccfda4 100644 --- a/src/gui/widgets/unit_preview_pane.cpp +++ b/src/gui/widgets/unit_preview_pane.cpp @@ -460,8 +460,13 @@ void unit_preview_pane::set_displayed_unit(const unit& u) str << font::span_color(u.hp_color()) << _("HP: ") << u.hitpoints() << "/" << u.max_hitpoints() << "" << "\n"; - str << font::span_color(u.xp_color()) - << _("XP: ") << u.experience() << "/" << u.max_experience() << ""; + str << font::span_color(u.xp_color()) << _("XP: "); + if(u.can_advance()) { + str << u.experience() << "/" << u.max_experience(); + } else { + str << font::unicode_en_dash; + } + str << ""; label_details_->set_label(str.str()); label_details_->set_use_markup(true); @@ -469,6 +474,7 @@ void unit_preview_pane::set_displayed_unit(const unit& u) if(tree_details_) { tree_details_->clear(); + const std::string unit_xp = u.can_advance() ? (formatter() << u.experience() << "/" << u.max_experience()).str() : font::unicode_en_dash; tree_details_->add_node("hp_xp_mp", { { "hp",{ { "label", (formatter() << "" << font::span_color(u.hp_color()) << "" << _("HP: ") << "" << u.hitpoints() << "/" << u.max_hitpoints() << "" << " | ").str() }, @@ -476,7 +482,7 @@ void unit_preview_pane::set_displayed_unit(const unit& u) { "tooltip", get_hp_tooltip(u.get_base_resistances(), [&u](const std::string& dt, bool is_attacker) { return u.resistance_against(dt, is_attacker, u.get_location()); }) } } }, { "xp",{ - { "label", (formatter() << "" << font::span_color(u.xp_color()) << "" << _("XP: ") << "" << u.experience() << "/" << u.max_experience() << "" << " | ").str() }, + { "label", (formatter() << "" << font::span_color(u.xp_color()) << "" << _("XP: ") << "" << unit_xp << "" << " | ").str() }, { "use_markup", "true" }, { "tooltip", (formatter() << _("Experience Modifier: ") << unit_experience_accelerator::get_acceleration() << '%').str() } } }, diff --git a/src/reports.cpp b/src/reports.cpp index 612080d3f5a0..d7570344ff47 100644 --- a/src/reports.cpp +++ b/src/reports.cpp @@ -468,8 +468,13 @@ static config unit_xp(const unit* u) { if (!u) return config(); std::ostringstream str, tooltip; - str << span_color(u->xp_color()) << u->experience() - << '/' << u->max_experience() << naps; + str << span_color(u->xp_color()); + if(u->can_advance()) { + str << u->experience() << '/' << u->max_experience(); + } else { + str << font::unicode_en_dash; + } + str << naps; int exp_mod = unit_experience_accelerator::get_acceleration(); tooltip << _("Experience Modifier: ") << exp_mod << '%';