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