* Compute base parameters of the smallmap such that tile (\a tx, \a ty) starts at pixel (\a x, \a y). * @param tx Tile x coordinate. * @param ty Tile y coordinate. * @param x Non-negative horizontal position in the display where the tile starts. * @param y Non-negative vertical position in the display where the tile starts. * @param[out] sub Value of #subscroll
| 1178 | * @return #scroll_x, #scroll_y values. |
| 1179 | */ |
| 1180 | Point ComputeScroll(int tx, int ty, int x, int y, int *sub) const |
| 1181 | { |
| 1182 | assert(x >= 0 && y >= 0); |
| 1183 | |
| 1184 | int new_sub; |
| 1185 | Point tile_xy = PixelToTile(x, y, &new_sub, false); |
| 1186 | tx -= tile_xy.x; |
| 1187 | ty -= tile_xy.y; |
| 1188 | |
| 1189 | Point scroll; |
| 1190 | if (new_sub == 0) { |
| 1191 | *sub = 0; |
| 1192 | scroll.x = (tx + this->zoom) * TILE_SIZE; |
| 1193 | scroll.y = (ty - this->zoom) * TILE_SIZE; |
| 1194 | } else { |
| 1195 | *sub = 4 - new_sub; |
| 1196 | scroll.x = (tx + 2 * this->zoom) * TILE_SIZE; |
| 1197 | scroll.y = (ty - 2 * this->zoom) * TILE_SIZE; |
| 1198 | } |
| 1199 | return scroll; |
| 1200 | } |
| 1201 | |
| 1202 | /** |
| 1203 | * Initialize or change the zoom level. |
no outgoing calls
no test coverage detected