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

Method DrawWidget

src/rail_gui.cpp:1199–1236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1197 }
1198
1199 void DrawWidget(const Rect &r, WidgetID widget) const override
1200 {
1201 DrawPixelInfo tmp_dpi;
1202
1203 switch (widget) {
1204 case WID_BRAS_PLATFORM_DIR_X: {
1205 /* Set up a clipping area for the '/' station preview */
1206 Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
1207 if (FillDrawPixelInfo(&tmp_dpi, ir)) {
1208 AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
1209 int x = (ir.Width() - ScaleSpriteTrad(PREVIEW_WIDTH)) / 2 + ScaleSpriteTrad(PREVIEW_LEFT);
1210 int y = (ir.Height() + ScaleSpriteTrad(PREVIEW_HEIGHT)) / 2 - ScaleSpriteTrad(PREVIEW_BOTTOM);
1211 if (!DrawStationTile(x, y, _cur_railtype, AXIS_X, _station_gui.sel_class, _station_gui.sel_type)) {
1212 StationPickerDrawSprite(x, y, StationType::Rail, _cur_railtype, INVALID_ROADTYPE, 2);
1213 }
1214 }
1215 break;
1216 }
1217
1218 case WID_BRAS_PLATFORM_DIR_Y: {
1219 /* Set up a clipping area for the '\' station preview */
1220 Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
1221 if (FillDrawPixelInfo(&tmp_dpi, ir)) {
1222 AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
1223 int x = (ir.Width() - ScaleSpriteTrad(PREVIEW_WIDTH)) / 2 + ScaleSpriteTrad(PREVIEW_LEFT);
1224 int y = (ir.Height() + ScaleSpriteTrad(PREVIEW_HEIGHT)) / 2 - ScaleSpriteTrad(PREVIEW_BOTTOM);
1225 if (!DrawStationTile(x, y, _cur_railtype, AXIS_Y, _station_gui.sel_class, _station_gui.sel_type)) {
1226 StationPickerDrawSprite(x, y, StationType::Rail, _cur_railtype, INVALID_ROADTYPE, 3);
1227 }
1228 }
1229 break;
1230 }
1231
1232 default:
1233 this->PickerWindow::DrawWidget(r, widget);
1234 break;
1235 }
1236 }
1237
1238 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1239 {

Callers

nothing calls this directly

Calls 7

ScaleSpriteTradFunction · 0.85
DrawStationTileFunction · 0.85
StationPickerDrawSpriteFunction · 0.85
ShrinkMethod · 0.80
FillDrawPixelInfoFunction · 0.70
WidthMethod · 0.45
HeightMethod · 0.45

Tested by

no test coverage detected