void mouse_handler_base::mouse_press(const SDL_MouseButtonEvent& event, const bool browse) { if(is_middle_click(event) && !preferences::middle_click_scrolls()) { simple_warp_ = true; } show_menu_ = false; map_location loc = gui().hex_clicked_on(event.x,event.y); mouse_update(browse, loc); #if !SDL_VERSION_ATLEAST(2,0,0) int scrollx = 0; int scrolly = 0; #endif if (is_left_click(event)) { if (event.state == SDL_PRESSED) { cancel_dragging(); init_dragging(dragging_left_); left_click(event.x, event.y, browse); } else if (event.state == SDL_RELEASED) { minimap_scrolling_ = false; clear_dragging(event, browse); left_mouse_up(event.x, event.y, browse); } } else if (is_right_click(event)) { if (event.state == SDL_PRESSED) { cancel_dragging(); init_dragging(dragging_right_); right_click(event.x, event.y, browse); } else if (event.state == SDL_RELEASED) { minimap_scrolling_ = false; clear_dragging(event, browse); right_mouse_up(event.x, event.y, browse); } } else if (is_middle_click(event)) { if (event.state == SDL_PRESSED) { set_scroll_start(event.x, event.y); scroll_started_ = true; map_location loc = gui().minimap_location_on(event.x,event.y); minimap_scrolling_ = false; if(loc.valid()) { simple_warp_ = false; minimap_scrolling_ = true; last_hex_ = loc; gui().scroll_to_tile(loc,display::WARP,false); } else if(simple_warp_) { // middle click not on minimap, check gamemap instead loc = gui().hex_clicked_on(event.x,event.y); if(loc.valid()) { last_hex_ = loc; gui().scroll_to_tile(loc,display::WARP,false); } } } else if (event.state == SDL_RELEASED) { minimap_scrolling_ = false; simple_warp_ = false; scroll_started_ = false; } } #if !SDL_VERSION_ATLEAST(2,0,0) else if (allow_mouse_wheel_scroll(event.x, event.y)) { if (event.button == SDL_BUTTON_WHEELUP) { scrolly = - preferences::scroll_speed(); mouse_wheel_up(event.x, event.y, browse); } else if (event.button == SDL_BUTTON_WHEELDOWN) { scrolly = preferences::scroll_speed(); mouse_wheel_down(event.x, event.y, browse); } else if (event.button == SDL_BUTTON_WHEELLEFT) { scrollx = - preferences::scroll_speed(); mouse_wheel_left(event.x, event.y, browse); } else if (event.button == SDL_BUTTON_WHEELRIGHT) { scrollx = preferences::scroll_speed(); mouse_wheel_right(event.x, event.y, browse); } // Don't scroll map and map zoom slider at same time gui::slider* s = gui().find_slider("map-zoom-slider"); if (s && sdl::point_in_rect(event.x, event.y, s->location())) { scrollx = 0; scrolly = 0; } } if (scrollx != 0 || scrolly != 0) { CKey pressed; // Alt + mousewheel do an 90° rotation on the scroll direction if (pressed[SDLK_LALT] || pressed[SDLK_RALT]) gui().scroll(scrolly,scrollx); else gui().scroll(scrollx,scrolly); } #endif if (!dragging_left_ && !dragging_right_ && dragging_started_) { dragging_started_ = false; cursor::set_dragging(false); } mouse_update(browse, loc); }
void mouse_handler_base::mouse_press(const SDL_MouseButtonEvent& event, const bool browse) { if(is_middle_click(event) && !preferences::middle_click_scrolls()) { simple_warp_ = true; } show_menu_ = false; map_location loc = gui().hex_clicked_on(event.x,event.y); mouse_update(browse, loc); if (is_left_click(event)) { if (event.state == SDL_PRESSED) { cancel_dragging(); init_dragging(dragging_left_); left_click(event.x, event.y, browse); } else if (event.state == SDL_RELEASED) { minimap_scrolling_ = false; clear_dragging(event, browse); left_mouse_up(event.x, event.y, browse); } } else if (is_right_click(event)) { if (event.state == SDL_PRESSED) { cancel_dragging(); init_dragging(dragging_right_); right_click(event.x, event.y, browse); } else if (event.state == SDL_RELEASED) { minimap_scrolling_ = false; clear_dragging(event, browse); right_mouse_up(event.x, event.y, browse); } } else if (is_middle_click(event)) { if (event.state == SDL_PRESSED) { set_scroll_start(event.x, event.y); scroll_started_ = true; map_location loc = gui().minimap_location_on(event.x,event.y); minimap_scrolling_ = false; if(loc.valid()) { simple_warp_ = false; minimap_scrolling_ = true; last_hex_ = loc; gui().scroll_to_tile(loc,display::WARP,false); } else if(simple_warp_) { // middle click not on minimap, check gamemap instead loc = gui().hex_clicked_on(event.x,event.y); if(loc.valid()) { last_hex_ = loc; gui().scroll_to_tile(loc,display::WARP,false); } } } else if (event.state == SDL_RELEASED) { minimap_scrolling_ = false; simple_warp_ = false; scroll_started_ = false; } } if (!dragging_left_ && !dragging_right_ && dragging_started_) { dragging_started_ = false; cursor::set_dragging(false); } mouse_update(browse, loc); }