MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / UpdateViewport

Method UpdateViewport

src/openrct2-ui/windows/Player.cpp:280–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278 }
279
280 void UpdateViewport(bool scroll)
281 {
282 int32_t playerIndex = Network::GetPlayerIndex(static_cast<uint8_t>(number));
283 if (playerIndex == -1)
284 {
285 return;
286 }
287
288 if (viewport != nullptr)
289 {
290 auto coord = Network::GetPlayerLastActionCoord(playerIndex);
291 if (coord.x != 0 || coord.y != 0 || coord.z != 0)
292 {
293 auto centreLoc = centre2dCoordinates(coord, viewport);
294 if (!centreLoc.has_value())
295 {
296 return;
297 }
298 // Don't scroll if the view was originally undefined
299 if (!_drawViewport)
300 {
301 scroll = false;
302 }
303
304 if (!scroll || savedViewPos != centreLoc.value())
305 {
306 flags |= WindowFlag::scrollingToLocation;
307 savedViewPos = centreLoc.value();
308 if (!scroll)
309 {
310 viewport->viewPos = centreLoc.value();
311 }
312 invalidateWidget(WIDX_VIEWPORT);
313 }
314
315 // Draw the viewport
316 _drawViewport = true;
317 }
318 else
319 {
320 // Don't draw the viewport
321 _drawViewport = false;
322 }
323 }
324 }
325
326 void UpdateTitle()
327 {

Callers

nothing calls this directly

Calls 4

GetPlayerIndexFunction · 0.85
GetPlayerLastActionCoordFunction · 0.85
centre2dCoordinatesFunction · 0.85
valueMethod · 0.80

Tested by

no test coverage detected