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

Function drawScroll

src/OpenLoco/src/Ui/Windows/MessageWindow.cpp:227–282  ·  view source on GitHub ↗

0x0042A5D7

Source from the content-addressed store, hash-verified

225
226 // 0x0042A5D7
227 static void drawScroll(Ui::Window& self, Gfx::DrawingContext& drawingCtx, [[maybe_unused]] const uint32_t scrollIndex)
228 {
229 auto colour = Colours::getShade(self.getColour(WindowColour::secondary).c(), 4);
230
231 const auto& rt = drawingCtx.currentRenderTarget();
232 auto tr = Gfx::TextRenderer(drawingCtx);
233
234 drawingCtx.clearSingle(colour);
235
236 auto height = 0;
237 for (auto i = 0; i < MessageManager::getNumMessages(); i++)
238 {
239 if (height + messageHeight <= rt.y)
240 {
241 height += messageHeight;
242 continue;
243 }
244 else if (height >= rt.y + rt.height)
245 {
246 break;
247 }
248
249 auto message = MessageManager::get(MessageId(i));
250 char* buffer = message->messageString;
251 auto str = const_cast<char*>(StringManager::getString(StringIds::buffer_2039));
252
253 const size_t bufferLength = 512;
254 strncpy(str, buffer, bufferLength);
255
256 auto stringId = StringIds::black_stringid;
257
258 if (self.rowHover == i)
259 {
260 drawingCtx.drawRect(0, height, self.width, 38, enumValue(ExtColour::unk30), Gfx::RectFlags::transparent);
261 stringId = StringIds::wcolour2_stringid;
262 }
263
264 {
265 auto args = FormatArguments();
266 args.push(StringIds::tiny_font_date);
267 args.push(message->date);
268
269 auto point = Point(0, height);
270 tr.drawStringLeft(point, Colour::black, stringId, args);
271 }
272 {
273 auto args = FormatArguments();
274 args.push(StringIds::buffer_2039);
275
276 auto width = self.widgets[widx::scrollview].width() - 14;
277 auto point = Point(0, height + 6);
278 tr.drawStringLeftWrapped(point, width, Colour::black, stringId, args);
279 height += messageHeight;
280 }
281 }
282 }
283
284 // 0x0042A7B9

Callers

nothing calls this directly

Calls 15

getShadeFunction · 0.85
TextRendererClass · 0.85
getNumMessagesFunction · 0.85
MessageIdEnum · 0.85
getStringFunction · 0.85
enumValueFunction · 0.85
cMethod · 0.80
getColourMethod · 0.80
clearSingleMethod · 0.80
drawStringLeftMethod · 0.80
drawStringLeftWrappedMethod · 0.80
getFunction · 0.50

Tested by

no test coverage detected