0x004CFA49
| 65 | |
| 66 | // 0x004CFA49 |
| 67 | static void graphDrawAxesAndLabels(const GraphSettings& gs, Window& self, Gfx::DrawingContext& drawingCtx) |
| 68 | { |
| 69 | auto xAxisLabelValue = gs.xAxisRange; |
| 70 | if ((gs.flags & GraphFlags::dataFrontToBack) != GraphFlags::none) |
| 71 | { |
| 72 | xAxisLabelValue -= (gs.dataEnd - 1) * gs.xAxisStepSize; |
| 73 | } |
| 74 | |
| 75 | // 0x004CFA74 |
| 76 | for (auto xTickPos = 0U; xTickPos < gs.dataEnd; xTickPos++) |
| 77 | { |
| 78 | auto remainder = xAxisLabelValue % gs.xAxisLabelIncrement; |
| 79 | |
| 80 | // Draw vertical lines for each of the data points |
| 81 | { |
| 82 | auto xPos = xTickPos * gs.xAxisTickIncrement + gs.left + gs.xOffset; |
| 83 | auto height = gs.canvasHeight + (remainder == 0 ? 3 : 0); |
| 84 | |
| 85 | auto colour = self.getColour(WindowColour::secondary).c(); |
| 86 | auto paletteIndex = Colours::getShade(colour, remainder == 0 ? 6 : 4); |
| 87 | |
| 88 | drawingCtx.drawRect(xPos, gs.top, 1, height, paletteIndex, Gfx::RectFlags::none); |
| 89 | } |
| 90 | |
| 91 | // No remainder means we get to draw a label on the horizontal axis, too |
| 92 | if (remainder == 0) |
| 93 | { |
| 94 | int16_t xPos = xTickPos * gs.xAxisTickIncrement + gs.left + gs.xOffset; |
| 95 | int16_t yPos = gs.canvasBottom + 5; |
| 96 | |
| 97 | auto tr = Gfx::TextRenderer(drawingCtx); |
| 98 | auto formatArgs = FormatArguments{}; |
| 99 | formatArgs.push(gs.xLabel); |
| 100 | formatArgs.push(xAxisLabelValue); |
| 101 | |
| 102 | tr.drawStringCentred({ xPos, yPos }, Colour::black, StringIds::graph_label_format, formatArgs); |
| 103 | } |
| 104 | |
| 105 | xAxisLabelValue += gs.xAxisStepSize; |
| 106 | } |
| 107 | |
| 108 | // 0x004CFB5C |
| 109 | auto yAxisPos = 0; |
| 110 | while (true) |
| 111 | { |
| 112 | // Draw horizontal lines for each of the vertical axis labels |
| 113 | { |
| 114 | auto colour = self.getColour(WindowColour::secondary).c(); |
| 115 | auto paletteIndex = Colours::getShade(colour, 6); |
| 116 | |
| 117 | auto xPos = gs.left + gs.xOffset - 2; |
| 118 | auto width = gs.width - gs.xOffset + 3; |
| 119 | auto yPos = -yAxisPos + gs.canvasHeight + gs.top; |
| 120 | if ((gs.flags & GraphFlags::showNegativeValues) != GraphFlags::none) |
| 121 | { |
| 122 | yPos -= gs.canvasHeight / 2; |
| 123 | } |
| 124 |
no test coverage detected