mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-06 19:48:11 +00:00
Use an array for sort function storage, since it's always fixed-size
This commit is contained in:
parent
105fbe6bc6
commit
fe1f17a55f
@ -186,7 +186,7 @@ void tgame_load::fill_game_list(twindow& window,
|
||||
|
||||
list.add_row(data);
|
||||
}
|
||||
std::vector<tgenerator_::torder_func> order_funcs(2);
|
||||
generator_sort_array order_funcs;
|
||||
order_funcs[0] = std::bind(&tgame_load::compare_name, this, _1, _2);
|
||||
order_funcs[1] = std::bind(&tgame_load::compare_name_rev, this, _1, _2);
|
||||
list.set_column_order(0, order_funcs);
|
||||
|
@ -878,7 +878,7 @@ void tpreferences::initialize_members(twindow& window)
|
||||
|
||||
tlistbox& hotkey_list = find_widget<tlistbox>(&window, "list_hotkeys", false);
|
||||
|
||||
std::vector<tgenerator_::torder_func> order_funcs(2);
|
||||
generator_sort_array order_funcs;
|
||||
|
||||
order_funcs[0] = hotkey_sort_by_desc<false>(visible_hotkeys_);
|
||||
order_funcs[1] = hotkey_sort_by_desc<true>(visible_hotkeys_);
|
||||
|
@ -158,7 +158,7 @@ void tunit_create::pre_show(twindow& window)
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
std::vector<tgenerator_::torder_func> order_funcs(2);
|
||||
generator_sort_array order_funcs;
|
||||
order_funcs[0] = std::bind(&tunit_create::compare_race, this, _1, _2);
|
||||
order_funcs[1] = std::bind(&tunit_create::compare_race_rev, this, _1, _2);
|
||||
list.set_column_order(0, order_funcs);
|
||||
|
@ -122,7 +122,7 @@ static std::string trait_key(unit_const_ptr u)
|
||||
}
|
||||
|
||||
template<typename Fnc>
|
||||
void tunit_recall::init_sorting_option(std::vector<tgenerator_::torder_func>& order_funcs, Fnc filter_on)
|
||||
void tunit_recall::init_sorting_option(generator_sort_array& order_funcs, Fnc filter_on)
|
||||
{
|
||||
order_funcs[0] = [this, filter_on](unsigned i1, unsigned i2) {
|
||||
return filter_on((*recall_list_)[i1]) < filter_on((*recall_list_)[i2]);
|
||||
@ -249,7 +249,7 @@ void tunit_recall::pre_show(twindow& window)
|
||||
filter_options_.push_back(filter_text);
|
||||
}
|
||||
|
||||
std::vector<tgenerator_::torder_func> order_funcs(2);
|
||||
generator_sort_array order_funcs;
|
||||
|
||||
init_sorting_option(order_funcs, std::bind(&tstr_key, _1, &unit::type_name));
|
||||
list.set_column_order(0, order_funcs);
|
||||
|
@ -55,7 +55,7 @@ private:
|
||||
std::vector<std::string> last_words_;
|
||||
|
||||
template<typename T>
|
||||
void init_sorting_option(std::vector<tgenerator_::torder_func>& order_funcs, T filter_on);
|
||||
void init_sorting_option(generator_sort_array& order_funcs, T filter_on);
|
||||
|
||||
/** Callbacks */
|
||||
void list_item_clicked(twindow& window);
|
||||
|
@ -364,6 +364,8 @@ protected:
|
||||
virtual unsigned get_item_at_ordered(unsigned index_ordered) const = 0;
|
||||
};
|
||||
|
||||
using generator_sort_array = std::array<tgenerator_::torder_func, 2>;
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
#endif
|
||||
|
@ -593,7 +593,7 @@ void tlistbox::order_by(const tgenerator_::torder_func& func)
|
||||
need_layout_ = true;
|
||||
}
|
||||
|
||||
void tlistbox::set_column_order(unsigned col, const std::vector<tgenerator_::torder_func>& func)
|
||||
void tlistbox::set_column_order(unsigned col, const generator_sort_array& func)
|
||||
{
|
||||
if(col >= orders_.size()) {
|
||||
orders_.resize(col + 1);
|
||||
|
@ -234,7 +234,7 @@ public:
|
||||
|
||||
void order_by(const tgenerator_::torder_func& func);
|
||||
|
||||
void set_column_order(unsigned col, const std::vector<tgenerator_::torder_func>& func);
|
||||
void set_column_order(unsigned col, const generator_sort_array& func);
|
||||
protected:
|
||||
/***** ***** ***** ***** keyboard functions ***** ***** ***** *****/
|
||||
|
||||
@ -308,7 +308,7 @@ private:
|
||||
|
||||
bool need_layout_;
|
||||
|
||||
typedef std::vector<std::pair<tselectable_*, std::vector<tgenerator_::torder_func> > > torder_list;
|
||||
typedef std::vector<std::pair<tselectable_*, generator_sort_array > > torder_list;
|
||||
torder_list orders_;
|
||||
/**
|
||||
* Resizes the content.
|
||||
|
Loading…
x
Reference in New Issue
Block a user