Mercurial > mm7
annotate GUIFont.cpp @ 1872:661ea35def76
Merge
author | Grumpy7 |
---|---|
date | Thu, 17 Oct 2013 03:47:31 +0200 |
parents | c4ab816fcc5e |
children | 259df09dfb50 |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
4 |
0 | 5 #include <string> |
200 | 6 |
180 | 7 #include "LOD.h" |
0 | 8 #include "GUIFont.h" |
9 #include "GUIWindow.h" | |
10 #include "Render.h" | |
11 | |
12 #include "mm7_data.h" | |
13 | |
14 | |
180 | 15 extern LODFile_IconsBitmaps *pIcons_LOD; |
0 | 16 |
17 | |
18 struct GUIFont *pAutonoteFont; | |
19 struct GUIFont *pSpellFont; | |
20 struct GUIFont *pFontArrus; | |
21 struct GUIFont *pFontLucida; | |
22 struct GUIFont *pBook2Font; | |
23 struct GUIFont *pBookFont; | |
24 struct GUIFont *pFontCreate; | |
25 struct GUIFont *pFontCChar; | |
26 struct GUIFont *pFontComic; | |
27 struct GUIFont *pFontSmallnum; | |
28 | |
189 | 29 char temp_string[2048]; |
30 | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1168
diff
changeset
|
31 std::array<char, 10000> pTmpBuf3; |
189 | 32 |
1160 | 33 void DrawCharToBuff(unsigned short* uXpos,unsigned char* pCharPixels, int uCharWidth, int uCharHeight, unsigned __int16* pFontPalette, __int16 draw_color, int line_width); |
34 | |
35 | |
180 | 36 //----- (0044C448) -------------------------------------------------------- |
37 GUIFont *LoadFont(const char *pFontFile, const char *pFontPalette, ...) | |
1160 | 38 { |
39 int pallete_index; // eax@3 | |
40 GUIFont *pFont; | |
41 unsigned int palletes_count =0; | |
42 va_list palettes_ptr; | |
180 | 43 |
1160 | 44 pFont = (GUIFont *)pIcons_LOD->LoadRaw(pFontFile, 0); |
45 va_start(palettes_ptr, pFontFile); | |
180 | 46 |
1160 | 47 while (NULL!=(pFontPalette=va_arg(palettes_ptr, const char *))) |
48 { | |
49 pallete_index =pIcons_LOD->LoadTexture(pFontPalette, TEXTURE_16BIT_PALETTE); | |
50 if (pallete_index == -1) | |
1545 | 51 Error("Unable to open %s", pFontPalette); |
52 | |
1160 | 53 pFont->pFontPalettes[palletes_count] = pIcons_LOD->pTextures[pallete_index].pPalette16; |
54 ++palletes_count; | |
55 } | |
56 va_end(palettes_ptr); | |
57 pFont->palletes_count = palletes_count; | |
58 return pFont; | |
59 } | |
0 | 60 |
61 | |
62 | |
63 //----- (0044D2FD) -------------------------------------------------------- | |
1168 | 64 void GUIFont::_44D2FD_prolly_draw_credits_entry( GUIFont *pSecondFont, int uFrameX, int uFrameY, unsigned int w, unsigned int h, |
65 unsigned __int16 firstColor, unsigned __int16 secondColor, const char *pString, | |
66 unsigned __int16 *pPixels, unsigned int uPixelsWidth ) | |
67 { | |
68 char *work_string; // eax@1 | |
69 unsigned __int16 *curr_pixel_pos; // esi@1 | |
70 GUIFont *currentFont; // edi@4 | |
71 signed int start_str_pos; // ecx@4 | |
72 signed int line_w; // eax@6 | |
73 GUIWindow draw_window; // [sp+Ch] [bp-5Ch]@ | |
74 int currentColor; // [sp+74h] [bp+Ch]@4 | |
75 int half_frameX; // [sp+80h] [bp+18h]@2 | |
0 | 76 |
1168 | 77 draw_window.uFrameHeight = h; |
78 draw_window.uFrameW = uFrameY + h - 1; | |
79 draw_window.uFrameWidth = w; | |
80 draw_window.uFrameZ = uFrameX + w - 1; | |
81 ui_current_text_color = firstColor; | |
82 draw_window.uFrameX = uFrameX; | |
83 draw_window.uFrameY = uFrameY; | |
84 | |
85 work_string = GUIFont::FitTwoFontStringINWindow(pString, this, pSecondFont, &draw_window, 0, 1); | |
86 work_string = strtok(work_string, "\n"); | |
87 curr_pixel_pos = &pPixels[uPixelsWidth * uFrameY]; | |
88 if ( work_string ) | |
0 | 89 { |
1168 | 90 half_frameX = uFrameX >> 1; |
0 | 91 while ( 1 ) |
92 { | |
1168 | 93 currentFont = this; |
94 ui_current_text_color = firstColor; | |
95 start_str_pos = 0; | |
96 currentColor = firstColor; | |
97 if ( *work_string == '_' ) | |
0 | 98 { |
1168 | 99 currentFont = pSecondFont; |
100 currentColor = secondColor; | |
101 ui_current_text_color = secondColor; | |
102 start_str_pos = 1; | |
0 | 103 } |
1168 | 104 line_w = (signed int)(w - currentFont->GetLineWidth(&work_string[start_str_pos]))/2; |
105 if ( line_w < 0 ) | |
106 line_w = 0; | |
107 currentFont->DrawTextLineToBuff(currentColor, secondColor, &curr_pixel_pos[line_w + half_frameX], work_string, uPixelsWidth); | |
108 curr_pixel_pos += uPixelsWidth * (currentFont->uFontHeight - 3); | |
109 work_string = strtok(0, "\n"); | |
110 if ( !work_string ) | |
0 | 111 break; |
112 } | |
113 } | |
114 } | |
1168 | 115 |
0 | 116 |
117 | |
118 //----- (0044D1E7) -------------------------------------------------------- | |
1160 | 119 void GUIFont::DrawTextLine( unsigned int uDefaultColor, signed int uX, signed int uY, |
120 const char *text, int max_len_pix ) | |
0 | 121 { |
1160 | 122 signed int uX_pos; // edi@3 |
123 unsigned char c; // cl@4 | |
124 unsigned __int16 draw_color; // cx@12 | |
125 unsigned __int8 *pCharPixels; // eax@12 | |
126 char color_code[20]; // [sp+Ch] [bp-1Ch]@16 | |
127 int text_length; // [sp+20h] [bp-8h]@2 | |
128 int text_color; // [sp+24h] [bp-4h]@1 | |
129 int uCharWidth; // [sp+30h] [bp+8h]@9 | |
0 | 130 |
1160 | 131 if ( !text ) |
132 return; | |
133 text_color = ui_current_text_color; | |
134 text_length = strlen(text); | |
135 uX_pos=uX; | |
136 for (int i=0; i<text_length; ++i ) | |
0 | 137 { |
1160 | 138 c = text[i]; |
139 if ( IsCharValid(c) ) | |
0 | 140 { |
1160 | 141 switch (c) |
0 | 142 { |
1160 | 143 case '\n': //Line Feed 0A 10: |
144 return; | |
145 break; | |
146 case '\f': //Form Feed, page eject 0C 12 | |
147 strncpy(color_code, &text[i + 1], 5); | |
148 color_code[5] = 0; | |
149 text_color = atoi(color_code); | |
150 ui_current_text_color = text_color; | |
151 i += 5; | |
152 break; | |
153 case '\t': // Horizontal tab 09 | |
154 case '\r': //Carriage Return 0D 13 | |
155 break; | |
156 default: | |
157 uCharWidth = pMetrics[c].uWidth; | |
158 if ( uCharWidth ) | |
159 { | |
160 if ( i > 0 ) | |
161 uX_pos += pMetrics[c].uLeftSpacing; | |
162 draw_color = text_color; | |
163 pCharPixels = &pFontData[font_pixels_offset[c]]; | |
164 if ( !text_color ) | |
165 draw_color = -1; | |
166 pRenderer->DrawText(uX_pos, uY, pCharPixels, uCharWidth, uFontHeight, pFontPalettes[0], draw_color, 0); | |
167 uX_pos += uCharWidth; | |
168 if ( i < text_length ) | |
169 uX_pos += pMetrics[c].uRightSpacing; | |
170 } | |
0 | 171 } |
172 } | |
1160 | 173 } |
174 | |
175 } | |
176 | |
177 //----- (0040F845) -------------------------------------------------------- | |
178 void DrawCharToBuff( unsigned short* uXpos,unsigned char* pCharPixels, int uCharWidth, int uCharHeight, | |
179 unsigned __int16* pFontPalette, __int16 draw_color, int line_width ) | |
180 { | |
181 unsigned __int16* draw_buff; // edi@1 | |
182 unsigned char* pPixels; // esi@1 | |
183 unsigned char char_pxl; // eax@3 | |
184 | |
185 draw_buff = uXpos; | |
186 pPixels = pCharPixels; | |
187 for(int i=0; i<uCharHeight; ++i) | |
188 { | |
189 for(int j=0; j<uCharWidth; ++j) | |
0 | 190 { |
1160 | 191 char_pxl = *pPixels++; |
192 if ( char_pxl ) | |
193 { | |
194 if ( char_pxl == 1 ) | |
195 *draw_buff = pFontPalette[1]; | |
196 else | |
197 *draw_buff = draw_color; | |
198 } | |
199 ++draw_buff; | |
0 | 200 } |
1160 | 201 draw_buff+=line_width-uCharWidth; |
0 | 202 } |
1160 | 203 |
0 | 204 } |
205 | |
206 //----- (0044D0B5) -------------------------------------------------------- | |
1160 | 207 void GUIFont::DrawTextLineToBuff( int uColor, int a3, unsigned short* uX_buff_pos, const char *text, int line_width ) |
208 { | |
209 | |
210 unsigned short* uX_pos; // edi@3 | |
211 unsigned char c; // cl@4 | |
212 unsigned __int16 draw_color; // cx@12 | |
213 unsigned __int8 *pCharPixels; // eax@12 | |
214 char color_code[20]; // [sp+Ch] [bp-1Ch]@16 | |
215 int text_length; // [sp+20h] [bp-8h]@2 | |
216 int text_color; // [sp+24h] [bp-4h]@1 | |
217 int uCharWidth; // [sp+30h] [bp+8h]@9 | |
0 | 218 |
1160 | 219 if ( !text ) |
220 return; | |
221 text_color = ui_current_text_color; | |
222 text_length = strlen(text); | |
223 uX_pos=uX_buff_pos; | |
224 for (int i=0; i<text_length; ++i ) | |
0 | 225 { |
1160 | 226 c = text[i]; |
227 if ( IsCharValid(c) ) | |
0 | 228 { |
1160 | 229 switch (c) |
230 { | |
231 case '\n': //Line Feed 0A 10: | |
0 | 232 return; |
1160 | 233 break; |
234 case '\f': //Form Feed, page eject 0C 12 | |
235 strncpy(color_code, &text[i + 1], 5); | |
236 color_code[5] = 0; | |
237 text_color = atoi(color_code); | |
238 ui_current_text_color = text_color; | |
239 i += 5; | |
240 break; | |
241 case '\t': // Horizontal tab 09 | |
1168 | 242 case '_': |
1160 | 243 break; |
244 default: | |
245 uCharWidth = pMetrics[c].uWidth; | |
246 if ( uCharWidth ) | |
0 | 247 { |
1160 | 248 if ( i > 0 ) |
249 uX_pos += pMetrics[c].uLeftSpacing; | |
250 draw_color = text_color; | |
251 pCharPixels = &pFontData[font_pixels_offset[c]]; | |
252 if ( !text_color ) | |
253 draw_color = -1; | |
254 DrawCharToBuff(uX_pos, pCharPixels, uCharWidth, uFontHeight, pFontPalettes[0], draw_color, line_width); | |
255 uX_pos += uCharWidth; | |
256 if ( i < text_length ) | |
257 uX_pos += pMetrics[c].uRightSpacing; | |
0 | 258 } |
259 } | |
260 } | |
261 } | |
262 } | |
1160 | 263 |
0 | 264 |
265 | |
266 //----- (0044C933) -------------------------------------------------------- | |
1168 | 267 char * GUIFont::FitTwoFontStringINWindow( const char *pString, GUIFont *pFontMain, GUIFont *pFontSecond, GUIWindow* pWindow, int startPixlOff, int a6 ) |
268 { | |
269 | |
270 GUIFont *currentFont; // esi@3 | |
271 unsigned char c; | |
272 int uInStrLen; | |
273 char digits[4]; | |
274 int possible_transition_point; | |
275 int string_pixel_Width; | |
276 int start_pixel_offset; | |
277 | |
278 if (!pString) | |
279 { | |
280 MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:445", 0); | |
281 return 0; | |
282 } | |
283 currentFont=pFontMain; // esi@3 | |
284 uInStrLen = strlen(pString); | |
1545 | 285 Assert(uInStrLen < sizeof(pTmpBuf3)); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1168
diff
changeset
|
286 strcpy(pTmpBuf3.data(), pString); |
1168 | 287 if (uInStrLen==0) |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1168
diff
changeset
|
288 return pTmpBuf3.data(); |
0 | 289 |
1168 | 290 start_pixel_offset=string_pixel_Width=startPixlOff; |
291 possible_transition_point=0; | |
292 for(int i=0; i<uInStrLen; ++i) | |
293 { | |
294 c=pTmpBuf3[i]; | |
295 if (pFontMain->IsCharValid(c)) | |
296 { | |
297 switch (c) | |
298 { | |
299 case '\t': // Horizontal tab 09 | |
300 { | |
301 strncpy(digits, &pTmpBuf3[i+1],3); | |
302 digits[3]=0; | |
303 string_pixel_Width = atoi(digits)+startPixlOff; | |
304 i+=3; | |
305 break; | |
306 } | |
307 case '\n': //Line Feed 0A 10 | |
308 { | |
309 string_pixel_Width=start_pixel_offset; | |
310 possible_transition_point=i; | |
311 currentFont=pFontMain; | |
312 break; | |
313 } | |
314 case '\f': //Form Feed, page eject 0C 12 | |
315 { | |
316 i+=5; | |
317 break; | |
318 } | |
319 case '\r': //Carriage Return 0D 13 | |
320 { | |
321 if (!a6) | |
322 return (char*)pString; | |
323 break; | |
324 } | |
325 case ' ' : | |
326 { | |
327 string_pixel_Width+=currentFont->pMetrics[c].uWidth; | |
328 possible_transition_point=i; | |
329 break; | |
330 } | |
331 case '_' : | |
332 currentFont=pFontSecond; | |
333 break; | |
334 default: | |
200 | 335 |
1168 | 336 if ((string_pixel_Width+currentFont->pMetrics[c].uWidth+ currentFont->pMetrics[c].uLeftSpacing+ |
337 currentFont->pMetrics[c].uRightSpacing)<pWindow->uFrameWidth) | |
0 | 338 { |
1168 | 339 if(i>possible_transition_point) |
340 string_pixel_Width+=currentFont->pMetrics[c].uLeftSpacing; | |
341 string_pixel_Width+=currentFont->pMetrics[c].uWidth; | |
342 if (i<uInStrLen) | |
343 string_pixel_Width+=currentFont->pMetrics[c].uRightSpacing; | |
344 } | |
345 else | |
346 { | |
347 pTmpBuf3[possible_transition_point]='\n'; | |
348 | |
349 if ( currentFont== pFontSecond) | |
0 | 350 { |
1168 | 351 |
352 for(int k=uInStrLen-1; k>=possible_transition_point+1; --k) | |
353 pTmpBuf3[k] = pTmpBuf3[k-1]; | |
354 | |
355 ++uInStrLen; | |
356 ++possible_transition_point; | |
357 pTmpBuf3[possible_transition_point] = '_'; | |
358 | |
0 | 359 } |
1168 | 360 string_pixel_Width=start_pixel_offset; |
361 | |
362 for(int j=possible_transition_point;j<i; ++j ) | |
363 { | |
364 c=pTmpBuf3[j]; | |
365 if (pFontMain->IsCharValid(c)) | |
366 { | |
367 if(j>possible_transition_point) | |
368 string_pixel_Width+=pFontMain->pMetrics[c].uLeftSpacing; | |
369 string_pixel_Width+=pFontMain->pMetrics[c].uWidth; | |
370 if (j<i) | |
371 string_pixel_Width+=pFontMain->pMetrics[c].uRightSpacing; | |
372 | |
373 } | |
374 } | |
0 | 375 } |
376 } | |
377 } | |
378 } | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1168
diff
changeset
|
379 return pTmpBuf3.data(); |
1168 | 380 |
0 | 381 } |
382 | |
383 | |
384 //----- (0044C6C2) -------------------------------------------------------- | |
1453 | 385 char* GUIFont::GetPageTop( const char *pInString, GUIWindow *pWindow, unsigned int uX, int a5 ) |
386 { | |
1160 | 387 int text_height; // edi@1 |
388 char *text_str; // ebx@3 | |
389 unsigned char c; // cl@4 | |
390 int text_length; | |
0 | 391 |
1160 | 392 text_height = 0; |
393 | |
0 | 394 if ( !pInString ) |
395 return 0; | |
1160 | 396 text_str = FitTextInAWindow(pInString, this, pWindow, uX, 0); |
397 text_length = strlen(text_str); | |
1453 | 398 for ( int i = 0; i < text_length; ++i ) |
399 { | |
400 c = text_str[i]; | |
401 if ( IsCharValid(c) ) | |
402 { | |
403 switch (c) | |
1160 | 404 { |
1453 | 405 case '\n': //Line Feed 0A 10: |
406 text_height = text_height + (uFontHeight - 3); | |
407 if ( text_height >= (signed int)(a5 * (pWindow->uFrameHeight - (uFontHeight - 3))) ) | |
408 return &text_str[i]; | |
409 break; | |
410 case '\f': //Form Feed, page eject 0C 12 | |
411 i += 5; | |
412 break; | |
413 case '\t': // Horizontal tab 09 | |
414 case '\r': //Carriage Return 0D 13 | |
415 i += 3; | |
416 break; | |
1160 | 417 } |
1453 | 418 if ( text_height >= (signed int)(a5 * pWindow->uFrameHeight) ) |
419 break; | |
420 } | |
421 } | |
422 return &text_str[0]; | |
0 | 423 } |
424 | |
425 //----- (0044C62E) -------------------------------------------------------- | |
1168 | 426 int GUIFont::GetStringHeight2( GUIFont *secondFont, const char *text_str, GUIWindow* pWindow, int startX, int a6 ) |
427 { | |
1166 | 428 |
429 int uAllHeght; | |
430 int uStringLen; | |
431 unsigned char c; | |
432 char *test_string; | |
0 | 433 |
1168 | 434 if ( !text_str ) |
0 | 435 return 0; |
1168 | 436 uAllHeght = uFontHeight - 3; |
437 test_string = FitTwoFontStringINWindow(text_str, this, secondFont, pWindow, startX, 0); | |
1166 | 438 uStringLen = strlen(test_string); |
439 for (int i = 0; i < uStringLen; ++i) | |
0 | 440 { |
1166 | 441 c = test_string[i]; |
442 if (IsCharValid(c)) | |
0 | 443 { |
1166 | 444 switch (c) |
445 { | |
446 case '\n': //Line Feed 0A 10: | |
1168 | 447 uAllHeght+= uFontHeight - 3; |
1166 | 448 break; |
449 case '\f': //Form Feed, page eject 0C 12 | |
450 i += 5; | |
451 break; | |
452 case '\t': // Horizontal tab 09 | |
453 case '\r': //Carriage Return 0D 13 | |
454 if (a6 != 1) | |
455 i += 3; | |
456 break; | |
457 } | |
0 | 458 } |
459 } | |
1166 | 460 |
461 return uAllHeght; | |
0 | 462 } |
463 | |
464 //----- (0044C59D) -------------------------------------------------------- | |
1160 | 465 int GUIFont::CalcTextHeight( const char *pString, struct GUIWindow *pWindow, int uXOffset, int a5 ) |
1453 | 466 { |
467 int uAllHeght; | |
468 int uStringLen; | |
469 unsigned char c; | |
470 char *test_string; | |
0 | 471 |
1453 | 472 if (!pString) |
473 return 0; | |
474 uAllHeght = uFontHeight - 6; | |
475 test_string = FitTextInAWindow(pString, this, pWindow, uXOffset, 0); | |
476 uStringLen = strlen(pString); | |
477 for (int i = 0; i < uStringLen; ++i) | |
478 { | |
479 c = test_string[i]; | |
480 if (IsCharValid(c)) | |
481 { | |
482 switch (c) | |
483 { | |
484 case '\n': //Line Feed 0A 10: | |
485 uAllHeght += uFontHeight - 3; | |
486 break; | |
487 case '\f': //Form Feed, page eject 0C 12 | |
488 i += 5; | |
489 break; | |
490 case '\t': // Horizontal tab 09 | |
491 case '\r': //Carriage Return 0D 13 | |
492 if (a5 != 1) | |
493 i += 3; | |
494 break; | |
495 } | |
496 } | |
497 } | |
498 return uAllHeght; | |
499 } | |
0 | 500 |
501 //----- (0044C51E) -------------------------------------------------------- | |
502 int GUIFont::GetLineWidth(const char *pString) | |
180 | 503 { |
1160 | 504 int str_len; // ebp@3 |
180 | 505 int string_line_width; // esi@3 |
506 unsigned char c; | |
0 | 507 |
180 | 508 if (!pString) |
509 return 0; | |
510 str_len = strlen(pString); | |
511 string_line_width = 0; | |
512 for ( int i = 0; i < str_len; ++i ) | |
513 { | |
514 c = pString[i]; | |
515 if (IsCharValid(c)) | |
516 { | |
517 switch (c) | |
518 { | |
519 case '\t': | |
520 case '\n': | |
521 case '\r': | |
522 return string_line_width; | |
523 case '\f': | |
524 i += 5; | |
525 break; | |
526 default: | |
527 if (i > 0) | |
1168 | 528 string_line_width += pMetrics[c].uLeftSpacing; |
529 string_line_width += pMetrics[c].uWidth; | |
180 | 530 if (i < str_len) |
1168 | 531 string_line_width +=pMetrics[c].uRightSpacing; |
180 | 532 } |
533 } | |
534 } | |
535 return string_line_width; | |
536 } | |
0 | 537 |
538 | |
539 //----- (0044C502) -------------------------------------------------------- | |
540 int GUIFont::AlignText_Center(unsigned int uCenterX, const char *pString) | |
541 { | |
180 | 542 signed int position; // esi@1 |
543 | |
544 position = (signed int)(uCenterX - GetLineWidth(pString)) >> 1; | |
545 if ( position >= 0 ) | |
546 return position; | |
547 else | |
548 return 0; | |
0 | 549 } |
550 | |
180 | 551 //----- (0044C768) -------------------------------------------------------- |
688 | 552 char * FitTextInAWindow( const char *pInString, GUIFont *pFont, GUIWindow *pWindow, signed int uX, int a5 ) |
1453 | 553 { |
554 unsigned char c; | |
555 int uInStrLen; | |
556 char digits[4]; | |
557 int possible_transition_point; | |
558 int string_pixel_Width; | |
559 int start_pixel_offset; | |
0 | 560 |
1453 | 561 if (!pInString) |
562 { | |
563 MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:445", 0); | |
564 return 0; | |
565 } | |
566 uInStrLen = strlen(pInString); | |
567 strcpy(&temp_string[0], pInString); | |
568 if (uInStrLen == 0) | |
569 return &temp_string[0]; | |
189 | 570 |
1453 | 571 start_pixel_offset = string_pixel_Width=uX; |
572 possible_transition_point = 0; | |
573 for ( int i = 0; i < uInStrLen; ++i ) | |
574 { | |
575 c = temp_string[i]; | |
576 if (pFont->IsCharValid(c)) | |
577 { | |
578 switch (c) | |
579 { | |
580 case '\t': // Horizontal tab 09 | |
581 { | |
582 strncpy(digits, &temp_string[i + 1],3); | |
583 digits[3] = 0; | |
584 string_pixel_Width = atoi(digits)+uX; | |
585 i += 3; | |
586 break; | |
587 } | |
588 case '\n': //Line Feed 0A 10 (конец строки) | |
589 { | |
590 string_pixel_Width = start_pixel_offset; | |
591 possible_transition_point = i; | |
592 break; | |
593 } | |
594 case '\f': //Form Feed, page eject 0C 12 | |
595 { | |
596 i += 5; | |
597 break; | |
598 } | |
599 case '\r': //Carriage Return 0D 13 | |
600 { | |
601 if ( !a5 ) | |
602 return (char*)pInString; | |
603 break; | |
604 } | |
605 case ' '://пробел | |
606 { | |
607 string_pixel_Width += pFont->pMetrics[c].uWidth; | |
608 possible_transition_point = i; | |
609 break; | |
610 } | |
611 default: | |
612 if ((string_pixel_Width + pFont->pMetrics[c].uWidth + pFont->pMetrics[c].uLeftSpacing + | |
613 pFont->pMetrics[c].uRightSpacing) < pWindow->uFrameWidth )//наращивание длины строки или перенос | |
614 { | |
615 if ( i > possible_transition_point ) | |
616 string_pixel_Width += pFont->pMetrics[c].uLeftSpacing; | |
617 string_pixel_Width += pFont->pMetrics[c].uWidth; | |
618 if (i < uInStrLen) | |
619 string_pixel_Width += pFont->pMetrics[c].uRightSpacing; | |
620 } | |
621 else//перенос строки и слова | |
622 { | |
623 temp_string[possible_transition_point] ='\n'; | |
624 string_pixel_Width = start_pixel_offset; | |
625 if ( i > possible_transition_point ) | |
626 { | |
627 for ( int j = possible_transition_point; j < i; ++j ) | |
628 { | |
629 c = temp_string[j]; | |
630 if (pFont->IsCharValid(c)) | |
631 { | |
632 if ( j > possible_transition_point ) | |
633 string_pixel_Width += pFont->pMetrics[c].uLeftSpacing; | |
634 string_pixel_Width += pFont->pMetrics[c].uWidth; | |
635 if ( j < i ) | |
636 string_pixel_Width += pFont->pMetrics[c].uRightSpacing; | |
637 } | |
638 } | |
639 } | |
640 } | |
641 } | |
642 } | |
643 } | |
644 return &temp_string[0]; | |
645 } | |
1297 | 646 //----- (00414162) -------------------------------------------------------- |
647 void uGameUIFontMain_initialize() | |
648 { | |
649 uGameUIFontMain = TargetColor(0xAu, 0, 0); | |
650 } | |
651 | |
652 //----- (00414174) -------------------------------------------------------- | |
653 void uGameUIFontShadow_initialize() | |
654 { | |
655 uGameUIFontShadow = TargetColor(0xE6u, 214u, 193u); | |
656 } |