comparison GUIFont.cpp @ 1180:b542660e7302

Слияние
author Ritor1
date Wed, 05 Jun 2013 17:40:17 +0600
parents 8b3e7d5ba069
children 8c02e6f74b29
comparison
equal deleted inserted replaced
1179:883eaee77094 1180:b542660e7302
62 } 62 }
63 63
64 64
65 65
66 //----- (0044D2FD) -------------------------------------------------------- 66 //----- (0044D2FD) --------------------------------------------------------
67 void GUIFont::_44D2FD_prolly_draw_credits_entry(GUIFont *pFont, int Str, int a4, unsigned int w, unsigned int h, 67 void GUIFont::_44D2FD_prolly_draw_credits_entry( GUIFont *pSecondFont, int uFrameX, int uFrameY, unsigned int w, unsigned int h,
68 unsigned __int16 a7, unsigned __int16 a8, const char *pString, 68 unsigned __int16 firstColor, unsigned __int16 secondColor, const char *pString,
69 unsigned __int16 *pPixels, unsigned int uPixelsWidth) 69 unsigned __int16 *pPixels, unsigned int uPixelsWidth )
70 { 70 {
71 int v11; // ebx@1 71 char *work_string; // eax@1
72 int v12; // edi@1 72 unsigned __int16 *curr_pixel_pos; // esi@1
73 char *v13; // eax@1 73 GUIFont *currentFont; // edi@4
74 char *v14; // eax@1 74 signed int start_str_pos; // ecx@4
75 unsigned __int16 *v15; // esi@1 75 signed int line_w; // eax@6
76 GUIFont *v16; // edi@4 76 GUIWindow draw_window; // [sp+Ch] [bp-5Ch]@
77 signed int v17; // ecx@4 77 int currentColor; // [sp+74h] [bp+Ch]@4
78 signed int v18; // eax@6 78 int half_frameX; // [sp+80h] [bp+18h]@2
79 int v19; // [sp+Ch] [bp-5Ch]@1 79
80 int v20; // [sp+10h] [bp-58h]@1 80 draw_window.uFrameHeight = h;
81 unsigned int v21; // [sp+14h] [bp-54h]@1 81 draw_window.uFrameW = uFrameY + h - 1;
82 unsigned int v22; // [sp+18h] [bp-50h]@1 82 draw_window.uFrameWidth = w;
83 unsigned int v23; // [sp+1Ch] [bp-4Ch]@1 83 draw_window.uFrameZ = uFrameX + w - 1;
84 unsigned int v24; // [sp+20h] [bp-48h]@1 84 ui_current_text_color = firstColor;
85 GUIFont *v25; // [sp+60h] [bp-8h]@1 85 draw_window.uFrameX = uFrameX;
86 GUIFont *v26; // [sp+64h] [bp-4h]@1 86 draw_window.uFrameY = uFrameY;
87 char *Stra; // [sp+70h] [bp+8h]@1 87
88 int a4a; // [sp+74h] [bp+Ch]@4 88 work_string = GUIFont::FitTwoFontStringINWindow(pString, this, pSecondFont, &draw_window, 0, 1);
89 int a7a; // [sp+80h] [bp+18h]@2 89 work_string = strtok(work_string, "\n");
90 90 curr_pixel_pos = &pPixels[uPixelsWidth * uFrameY];
91 v11 = a7; 91 if ( work_string )
92 v22 = h;
93 v12 = Str;
94 v26 = this;
95 v24 = a4 + h - 1;
96 v21 = w;
97 v25 = pFont;
98 v23 = Str + w - 1;
99 ui_current_text_color = a7;
100 v19 = Str;
101 v20 = a4;
102 v13 = GUIFont::_44C933(pString, this, pFont, (int)&v19, 0, 1);
103 v14 = strtok(v13, "\n");
104 Stra = v14;
105 v15 = &pPixels[uPixelsWidth * a4];
106 if ( v14 )
107 { 92 {
108 a7a = v12 >> 1; 93 half_frameX = uFrameX >> 1;
109 while ( 1 ) 94 while ( 1 )
110 { 95 {
111 v16 = v26; 96 currentFont = this;
112 ui_current_text_color = v11; 97 ui_current_text_color = firstColor;
113 v17 = 0; 98 start_str_pos = 0;
114 a4a = v11; 99 currentColor = firstColor;
115 if ( *v14 == '_' ) 100 if ( *work_string == '_' )
116 { 101 {
117 v16 = v25; 102 currentFont = pSecondFont;
118 a4a = a8; 103 currentColor = secondColor;
119 ui_current_text_color = a8; 104 ui_current_text_color = secondColor;
120 v17 = 1; 105 start_str_pos = 1;
121 } 106 }
122 v18 = (signed int)(w - v16->GetLineWidth(&v14[v17])) >> 1; 107 line_w = (signed int)(w - currentFont->GetLineWidth(&work_string[start_str_pos]))/2;
123 if ( v18 < 0 ) 108 if ( line_w < 0 )
124 v18 = 0; 109 line_w = 0;
125 v16->DrawTextLineToBuff(a4a, a8, &v15[v18 + a7a], Stra, uPixelsWidth); 110 currentFont->DrawTextLineToBuff(currentColor, secondColor, &curr_pixel_pos[line_w + half_frameX], work_string, uPixelsWidth);
126 v15 += uPixelsWidth * (LOBYTE(v16->uFontHeight) - 3); 111 curr_pixel_pos += uPixelsWidth * (currentFont->uFontHeight - 3);
127 Stra = strtok(0, "\n"); 112 work_string = strtok(0, "\n");
128 if ( !Stra ) 113 if ( !work_string )
129 break; 114 break;
130 v14 = Stra;
131 } 115 }
132 } 116 }
133 } 117 }
134 // 5C6DB4: using guessed type int ui_current_text_color; 118
135 119
136 120
137 //----- (0044D1E7) -------------------------------------------------------- 121 //----- (0044D1E7) --------------------------------------------------------
138 void GUIFont::DrawTextLine( unsigned int uDefaultColor, signed int uX, signed int uY, 122 void GUIFont::DrawTextLine( unsigned int uDefaultColor, signed int uX, signed int uY,
139 const char *text, int max_len_pix ) 123 const char *text, int max_len_pix )
256 text_color = atoi(color_code); 240 text_color = atoi(color_code);
257 ui_current_text_color = text_color; 241 ui_current_text_color = text_color;
258 i += 5; 242 i += 5;
259 break; 243 break;
260 case '\t': // Horizontal tab 09 244 case '\t': // Horizontal tab 09
261 case '\r': //Carriage Return 0D 13 245 case '_':
262 break; 246 break;
263 default: 247 default:
264 uCharWidth = pMetrics[c].uWidth; 248 uCharWidth = pMetrics[c].uWidth;
265 if ( uCharWidth ) 249 if ( uCharWidth )
266 { 250 {
281 } 265 }
282 266
283 267
284 268
285 //----- (0044C933) -------------------------------------------------------- 269 //----- (0044C933) --------------------------------------------------------
286 char * GUIFont::_44C933(const char *pString, GUIFont *pFont, GUIFont *a3, int a4, int a5, int a6) 270 char * GUIFont::FitTwoFontStringINWindow( const char *pString, GUIFont *pFontMain, GUIFont *pFontSecond, GUIWindow* pWindow, int startPixlOff, int a6 )
287 { 271 {
288 const char *v6; // esi@1 272
289 size_t v8; // eax@3 273 GUIFont *currentFont; // esi@3
290 size_t v9; // edi@3 274 unsigned char c;
291 int v10; // eax@3 275 int uInStrLen;
292 GUIFont *v11; // esi@3 276 char digits[4];
293 int v12; // ebx@3 277 int possible_transition_point;
294 char v13; // cl@5 278 int string_pixel_Width;
295 int v14; // edx@11 279 int start_pixel_offset;
296 int v15; // ecx@11 280
297 int v16; // edx@12 281 if (!pString)
298 int v17; // edx@13
299 int v18; // edx@14
300 int v19; // edx@15
301 int v20; // edi@17
302 int v21; // edx@17
303 int v22; // ecx@17
304 int v23; // edi@18
305 char v24; // zf@18
306 int v25; // ecx@19
307 int v26; // eax@19
308 char v27; // dl@24
309 int v28; // eax@46
310 std::string v29; // [sp-18h] [bp-48h]@2
311 const char *v30; // [sp-8h] [bp-38h]@2
312 int v31; // [sp-4h] [bp-34h]@2
313 const char *v32; // [sp+Ch] [bp-24h]@1
314 char Str; // [sp+10h] [bp-20h]@46
315 char v34; // [sp+13h] [bp-1Dh]@46
316 GUIFont *v35; // [sp+14h] [bp-1Ch]@1
317 int v36; // [sp+18h] [bp-18h]@3
318 int v37; // [sp+1Ch] [bp-14h]@3
319 int v38; // [sp+20h] [bp-10h]@4
320 int v39; // [sp+24h] [bp-Ch]@3
321 int v40; // [sp+28h] [bp-8h]@3
322 int i; // [sp+2Ch] [bp-4h]@17
323 std::string *v42; // [sp+38h] [bp+8h]@2
324
325 v6 = pString;
326 v35 = pFont;
327 v32 = pString;
328 if ( !pString )
329 {
330 MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:558", 0);
331 return 0;
332 }
333 v8 = strlen(pString);
334 v9 = v8;
335 v39 = v8;
336
337 assert(strlen(v6) < sizeof(pTmpBuf3));
338 strcpy(pTmpBuf3, v6);
339 v10 = a5;
340 v11 = v35;
341 v12 = 0;
342 v40 = 0;
343 v37 = a5;
344 v36 = 0;
345 if ( (signed int)v9 > 0 )
346 {
347 v38 = v9 - 1;
348 do
349 {
350 v13 = pTmpBuf3[v12];
351 if ( (unsigned __int8)v13 >= v11->cFirstChar && (unsigned __int8)v13 <= v11->cLastChar
352 || v13 == '\f'
353 || v13 == '\r'
354 || v13 == '\t'
355 || v13 == '\n' )
356 { 282 {
357 v14 = (unsigned __int8)v13 - 9; 283 MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:445", 0);
358 v15 = (int)&v11->pMetrics[(unsigned __int8)v13]; 284 return 0;
359 if ( v14 ) 285 }
360 { 286 currentFont=pFontMain; // esi@3
361 v16 = v14 - 1; 287 uInStrLen = strlen(pString);
362 if ( v16 ) 288 assert(uInStrLen < sizeof(pTmpBuf3));
289 strcpy(pTmpBuf3, pString);
290 if (uInStrLen==0)
291 return pTmpBuf3;
292
293 start_pixel_offset=string_pixel_Width=startPixlOff;
294 possible_transition_point=0;
295 for(int i=0; i<uInStrLen; ++i)
296 {
297 c=pTmpBuf3[i];
298 if (pFontMain->IsCharValid(c))
363 { 299 {
364 v17 = v16 - 2; 300 switch (c)
365 if ( v17 ) 301 {
366 { 302 case '\t': // Horizontal tab 09
367 v18 = v17 - 1; 303 {
368 if ( v18 ) 304 strncpy(digits, &pTmpBuf3[i+1],3);
369 { 305 digits[3]=0;
370 v19 = v18 - 19; 306 string_pixel_Width = atoi(digits)+startPixlOff;
371 if ( v19 ) 307 i+=3;
372 { 308 break;
373 if ( v19 == 63 ) 309 }
310 case '\n': //Line Feed 0A 10
311 {
312 string_pixel_Width=start_pixel_offset;
313 possible_transition_point=i;
314 currentFont=pFontMain;
315 break;
316 }
317 case '\f': //Form Feed, page eject 0C 12
318 {
319 i+=5;
320 break;
321 }
322 case '\r': //Carriage Return 0D 13
323 {
324 if (!a6)
325 return (char*)pString;
326 break;
327 }
328 case ' ' :
329 {
330 string_pixel_Width+=currentFont->pMetrics[c].uWidth;
331 possible_transition_point=i;
332 break;
333 }
334 case '_' :
335 currentFont=pFontSecond;
336 break;
337 default:
338
339 if ((string_pixel_Width+currentFont->pMetrics[c].uWidth+ currentFont->pMetrics[c].uLeftSpacing+
340 currentFont->pMetrics[c].uRightSpacing)<pWindow->uFrameWidth)
374 { 341 {
375 v11 = a3; 342 if(i>possible_transition_point)
343 string_pixel_Width+=currentFont->pMetrics[c].uLeftSpacing;
344 string_pixel_Width+=currentFont->pMetrics[c].uWidth;
345 if (i<uInStrLen)
346 string_pixel_Width+=currentFont->pMetrics[c].uRightSpacing;
376 } 347 }
377 else 348 else
378 { 349 {
379 v20 = *(int *)(v15 + 8); 350 pTmpBuf3[possible_transition_point]='\n';
380 v21 = *(int *)(v15 + 4); 351
381 v22 = *(int *)v15; 352 if ( currentFont== pFontSecond)
382 i = v20;
383 if ( (unsigned int)(v10 + v20 + v22 + v21) < *(int *)(a4 + 8) )
384 {
385 v12 = v36;
386 if ( v36 > v40 )
387 v10 += v22;
388 v10 += v21;
389 if ( v36 < v39 )
390 v10 += i;
391 }
392 else
393 {
394 v23 = v40;
395 v24 = v11 == a3;
396 pTmpBuf3[v40] = 10;
397 if ( v24 )
398 { 353 {
399 v25 = v38; 354
400 v26 = v23 + 1; 355 for(int k=uInStrLen-1; k>=possible_transition_point+1; --k)
401 while ( v25 >= v26 ) 356 pTmpBuf3[k] = pTmpBuf3[k-1];
402 { 357
403 pTmpBuf3[v25] = byte_5C45AF[v25]; 358 ++uInStrLen;
404 --v25; 359 ++possible_transition_point;
405 } 360 pTmpBuf3[possible_transition_point] = '_';
406 ++v39; 361
407 ++v38;
408 pTmpBuf3[v23++ + 1] = 95;
409 v40 = v26;
410 } 362 }
411 v12 = v36; 363 string_pixel_Width=start_pixel_offset;
412 v10 = v37; 364
413 for ( i = v23; i <= v36; ++i ) 365 for(int j=possible_transition_point;j<i; ++j )
414 { 366 {
415 v27 = pTmpBuf3[i]; 367 c=pTmpBuf3[j];
416 if ( (unsigned __int8)v27 >= v11->cFirstChar && (unsigned __int8)v27 <= v11->cLastChar 368 if (pFontMain->IsCharValid(c))
417 || v27 == 12 369 {
418 || v27 == 13 370 if(j>possible_transition_point)
419 || v27 == 9 371 string_pixel_Width+=pFontMain->pMetrics[c].uLeftSpacing;
420 || v27 == 10 ) 372 string_pixel_Width+=pFontMain->pMetrics[c].uWidth;
421 { 373 if (j<i)
422 if ( i > v23 ) 374 string_pixel_Width+=pFontMain->pMetrics[c].uRightSpacing;
423 v10 += v11->pMetrics[(unsigned __int8)v27].uLeftSpacing; 375
424 v10 += *((int *)&v11->cFirstChar + 3 * (unsigned __int8)v27 + 9); 376 }
425 if ( i < v36 ) 377 }
426 v10 += v11->pMetrics[(unsigned __int8)v27].uRightSpacing;
427 }
428 }
429 }
430 } 378 }
431 } 379 }
432 else
433 {
434 v10 += *(int *)(v15 + 4);
435 v40 = v12;
436 }
437 }
438 else
439 {
440 if ( !a6 )
441 return (char *)v32;
442 }
443 }
444 else
445 {
446 v12 += 5;
447 }
448 } 380 }
449 else
450 {
451 v10 = v37;
452 v11 = v35;
453 v40 = v12;
454 }
455 }
456 else
457 {
458 strncpy(&Str, &pTmpBuf3[v12 + 1], 3u);
459 v34 = 0;
460 v28 = atoi(&Str);
461 v10 = a5 + v28;
462 v12 += 3;
463 v37 = v10;
464 }
465 } 381 }
466 ++v12;
467 v36 = v12;
468 }
469 while ( v12 < v39 );
470 }
471 return pTmpBuf3; 382 return pTmpBuf3;
383
472 } 384 }
473 385
474 386
475 //----- (0044C6C2) -------------------------------------------------------- 387 //----- (0044C6C2) --------------------------------------------------------
476 char* GUIFont::_44C6C2( const char *pInString, GUIWindow *pWindow, unsigned int uX, int a5 ) 388 char* GUIFont::_44C6C2( const char *pInString, GUIWindow *pWindow, unsigned int uX, int a5 )
485 397
486 if ( !pInString ) 398 if ( !pInString )
487 return 0; 399 return 0;
488 text_str = FitTextInAWindow(pInString, this, pWindow, uX, 0); 400 text_str = FitTextInAWindow(pInString, this, pWindow, uX, 0);
489 text_length = strlen(text_str); 401 text_length = strlen(text_str);
490 //uX_pos=uX_buff_pos;
491 for (i=0; i<text_length; ++i ) 402 for (i=0; i<text_length; ++i )
492 { 403 {
493 c = text_str[i]; 404 c = text_str[i];
494 if ( IsCharValid(c) ) 405 if ( IsCharValid(c) )
495 { 406 {
507 case '\r': //Carriage Return 0D 13 418 case '\r': //Carriage Return 0D 13
508 i += 3; 419 i += 3;
509 break; 420 break;
510 } 421 }
511 if ( text_height >= (signed int)(a5 * pWindow->uFrameHeight) ) 422 if ( text_height >= (signed int)(a5 * pWindow->uFrameHeight) )
512 return &text_str[i]; 423 break;
513 } 424 }
514 } 425 }
515 return &text_str[i]; 426 return &text_str[i];
516 } 427 }
517 428
518 429
519 430
520 //----- (0044C62E) -------------------------------------------------------- 431 //----- (0044C62E) --------------------------------------------------------
521 int GUIFont::GetStringHeight2(GUIFont *a2, const char *Str, int a4, int a5, int a6) 432 int GUIFont::GetStringHeight2( GUIFont *secondFont, const char *text_str, GUIWindow* pWindow, int startX, int a6 )
522 { 433 {
523 GUIFont *v6; // edi@1 434
524 int v8; // esi@3 435 int uAllHeght;
525 unsigned __int8 *v9; // ebx@3 436 int uStringLen;
526 size_t v10; // eax@3 437 unsigned char c;
527 unsigned __int8 v11; // cl@4 438 char *test_string;
528 signed int Stra; // [sp+Ch] [bp+8h]@3 439
529 size_t v13; // [sp+14h] [bp+10h]@3 440 if ( !text_str )
530
531 auto a1 = this;
532 v6 = a1;
533 if ( !Str )
534 return 0; 441 return 0;
535 v8 = LOBYTE(a1->uFontHeight) - 3; 442 uAllHeght = uFontHeight - 3;
536 v9 = (unsigned __int8 *)GUIFont::_44C933(Str, a1, a2, a4, a5, 0); 443 test_string = FitTwoFontStringINWindow(text_str, this, secondFont, pWindow, startX, 0);
537 v10 = strlen(Str); 444 uStringLen = strlen(test_string);
538 Stra = 0; 445 for (int i = 0; i < uStringLen; ++i)
539 v13 = v10;
540 while ( Stra < (signed int)v13 )
541 {
542 if ( GUIFont::IsCharValid(v11 = *v9) )
543 {
544 if ( v11 == 9 )
545 goto LABEL_9;
546 switch ( v11 )
547 { 446 {
548 case 0xAu: 447 c = test_string[i];
549 v8 = v8 + LOBYTE(v6->uFontHeight) - 3; 448 if (IsCharValid(c))
550 break;
551 case 0xCu:
552 v9 += 5;
553 Stra += 5;
554 break;
555 case 0xDu:
556 LABEL_9:
557 if ( a6 != 1 )
558 { 449 {
559 v9 += 3; 450 switch (c)
560 Stra += 3; 451 {
452 case '\n': //Line Feed 0A 10:
453 uAllHeght+= uFontHeight - 3;
454 break;
455 case '\f': //Form Feed, page eject 0C 12
456 i += 5;
457 break;
458 case '\t': // Horizontal tab 09
459 case '\r': //Carriage Return 0D 13
460 if (a6 != 1)
461 i += 3;
462 break;
463 }
561 } 464 }
562 break;
563 } 465 }
564 } 466
565 ++Stra; 467 return uAllHeght;
566 ++v9;
567 }
568 return v8;
569 } 468 }
570 469
571 //----- (0044C59D) -------------------------------------------------------- 470 //----- (0044C59D) --------------------------------------------------------
572 int GUIFont::CalcTextHeight( const char *pString, struct GUIWindow *pWindow, int uXOffset, int a5 ) 471 int GUIFont::CalcTextHeight( const char *pString, struct GUIWindow *pWindow, int uXOffset, int a5 )
573 { 472 {
576 unsigned char c; 475 unsigned char c;
577 char *test_string; 476 char *test_string;
578 477
579 if (!pString) 478 if (!pString)
580 return 0; 479 return 0;
581 uAllHeght = this->uFontHeight - 3; 480 uAllHeght = uFontHeight - 3;
582 test_string = FitTextInAWindow(pString, this, pWindow, uXOffset, 0); 481 test_string = FitTextInAWindow(pString, this, pWindow, uXOffset, 0);
583 uStringLen = strlen(pString); 482 uStringLen = strlen(pString);
584 for (int i = 0; i < uStringLen; ++i) 483 for (int i = 0; i < uStringLen; ++i)
585 { 484 {
586 c = test_string[i]; 485 c = test_string[i];
587 if (IsCharValid(c)) 486 if (IsCharValid(c))
588 { 487 {
589 switch (c) 488 switch (c)
590 { 489 {
591 case '\n': //Line Feed 0A 10: 490 case '\n': //Line Feed 0A 10:
592 uAllHeght+= this->uFontHeight - 3; 491 uAllHeght+= uFontHeight - 3;
593 break; 492 break;
594 case '\f': //Form Feed, page eject 0C 12 493 case '\f': //Form Feed, page eject 0C 12
595 i += 5; 494 i += 5;
596 break; 495 break;
597 case '\t': // Horizontal tab 09 496 case '\t': // Horizontal tab 09
631 case '\f': 530 case '\f':
632 i += 5; 531 i += 5;
633 break; 532 break;
634 default: 533 default:
635 if (i > 0) 534 if (i > 0)
636 string_line_width += this->pMetrics[c].uLeftSpacing; 535 string_line_width += pMetrics[c].uLeftSpacing;
637 string_line_width += this->pMetrics[c].uWidth; 536 string_line_width += pMetrics[c].uWidth;
638 if (i < str_len) 537 if (i < str_len)
639 string_line_width +=this->pMetrics[c].uRightSpacing; 538 string_line_width +=pMetrics[c].uRightSpacing;
640 } 539 }
641 } 540 }
642 } 541 }
643 return string_line_width; 542 return string_line_width;
644 } 543 }