mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-21 20:44:24 +00:00
Remove the use of level for sorting XP (recall and unit list dialogs).
Make no sense with the current "XP needed for the next level" sorting, make it even more harder to understand that this order is used, and using another column as main base to sort the clicked column was bad UI.
This commit is contained in:
parent
948aa9f5f7
commit
10caf03d73
@ -210,7 +210,7 @@ void menu_handler::unit_list()
|
||||
|
||||
gui::menu::basic_sorter sorter;
|
||||
sorter.set_alpha_sort(0).set_alpha_sort(1).set_numeric_sort(2).set_numeric_sort(3)
|
||||
.set_xp_sort(4,2).set_alpha_sort(5).set_numeric_sort(6);
|
||||
.set_xp_sort(4).set_alpha_sort(5).set_numeric_sort(6);
|
||||
|
||||
std::vector<std::string> items;
|
||||
items.push_back(heading);
|
||||
@ -844,7 +844,7 @@ void menu_handler::recall(int side_num, const map_location &last_hex)
|
||||
#endif
|
||||
|
||||
gui::menu::basic_sorter sorter;
|
||||
sorter.set_alpha_sort(1).set_alpha_sort(2).set_id_sort(3).set_xp_sort(4,3).set_alpha_sort(5);
|
||||
sorter.set_alpha_sort(1).set_alpha_sort(2).set_id_sort(3).set_xp_sort(4).set_alpha_sort(5);
|
||||
|
||||
options.push_back(heading.str());
|
||||
options_to_filter.push_back(options.back());
|
||||
|
@ -47,10 +47,9 @@ menu::basic_sorter& menu::basic_sorter::set_numeric_sort(int column)
|
||||
return *this;
|
||||
}
|
||||
|
||||
menu::basic_sorter& menu::basic_sorter::set_xp_sort(int xp_column, int level_column)
|
||||
menu::basic_sorter& menu::basic_sorter::set_xp_sort(int column)
|
||||
{
|
||||
xp_sort_.insert(xp_column);
|
||||
level_col_ = level_column;
|
||||
xp_sort_.insert(column);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -139,13 +138,11 @@ bool menu::basic_sorter::less(int column, const item& row1, const item& row2) co
|
||||
} else if(xp_sort_.count(column) == 1) {
|
||||
const std::string& item1 = font::del_tags(row1.fields[column]);
|
||||
const std::string& item2 = font::del_tags(row2.fields[column]);
|
||||
const std::string& item1_lev = font::del_tags(row1.fields[level_col_]);
|
||||
const std::string& item2_lev = font::del_tags(row2.fields[level_col_]);
|
||||
|
||||
const char* digits[4] = {item1.c_str(),item2.c_str(),item1_lev.c_str(),item2_lev.c_str()};
|
||||
const char* digits[2] = {item1.c_str(),item2.c_str()};
|
||||
//we must move past any non-digit characters for atoi() to work later
|
||||
//outer loop iterates over the strings we have to fix, inner loop over characters
|
||||
for(int i = 0; i < 4; i++) {
|
||||
for(int i = 0; i < 2; i++) {
|
||||
while(*digits[i] != 0 && !isdigit(*digits[i])) {
|
||||
++digits[i];
|
||||
}
|
||||
@ -168,12 +165,6 @@ bool menu::basic_sorter::less(int column, const item& row1, const item& row2) co
|
||||
int xp1_x = atoi(digits[0]); //atoi stops at the first invalid char, which is slash character
|
||||
int xp2_x = atoi(digits[1]);
|
||||
|
||||
int level1 = atoi(digits[2]);
|
||||
int level2 = atoi(digits[3]);
|
||||
if(level1 > level2)
|
||||
return true;
|
||||
if(level1 < level2)
|
||||
return false;
|
||||
return (xp1_y - xp1_x) < (xp2_y - xp2_x);
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ public:
|
||||
|
||||
basic_sorter& set_alpha_sort(int column);
|
||||
basic_sorter& set_numeric_sort(int column);
|
||||
basic_sorter& set_xp_sort(int xp_column, int level_column);
|
||||
basic_sorter& set_xp_sort(int column);
|
||||
basic_sorter& set_id_sort(int column);
|
||||
basic_sorter& set_redirect_sort(int column, int to);
|
||||
basic_sorter& set_position_sort(int column, const std::vector<int>& pos);
|
||||
@ -152,7 +152,6 @@ public:
|
||||
std::set<int> alpha_sort_, numeric_sort_, id_sort_, xp_sort_;
|
||||
std::map<int,int> redirect_sort_;
|
||||
std::map<int,std::vector<int> > pos_sort_;
|
||||
int level_col_; //used by xp sort
|
||||
};
|
||||
|
||||
menu(CVideo& video, const std::vector<std::string>& items,
|
||||
|
Loading…
x
Reference in New Issue
Block a user