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

Method onDrawOverview

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

Source from the content-addressed store, hash-verified

411 }
412
413 void onDrawOverview(Drawing::RenderTarget& rt)
414 {
415 drawWidgets(rt);
416 DrawTabImages(rt);
417
418 int32_t player = Network::GetPlayerIndex(static_cast<uint8_t>(number));
419 if (player == -1)
420 {
421 return;
422 }
423
424 // Draw current group
425 int32_t groupindex = Network::GetGroupIndex(Network::GetPlayerGroup(player));
426 if (groupindex != -1)
427 {
428 Widget* widget = &widgets[WIDX_GROUP];
429
430 thread_local std::string _buffer;
431 _buffer.assign("{WINDOW_COLOUR_2}");
432 _buffer += Network::GetGroupName(groupindex);
433
434 drawTextEllipsised(
435 rt, windowPos + ScreenCoordsXY{ widget->midX() - 5, widget->top }, widget->width() - 9, _buffer,
436 { TextAlignment::centre });
437 }
438
439 // Draw ping
440 auto screenCoords = windowPos + ScreenCoordsXY{ 90, widgets[WIDX_TAB_1].midY() };
441
442 auto ft = Formatter();
443 ft.Add<StringId>(STR_PING);
444 drawText(rt, screenCoords, STR_WINDOW_COLOUR_2_STRINGID, ft);
445 char ping[64];
446 snprintf(ping, 64, "%d ms", Network::GetPlayerPing(player));
447 drawText(rt, screenCoords + ScreenCoordsXY(30, 0), ping, { colours[2] });
448
449 // Draw last action
450 screenCoords = windowPos + ScreenCoordsXY{ width / 2, height - 13 };
451 int32_t updatedWidth = this->width - 8;
452 int32_t lastaction = Network::GetPlayerLastAction(player, 0);
453 ft = Formatter();
454 if (lastaction != -999)
455 {
456 ft.Add<StringId>(Network::GetActionNameStringID(lastaction));
457 }
458 else
459 {
460 ft.Add<StringId>(STR_ACTION_NA);
461 }
462 drawTextEllipsised(rt, screenCoords, updatedWidth, STR_LAST_ACTION_RAN, ft, { TextAlignment::centre });
463
464 if (viewport != nullptr && _drawViewport)
465 {
466 WindowDrawViewport(rt, *this);
467 }
468 }
469
470 void onMouseDownOverview(WidgetIndex widgetIndex)

Callers

nothing calls this directly

Calls 15

GetPlayerIndexFunction · 0.85
GetGroupIndexFunction · 0.85
GetPlayerGroupFunction · 0.85
GetGroupNameFunction · 0.85
drawTextEllipsisedFunction · 0.85
drawTextFunction · 0.85
GetPlayerPingFunction · 0.85
GetPlayerLastActionFunction · 0.85
GetActionNameStringIDFunction · 0.85
WindowDrawViewportFunction · 0.85
midXMethod · 0.80
widthMethod · 0.80

Tested by

no test coverage detected