Changeset 26 for trunk/Classes/multiplayer_lobby.cpp
- Timestamp:
- 2010-05-28 07:39:52 (2 years ago)
- File:
-
- 1 edited
-
trunk/Classes/multiplayer_lobby.cpp (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Classes/multiplayer_lobby.cpp
r19 r26 65 65 void gamebrowser::set_inner_location(const SDL_Rect& rect) 66 66 { 67 set_full_size(games_.size()); 68 set_shown_size(rect.h / row_height()); 67 //set_full_size(games_.size()); 68 set_full_size(games_.size() * item_height_); 69 //set_shown_size(rect.h / row_height()); 70 set_shown_size(rect.h); 69 71 bg_register(rect); 70 72 scroll(get_position()); … … 73 75 void gamebrowser::scroll(unsigned int pos) 74 76 { 75 if(pos < games_.size()) { 76 visible_range_.first = pos; 77 visible_range_.second = std::min<size_t>(pos + inner_location().h / row_height(), games_.size()); 78 set_dirty(); 77 // if(pos < games_.size()) 78 { 79 pos = pos/item_height_; 80 if (pos < games_.size()) 81 { 82 visible_range_.first = pos; 83 visible_range_.second = std::min<size_t>(pos + (inner_location().h / row_height()) +2, games_.size()); 84 set_dirty(); 85 } 79 86 } 80 87 } … … 86 93 } 87 94 const SDL_Rect& loc = inner_location(); 88 const SDL_Rect res = { loc.x, loc.y + (index - visible_range_.first) * row_height(), loc.w, row_height()}; 95 int firstShown = get_position() / item_height_; 96 int leftovers = get_position() - firstShown*item_height_; 97 const SDL_Rect res = { loc.x, loc.y + (index - visible_range_.first) * row_height() - leftovers, loc.w, row_height()}; 89 98 return res; 90 99 } … … 107 116 void gamebrowser::draw_contents() 108 117 { 118 SDL_Rect content_rect = inner_location(); 119 clip_rect_setter clippy(content_rect); 120 109 121 if(!games_.empty()) { 110 122 for(size_t i = visible_range_.first; i != visible_range_.second; ++i) { … … 278 290 { 279 291 scrollarea::handle_event(event); 292 if (scrollarea::handle_drag_event(event)) 293 return; 294 280 295 if(event.type == SDL_KEYDOWN) { 281 296 if(focus(&event) && !games_.empty()) { … … 284 299 if(selected_ > 0) { 285 300 --selected_; 286 adjust_position(selected_ );301 adjust_position(selected_*item_height_); 287 302 set_dirty(); 288 303 } … … 291 306 if(selected_ < games_.size() - 1) { 292 307 ++selected_; 293 adjust_position(selected_ );308 adjust_position(selected_*item_height_); 294 309 set_dirty(); 295 310 } … … 299 314 const long items_on_screen = visible_range_.second - visible_range_.first; 300 315 selected_ = static_cast<size_t>(std::max<long>(static_cast<long>(selected_) - items_on_screen, 0)); 301 adjust_position(selected_ );316 adjust_position(selected_*item_height_); 302 317 set_dirty(); 303 318 } … … 307 322 const size_t items_on_screen = visible_range_.second - visible_range_.first; 308 323 selected_ = std::min<size_t>(selected_ + items_on_screen, games_.size() - 1); 309 adjust_position(selected_ );324 adjust_position(selected_*item_height_); 310 325 set_dirty(); 311 326 } … … 313 328 case SDLK_HOME: 314 329 selected_ = 0; 315 adjust_position(selected_ );330 adjust_position(selected_*item_height_); 316 331 set_dirty(); 317 332 break; 318 333 case SDLK_END: 319 334 selected_ = games_.size() - 1; 320 adjust_position(selected_ );335 adjust_position(selected_*item_height_); 321 336 set_dirty(); 322 337 break; … … 567 582 games_.back().verified = verified; 568 583 } 569 set_full_size(games_.size() );570 set_shown_size(inner_location().h / row_height());584 set_full_size(games_.size()*item_height_); 585 set_shown_size(inner_location().h); 571 586 572 587 // Try to preserve the game selection … … 588 603 if (selection_visible && (visible_range_.first > selected_ 589 604 || visible_range_.second < selected_)) { 590 set_position(selected_ );605 set_position(selected_*item_height_); 591 606 } 592 607 } … … 604 619 } 605 620 } 606 adjust_position(selected_ );621 adjust_position(selected_*item_height_); 607 622 set_dirty(); 608 623 } … … 680 695 game_observers_(), 681 696 682 observe_game_(disp.video(), _("Observe Game") ),683 join_game_(disp.video(), _("Join Game") ),684 create_game_(disp.video(), _("Create Game") ),697 observe_game_(disp.video(), _("Observe Game"), gui::button::TYPE_PRESS, "button"), 698 join_game_(disp.video(), _("Join Game"), gui::button::TYPE_PRESS, "button"), 699 create_game_(disp.video(), _("Create Game"), gui::button::TYPE_PRESS, "button"), 685 700 skip_replay_(disp.video(), _("Quick Replays"), gui::button::TYPE_CHECK), 686 701 #ifndef USE_TINY_GUI 687 702 game_preferences_(disp.video(), _("Preferences")), 688 703 #endif 689 quit_game_(disp.video(), _("Quit") ),704 quit_game_(disp.video(), _("Quit"), gui::button::TYPE_PRESS, "button"), 690 705 last_selected_game_(-1), sorter_(gamelist), 691 706 games_menu_(disp.video(),cfg.child("multiplayer_hashes")),
Note: See TracChangeset
for help on using the changeset viewer.