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

Function setBitmapForSprite

src/openrct2/drawing/ScrollingText.cpp:1469–1523  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1467 }
1468
1469 static void setBitmapForSprite(
1470 std::string_view text, int32_t scroll, PaletteIndex* bitmap, const int16_t* scrollPositionOffsets, PaletteIndex colour)
1471 {
1472 auto characterColour = colour;
1473 auto fmt = FmtString(text);
1474
1475 // Repeat string a maximum of four times (eliminates possibility of infinite loop)
1476 for (auto i = 0; i < 4; i++)
1477 {
1478 for (const auto& token : fmt)
1479 {
1480 if (token.IsLiteral())
1481 {
1482 CodepointView codepoints(token.text);
1483 for (auto codepoint : codepoints)
1484 {
1485 auto characterWidth = FontSpriteGetCodepointWidth(FontStyle::tiny, codepoint);
1486 auto characterBitmap = FontSpriteGetCodepointBitmap(codepoint);
1487 for (; characterWidth != 0; characterWidth--, characterBitmap++)
1488 {
1489 // Skip any non-displayed columns
1490 if (scroll != 0)
1491 {
1492 scroll--;
1493 continue;
1494 }
1495
1496 int16_t scrollPosition = *scrollPositionOffsets;
1497 if (scrollPosition == -1)
1498 return;
1499
1500 if (scrollPosition > -1)
1501 {
1502 auto dst = &bitmap[scrollPosition];
1503 for (uint8_t char_bitmap = *characterBitmap; char_bitmap != 0; char_bitmap >>= 1)
1504 {
1505 if (char_bitmap & 1)
1506 *dst = characterColour;
1507
1508 // Jump to next row
1509 dst += 64;
1510 }
1511 }
1512 scrollPositionOffsets++;
1513 }
1514 }
1515 }
1516 else if (FormatTokenIsColour(token.kind))
1517 {
1518 auto colourIndex = FormatTokenToTextColour(token.kind);
1519 characterColour = getTextColourMapping(colourIndex).fill;
1520 }
1521 }
1522 }
1523 }
1524
1525 static void setBitmapForTTF(
1526 std::string_view text, int32_t scroll, PaletteIndex* bitmap, const int16_t* scrollPositionOffsets, PaletteIndex colour)

Callers 2

setupFunction · 0.85
setBitmapForTTFFunction · 0.85

Calls 7

FmtStringClass · 0.85
FormatTokenIsColourFunction · 0.85
FormatTokenToTextColourFunction · 0.85
getTextColourMappingFunction · 0.85
IsLiteralMethod · 0.80

Tested by

no test coverage detected