comparison GUIFont.cpp @ 1453:dfc9484ed94c

GetDayPart and Journal_Draw
author Ritor1
date Thu, 08 Aug 2013 16:34:19 +0600
parents 5450af4f57ef
children c4ab816fcc5e
comparison
equal deleted inserted replaced
1452:9add223260ce 1453:dfc9484ed94c
383 383
384 } 384 }
385 385
386 386
387 //----- (0044C6C2) -------------------------------------------------------- 387 //----- (0044C6C2) --------------------------------------------------------
388 char* GUIFont::_44C6C2( const char *pInString, GUIWindow *pWindow, unsigned int uX, int a5 ) 388 char* GUIFont::GetPageTop( const char *pInString, GUIWindow *pWindow, unsigned int uX, int a5 )
389 { 389 {
390 int text_height; // edi@1 390 int text_height; // edi@1
391 char *text_str; // ebx@3 391 char *text_str; // ebx@3
392 int i;
393 unsigned char c; // cl@4 392 unsigned char c; // cl@4
394 int text_length; 393 int text_length;
395 394
396 text_height = 0; 395 text_height = 0;
397 396
398 if ( !pInString ) 397 if ( !pInString )
399 return 0; 398 return 0;
400 text_str = FitTextInAWindow(pInString, this, pWindow, uX, 0); 399 text_str = FitTextInAWindow(pInString, this, pWindow, uX, 0);
401 text_length = strlen(text_str); 400 text_length = strlen(text_str);
402 for (i=0; i<text_length; ++i ) 401 for ( int i = 0; i < text_length; ++i )
403 { 402 {
404 c = text_str[i]; 403 c = text_str[i];
405 if ( IsCharValid(c) ) 404 if ( IsCharValid(c) )
406 { 405 {
407 switch (c) 406 switch (c)
408 { 407 {
409 case '\n': //Line Feed 0A 10: 408 case '\n': //Line Feed 0A 10:
410 text_height = text_height + uFontHeight - 3; 409 text_height = text_height + (uFontHeight - 3);
411 if ( text_height >= (signed int)(a5 * pWindow->uFrameHeight) ) 410 if ( text_height >= (signed int)(a5 * (pWindow->uFrameHeight - (uFontHeight - 3))) )
412 return &text_str[i+1]; 411 return &text_str[i];
413 break; 412 break;
414 case '\f': //Form Feed, page eject 0C 12 413 case '\f': //Form Feed, page eject 0C 12
415 i += 5; 414 i += 5;
416 break; 415 break;
417 case '\t': // Horizontal tab 09 416 case '\t': // Horizontal tab 09
418 case '\r': //Carriage Return 0D 13 417 case '\r': //Carriage Return 0D 13
419 i += 3; 418 i += 3;
420 break; 419 break;
421 }
422 if ( text_height >= (signed int)(a5 * pWindow->uFrameHeight) )
423 break;
424 }
425 } 420 }
426 return &text_str[i]; 421 if ( text_height >= (signed int)(a5 * pWindow->uFrameHeight) )
427 } 422 break;
428 423 }
429 424 }
425 return &text_str[0];
426 }
430 427
431 //----- (0044C62E) -------------------------------------------------------- 428 //----- (0044C62E) --------------------------------------------------------
432 int GUIFont::GetStringHeight2( GUIFont *secondFont, const char *text_str, GUIWindow* pWindow, int startX, int a6 ) 429 int GUIFont::GetStringHeight2( GUIFont *secondFont, const char *text_str, GUIWindow* pWindow, int startX, int a6 )
433 { 430 {
434 431
467 return uAllHeght; 464 return uAllHeght;
468 } 465 }
469 466
470 //----- (0044C59D) -------------------------------------------------------- 467 //----- (0044C59D) --------------------------------------------------------
471 int GUIFont::CalcTextHeight( const char *pString, struct GUIWindow *pWindow, int uXOffset, int a5 ) 468 int GUIFont::CalcTextHeight( const char *pString, struct GUIWindow *pWindow, int uXOffset, int a5 )
472 { 469 {
473 int uAllHeght; 470 int uAllHeght;
474 int uStringLen; 471 int uStringLen;
475 unsigned char c; 472 unsigned char c;
476 char *test_string; 473 char *test_string;
477 474
478 if (!pString) 475 if (!pString)
479 return 0; 476 return 0;
480 uAllHeght = uFontHeight - 3; 477 uAllHeght = uFontHeight - 6;
481 test_string = FitTextInAWindow(pString, this, pWindow, uXOffset, 0); 478 test_string = FitTextInAWindow(pString, this, pWindow, uXOffset, 0);
482 uStringLen = strlen(pString); 479 uStringLen = strlen(pString);
483 for (int i = 0; i < uStringLen; ++i) 480 for (int i = 0; i < uStringLen; ++i)
484 { 481 {
485 c = test_string[i]; 482 c = test_string[i];
486 if (IsCharValid(c)) 483 if (IsCharValid(c))
487 { 484 {
488 switch (c) 485 switch (c)
489 { 486 {
490 case '\n': //Line Feed 0A 10: 487 case '\n': //Line Feed 0A 10:
491 uAllHeght+= uFontHeight - 3; 488 uAllHeght += uFontHeight - 3;
492 break; 489 break;
493 case '\f': //Form Feed, page eject 0C 12 490 case '\f': //Form Feed, page eject 0C 12
494 i += 5; 491 i += 5;
495 break; 492 break;
496 case '\t': // Horizontal tab 09 493 case '\t': // Horizontal tab 09
497 case '\r': //Carriage Return 0D 13 494 case '\r': //Carriage Return 0D 13
498 if (a5 != 1) 495 if (a5 != 1)
499 i += 3; 496 i += 3;
500 break; 497 break;
501 } 498 }
502 } 499 }
503 } 500 }
504 return uAllHeght; 501 return uAllHeght;
505 } 502 }
506
507 503
508 //----- (0044C51E) -------------------------------------------------------- 504 //----- (0044C51E) --------------------------------------------------------
509 int GUIFont::GetLineWidth(const char *pString) 505 int GUIFont::GetLineWidth(const char *pString)
510 { 506 {
511 int str_len; // ebp@3 507 int str_len; // ebp@3
551 position = (signed int)(uCenterX - GetLineWidth(pString)) >> 1; 547 position = (signed int)(uCenterX - GetLineWidth(pString)) >> 1;
552 if ( position >= 0 ) 548 if ( position >= 0 )
553 return position; 549 return position;
554 else 550 else
555 return 0; 551 return 0;
556
557 } 552 }
558 553
559 //----- (0044C768) -------------------------------------------------------- 554 //----- (0044C768) --------------------------------------------------------
560 char * FitTextInAWindow( const char *pInString, GUIFont *pFont, GUIWindow *pWindow, signed int uX, int a5 ) 555 char * FitTextInAWindow( const char *pInString, GUIFont *pFont, GUIWindow *pWindow, signed int uX, int a5 )
561 { 556 {
562 unsigned char c; 557 unsigned char c;
563 int uInStrLen; 558 int uInStrLen;
564 char digits[4]; 559 char digits[4];
565 int possible_transition_point; 560 int possible_transition_point;
566 int string_pixel_Width; 561 int string_pixel_Width;
567 int start_pixel_offset; 562 int start_pixel_offset;
568 563
569 if (!pInString) 564 if (!pInString)
570 { 565 {
571 MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:445", 0); 566 MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:445", 0);
572 return 0; 567 return 0;
573 } 568 }
574 uInStrLen = strlen(pInString); 569 uInStrLen = strlen(pInString);
575 strcpy(&temp_string[0], pInString); 570 strcpy(&temp_string[0], pInString);
576 if (uInStrLen==0) 571 if (uInStrLen == 0)
577 return &temp_string[0]; 572 return &temp_string[0];
578 573
579 start_pixel_offset=string_pixel_Width=uX; 574 start_pixel_offset = string_pixel_Width=uX;
580 possible_transition_point=0; 575 possible_transition_point = 0;
581 for(int i=0; i<uInStrLen; ++i) 576 for ( int i = 0; i < uInStrLen; ++i )
582 { 577 {
583 c=temp_string[i]; 578 c = temp_string[i];
584 if (pFont->IsCharValid(c)) 579 if (pFont->IsCharValid(c))
585 { 580 {
586 switch (c) 581 switch (c)
587 { 582 {
588 case '\t': // Horizontal tab 09 583 case '\t': // Horizontal tab 09
589 { 584 {
590 strncpy(digits, &temp_string[i+1],3); 585 strncpy(digits, &temp_string[i + 1],3);
591 digits[3]=0; 586 digits[3] = 0;
592 string_pixel_Width= atoi(digits)+uX; 587 string_pixel_Width = atoi(digits)+uX;
593 i+=3; 588 i += 3;
594 break; 589 break;
595 } 590 }
596 case '\n': //Line Feed 0A 10 591 case '\n': //Line Feed 0A 10 (конец строки)
597 { 592 {
598 string_pixel_Width=start_pixel_offset; 593 string_pixel_Width = start_pixel_offset;
599 possible_transition_point=i; 594 possible_transition_point = i;
600 break; 595 break;
601 } 596 }
602 case '\f': //Form Feed, page eject 0C 12 597 case '\f': //Form Feed, page eject 0C 12
603 { 598 {
604 i+=5; 599 i += 5;
605 break; 600 break;
606 } 601 }
607 case '\r': //Carriage Return 0D 13 602 case '\r': //Carriage Return 0D 13
608 { 603 {
609 if (!a5) 604 if ( !a5 )
610 return (char*)pInString; 605 return (char*)pInString;
611 break; 606 break;
612 } 607 }
613 case ' ' : 608 case ' '://пробел
614 { 609 {
615 string_pixel_Width+=pFont->pMetrics[c].uWidth; 610 string_pixel_Width += pFont->pMetrics[c].uWidth;
616 possible_transition_point=i; 611 possible_transition_point = i;
617 break; 612 break;
618 } 613 }
619 default: 614 default:
620 615 if ((string_pixel_Width + pFont->pMetrics[c].uWidth + pFont->pMetrics[c].uLeftSpacing +
621 if ((string_pixel_Width+pFont->pMetrics[c].uWidth+ pFont->pMetrics[c].uLeftSpacing+ 616 pFont->pMetrics[c].uRightSpacing) < pWindow->uFrameWidth )//наращивание длины строки или перенос
622 pFont->pMetrics[c].uRightSpacing)<pWindow->uFrameWidth) 617 {
623 { 618 if ( i > possible_transition_point )
624 if(i>possible_transition_point) 619 string_pixel_Width += pFont->pMetrics[c].uLeftSpacing;
625 string_pixel_Width+=pFont->pMetrics[c].uLeftSpacing; 620 string_pixel_Width += pFont->pMetrics[c].uWidth;
626 string_pixel_Width+=pFont->pMetrics[c].uWidth; 621 if (i < uInStrLen)
627 if (i<uInStrLen) 622 string_pixel_Width += pFont->pMetrics[c].uRightSpacing;
628 string_pixel_Width+=pFont->pMetrics[c].uRightSpacing; 623 }
629 } 624 else//перенос строки и слова
630 else 625 {
631 { 626 temp_string[possible_transition_point] ='\n';
632 temp_string[possible_transition_point]='\n'; 627 string_pixel_Width = start_pixel_offset;
633 string_pixel_Width=start_pixel_offset; 628 if ( i > possible_transition_point )
634 if (i>possible_transition_point) 629 {
635 { 630 for ( int j = possible_transition_point; j < i; ++j )
636 for(int j=possible_transition_point;j<i; ++j ) 631 {
637 { 632 c = temp_string[j];
638 c=temp_string[j]; 633 if (pFont->IsCharValid(c))
639 if (pFont->IsCharValid(c)) 634 {
640 { 635 if ( j > possible_transition_point )
641 if(j>possible_transition_point) 636 string_pixel_Width += pFont->pMetrics[c].uLeftSpacing;
642 string_pixel_Width+=pFont->pMetrics[c].uLeftSpacing; 637 string_pixel_Width += pFont->pMetrics[c].uWidth;
643 string_pixel_Width+=pFont->pMetrics[c].uWidth; 638 if ( j < i )
644 if (j<i) 639 string_pixel_Width += pFont->pMetrics[c].uRightSpacing;
645 string_pixel_Width+=pFont->pMetrics[c].uRightSpacing; 640 }
646 641 }
647 } 642 }
648 } 643 }
649 } 644 }
650 } 645 }
651 } 646 }
652 } 647 return &temp_string[0];
653 } 648 }
654 return &temp_string[0];
655 }
656 //----- (00414162) -------------------------------------------------------- 649 //----- (00414162) --------------------------------------------------------
657 void uGameUIFontMain_initialize() 650 void uGameUIFontMain_initialize()
658 { 651 {
659 uGameUIFontMain = TargetColor(0xAu, 0, 0); 652 uGameUIFontMain = TargetColor(0xAu, 0, 0);
660 } 653 }