gui2/campaign_selection: Add difficulty-specific laurels

This brings back laurels for the difficulty menu. Because I really don't
want to break into menu_button's implementations details just yet, this
is a bit of a hack using the BLIT IPF instead of stacked_widget.

To make up for it, this version uses the three different difficulty
laurels depending on the difficulty being displayed, instead of always
using the standard laurel.
This commit is contained in:
Iris Morelle 2020-12-15 04:28:09 -03:00
parent 3bfb9e34c5
commit 8a4515e9d2

View file

@ -118,7 +118,7 @@ void campaign_selection::campaign_selected()
if(!diff_config.empty()) {
std::vector<config> entry_list;
unsigned n = 0, selection = 0;
unsigned n = 0, selection = 0, max_n = diff_config.child_count("difficulty");
for(const auto& cfg : diff_config.child_range("difficulty")) {
config entry;
@ -127,6 +127,20 @@ void campaign_selection::campaign_selected()
entry["label"] = cfg["label"].str() + " (" + cfg["description"].str() + ")";
entry["image"] = cfg["image"].str("misc/blank-hex.png");
if(preferences::is_campaign_completed(tree.selected_item()->id(), cfg["define"])) {
std::string laurel;
if(n + 1 >= max_n) {
laurel = game_config::images::victory_laurel_hardest;
} else if(n == 0) {
laurel = game_config::images::victory_laurel_easy;
} else {
laurel = game_config::images::victory_laurel;
}
entry["image"] = laurel + "~BLIT(" + entry["image"] + ")";
}
if(!cfg["description"].empty()) {
std::string desc;
if(cfg["auto_markup"].to_bool(true) == false) {