Skip to content

Commit

Permalink
gui2: indicate that unit cannot advance
Browse files Browse the repository at this point in the history
  • Loading branch information
hryniuk authored and jyrkive committed Sep 13, 2018
1 parent 2095df5 commit cef774d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
9 changes: 7 additions & 2 deletions src/gui/dialogs/unit_list.cpp
Expand Up @@ -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) << "</span>";
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 << "</span>";

column["label"] = exp_str.str();
row_data.emplace("unit_experience", column);
Expand Down
9 changes: 7 additions & 2 deletions src/gui/dialogs/unit_recall.cpp
Expand Up @@ -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) << "</span>";
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 << "</span>";

column["label"] = exp_str.str();
row_data.emplace("unit_experience", column);
Expand Down
12 changes: 9 additions & 3 deletions src/gui/widgets/unit_preview_pane.cpp
Expand Up @@ -460,23 +460,29 @@ void unit_preview_pane::set_displayed_unit(const unit& u)
str << font::span_color(u.hp_color())
<< _("HP: ") << u.hitpoints() << "/" << u.max_hitpoints() << "</span>" << "\n";

str << font::span_color(u.xp_color())
<< _("XP: ") << u.experience() << "/" << u.max_experience() << "</span>";
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 << "</span>";

label_details_->set_label(str.str());
label_details_->set_use_markup(true);
}

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() << "<small>" << font::span_color(u.hp_color()) << "<b>" << _("HP: ") << "</b>" << u.hitpoints() << "/" << u.max_hitpoints() << "</span>" << " | </small>").str() },
{ "use_markup", "true" },
{ "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() << "<small>" << font::span_color(u.xp_color()) << "<b>" << _("XP: ") << "</b>" << u.experience() << "/" << u.max_experience() << "</span>" << " | </small>").str() },
{ "label", (formatter() << "<small>" << font::span_color(u.xp_color()) << "<b>" << _("XP: ") << "</b>" << unit_xp << "</span>" << " | </small>").str() },
{ "use_markup", "true" },
{ "tooltip", (formatter() << _("Experience Modifier: ") << unit_experience_accelerator::get_acceleration() << '%').str() }
} },
Expand Down
9 changes: 7 additions & 2 deletions src/reports.cpp
Expand Up @@ -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 << '%';
Expand Down

0 comments on commit cef774d

Please sign in to comment.