Mercurial > mm7
comparison GUI/GUIWindow.cpp @ 2529:dbaf6fc71525
GUIWindow::DrawText: cleaned
author | a.parshin |
---|---|
date | Mon, 13 Oct 2014 17:18:55 +0300 |
parents | e72e62ec9273 |
children | 9ec6b8be16fe |
comparison
equal
deleted
inserted
replaced
2528:e72e62ec9273 | 2529:dbaf6fc71525 |
---|---|
1069 } | 1069 } |
1070 } | 1070 } |
1071 // 5C6DB4: using guessed type int ui_current_text_color; | 1071 // 5C6DB4: using guessed type int ui_current_text_color; |
1072 | 1072 |
1073 //----- (0044CE08) -------------------------------------------------------- | 1073 //----- (0044CE08) -------------------------------------------------------- |
1074 void GUIWindow::DrawText(GUIFont *a2, signed int uX, int uY, unsigned int uFontColor, const char *Str, int a7, int max_text_height, signed int uFontShadowColor ) | 1074 void GUIWindow::DrawText(GUIFont *font, signed int uX, int uY, unsigned short uFontColor, const char *Str, bool present_time_transparency, int max_text_height, signed int uFontShadowColor ) |
1075 { | 1075 { |
1076 GUIFont *v10; // ebx@1 | |
1077 signed int v12; // esi@9 | |
1078 signed int v13; // edi@9 | |
1079 int v14; // edx@9 | 1076 int v14; // edx@9 |
1080 int v15; // eax@25 | |
1081 unsigned int v16; // ecx@25 | |
1082 int v17; // eax@27v21 | |
1083 int v18; // edi@32 | 1077 int v18; // edi@32 |
1084 int v19; // esi@38 | |
1085 char Dest[6]; // [sp+Ch] [bp-2Ch]@32 | 1078 char Dest[6]; // [sp+Ch] [bp-2Ch]@32 |
1086 const char *v27; // [sp+20h] [bp-18h]@25 | |
1087 int v28; // [sp+24h] [bp-14h]@25 | |
1088 int v29; // [sp+28h] [bp-10h]@1 | |
1089 size_t v30; // [sp+2Ch] [bp-Ch]@4 | 1079 size_t v30; // [sp+2Ch] [bp-Ch]@4 |
1090 const char *v32; // [sp+34h] [bp-4h]@7 | 1080 |
1091 size_t pInString; // [sp+4Ch] [bp+14h]@11 | 1081 int left_margin = 0; |
1092 | |
1093 v29 = 0; | |
1094 v10 = a2; | |
1095 if ( !Str ) | 1082 if ( !Str ) |
1096 { | 1083 { |
1097 MessageBoxW(nullptr, L"Invalid string passed!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:859", 0); | 1084 MessageBoxW(nullptr, L"Invalid string passed!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:859", 0); |
1098 return; | 1085 return; |
1099 } | 1086 } |
1103 v30 = strlen(Str); | 1090 v30 = strlen(Str); |
1104 //int v11 = 0; | 1091 //int v11 = 0; |
1105 if ( !uX ) | 1092 if ( !uX ) |
1106 uX = 12; | 1093 uX = 12; |
1107 | 1094 |
1095 const char *string_begin = Str; | |
1108 if ( max_text_height != 0 ) | 1096 if ( max_text_height != 0 ) |
1109 v32 = Str; | 1097 string_begin = FitTextInAWindow(Str, font, this, uX, 0); |
1110 else | 1098 auto string_end = string_begin; |
1111 v32 = FitTextInAWindow(Str, v10, this, uX, 0); | 1099 auto string_base = string_begin; |
1112 | 1100 |
1113 v12 = uX + uFrameX; | 1101 int out_x = uX + uFrameX; |
1114 v13 = uY + uFrameY; | 1102 int out_y = uY + uFrameY; |
1115 v14 = 0; | 1103 v14 = 0; |
1116 | 1104 |
1117 if (max_text_height != 0 && v13 + LOBYTE(v10->uFontHeight) > max_text_height) | 1105 if (max_text_height != 0 && out_y + LOBYTE(font->uFontHeight) > max_text_height) |
1118 return; | 1106 return; |
1119 | 1107 |
1120 pInString = 0; | |
1121 if ( (signed int)v30 > 0 ) | 1108 if ( (signed int)v30 > 0 ) |
1122 { | 1109 { |
1123 do | 1110 do |
1124 { | 1111 { |
1125 unsigned char c = v32[v14]; | 1112 unsigned char c = string_base[v14]; |
1126 if ( c >= v10->cFirstChar && c <= v10->cLastChar | 1113 if ( c >= font->cFirstChar && c <= font->cLastChar |
1127 || c == 12 | 1114 || c == '\f' |
1128 || c == 13 | 1115 || c == '\r' |
1129 || c == 9 | 1116 || c == '\t' |
1130 || c == 10 ) | 1117 || c == '\n' ) |
1131 { | 1118 { |
1132 switch ( c ) | 1119 switch ( c ) |
1133 { | 1120 { |
1134 case 9u: | 1121 case '\t': |
1135 strncpy(Dest, &v32[v14 + 1], 3); | 1122 strncpy(Dest, &string_base[v14 + 1], 3); |
1136 Dest[3] = 0; | 1123 Dest[3] = 0; |
1137 pInString += 3; | 1124 v14 += 3; |
1138 v29 = atoi(Dest); | 1125 left_margin = atoi(Dest); |
1139 v19 = atoi(Dest); | 1126 out_x = uX + uFrameX + left_margin; |
1140 v12 = uX + uFrameX + v19; | |
1141 break; | 1127 break; |
1142 case 0xAu: | 1128 case '\n': |
1143 uY = uY + LOBYTE(v10->uFontHeight) - 3; | 1129 uY = uY + LOBYTE(font->uFontHeight) - 3; |
1144 v13 = uY + uFrameY; | 1130 out_y = uY + uFrameY; |
1145 v12 = uX + v29 + uFrameX; | 1131 out_x = uX + uFrameX + left_margin; |
1146 if ( max_text_height != 0 ) | 1132 if ( max_text_height != 0 ) |
1147 { | 1133 { |
1148 if (LOBYTE(v10->uFontHeight) + v13 - 3 > max_text_height ) | 1134 if (LOBYTE(font->uFontHeight) + out_y - 3 > max_text_height ) |
1149 return; | 1135 return; |
1150 } | 1136 } |
1151 break; | 1137 break; |
1152 case 0xCu: | 1138 case '\f': |
1153 strncpy(Dest, &v32[v14 + 1], 5); | 1139 strncpy(Dest, &string_base[v14 + 1], 5); |
1154 Dest[5] = 0; | 1140 Dest[5] = 0; |
1155 uFontColor = atoi(Dest); | 1141 uFontColor = atoi(Dest); |
1156 pInString += 5; | 1142 v14 += 5; |
1157 break; | 1143 break; |
1158 case 0xDu: | 1144 case '\r': |
1159 strncpy(Dest, &v32[v14 + 1], 3); | 1145 strncpy(Dest, &string_base[v14 + 1], 3); |
1160 Dest[3] = 0; | 1146 Dest[3] = 0; |
1161 pInString += 3; | 1147 v14 += 3; |
1162 v18 = atoi(Dest); | 1148 v18 = atoi(Dest); |
1163 v12 = uFrameZ - v10->GetLineWidth(&v32[pInString]) - v18; | 1149 out_x = uFrameZ - font->GetLineWidth(&string_base[v14]) - v18; |
1164 v13 = uY + uFrameY; | 1150 out_y = uY + uFrameY; |
1165 if ( max_text_height != 0 ) | 1151 if ( max_text_height != 0 ) |
1166 { | 1152 { |
1167 if (LOBYTE(v10->uFontHeight) + v13 - 3 > max_text_height ) | 1153 if (LOBYTE(font->uFontHeight) + out_y - 3 > max_text_height ) |
1168 return; | 1154 return; |
1169 break; | 1155 break; |
1170 } | 1156 } |
1171 break; | 1157 break; |
1158 | |
1172 default: | 1159 default: |
1173 if (c == 34 && v32[v14 + 1] == 34 ) | 1160 if (c == '\"' && string_base[v14 + 1] == '\"') |
1174 { | |
1175 ++v14; | 1161 ++v14; |
1176 pInString = v14; | 1162 |
1177 } | 1163 c = (unsigned __int8)string_base[v14]; |
1178 v27 = &v32[v14]; | |
1179 v15 = (unsigned __int8)v32[v14]; | |
1180 v16 = *((int *)&v10->cFirstChar + 3 * v15 + 9); | |
1181 v28 = *((int *)&v10->cFirstChar + 3 * v15 + 9); | |
1182 if ( v14 > 0 ) | 1164 if ( v14 > 0 ) |
1183 v12 += v10->pMetrics[v15].uLeftSpacing; | 1165 out_x += font->pMetrics[c].uLeftSpacing; |
1184 v17 = (int)((char *)&v10[1] + v10->font_pixels_offset[v15]); | 1166 |
1185 if ( (short)uFontColor ) | 1167 unsigned char *letter_pixels = &font->pFontData[font->font_pixels_offset[c]]; |
1186 pRenderer->DrawText(v12, v13, (unsigned __int8 *)v17, v16, LOBYTE(v10->uFontHeight), | 1168 if ( uFontColor ) |
1187 v10->pFontPalettes[0], uFontColor, uFontShadowColor); | 1169 pRenderer->DrawText(out_x, out_y, letter_pixels, font->pMetrics[c].uWidth, LOBYTE(font->uFontHeight), |
1170 font->pFontPalettes[0], uFontColor, uFontShadowColor); | |
1188 else | 1171 else |
1189 pRenderer->DrawTextAlpha(v12, v13, (unsigned char*)v17, v16, LOBYTE(v10->uFontHeight), | 1172 pRenderer->DrawTextAlpha(out_x, out_y, letter_pixels, font->pMetrics[c].uWidth, LOBYTE(font->uFontHeight), |
1190 v10->pFontPalettes[0], a7); | 1173 font->pFontPalettes[0], present_time_transparency); |
1191 v12 += v28; | 1174 |
1192 if ( (signed int)pInString < (signed int)v30 ) | 1175 out_x += font->pMetrics[c].uWidth; |
1193 v12 += v10->pMetrics[(unsigned __int8)*v27].uRightSpacing; | 1176 if ( (signed int)v14 < (signed int)v30 ) |
1177 out_x += font->pMetrics[c].uRightSpacing; | |
1194 break; | 1178 break; |
1195 } | 1179 } |
1196 } | 1180 } |
1197 v14 = pInString++ + 1; | |
1198 } | 1181 } |
1199 while ( (signed int)pInString < (signed int)v30 ); | 1182 while ( (signed int)++v14 < (signed int)v30 ); |
1200 } | 1183 } |
1201 } | 1184 } |
1202 | 1185 |
1203 | 1186 |
1204 //----- (0044CB4F) -------------------------------------------------------- | 1187 //----- (0044CB4F) -------------------------------------------------------- |