| 269 | } |
| 270 | |
| 271 | void CStatic::FormatText() |
| 272 | { |
| 273 | _lines.Clear(); |
| 274 | |
| 275 | float lineWidth = _w - 2 * _scale * textBorder; |
| 276 | float size = _scale * _size; |
| 277 | |
| 278 | const char* p = _text; |
| 279 | while (*p != 0) |
| 280 | { |
| 281 | // begin of the line |
| 282 | _lines.Add(p - (const char*)_text); |
| 283 | const char* word = p; |
| 284 | int n = 0; |
| 285 | float width = 0; |
| 286 | while (true) |
| 287 | { |
| 288 | const char* q = p; |
| 289 | char c = *p++; |
| 290 | if (c == 0) |
| 291 | { |
| 292 | return; |
| 293 | } |
| 294 | if (c == '\\' && *p == 'n') |
| 295 | { |
| 296 | p++; |
| 297 | break; |
| 298 | } |
| 299 | if (ISSPACE(c)) |
| 300 | { |
| 301 | n++; |
| 302 | word = p; |
| 303 | } |
| 304 | |
| 305 | char temp[8]; |
| 306 | p = _text + CopyTextElement(_text, static_cast<int>(q - (const char*)_text), _font->GetLangID(), temp, |
| 307 | sizeof(temp)); |
| 308 | width += GLOB_ENGINE->GetTextWidth(size, _font, temp); |
| 309 | |
| 310 | if (width > lineWidth) |
| 311 | { |
| 312 | if (n > 0) |
| 313 | { |
| 314 | p = word; |
| 315 | break; |
| 316 | } |
| 317 | else |
| 318 | { |
| 319 | p = q; |
| 320 | break; |
| 321 | } |
| 322 | } |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | inline PackedColor ModAlpha(PackedColor color, float alpha) |
| 328 | { |
no test coverage detected