0x004C68E4
| 204 | |
| 205 | // 0x004C68E4 |
| 206 | static void viewportMove(int16_t x, int16_t y, Ui::Window* w, Ui::Viewport* vp) |
| 207 | { |
| 208 | int origX = vp->viewX >> vp->zoom; |
| 209 | int origY = vp->viewY >> vp->zoom; |
| 210 | int newX = x >> vp->zoom; |
| 211 | int newY = y >> vp->zoom; |
| 212 | int diffX = origX - newX; |
| 213 | int diffY = origY - newY; |
| 214 | |
| 215 | vp->viewX = x; |
| 216 | vp->viewY = y; |
| 217 | |
| 218 | // If no change in viewing area |
| 219 | if (diffX == 0 && diffY == 0) |
| 220 | { |
| 221 | return; |
| 222 | } |
| 223 | |
| 224 | if (vp->hasFlags(ViewportFlags::seeThroughTracks | ViewportFlags::seeThroughScenery | ViewportFlags::seeThroughRoads | ViewportFlags::seeThroughBuildings | ViewportFlags::seeThroughTrees | ViewportFlags::seeThroughBridges) || w->hasFlags(WindowFlags::viewportNoShiftPixels)) |
| 225 | { |
| 226 | auto rect = Ui::Rect(vp->x, vp->y, vp->width, vp->height); |
| 227 | Gfx::render(rect); |
| 228 | return; |
| 229 | } |
| 230 | |
| 231 | uint8_t zoom = (1 << vp->zoom); |
| 232 | Viewport backup = *vp; |
| 233 | |
| 234 | if (vp->x < 0) |
| 235 | { |
| 236 | vp->width += vp->x; |
| 237 | vp->viewWidth += vp->x * zoom; |
| 238 | vp->viewX -= vp->x * zoom; |
| 239 | vp->x = 0; |
| 240 | } |
| 241 | |
| 242 | int32_t eax = vp->x + vp->width - Ui::width(); |
| 243 | if (eax > 0) |
| 244 | { |
| 245 | vp->width -= eax; |
| 246 | vp->viewWidth -= eax * zoom; |
| 247 | } |
| 248 | |
| 249 | if (vp->width <= 0) |
| 250 | { |
| 251 | *vp = backup; |
| 252 | return; |
| 253 | } |
| 254 | |
| 255 | if (vp->y < 0) |
| 256 | { |
| 257 | vp->height += vp->y; |
| 258 | vp->viewHeight += vp->y * zoom; |
| 259 | vp->viewY -= vp->y * zoom; |
| 260 | vp->y = 0; |
| 261 | } |
| 262 | |
| 263 | eax = vp->y + vp->height - Ui::height(); |
no test coverage detected