MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / Draw

Method Draw

src/openrct2-ui/interface/InGameConsole.cpp:298–407  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296}
297
298void InGameConsole::Draw(RenderTarget& rt) const
299{
300 if (!_isOpen)
301 return;
302
303 // Set font
304 ColourWithFlags textColour = { ThemeGetColour(WindowClass::console, 1).colour, {} };
305 const FontStyle style = InGameConsoleGetFontStyle();
306 const int32_t lineHeight = InGameConsoleGetLineHeight();
307 const int32_t maxLines = GetNumVisibleLines();
308
309 // TTF looks far better without the outlines
310 if (!LocalisationService_UseTrueTypeFont())
311 {
312 textColour.flags.set(ColourFlag::withOutline, true);
313 }
314
315 Invalidate();
316
317 // Give console area a translucent effect.
318 Rectangle::filter(rt, { _consoleTopLeft, _consoleBottomRight }, FilterPaletteID::palette51);
319
320 // Make input area more opaque.
321 Rectangle::filter(
322 rt, { { _consoleTopLeft.x, _consoleBottomRight.y - lineHeight - 10 }, _consoleBottomRight - ScreenCoordsXY{ 0, 1 } },
323 FilterPaletteID::palette51);
324
325 // Paint background colour.
326 auto backgroundColour = ThemeGetColour(WindowClass::console, 0);
327 Rectangle::fillInset(
328 rt, { _consoleTopLeft, _consoleBottomRight }, backgroundColour, Rectangle::BorderStyle::outset,
329 Rectangle::FillBrightness::light, Rectangle::FillMode::none);
330 Rectangle::fillInset(
331 rt, { _consoleTopLeft + ScreenCoordsXY{ 1, 1 }, _consoleBottomRight - ScreenCoordsXY{ 1, 1 } }, backgroundColour,
332 Rectangle::BorderStyle::inset);
333
334 std::string lineBuffer;
335 auto screenCoords = _consoleTopLeft + ScreenCoordsXY{ kConsoleEdgePadding, kConsoleEdgePadding };
336
337 // Draw text inside console
338 for (std::size_t i = 0; i < _consoleLines.size() && i < static_cast<size_t>(maxLines); i++)
339 {
340 const size_t index = i + _consoleScrollPos;
341 if (_consoleLines[index].second == FormatToken::colourWindow2)
342 {
343 // This is something of a hack to ensure the text is actually black
344 // as opposed to a desaturated grey
345 if (textColour.colour == OpenRCT2::Drawing::Colour::black)
346 {
347 drawText(rt, screenCoords, "{BLACK}", { textColour, style });
348 drawText(rt, screenCoords, _consoleLines[index].first, { kColourNull, style, { TextPaintFlag::noFormatting } });
349 }
350 else
351 {
352 drawText(rt, screenCoords, _consoleLines[index].first, { textColour, style, { TextPaintFlag::noFormatting } });
353 }
354 }
355 else

Callers 1

DrawFunction · 0.45

Calls 13

ThemeGetColourFunction · 0.85
filterFunction · 0.85
fillInsetFunction · 0.85
drawTextFunction · 0.85
getColourMapFunction · 0.85
fillFunction · 0.85
setMethod · 0.65
InvalidateFunction · 0.50

Tested by

no test coverage detected