MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / draw

Function draw

src/OpenLoco/src/Ui/Windows/Construction/ConstructionTab.cpp:3223–3358  ·  view source on GitHub ↗

0x0049CF36

Source from the content-addressed store, hash-verified

3221
3222 // 0x0049CF36
3223 static void draw(Window& self, Gfx::DrawingContext& drawingCtx)
3224 {
3225 self.draw(drawingCtx);
3226 Common::drawTabs(self, drawingCtx);
3227
3228 auto& cState = getConstructionState();
3229
3230 if (!self.widgets[widx::bridge].hidden)
3231 {
3232 if (cState.lastSelectedBridge != 0xFF)
3233 {
3234 auto bridgeObj = ObjectManager::get<BridgeObject>(cState.lastSelectedBridge);
3235 if (bridgeObj != nullptr)
3236 {
3237 auto company = CompanyManager::getPlayerCompany();
3238 auto imageId = Gfx::recolour(bridgeObj->image, company->mainColours.primary);
3239 auto x = self.x + self.widgets[widx::bridge].left + 2;
3240 auto y = self.y + self.widgets[widx::bridge].top + 1;
3241
3242 drawingCtx.drawImage(x, y, imageId);
3243 }
3244 }
3245 }
3246
3247 if (self.widgets[widx::construct].hidden)
3248 {
3249 return;
3250 }
3251
3252 if (cState.trackType & (1 << 7))
3253 {
3254 auto road = getRoadPieceId(cState.lastSelectedTrackPiece, cState.lastSelectedTrackGradient, cState.constructionRotation);
3255
3256 cState.previewMods = cState.lastSelectedMods;
3257
3258 if (!road)
3259 {
3260 return;
3261 }
3262
3263 cState.previewTrackType = cState.trackType & ~(1 << 7);
3264 cState.previewRotation = road->rotation;
3265 cState.lastSelectedTrackPieceId = road->id;
3266 cState.previewTrackPieceId = cState.lastSelectedTrackPieceId & 0x1F;
3267
3268 auto x = self.x + self.widgets[widx::construct].left + 1;
3269 auto y = self.y + self.widgets[widx::construct].top + 1;
3270 auto width = self.widgets[widx::construct].width();
3271 auto height = self.widgets[widx::construct].height();
3272
3273 const auto& rt = drawingCtx.currentRenderTarget();
3274 auto clipped = Gfx::clipRenderTarget(rt, Ui::Rect(x, y, width, height));
3275 if (clipped)
3276 {
3277 const auto& roadPiece = World::TrackData::getRoadPiece(cState.lastSelectedTrackPieceId);
3278 const auto& lastRoadPart = roadPiece.back();
3279
3280 Pos3 pos3D = { lastRoadPart.x, lastRoadPart.y, lastRoadPart.z };

Callers

nothing calls this directly

Calls 15

getPlayerCompanyFunction · 0.85
recolourFunction · 0.85
getRoadPieceIdFunction · 0.85
clipRenderTargetFunction · 0.85
RectClass · 0.85
getRoadPieceFunction · 0.85
gameToScreenFunction · 0.85
getCurrentRotationFunction · 0.85
drawRoadCostFunction · 0.85
drawCostStringFunction · 0.85
getTrackPieceIdFunction · 0.85
getTrackPieceFunction · 0.85

Tested by

no test coverage detected