Mercurial > mm7
comparison GUIFont.cpp @ 189:038a4d09406f
new texts file, fix text rendender error
author | Gloval |
---|---|
date | Sat, 16 Feb 2013 00:33:21 +0400 |
parents | c5bd7a825ef2 |
children | 1527f66fd81b |
comparison
equal
deleted
inserted
replaced
185:16d257ffc802 | 189:038a4d09406f |
---|---|
18 struct GUIFont *pBookFont; | 18 struct GUIFont *pBookFont; |
19 struct GUIFont *pFontCreate; | 19 struct GUIFont *pFontCreate; |
20 struct GUIFont *pFontCChar; | 20 struct GUIFont *pFontCChar; |
21 struct GUIFont *pFontComic; | 21 struct GUIFont *pFontComic; |
22 struct GUIFont *pFontSmallnum; | 22 struct GUIFont *pFontSmallnum; |
23 | |
24 char temp_string[2048]; | |
25 | |
26 char pTmpBuf3[2048]; | |
23 | 27 |
24 //----- (0044C448) -------------------------------------------------------- | 28 //----- (0044C448) -------------------------------------------------------- |
25 GUIFont *LoadFont(const char *pFontFile, const char *pFontPalette, ...) | 29 GUIFont *LoadFont(const char *pFontFile, const char *pFontPalette, ...) |
26 { | 30 { |
27 | 31 |
603 } | 607 } |
604 | 608 |
605 //----- (0044C59D) -------------------------------------------------------- | 609 //----- (0044C59D) -------------------------------------------------------- |
606 int GUIFont::CalcTextHeight(const char *pString, GUIWindow *pWindow, int uXOffset, int a5) | 610 int GUIFont::CalcTextHeight(const char *pString, GUIWindow *pWindow, int uXOffset, int a5) |
607 { | 611 { |
608 int uAllHeght; // esi@3 | 612 int uAllHeght; |
609 unsigned int uStringLen; // eax@3 | 613 unsigned int uStringLen; |
610 char c; // cl@4 | 614 char c; |
611 char *test_string; // [sp+14h] [bp+Ch]@3 | 615 char *test_string; |
612 | 616 |
613 if (!pString) | 617 if (!pString) |
614 return 0; | 618 return 0; |
615 uAllHeght = this->uFontHeight - 3; | 619 uAllHeght = this->uFontHeight - 3; |
616 test_string = FitTextInAWindow(pString, this, pWindow, uXOffset, 0); | 620 test_string = FitTextInAWindow(pString, this, pWindow, uXOffset, 0); |
692 } | 696 } |
693 | 697 |
694 //----- (0044C768) -------------------------------------------------------- | 698 //----- (0044C768) -------------------------------------------------------- |
695 char * FitTextInAWindow(const char *pInString, GUIFont *pFont, GUIWindow *pWindow, unsigned int uX, int a5) | 699 char * FitTextInAWindow(const char *pInString, GUIFont *pFont, GUIWindow *pWindow, unsigned int uX, int a5) |
696 { | 700 { |
697 const char *v5; // edi@1 | 701 unsigned char c; |
698 GUIFont *v6; // esi@1 | 702 unsigned int uInStrLen; |
699 unsigned int v8; // eax@3 | 703 char digits[4]; |
700 int v9; // edi@3 | 704 int possible_transition_point; |
701 unsigned __int8 v10; // cl@4 | 705 int string_pixel_Width; |
702 int v11; // edx@10 | 706 int start_pixel_offset; |
703 GUICharMetric *v12; // ecx@10 | 707 |
704 int v13; // edx@11 | 708 if (!pInString) |
705 int v14; // edx@12 | |
706 int v15; // edx@13 | |
707 unsigned int v16; // esi@15 | |
708 unsigned int v17; // edx@15 | |
709 unsigned int v18; // ecx@15 | |
710 int v19; // ebx@16 | |
711 unsigned __int8 v20; // zf@16 | |
712 char v21; // sf@16 | |
713 unsigned __int8 v22; // of@16 | |
714 int v23; // edi@16 | |
715 unsigned __int8 v24; // dl@17 | |
716 int v25; // edi@39 | |
717 int v26; // eax@42 | |
718 std::string v27; // [sp-18h] [bp-40h]@2 | |
719 const char *v28; // [sp-8h] [bp-30h]@2 | |
720 int v29; // [sp-4h] [bp-2Ch]@2 | |
721 const char *v30; // [sp+Ch] [bp-1Ch]@1 | |
722 char Str[3]; // [sp+10h] [bp-18h]@42 | |
723 char v32; // [sp+13h] [bp-15h]@42 | |
724 size_t v33; // [sp+14h] [bp-14h]@3 | |
725 unsigned int v34; // [sp+18h] [bp-10h]@3 | |
726 GUIFont *v35; // [sp+1Ch] [bp-Ch]@1 | |
727 int v36; // [sp+20h] [bp-8h]@3 | |
728 int v37; // [sp+24h] [bp-4h]@3 | |
729 | |
730 v5 = pInString; | |
731 v6 = pFont; | |
732 v30 = pInString; | |
733 v35 = pFont; | |
734 if ( !pInString ) | |
735 { | 709 { |
736 MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:445", 0); | 710 MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:445", 0); |
737 return 0; | 711 return 0; |
738 } | 712 } |
739 v33 = strlen(pInString); | 713 uInStrLen = strlen(pInString); |
740 strcpy(pTmpBuf3, v5); | 714 strcpy(&temp_string[0], pInString); |
741 v8 = uX; | 715 if (uInStrLen==0) |
742 v9 = 0; | 716 return &temp_string[0]; |
743 v36 = 0; | 717 |
744 v34 = uX; | 718 start_pixel_offset=string_pixel_Width=uX; |
745 v37 = 0; | 719 possible_transition_point=0; |
746 if ( (signed int)v33 > 0 ) | 720 for(int i=0; i<uInStrLen; ++i) |
747 { | 721 { |
748 while ( 1 ) | 722 c=temp_string[i]; |
723 if (pFont->IsCharValid(c)) | |
749 { | 724 { |
750 v10 = pTmpBuf3[v9]; | 725 switch (c) |
751 if ((v10 < v6->cFirstChar || v10 > v6->cLastChar) | |
752 && v10 != '\f' && v10 != '\r' && v10 != '\t' && v10 != '\n' ) | |
753 goto LABEL_34; | |
754 v11 = v10 - 9; | |
755 v12 = &v6->pMetrics[v10]; | |
756 if ( !v11 ) | |
757 { | 726 { |
758 strncpy(Str, &pTmpBuf3[v9 + 1], 3u); | 727 case '\t': // Horizontal tab 09 |
759 v32 = 0; | 728 { |
760 v26 = atoi(Str); | 729 strncpy(digits, &temp_string[i+1],3); |
761 v8 = uX + v26; | 730 digits[3]=0; |
762 v25 = v9 + 3; | 731 string_pixel_Width= atoi(digits)+uX; |
763 v34 = v8; | 732 i+=3; |
764 goto LABEL_43; | 733 break; |
765 } | 734 } |
766 v13 = v11 - 1; | 735 case '\n': //Line Feed 0A 10 |
767 if ( !v13 ) | |
768 break; | |
769 v14 = v13 - 2; | |
770 if ( !v14 ) | |
771 { | 736 { |
772 v25 = v9 + 5; | 737 string_pixel_Width=start_pixel_offset; |
773 LABEL_43: | 738 possible_transition_point=i; |
774 v37 = v25; | 739 break; |
775 goto LABEL_34; | |
776 } | 740 } |
777 v15 = v14 - 1; | 741 case '\f': //Form Feed, page eject 0C 12 |
778 if ( v15 ) | |
779 { | 742 { |
780 if ( v15 != 19 ) | 743 i+=5; |
744 break; | |
745 } | |
746 case '\r': //Carriage Return 0D 13 | |
747 { | |
748 if (!a5) | |
749 return (char*)pInString; | |
750 break; | |
751 } | |
752 case ' ' : | |
753 { | |
754 string_pixel_Width+=pFont->pMetrics[c].uWidth; | |
755 possible_transition_point=i; | |
756 break; | |
757 } | |
758 default: | |
759 | |
760 if ((string_pixel_Width+pFont->pMetrics[c].uWidth+ pFont->pMetrics[c].uLeftSpacing+ | |
761 pFont->pMetrics[c].uRightSpacing)<pWindow->uFrameWidth) | |
781 { | 762 { |
782 v16 = v12->uRightSpacing; | 763 if(i>possible_transition_point) |
783 v17 = v12->uWidth; | 764 string_pixel_Width+=pFont->pMetrics[c].uLeftSpacing; |
784 v18 = v12->uLeftSpacing; | 765 string_pixel_Width+=pFont->pMetrics[c].uWidth; |
785 if ( v8 + v16 + v18 + v17 < pWindow->uFrameWidth ) | 766 if (i<uInStrLen) |
767 string_pixel_Width+=pFont->pMetrics[c].uRightSpacing; | |
768 } | |
769 else | |
770 { | |
771 temp_string[possible_transition_point]='\n'; | |
772 string_pixel_Width=start_pixel_offset; | |
773 if (i>possible_transition_point) | |
786 { | 774 { |
787 if ( v37 > v36 ) | 775 for(int j=possible_transition_point;j<i; ++j ) |
788 v8 += v18; | 776 { |
789 v8 += v17; | 777 c=temp_string[j]; |
790 if ( v37 < (signed int)v33 ) | 778 if (pFont->IsCharValid(c)) |
791 v8 += v16; | 779 { |
792 v6 = v35; | 780 if(j>possible_transition_point) |
781 string_pixel_Width+=pFont->pMetrics[c].uLeftSpacing; | |
782 string_pixel_Width+=pFont->pMetrics[c].uWidth; | |
783 if (j<i) | |
784 string_pixel_Width+=pFont->pMetrics[c].uRightSpacing; | |
785 | |
786 } | |
787 } | |
793 } | 788 } |
794 else | |
795 { | |
796 v19 = v36; | |
797 v8 = v34; | |
798 v22 = v36 > v37; | |
799 v20 = v36 == v37; | |
800 v21 = v36 - v37 < 0; | |
801 v6 = v35; | |
802 pTmpBuf3[v36] = 10; | |
803 v23 = v19; | |
804 if ( (unsigned __int8)(v21 ^ v22) | v20 ) | |
805 { | |
806 do | |
807 { | |
808 v24 = pTmpBuf3[v23]; | |
809 if ( v24 >= v6->cFirstChar && v24 <= v6->cLastChar || v24 == 12 || v24 == 13 || v24 == 9 || v24 == 10 ) | |
810 { | |
811 if ( v23 > v19 ) | |
812 v8 += v6->pMetrics[v24].uLeftSpacing; | |
813 v8 += *((int *)&v6->cFirstChar + 3 * v24 + 9); | |
814 if ( v23 < v37 ) | |
815 v8 += v6->pMetrics[v24].uRightSpacing; | |
816 } | |
817 ++v23; | |
818 } | |
819 while ( v23 <= v37 ); | |
820 } | |
821 } | |
822 goto LABEL_34; | |
823 } | 789 } |
824 v8 += v12->uWidth; | |
825 goto LABEL_41; | |
826 } | 790 } |
827 if ( !a5 ) | |
828 return (char *)v30; | |
829 LABEL_34: | |
830 v9 = v37++ + 1; | |
831 if ( v37 >= (signed int)v33 ) | |
832 return pTmpBuf3; | |
833 } | 791 } |
834 v8 = v34; | |
835 LABEL_41: | |
836 v36 = v9; | |
837 goto LABEL_34; | |
838 } | 792 } |
839 return pTmpBuf3; | 793 return &temp_string[0]; |
840 } | 794 } |