mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-16 19:58:22 +00:00
units_dialog: more fixes related to recruitability (#9813)
This commit is contained in:
parent
e94f577d9a
commit
d5d20b9305
|
@ -474,15 +474,16 @@ std::unique_ptr<units_dialog> units_dialog::build_recruit_dialog(
|
||||||
}
|
}
|
||||||
image_string += "~RC(" + recruit->flag_rgb() + ">" + team.color() + ")";
|
image_string += "~RC(" + recruit->flag_rgb() + ">" + team.color() + ")";
|
||||||
image_string += "~SCALE_INTO(72,72)";
|
image_string += "~SCALE_INTO(72,72)";
|
||||||
bool recruitable = unit_helper::recruit_message(recruit->id(), recruit_hex, map_location::null_location(), team).has_value();
|
bool not_recruitable = unit_helper::recruit_message(
|
||||||
if (!recruitable) {
|
recruit->id(), recruit_hex, map_location::null_location(), team).has_value();
|
||||||
|
if (not_recruitable) {
|
||||||
image_string += "~GS()";
|
image_string += "~GS()";
|
||||||
}
|
}
|
||||||
return image_string;
|
return image_string;
|
||||||
}, sort_type::none);
|
}, sort_type::none);
|
||||||
|
|
||||||
set_column("unit_details", [&team, &recruit_hex](const auto& recruit) {
|
set_column("unit_details", [&team, &recruit_hex](const auto& recruit) {
|
||||||
bool recruitable = unit_helper::recruit_message(recruit->id(), recruit_hex, map_location::null_location(), team).has_value();
|
bool recruitable = !unit_helper::recruit_message(recruit->id(), recruit_hex, map_location::null_location(), team).has_value();
|
||||||
return unit_helper::maybe_inactive(recruit->type_name(), recruitable)
|
return unit_helper::maybe_inactive(recruit->type_name(), recruitable)
|
||||||
+ unit_helper::format_cost_string(recruit->cost(), recruitable);
|
+ unit_helper::format_cost_string(recruit->cost(), recruitable);
|
||||||
}, sort_type::generator);
|
}, sort_type::generator);
|
||||||
|
@ -493,7 +494,8 @@ std::unique_ptr<units_dialog> units_dialog::build_recruit_dialog(
|
||||||
.set_row_num(recruit_list.size());
|
.set_row_num(recruit_list.size());
|
||||||
|
|
||||||
dlg->set_tooltip_generator([&team, &recruit_hex, &recruit_list](std::size_t index) {
|
dlg->set_tooltip_generator([&team, &recruit_hex, &recruit_list](std::size_t index) {
|
||||||
return unit_helper::recruit_message(recruit_list[index]->id(), recruit_hex, map_location::null_location(), team).value();
|
const auto& msg = unit_helper::recruit_message(recruit_list[index]->id(), recruit_hex, map_location::null_location(), team);
|
||||||
|
return msg.has_value() ? msg.value() : std::string();
|
||||||
});
|
});
|
||||||
|
|
||||||
dlg->on_modified([&recruit_list](std::size_t index) -> const auto& { return *recruit_list[index]; });
|
dlg->on_modified([&recruit_list](std::size_t index) -> const auto& { return *recruit_list[index]; });
|
||||||
|
|
Loading…
Reference in New Issue
Block a user