Keep laurel decorations consistent with difficulty level (resolves #8442).
(cherry picked from commit a84561390a
)
This commit is contained in:
parent
165d2ba37f
commit
815cc536b7
1 changed files with 26 additions and 3 deletions
|
@ -67,6 +67,8 @@ void campaign_difficulty::pre_show(window& window)
|
|||
listbox& list = find_widget<listbox>(&window, "listbox", false);
|
||||
window.keyboard_capture(&list);
|
||||
|
||||
unsigned difficulty_count = 0;
|
||||
const unsigned difficulty_max = difficulties_.child_count("difficulty");
|
||||
for(const config& d : difficulties_.child_range("difficulty")) {
|
||||
std::map<std::string, string_map> data;
|
||||
string_map item;
|
||||
|
@ -98,10 +100,31 @@ void campaign_difficulty::pre_show(window& window)
|
|||
list.select_last_row();
|
||||
}
|
||||
|
||||
widget* widget = grid.find("victory", false);
|
||||
if(widget && !preferences::is_campaign_completed(campaign_id_, d["define"])) {
|
||||
widget->set_visible(widget::visibility::hidden);
|
||||
styled_widget &widget = find_widget<styled_widget>(&grid, "victory", false);
|
||||
if(&widget) {
|
||||
// Use different laurels according to the difficulty level, following the
|
||||
// pre-existing convention established in campaign_selection class.
|
||||
// Assumes ascending order of difficulty.
|
||||
if(preferences::is_campaign_completed(campaign_id_, d["define"])) {
|
||||
if(difficulty_count == 0) {
|
||||
widget.set_label(game_config::images::victory_laurel_easy);
|
||||
}
|
||||
|
||||
else if(difficulty_count + 1 >= difficulty_max) {
|
||||
widget.set_label(game_config::images::victory_laurel_hardest);
|
||||
}
|
||||
|
||||
else {
|
||||
widget.set_label(game_config::images::victory_laurel);
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
widget.set_visible(widget::visibility::hidden);
|
||||
}
|
||||
}
|
||||
|
||||
difficulty_count++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue