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