* Center the small map on the current center of the viewport. */
| 1476 | * Center the small map on the current center of the viewport. |
| 1477 | */ |
| 1478 | void SmallMapCenterOnCurrentPos() |
| 1479 | { |
| 1480 | const Viewport &vp = *GetMainWindow()->viewport; |
| 1481 | Point viewport_center = InverseRemapCoords2(vp.virtual_left + vp.virtual_width / 2, vp.virtual_top + vp.virtual_height / 2); |
| 1482 | |
| 1483 | int sub; |
| 1484 | const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_SM_MAP); |
| 1485 | Point sxy = this->ComputeScroll(viewport_center.x / (int)TILE_SIZE, viewport_center.y / (int)TILE_SIZE, |
| 1486 | std::max(0, (int)wid->current_x / 2 - 2), wid->current_y / 2, &sub); |
| 1487 | this->SetNewScroll(sxy.x, sxy.y, sub); |
| 1488 | this->SetDirty(); |
| 1489 | } |
| 1490 | |
| 1491 | /** |
| 1492 | * Get the center of the given station as point on the screen in the smallmap window. |
no test coverage detected