MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / FormatText

Method FormatText

engine/Poseidon/UI/Controls/UIControls.cpp:271–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

269}
270
271void 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
327inline PackedColor ModAlpha(PackedColor color, float alpha)
328{

Callers 1

DisplayRevertMethod · 0.45

Calls 5

CopyTextElementFunction · 0.85
GetLangIDMethod · 0.80
ClearMethod · 0.45
AddMethod · 0.45
GetTextWidthMethod · 0.45

Tested by

no test coverage detected