Issue #1738: Changed unit_recall dialogue box (#1760)

* Changed unit_recall dialogue box to sort by 1. level, 2. experience_to_advance

* Sorted recall_list_ by level, experience_to_advance and max_hitpoints

* Sorted recall_list by 1. Level, 2. Experience to advance

* Sorted recall_list_ by 1. Level, 2. Experience to advancement

* Sorted recall_list by 1. Level, 2. Experience to advance

* Sorted recall_list by 1. Level, 2. Experience to advance
This commit is contained in:
Pranav Deshpande 2017-06-08 01:38:25 +05:30 committed by Jyrki Vesterinen
parent bb9ee94e4b
commit 9628109666
2 changed files with 14 additions and 1 deletions

View file

@ -146,6 +146,14 @@ static std::string get_title_suffix(int side_num)
return msg.str();
}
bool unit_recall::unit_recall_default_compare(const unit_const_ptr first, const unit_const_ptr second)
{
if (first->level() > second->level()) return true;
if (first->level() < second->level()) return false;
if (first->experience_to_advance() < second->experience_to_advance()) return true;
return false;
}
void unit_recall::pre_show(window& window)
{
label& title = find_widget<label>(&window, "title", true);
@ -181,6 +189,8 @@ void unit_recall::pre_show(window& window)
find_widget<button>(&window, "show_help", false),
std::bind(&unit_recall::show_help, this, std::ref(window)));
std::sort(recall_list_.begin(), recall_list_.end(), unit_recall_default_compare);
for(const unit_const_ptr& unit : recall_list_) {
std::map<std::string, string_map> row_data;
string_map column;
@ -239,7 +249,7 @@ void unit_recall::pre_show(window& window)
list.register_sorting_option(0, [this](const int i) { return recall_list_[i]->type_name().str(); });
list.register_sorting_option(1, [this](const int i) { return recall_list_[i]->name().str(); });
list.register_sorting_option(2, [this](const int i) { return recall_list_[i]->level(); });
list.register_sorting_option(2, [this](const int i) { return recall_list_[i]->level()*1000 - static_cast<int>(recall_list_[i]->experience_to_advance()); });
list.register_sorting_option(3, [this](const int i) { return recall_list_[i]->experience(); });
list.register_sorting_option(4, [this](const int i) {
return !recall_list_[i]->trait_names().empty() ? recall_list_[i]->trait_names().front().str() : "";

View file

@ -61,6 +61,9 @@ private:
void dismiss_unit(window& window);
void show_help(window& window);
/** Function to sort recall_list_ by default. */
static bool unit_recall_default_compare(const unit_const_ptr first, const unit_const_ptr second);
/** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const override;