Mercurial > mm7
diff GUIFont.cpp @ 1463:b330df6a2183
Слияние
author | Ritor1 |
---|---|
date | Sun, 11 Aug 2013 12:09:33 +0600 |
parents | dfc9484ed94c |
children | c4ab816fcc5e |
line wrap: on
line diff
--- a/GUIFont.cpp Sun Aug 11 12:09:09 2013 +0600 +++ b/GUIFont.cpp Sun Aug 11 12:09:33 2013 +0600 @@ -385,11 +385,10 @@ //----- (0044C6C2) -------------------------------------------------------- -char* GUIFont::_44C6C2( const char *pInString, GUIWindow *pWindow, unsigned int uX, int a5 ) - { +char* GUIFont::GetPageTop( const char *pInString, GUIWindow *pWindow, unsigned int uX, int a5 ) +{ int text_height; // edi@1 char *text_str; // ebx@3 - int i; unsigned char c; // cl@4 int text_length; @@ -399,35 +398,33 @@ return 0; text_str = FitTextInAWindow(pInString, this, pWindow, uX, 0); text_length = strlen(text_str); - for (i=0; i<text_length; ++i ) + for ( int i = 0; i < text_length; ++i ) + { + c = text_str[i]; + if ( IsCharValid(c) ) + { + switch (c) { - c = text_str[i]; - if ( IsCharValid(c) ) - { - switch (c) - { - case '\n': //Line Feed 0A 10: - text_height = text_height + uFontHeight - 3; - if ( text_height >= (signed int)(a5 * pWindow->uFrameHeight) ) - return &text_str[i+1]; - break; - case '\f': //Form Feed, page eject 0C 12 - i += 5; - break; - case '\t': // Horizontal tab 09 - case '\r': //Carriage Return 0D 13 - i += 3; - break; - } - if ( text_height >= (signed int)(a5 * pWindow->uFrameHeight) ) - break; - } + case '\n': //Line Feed 0A 10: + text_height = text_height + (uFontHeight - 3); + if ( text_height >= (signed int)(a5 * (pWindow->uFrameHeight - (uFontHeight - 3))) ) + return &text_str[i]; + break; + case '\f': //Form Feed, page eject 0C 12 + i += 5; + break; + case '\t': // Horizontal tab 09 + case '\r': //Carriage Return 0D 13 + i += 3; + break; } - return &text_str[i]; + if ( text_height >= (signed int)(a5 * pWindow->uFrameHeight) ) + break; + } + } + return &text_str[0]; } - - //----- (0044C62E) -------------------------------------------------------- int GUIFont::GetStringHeight2( GUIFont *secondFont, const char *text_str, GUIWindow* pWindow, int startX, int a6 ) { @@ -469,41 +466,40 @@ //----- (0044C59D) -------------------------------------------------------- int GUIFont::CalcTextHeight( const char *pString, struct GUIWindow *pWindow, int uXOffset, int a5 ) - { - int uAllHeght; - int uStringLen; - unsigned char c; - char *test_string; +{ + int uAllHeght; + int uStringLen; + unsigned char c; + char *test_string; - if (!pString) - return 0; - uAllHeght = uFontHeight - 3; - test_string = FitTextInAWindow(pString, this, pWindow, uXOffset, 0); - uStringLen = strlen(pString); - for (int i = 0; i < uStringLen; ++i) - { - c = test_string[i]; - if (IsCharValid(c)) - { - switch (c) - { - case '\n': //Line Feed 0A 10: - uAllHeght+= uFontHeight - 3; - break; - case '\f': //Form Feed, page eject 0C 12 - i += 5; - break; - case '\t': // Horizontal tab 09 - case '\r': //Carriage Return 0D 13 - if (a5 != 1) - i += 3; - break; - } - } - } - return uAllHeght; - } - + if (!pString) + return 0; + uAllHeght = uFontHeight - 6; + test_string = FitTextInAWindow(pString, this, pWindow, uXOffset, 0); + uStringLen = strlen(pString); + for (int i = 0; i < uStringLen; ++i) + { + c = test_string[i]; + if (IsCharValid(c)) + { + switch (c) + { + case '\n': //Line Feed 0A 10: + uAllHeght += uFontHeight - 3; + break; + case '\f': //Form Feed, page eject 0C 12 + i += 5; + break; + case '\t': // Horizontal tab 09 + case '\r': //Carriage Return 0D 13 + if (a5 != 1) + i += 3; + break; + } + } + } + return uAllHeght; +} //----- (0044C51E) -------------------------------------------------------- int GUIFont::GetLineWidth(const char *pString) @@ -553,106 +549,103 @@ return position; else return 0; - } //----- (0044C768) -------------------------------------------------------- char * FitTextInAWindow( const char *pInString, GUIFont *pFont, GUIWindow *pWindow, signed int uX, int a5 ) - { - unsigned char c; - int uInStrLen; - char digits[4]; - int possible_transition_point; - int string_pixel_Width; - int start_pixel_offset; +{ + unsigned char c; + int uInStrLen; + char digits[4]; + int possible_transition_point; + int string_pixel_Width; + int start_pixel_offset; - if (!pInString) - { - MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:445", 0); - return 0; - } - uInStrLen = strlen(pInString); - strcpy(&temp_string[0], pInString); - if (uInStrLen==0) - return &temp_string[0]; + if (!pInString) + { + MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:445", 0); + return 0; + } + uInStrLen = strlen(pInString); + strcpy(&temp_string[0], pInString); + if (uInStrLen == 0) + return &temp_string[0]; - start_pixel_offset=string_pixel_Width=uX; - possible_transition_point=0; - for(int i=0; i<uInStrLen; ++i) - { - c=temp_string[i]; - if (pFont->IsCharValid(c)) - { - switch (c) - { - case '\t': // Horizontal tab 09 - { - strncpy(digits, &temp_string[i+1],3); - digits[3]=0; - string_pixel_Width= atoi(digits)+uX; - i+=3; - break; - } - case '\n': //Line Feed 0A 10 - { - string_pixel_Width=start_pixel_offset; - possible_transition_point=i; - break; - } - case '\f': //Form Feed, page eject 0C 12 - { - i+=5; - break; - } - case '\r': //Carriage Return 0D 13 - { - if (!a5) - return (char*)pInString; - break; - } - case ' ' : - { - string_pixel_Width+=pFont->pMetrics[c].uWidth; - possible_transition_point=i; - break; - } - default: - - if ((string_pixel_Width+pFont->pMetrics[c].uWidth+ pFont->pMetrics[c].uLeftSpacing+ - pFont->pMetrics[c].uRightSpacing)<pWindow->uFrameWidth) - { - if(i>possible_transition_point) - string_pixel_Width+=pFont->pMetrics[c].uLeftSpacing; - string_pixel_Width+=pFont->pMetrics[c].uWidth; - if (i<uInStrLen) - string_pixel_Width+=pFont->pMetrics[c].uRightSpacing; - } - else - { - temp_string[possible_transition_point]='\n'; - string_pixel_Width=start_pixel_offset; - if (i>possible_transition_point) - { - for(int j=possible_transition_point;j<i; ++j ) - { - c=temp_string[j]; - if (pFont->IsCharValid(c)) - { - if(j>possible_transition_point) - string_pixel_Width+=pFont->pMetrics[c].uLeftSpacing; - string_pixel_Width+=pFont->pMetrics[c].uWidth; - if (j<i) - string_pixel_Width+=pFont->pMetrics[c].uRightSpacing; - - } - } - } - } - } - } - } - return &temp_string[0]; - } + start_pixel_offset = string_pixel_Width=uX; + possible_transition_point = 0; + for ( int i = 0; i < uInStrLen; ++i ) + { + c = temp_string[i]; + if (pFont->IsCharValid(c)) + { + switch (c) + { + case '\t': // Horizontal tab 09 + { + strncpy(digits, &temp_string[i + 1],3); + digits[3] = 0; + string_pixel_Width = atoi(digits)+uX; + i += 3; + break; + } + case '\n': //Line Feed 0A 10 ( ) + { + string_pixel_Width = start_pixel_offset; + possible_transition_point = i; + break; + } + case '\f': //Form Feed, page eject 0C 12 + { + i += 5; + break; + } + case '\r': //Carriage Return 0D 13 + { + if ( !a5 ) + return (char*)pInString; + break; + } + case ' ':// + { + string_pixel_Width += pFont->pMetrics[c].uWidth; + possible_transition_point = i; + break; + } + default: + if ((string_pixel_Width + pFont->pMetrics[c].uWidth + pFont->pMetrics[c].uLeftSpacing + + pFont->pMetrics[c].uRightSpacing) < pWindow->uFrameWidth )// + { + if ( i > possible_transition_point ) + string_pixel_Width += pFont->pMetrics[c].uLeftSpacing; + string_pixel_Width += pFont->pMetrics[c].uWidth; + if (i < uInStrLen) + string_pixel_Width += pFont->pMetrics[c].uRightSpacing; + } + else// + { + temp_string[possible_transition_point] ='\n'; + string_pixel_Width = start_pixel_offset; + if ( i > possible_transition_point ) + { + for ( int j = possible_transition_point; j < i; ++j ) + { + c = temp_string[j]; + if (pFont->IsCharValid(c)) + { + if ( j > possible_transition_point ) + string_pixel_Width += pFont->pMetrics[c].uLeftSpacing; + string_pixel_Width += pFont->pMetrics[c].uWidth; + if ( j < i ) + string_pixel_Width += pFont->pMetrics[c].uRightSpacing; + } + } + } + } + } + } + } + return &temp_string[0]; +} //----- (00414162) -------------------------------------------------------- void uGameUIFontMain_initialize() {