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