MCPcopy Create free account
hub / github.com/JACoders/OpenJK / Item_Text_Wrapped_Paint

Function Item_Text_Wrapped_Paint

code/ui/ui_shared.cpp:6313–6368  ·  view source on GitHub ↗

================= Item_Text_Wrapped_Paint ================= */

Source from the content-addressed store, hash-verified

6311=================
6312*/
6313void Item_Text_Wrapped_Paint(itemDef_t *item)
6314{
6315 char text[1024];
6316 const char *p, *start, *textPtr;
6317 char buff[1024];
6318 int width, height;
6319 float x, y;
6320 vec4_t color;
6321
6322 // now paint the text and/or any optional images
6323 // default to left
6324
6325 if (item->text == NULL)
6326 {
6327 if (item->cvar == NULL)
6328 {
6329 return;
6330 }
6331 else
6332 {
6333 DC->getCVarString(item->cvar, text, sizeof(text));
6334 textPtr = text;
6335 }
6336 }
6337 else
6338 {
6339 textPtr = item->text;
6340 }
6341 if (*textPtr == '@') // string reference
6342 {
6343 textPtr = SE_GetString( &textPtr[1] );
6344 }
6345
6346 if (*textPtr == '\0')
6347 {
6348 return;
6349 }
6350
6351 Item_TextColor(item, &color);
6352 Item_SetTextExtents(item, &width, &height, textPtr);
6353
6354 x = item->textRect.x;
6355 y = item->textRect.y;
6356 start = textPtr;
6357 p = strchr(textPtr, '\r');
6358 while (p && *p)
6359 {
6360 strncpy(buff, start, p-start+1);
6361 buff[p-start] = '\0';
6362 DC->drawText(x, y, item->textscale, color, buff, 0, item->textStyle, item->font);
6363 y += height + 5;
6364 start += p - start + 1;
6365 p = strchr(p+1, '\r');
6366 }
6367 DC->drawText(x, y, item->textscale, color, start, 0, item->textStyle, item->font);
6368}
6369
6370

Callers 1

Item_Text_PaintFunction · 0.70

Calls 3

Item_TextColorFunction · 0.70
Item_SetTextExtentsFunction · 0.70
SE_GetStringFunction · 0.50

Tested by

no test coverage detected