| 41 | struct DemoText |
| 42 | { |
| 43 | DemoText(const std::filesystem::path& fontFilename, std::string_view message) : |
| 44 | font(std::make_unique<sf::Font>(resourcesDir() / fontFilename)), |
| 45 | text(*font, sf::String::fromUtf8(message.begin(), message.end()), textSize) |
| 46 | { |
| 47 | // Generate per-character effect data |
| 48 | // Since this is peformed on the input string data it only has to be done once |
| 49 | generateEffectData(); |
| 50 | |
| 51 | const auto localBounds = text.getLocalBounds(); |
| 52 | |
| 53 | // Fix cases where the text is so tall it starts at a negative offset |
| 54 | currentYPosition -= localBounds.position.y; |
| 55 | text.setPosition({(static_cast<float>(windowWidth) - localBounds.size.x) / 2.0f, currentYPosition}); |
| 56 | currentYPosition = text.getGlobalBounds().position.y + text.getGlobalBounds().size.y + textSpacing; |
| 57 | |
| 58 | // Set up text bounding box |
| 59 | boundingBox.setFillColor(sf::Color::Transparent); |
| 60 | boundingBox.setOutlineColor(sf::Color::Red); |
| 61 | boundingBox.setOutlineThickness(1.0f); |
| 62 | |
| 63 | // Set up glyph bounding box |
| 64 | glyphBox.setFillColor(sf::Color::Transparent); |
| 65 | glyphBox.setOutlineColor(sf::Color::Green); |
| 66 | glyphBox.setOutlineThickness(1.0f); |
| 67 | |
| 68 | // Set up cursor |
| 69 | cursor.setFillColor(sf::Color::White); |
| 70 | |
| 71 | // Set up dynamic data |
| 72 | update(); |
| 73 | } |
| 74 | |
| 75 | void setPosition(const sf::Vector2f& position) |
| 76 | { |
nothing calls this directly
no test coverage detected