Mercurial > mm7
comparison GUI/GUIWindow.cpp @ 2528:e72e62ec9273
GUIWindow::DrawText: some cleanings
author | a.parshin |
---|---|
date | Mon, 13 Oct 2014 16:14:07 +0300 |
parents | 4cc81f981afb |
children | dbaf6fc71525 |
comparison
equal
deleted
inserted
replaced
2527:8f12e6a1fcc2 | 2528:e72e62ec9273 |
---|---|
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 a8, signed int uFontShadowColor ) | 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 ) |
1075 { | 1075 { |
1076 GUIWindow *v9; // edi@1 | |
1077 GUIFont *v10; // ebx@1 | 1076 GUIFont *v10; // ebx@1 |
1078 int v11; // eax@2 | |
1079 signed int v12; // esi@9 | 1077 signed int v12; // esi@9 |
1080 signed int v13; // edi@9 | 1078 signed int v13; // edi@9 |
1081 int v14; // edx@9 | 1079 int v14; // edx@9 |
1082 int v15; // eax@25 | 1080 int v15; // eax@25 |
1083 unsigned int v16; // ecx@25 | 1081 unsigned int v16; // ecx@25 |
1084 int v17; // eax@27 | 1082 int v17; // eax@27v21 |
1085 int v18; // edi@32 | 1083 int v18; // edi@32 |
1086 int v19; // esi@38 | 1084 int v19; // esi@38 |
1087 std::string v21; // [sp-18h] [bp-50h]@2 | |
1088 // const char *v22; // [sp-8h] [bp-40h]@2 | |
1089 // int v23; // [sp-4h] [bp-3Ch]@2 | |
1090 char Dest[6]; // [sp+Ch] [bp-2Ch]@32 | 1085 char Dest[6]; // [sp+Ch] [bp-2Ch]@32 |
1091 //char v25; // [sp+Fh] [bp-29h]@32 | |
1092 //char v26; // [sp+11h] [bp-27h]@34 | |
1093 const char *v27; // [sp+20h] [bp-18h]@25 | 1086 const char *v27; // [sp+20h] [bp-18h]@25 |
1094 int v28; // [sp+24h] [bp-14h]@25 | 1087 int v28; // [sp+24h] [bp-14h]@25 |
1095 int v29; // [sp+28h] [bp-10h]@1 | 1088 int v29; // [sp+28h] [bp-10h]@1 |
1096 size_t v30; // [sp+2Ch] [bp-Ch]@4 | 1089 size_t v30; // [sp+2Ch] [bp-Ch]@4 |
1097 GUIWindow *v31; // [sp+30h] [bp-8h]@1 | |
1098 const char *v32; // [sp+34h] [bp-4h]@7 | 1090 const char *v32; // [sp+34h] [bp-4h]@7 |
1099 size_t pInString; // [sp+4Ch] [bp+14h]@11 | 1091 size_t pInString; // [sp+4Ch] [bp+14h]@11 |
1100 | 1092 |
1101 GUIWindow* a1 = this; | |
1102 v29 = 0; | 1093 v29 = 0; |
1103 v9 = a1; | |
1104 v10 = a2; | 1094 v10 = a2; |
1105 v31 = a1; | |
1106 if ( !Str ) | 1095 if ( !Str ) |
1107 { | 1096 { |
1108 MessageBoxW(nullptr, L"Invalid string passed!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:859", 0); | 1097 MessageBoxW(nullptr, L"Invalid string passed!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:859", 0); |
1109 return; | 1098 return; |
1110 } | 1099 } |
1111 v11 = strcmp(Str, "null"); | 1100 if (!strcmp(Str, "null")) |
1112 if ( v11 ) | 1101 return; |
1113 { | 1102 |
1114 v30 = strlen(Str); | 1103 v30 = strlen(Str); |
1115 LOBYTE(v11) = 0; | 1104 //int v11 = 0; |
1116 if ( !uX ) | 1105 if ( !uX ) |
1117 uX = 12; | 1106 uX = 12; |
1118 if ( a8 ) | 1107 |
1108 if ( max_text_height != 0 ) | |
1119 v32 = Str; | 1109 v32 = Str; |
1120 else | 1110 else |
1121 { | 1111 v32 = FitTextInAWindow(Str, v10, this, uX, 0); |
1122 v11 = (int)FitTextInAWindow(Str, v10, v9, uX, 0); | 1112 |
1123 v32 = (const char *)v11; | 1113 v12 = uX + uFrameX; |
1124 } | 1114 v13 = uY + uFrameY; |
1125 v12 = uX + v9->uFrameX; | |
1126 v13 = uY + v9->uFrameY; | |
1127 v14 = 0; | 1115 v14 = 0; |
1128 if ( !a8 || (v11 = v13 + LOBYTE(v10->uFontHeight), v11 <= a8) ) | 1116 |
1129 { | 1117 if (max_text_height != 0 && v13 + LOBYTE(v10->uFontHeight) > max_text_height) |
1118 return; | |
1119 | |
1130 pInString = 0; | 1120 pInString = 0; |
1131 if ( (signed int)v30 > 0 ) | 1121 if ( (signed int)v30 > 0 ) |
1132 { | 1122 { |
1133 do | 1123 do |
1134 { | 1124 { |
1135 LOBYTE(v11) = v32[v14]; | 1125 unsigned char c = v32[v14]; |
1136 if ( (unsigned __int8)v11 >= v10->cFirstChar && (unsigned __int8)v11 <= v10->cLastChar | 1126 if ( c >= v10->cFirstChar && c <= v10->cLastChar |
1137 || (char)v11 == 12 | 1127 || c == 12 |
1138 || (char)v11 == 13 | 1128 || c == 13 |
1139 || (char)v11 == 9 | 1129 || c == 9 |
1140 || (char)v11 == 10 ) | 1130 || c == 10 ) |
1141 { | 1131 { |
1142 switch ( (unsigned __int8)v11 ) | 1132 switch ( c ) |
1143 { | 1133 { |
1144 case 9u: | 1134 case 9u: |
1145 strncpy(Dest, &v32[v14 + 1], 3); | 1135 strncpy(Dest, &v32[v14 + 1], 3); |
1146 Dest[3] = 0; | 1136 Dest[3] = 0; |
1147 pInString += 3; | 1137 pInString += 3; |
1148 v29 = atoi(Dest); | 1138 v29 = atoi(Dest); |
1149 v19 = atoi(Dest); | 1139 v19 = atoi(Dest); |
1150 LOBYTE(v11) = (char)v31; | 1140 v12 = uX + uFrameX + v19; |
1151 v12 = uX + v31->uFrameX + v19; | |
1152 break; | 1141 break; |
1153 case 0xAu: | 1142 case 0xAu: |
1154 v11 = LOBYTE(v10->uFontHeight); | 1143 uY = uY + LOBYTE(v10->uFontHeight) - 3; |
1155 uY = uY + v11 - 3; | 1144 v13 = uY + uFrameY; |
1156 v13 = uY + v31->uFrameY; | 1145 v12 = uX + v29 + uFrameX; |
1157 v12 = uX + v29 + v31->uFrameX; | 1146 if ( max_text_height != 0 ) |
1158 if ( a8 ) | |
1159 { | 1147 { |
1160 v11 = v11 + v13 - 3; | 1148 if (LOBYTE(v10->uFontHeight) + v13 - 3 > max_text_height ) |
1161 if ( v11 > a8 ) | |
1162 return; | 1149 return; |
1163 } | 1150 } |
1164 break; | 1151 break; |
1165 case 0xCu: | 1152 case 0xCu: |
1166 strncpy(Dest, &v32[v14 + 1], 5); | 1153 strncpy(Dest, &v32[v14 + 1], 5); |
1167 Dest[5] = 0; | 1154 Dest[5] = 0; |
1168 v11 = atoi(Dest); | 1155 uFontColor = atoi(Dest); |
1169 pInString += 5; | 1156 pInString += 5; |
1170 uFontColor = v11; | |
1171 break; | 1157 break; |
1172 case 0xDu: | 1158 case 0xDu: |
1173 strncpy(Dest, &v32[v14 + 1], 3); | 1159 strncpy(Dest, &v32[v14 + 1], 3); |
1174 Dest[3] = 0; | 1160 Dest[3] = 0; |
1175 pInString += 3; | 1161 pInString += 3; |
1176 v18 = atoi(Dest); | 1162 v18 = atoi(Dest); |
1177 v11 = v10->GetLineWidth(&v32[pInString]); | 1163 v12 = uFrameZ - v10->GetLineWidth(&v32[pInString]) - v18; |
1178 v12 = v31->uFrameZ - v11 - v18; | 1164 v13 = uY + uFrameY; |
1179 v13 = uY + v31->uFrameY; | 1165 if ( max_text_height != 0 ) |
1180 if ( a8 ) | |
1181 { | 1166 { |
1182 v11 = LOBYTE(v10->uFontHeight); | 1167 if (LOBYTE(v10->uFontHeight) + v13 - 3 > max_text_height ) |
1183 v11 = v11 + v13 - 3; | |
1184 if ( v11 > a8 ) | |
1185 return; | 1168 return; |
1186 break; | 1169 break; |
1187 } | 1170 } |
1188 break; | 1171 break; |
1189 default: | 1172 default: |
1190 if ( (char)v11 == 34 && v32[v14 + 1] == 34 ) | 1173 if (c == 34 && v32[v14 + 1] == 34 ) |
1191 { | 1174 { |
1192 ++v14; | 1175 ++v14; |
1193 pInString = v14; | 1176 pInString = v14; |
1194 } | 1177 } |
1195 v27 = &v32[v14]; | 1178 v27 = &v32[v14]; |
1203 pRenderer->DrawText(v12, v13, (unsigned __int8 *)v17, v16, LOBYTE(v10->uFontHeight), | 1186 pRenderer->DrawText(v12, v13, (unsigned __int8 *)v17, v16, LOBYTE(v10->uFontHeight), |
1204 v10->pFontPalettes[0], uFontColor, uFontShadowColor); | 1187 v10->pFontPalettes[0], uFontColor, uFontShadowColor); |
1205 else | 1188 else |
1206 pRenderer->DrawTextAlpha(v12, v13, (unsigned char*)v17, v16, LOBYTE(v10->uFontHeight), | 1189 pRenderer->DrawTextAlpha(v12, v13, (unsigned char*)v17, v16, LOBYTE(v10->uFontHeight), |
1207 v10->pFontPalettes[0], a7); | 1190 v10->pFontPalettes[0], a7); |
1208 LOBYTE(v11) = v30; | |
1209 v12 += v28; | 1191 v12 += v28; |
1210 if ( (signed int)pInString < (signed int)v30 ) | 1192 if ( (signed int)pInString < (signed int)v30 ) |
1211 { | |
1212 LOBYTE(v11) = 3 * *v27; | |
1213 v12 += v10->pMetrics[(unsigned __int8)*v27].uRightSpacing; | 1193 v12 += v10->pMetrics[(unsigned __int8)*v27].uRightSpacing; |
1214 } | |
1215 break; | 1194 break; |
1216 } | 1195 } |
1217 } | 1196 } |
1218 v14 = pInString++ + 1; | 1197 v14 = pInString++ + 1; |
1219 } | 1198 } |
1220 while ( (signed int)pInString < (signed int)v30 ); | 1199 while ( (signed int)pInString < (signed int)v30 ); |
1221 } | 1200 } |
1222 } | |
1223 } | |
1224 return; | |
1225 } | 1201 } |
1226 | 1202 |
1227 | 1203 |
1228 //----- (0044CB4F) -------------------------------------------------------- | 1204 //----- (0044CB4F) -------------------------------------------------------- |
1229 int GUIWindow::DrawTextInRect( GUIFont *pFont, unsigned int uX, unsigned int uY, unsigned int uColor, const char *text, int rect_width, int reverse_text ) | 1205 int GUIWindow::DrawTextInRect( GUIFont *pFont, unsigned int uX, unsigned int uY, unsigned int uColor, const char *text, int rect_width, int reverse_text ) |
3176 v2 = pGlobalTXT_LocalizationStrings[535]; | 3152 v2 = pGlobalTXT_LocalizationStrings[535]; |
3177 pDialogueWindow->CreateButton(480, 160, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x4Fu, 0, v2, 0); | 3153 pDialogueWindow->CreateButton(480, 160, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x4Fu, 0, v2, 0); |
3178 pDialogueWindow->_41D08F_set_keyboard_control_group(1, 1, 0, 2); | 3154 pDialogueWindow->_41D08F_set_keyboard_control_group(1, 1, 0, 2); |
3179 dialog_menu_id = HOUSE_DIALOGUE_OTHER; | 3155 dialog_menu_id = HOUSE_DIALOGUE_OTHER; |
3180 } | 3156 } |
3181 // F8B19C: using guessed type int dword_F8B19C; | 3157 |
3182 // F8B1A8: using guessed type int dword_F8B1A8; | |
3183 //----- (004B1ECE) -------------------------------------------------------- | 3158 //----- (004B1ECE) -------------------------------------------------------- |
3184 void OracleDialogue() | 3159 void OracleDialogue() |
3185 { | 3160 { |
3186 __int16 *v0; // edi@1 | 3161 __int16 *v0; // edi@1 |
3187 signed int v4; // eax@9 | 3162 signed int v4; // eax@9 |