Skip to content

Commit

Permalink
editor: Translate recruit list in tooltip (#3303)
Browse files Browse the repository at this point in the history
  • Loading branch information
jostephd committed Oct 16, 2019
1 parent 9f08efe commit c4c4543
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/editor/action/mouse/mouse_action_unit.cpp
Expand Up @@ -18,6 +18,7 @@
#include "editor/action/action_unit.hpp"

#include "editor/editor_display.hpp"
#include "formula/string_utils.hpp"
#include "gui/dialogs/unit_create.hpp"
#include "tooltips.hpp"
#include "gettext.hpp"
Expand Down Expand Up @@ -59,12 +60,21 @@ void mouse_action_unit::move(editor_display& disp, const map_location& hex)
rect.h = disp.hex_size();
rect.w = disp.hex_size();
std::stringstream str;
const auto& recruits = unit_it->recruits();
std::vector<t_string> recruit_type_names;
std::transform(recruits.begin(), recruits.end(), std::back_inserter(recruit_type_names),
[](const std::string& type_id) -> std::string {
const unit_type *new_unit_type = unit_types.find(type_id);
if(!new_unit_type) return VGETTEXT("(Unknown unit type: $type)", { { "type", type_id } });
return new_unit_type->type_name();
}
);
str << _("Identifier: ") << unit_it->id() << "\n"
<< _("Name: ") << unit_it->name() << "\n"
<< _("Type: ") << unit_it->type_name() << "\n"
<< _("Level: ") << unit_it->level() << "\n"
<< _("Cost: ") << unit_it->cost() << "\n"
<< _("Recruit: ") << utils::join(unit_it->recruits()) << "\n";
<< _("Recruit: ") << utils::join(recruit_type_names) << "\n";
tooltips::clear_tooltips();
tooltips::add_tooltip(rect, str.str());
}
Expand Down

0 comments on commit c4c4543

Please sign in to comment.