Skip to content

Commit

Permalink
GUI2/Campaign Selection: some fixup to laurel selection
Browse files Browse the repository at this point in the history
* Simplified gold laurel check
* Ensured broze laurel shows if *only* the easiest difficulty has been completed.
  • Loading branch information
Vultraz committed Sep 12, 2017
1 parent 20eb424 commit b61a159
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/gui/dialogs/campaign_selection.cpp
Expand Up @@ -296,26 +296,26 @@ void campaign_selection::add_campaign_to_tree(window& window, const config& camp
if(campaign["completed"].to_bool()) {
config::const_child_itors difficulties = campaign.child_range("difficulty");

auto did_complete_at = [&difficulties](config::const_child_iterator i) {
return i == difficulties.end() ? false : (*i)["completed_at"].to_bool();
};
auto did_complete_at = [](const config& c) { return c["completed_at"].to_bool(); };

const bool has_multiple_difficulties = difficulties.size() > 1;
// Check for non-completion on every difficulty save the first.
const bool only_first_completed = difficulties.size() > 1 &&
std::none_of(difficulties.begin() + 1, difficulties.end(), did_complete_at);

/*
* Criteria:
*
* - Use the gold laurel (hardest) for campaigns with only one difficulty OR
* if out of two or more difficulties, the last one has been completed.
*
* - Use the bronze laurel (easiest) if the first difficulty out of two or more
* has been completed.
* - Use the bronze laurel (easiest) only if the first difficulty out of two
* or more has been completed.
*
* - Use the silver laurel otherwise.
*/
if(difficulties.size() == 1 || (has_multiple_difficulties && did_complete_at(difficulties.end() - 1))) {
if(!difficulties.empty() && did_complete_at(difficulties.back())) {
item["label"] = game_config::images::victory_laurel_hardest;
} else if(has_multiple_difficulties && did_complete_at(difficulties.begin())) {
} else if(only_first_completed && did_complete_at(difficulties.front())) {
item["label"] = game_config::images::victory_laurel_easy;
} else {
item["label"] = game_config::images::victory_laurel;
Expand Down

0 comments on commit b61a159

Please sign in to comment.