| 89 | } |
| 90 | |
| 91 | void ScriptTileOverlay::drawWrappedBody(const std::string& text, int bodyY) const |
| 92 | { |
| 93 | TextPool& text_pool = TextPool::get(); |
| 94 | const float maxW = (float)(ScriptTile::UI_W - 2 * ScriptTile::PAD); |
| 95 | std::string wrapped = StringUtils::wrap(text, BODY_SIZE, maxW); |
| 96 | |
| 97 | // Cut to the lines that fit above the button row rather than letting the |
| 98 | // paragraph run under it. |
| 99 | const float lineH = StringUtils::textHeight("A", BODY_SIZE); |
| 100 | const int maxLines = std::max(1, (int)((buttonRowY() - 6 - bodyY) / (lineH > 0 ? lineH : 1))); |
| 101 | int lines = 1; |
| 102 | for (size_t i = 0; i < wrapped.size(); i++) { |
| 103 | if (wrapped[i] == '\n' && ++lines > maxLines) { |
| 104 | wrapped = wrapped.substr(0, i) + "..."; |
| 105 | break; |
| 106 | } |
| 107 | } |
| 108 | text_pool.drawWrapped(wrapped, (float)(ScriptTile::UI_X + ScriptTile::PAD), (float)bodyY, BODY_SIZE, COLOR_TEXT, maxW, ScriptTile::Z); |
| 109 | } |
| 110 | |
| 111 | /* ---- gui_message -------------------------------------------------------- */ |
| 112 |
nothing calls this directly
no test coverage detected