fix scrolling through the player list in the mp lobby:

...trying to preserve the selected player the viewport of the list
would always be reset to show the selected player
This commit is contained in:
Thomas Baumhauer 2009-01-10 11:37:02 +00:00
parent 1d9114e198
commit c647a5b48c
3 changed files with 10 additions and 2 deletions

View file

@ -730,8 +730,7 @@ void ui::set_user_menu_items(const std::vector<std::string>& list)
std::vector<std::string>::const_iterator i =
std::find(user_list_.begin(), user_list_.end(), selected_user_);
if(i != user_list_.end()) {
users_menu_.reset_selection();
users_menu_.move_selection(i - user_list_.begin());
users_menu_.move_selection_keeping_viewport(i - user_list_.begin());
}
}

View file

@ -517,6 +517,14 @@ void menu::move_selection(size_t id)
}
}
// public function
void menu::move_selection_keeping_viewport(size_t id)
{
if(id < item_pos_.size()) {
set_selection_pos(item_pos_[id], true, NO_MOVE_VIEWPORT);
}
}
void menu::reset_selection()
{
set_selection_pos(0);

View file

@ -160,6 +160,7 @@ public:
int selection() const;
void move_selection(size_t id);
void move_selection_keeping_viewport(size_t id);
void reset_selection();
// allows user to change_item while running (dangerous)