| 6523 | } |
| 6524 | |
| 6525 | void Item_TextScroll_Paint(itemDef_t *item) |
| 6526 | { |
| 6527 | char cvartext[1024]; |
| 6528 | float x, y, size, count, thumb; |
| 6529 | int i; |
| 6530 | textScrollDef_t *scrollPtr = (textScrollDef_t*)item->typeData; |
| 6531 | |
| 6532 | size = item->window.rect.h - 2; |
| 6533 | |
| 6534 | // Re-arranged this function. Previous version had a plethora of bugs. |
| 6535 | // Still a little iffy - BTO (VV) |
| 6536 | if (item->cvar) |
| 6537 | { |
| 6538 | DC->getCVarString(item->cvar, cvartext, sizeof(cvartext)); |
| 6539 | item->text = cvartext; |
| 6540 | } |
| 6541 | |
| 6542 | Item_TextScroll_BuildLines ( item ); |
| 6543 | count = scrollPtr->iLineCount; |
| 6544 | |
| 6545 | // Draw scroll bar if text goes beyond bottom |
| 6546 | if (( scrollPtr->iLineCount * scrollPtr->lineHeight ) > size) |
| 6547 | { |
| 6548 | // draw scrollbar to right side of the window |
| 6549 | x = item->window.rect.x + item->window.rect.w - SCROLLBAR_SIZE - 1; |
| 6550 | y = item->window.rect.y + 1; |
| 6551 | DC->drawHandlePic(x, y, SCROLLBAR_SIZE, SCROLLBAR_SIZE, DC->Assets.scrollBarArrowUp); |
| 6552 | y += SCROLLBAR_SIZE - 1; |
| 6553 | |
| 6554 | scrollPtr->endPos = scrollPtr->startPos; |
| 6555 | size = item->window.rect.h - (SCROLLBAR_SIZE * 2); |
| 6556 | DC->drawHandlePic(x, y, SCROLLBAR_SIZE, size+1, DC->Assets.scrollBar); |
| 6557 | y += size - 1; |
| 6558 | DC->drawHandlePic(x, y, SCROLLBAR_SIZE, SCROLLBAR_SIZE, DC->Assets.scrollBarArrowDown); |
| 6559 | |
| 6560 | // thumb |
| 6561 | thumb = Item_TextScroll_ThumbDrawPosition(item); |
| 6562 | if (thumb > y - SCROLLBAR_SIZE - 1) |
| 6563 | { |
| 6564 | thumb = y - SCROLLBAR_SIZE - 1; |
| 6565 | } |
| 6566 | DC->drawHandlePic(x, thumb, SCROLLBAR_SIZE, SCROLLBAR_SIZE, DC->Assets.scrollBarThumb); |
| 6567 | } |
| 6568 | |
| 6569 | // adjust size for item painting |
| 6570 | size = item->window.rect.h - 2; |
| 6571 | x = item->window.rect.x + item->textalignx + 1; |
| 6572 | y = item->window.rect.y + item->textaligny + 1; |
| 6573 | |
| 6574 | |
| 6575 | for (i = scrollPtr->startPos; i < count; i++) |
| 6576 | { |
| 6577 | const char *text; |
| 6578 | |
| 6579 | text = scrollPtr->pLines[i]; |
| 6580 | if (!text) |
| 6581 | { |
| 6582 | continue; |
no test coverage detected