Skip to content

Commit

Permalink
FLG Manager: sort leader list alphabetically, with Random first
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Aug 29, 2016
1 parent 404f698 commit af30309
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/game_initialization/flg_manager.cpp
Expand Up @@ -492,6 +492,11 @@ void flg_manager::update_choosable_leaders()
choosable_leaders_.push_back(default_leader_type_);
}
}

// Sort alphabetically, but with the 'random' option always first
std::sort(choosable_leaders_.begin() + 1, choosable_leaders_.end(), [](const std::string& str1, const std::string& str2) {
return str1 < str2;
});
}

void flg_manager::update_choosable_genders()
Expand Down
7 changes: 1 addition & 6 deletions src/gui/dialogs/multiplayer/faction_select.cpp
Expand Up @@ -138,11 +138,6 @@ void tfaction_select::on_faction_select(twindow& window)
}
}

// TODO: this breaks ordering within the FLG manager
//std::sort(leaders.begin(), leaders.end(), [](const config& cfg1, const config& cfg2) {
// return cfg1["label"].str() < cfg2["label"].str();
//});

tmenu_button& leader_dropdown = find_widget<tmenu_button>(&window, "leader_menu", false);

leader_dropdown.set_values(leaders, flg_manager_.current_leader_index());
Expand Down Expand Up @@ -172,7 +167,7 @@ void tfaction_select::on_leader_select(twindow& window)
return std::find(genders.begin(), genders.end(), gender) != genders.end();
};

// TODO: should we decouple this from the dlg manager and instead just check the unit type directly?
// TODO: should we decouple this from the flg manager and instead just check the unit type directly?
find_widget<ttoggle_button>(&window, "gender_male", false).set_active(gender_available(unit_race::s_male));
find_widget<ttoggle_button>(&window, "gender_female", false).set_active(gender_available(unit_race::s_female));

Expand Down

0 comments on commit af30309

Please sign in to comment.