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

Function drawGraph

src/OpenLoco/src/Ui/Chart.cpp:246–294  ·  view source on GitHub ↗

0x004CF824

Source from the content-addressed store, hash-verified

244
245 // 0x004CF824
246 void drawGraph(GraphSettings& gs, Window& self, Gfx::DrawingContext& drawingCtx)
247 {
248 gs.canvasLeft = gs.xOffset + gs.left;
249 gs.canvasHeight = gs.height - gs.yOffset;
250 gs.canvasBottom = gs.top + gs.height - gs.yOffset;
251
252 int64_t maxValue = graphGetMaxValue(gs);
253
254 // 0x004CFA02
255
256 auto height = gs.canvasHeight;
257 if ((gs.flags & GraphFlags::showNegativeValues) != GraphFlags::none)
258 {
259 height >>= 1;
260 }
261
262 // We work out the number of shifts required to bring a 64bit value
263 // into something that is within the height range
264 gs.numValueShifts = 0;
265 for (auto adjustedMaxValue = maxValue; adjustedMaxValue > height; adjustedMaxValue >>= 1)
266 {
267 gs.numValueShifts++;
268 }
269
270 if ((gs.flags & GraphFlags::hideAxesAndLabels) == GraphFlags::none)
271 {
272 graphDrawAxesAndLabels(gs, self, drawingCtx);
273 }
274
275 // 0x004CFD59
276 for (auto j = 0; j < 2; j++)
277 {
278 auto pointFlag = GraphPointFlags(1U << j);
279 if ((gs.pointFlags & pointFlag) == GraphPointFlags::none)
280 {
281 continue;
282 }
283
284 for (auto i = 0U; i < gs.lineCount; i++)
285 {
286 if ((gs.linesToExclude & (1U << i)) != 0)
287 {
288 continue;
289 }
290
291 drawGraphLineSegments(gs, i, drawingCtx, pointFlag);
292 }
293 }
294 }
295}

Callers 2

drawFunction · 0.85
drawGraphAndLegendFunction · 0.85

Calls 4

graphGetMaxValueFunction · 0.85
graphDrawAxesAndLabelsFunction · 0.85
GraphPointFlagsEnum · 0.85
drawGraphLineSegmentsFunction · 0.85

Tested by

no test coverage detected