| 5068 | } |
| 5069 | |
| 5070 | static void Item_TextScroll_BuildLines ( itemDef_t* item ) |
| 5071 | { |
| 5072 | // new asian-aware line breaker... (pasted from elsewhere late @ night, hence aliasing-vars ;-) |
| 5073 | // |
| 5074 | textScrollDef_t* scrollPtr = (textScrollDef_t*) item->typeData; |
| 5075 | const char *psText = item->text; // for copy/paste ease |
| 5076 | int iBoxWidth = item->window.rect.w - SCROLLBAR_SIZE - 10; |
| 5077 | |
| 5078 | // this could probably be simplified now, but it was converted from something else I didn't originally write, |
| 5079 | // and it works anyway so wtf... |
| 5080 | // |
| 5081 | const char *psCurrentTextReadPos; |
| 5082 | const char *psReadPosAtLineStart; |
| 5083 | const char *psBestLineBreakSrcPos; |
| 5084 | const char *psLastGood_s; // needed if we get a full screen of chars with no punctuation or space (see usage notes) |
| 5085 | qboolean bIsTrailingPunctuation; |
| 5086 | unsigned int uiLetter; |
| 5087 | |
| 5088 | if (!psText) |
| 5089 | { |
| 5090 | return; |
| 5091 | } |
| 5092 | |
| 5093 | if (*psText == '@') // string reference |
| 5094 | { |
| 5095 | // trap_SP_GetStringTextString( &psText[1], text, sizeof(text)); |
| 5096 | psText = SE_GetString( &psText[1] ); |
| 5097 | } |
| 5098 | |
| 5099 | psCurrentTextReadPos = psText; |
| 5100 | psReadPosAtLineStart = psCurrentTextReadPos; |
| 5101 | psBestLineBreakSrcPos = psCurrentTextReadPos; |
| 5102 | |
| 5103 | scrollPtr->iLineCount = 0; |
| 5104 | memset((char*)scrollPtr->pLines,0,sizeof(scrollPtr->pLines)); |
| 5105 | |
| 5106 | while (*psCurrentTextReadPos && (scrollPtr->iLineCount < MAX_TEXTSCROLL_LINES) ) |
| 5107 | { |
| 5108 | char sLineForDisplay[2048]; // ott |
| 5109 | |
| 5110 | // construct a line... |
| 5111 | // |
| 5112 | psCurrentTextReadPos = psReadPosAtLineStart; |
| 5113 | sLineForDisplay[0] = '\0'; |
| 5114 | while ( *psCurrentTextReadPos ) |
| 5115 | { |
| 5116 | int iAdvanceCount; |
| 5117 | psLastGood_s = psCurrentTextReadPos; |
| 5118 | |
| 5119 | // read letter... |
| 5120 | // |
| 5121 | uiLetter = ui.AnyLanguage_ReadCharFromString((char *)psCurrentTextReadPos, &iAdvanceCount, &bIsTrailingPunctuation); |
| 5122 | psCurrentTextReadPos += iAdvanceCount; |
| 5123 | |
| 5124 | // concat onto string so far... |
| 5125 | // |
| 5126 | if (uiLetter == 32 && sLineForDisplay[0] == '\0') |
| 5127 | { |
no test coverage detected