Vultraz

Untitled

Jun 1st, 2014
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @@ -795,32 +795,35 @@
  2.  
  3.   map_location display::minimap_location_on(int x, int y)
  4.   {
  5.  -  //TODO: don't return location for this,
  6.  -  // instead directly scroll to the clicked pixel position
  7.  +  if(!view_locked_ || force) {
  8.  
  9.  -  if (!point_in_rect(x, y, minimap_area())) {
  10.  -      return map_location();
  11.  -  }
  12.  +      //TODO: don't return location for this,
  13.  +      // instead directly scroll to the clicked pixel position
  14.  
  15.  -  // we transform the coordinates from minimap to the full map image
  16.  -  // probably more adjustments to do (border, minimap shift...)
  17.  -  // but the mouse and human capacity to evaluate the rectangle center
  18.  -  // is not pixel precise.
  19.  -  int px = (x - minimap_location_.x) * get_map().w()*hex_width() / minimap_location_.w;
  20.  -  int py = (y - minimap_location_.y) * get_map().h()*hex_size() / minimap_location_.h;
  21.  +      if (!point_in_rect(x, y, minimap_area())) {
  22.  +          return map_location();
  23.  +      }
  24.  
  25.  -  map_location loc = pixel_position_to_hex(px, py);
  26.  -  if (loc.x < 0)
  27.  -      loc.x = 0;
  28.  -  else if (loc.x >= get_map().w())
  29.  -      loc.x = get_map().w() - 1;
  30.  +      // we transform the coordinates from minimap to the full map image
  31.  +      // probably more adjustments to do (border, minimap shift...)
  32.  +      // but the mouse and human capacity to evaluate the rectangle center
  33.  +      // is not pixel precise.
  34.  +      int px = (x - minimap_location_.x) * get_map().w()*hex_width() / minimap_location_.w;
  35.  +      int py = (y - minimap_location_.y) * get_map().h()*hex_size() / minimap_location_.h;
  36.  
  37.  -  if (loc.y < 0)
  38.  -      loc.y = 0;
  39.  -  else if (loc.y >= get_map().h())
  40.  -      loc.y = get_map().h() - 1;
  41.  +      map_location loc = pixel_position_to_hex(px, py);
  42.  +      if (loc.x < 0)
  43.  +          loc.x = 0;
  44.  +      else if (loc.x >= get_map().w())
  45.  +          loc.x = get_map().w() - 1;
  46.  
  47.  -  return loc;
  48.  +      if (loc.y < 0)
  49.  +          loc.y = 0;
  50.  +      else if (loc.y >= get_map().h())
  51.  +          loc.y = get_map().h() - 1;
  52.  +
  53.  +      return loc;
  54.  +  }
  55.   }
  56.  
  57.   int display::screenshot(std::string filename, bool map_screenshot)
Advertisement
Add Comment
Please, Sign In to add comment