MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / DrawWidget

Method DrawWidget

src/road_gui.cpp:1437–1467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1435 }
1436
1437 void DrawWidget(const Rect &r, WidgetID widget) const override
1438 {
1439 switch (widget) {
1440 case WID_BROS_STATION_NE:
1441 case WID_BROS_STATION_SE:
1442 case WID_BROS_STATION_SW:
1443 case WID_BROS_STATION_NW:
1444 case WID_BROS_STATION_X:
1445 case WID_BROS_STATION_Y: {
1446 StationType st = GetRoadStationTypeByWindowClass(this->window_class);
1447 const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui.sel_class)->GetSpec(_roadstop_gui.sel_type);
1448 DrawPixelInfo tmp_dpi;
1449 Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
1450 if (FillDrawPixelInfo(&tmp_dpi, ir)) {
1451 AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
1452 int x = (ir.Width() - ScaleSpriteTrad(PREVIEW_WIDTH)) / 2 + ScaleSpriteTrad(PREVIEW_LEFT);
1453 int y = (ir.Height() + ScaleSpriteTrad(PREVIEW_HEIGHT)) / 2 - ScaleSpriteTrad(PREVIEW_BOTTOM);
1454 if (spec == nullptr) {
1455 StationPickerDrawSprite(x, y, st, INVALID_RAILTYPE, _cur_roadtype, widget - WID_BROS_STATION_NE);
1456 } else {
1457 DrawRoadStopTile(x, y, _cur_roadtype, spec, st, widget - WID_BROS_STATION_NE);
1458 }
1459 }
1460 break;
1461 }
1462
1463 default:
1464 this->PickerWindow::DrawWidget(r, widget);
1465 break;
1466 }
1467 }
1468
1469 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1470 {

Callers

nothing calls this directly

Calls 8

ScaleSpriteTradFunction · 0.85
StationPickerDrawSpriteFunction · 0.85
DrawRoadStopTileFunction · 0.85
ShrinkMethod · 0.80
FillDrawPixelInfoFunction · 0.70
GetSpecMethod · 0.45
WidthMethod · 0.45
HeightMethod · 0.45

Tested by

no test coverage detected