Mercurial > mm7
annotate GUIFont.cpp @ 1347:84db43e7db93
Merge
author | Grumpy7 |
---|---|
date | Fri, 12 Jul 2013 23:08:35 +0200 |
parents | 5450af4f57ef |
children | dfc9484ed94c |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
4 |
0 | 5 #include <string> |
200 | 6 #include <assert.h> |
7 | |
180 | 8 #include "LOD.h" |
0 | 9 #include "GUIFont.h" |
10 #include "GUIWindow.h" | |
11 #include "Render.h" | |
12 | |
13 #include "mm7_data.h" | |
14 | |
15 | |
180 | 16 extern LODFile_IconsBitmaps *pIcons_LOD; |
0 | 17 |
18 | |
19 struct GUIFont *pAutonoteFont; | |
20 struct GUIFont *pSpellFont; | |
21 struct GUIFont *pFontArrus; | |
22 struct GUIFont *pFontLucida; | |
23 struct GUIFont *pBook2Font; | |
24 struct GUIFont *pBookFont; | |
25 struct GUIFont *pFontCreate; | |
26 struct GUIFont *pFontCChar; | |
27 struct GUIFont *pFontComic; | |
28 struct GUIFont *pFontSmallnum; | |
29 | |
189 | 30 char temp_string[2048]; |
31 | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1168
diff
changeset
|
32 std::array<char, 10000> pTmpBuf3; |
189 | 33 |
1160 | 34 void DrawCharToBuff(unsigned short* uXpos,unsigned char* pCharPixels, int uCharWidth, int uCharHeight, unsigned __int16* pFontPalette, __int16 draw_color, int line_width); |
35 | |
36 | |
180 | 37 //----- (0044C448) -------------------------------------------------------- |
38 GUIFont *LoadFont(const char *pFontFile, const char *pFontPalette, ...) | |
1160 | 39 { |
40 int pallete_index; // eax@3 | |
41 GUIFont *pFont; | |
42 unsigned int palletes_count =0; | |
43 va_list palettes_ptr; | |
180 | 44 |
1160 | 45 pFont = (GUIFont *)pIcons_LOD->LoadRaw(pFontFile, 0); |
46 va_start(palettes_ptr, pFontFile); | |
180 | 47 |
1160 | 48 while (NULL!=(pFontPalette=va_arg(palettes_ptr, const char *))) |
49 { | |
50 pallete_index =pIcons_LOD->LoadTexture(pFontPalette, TEXTURE_16BIT_PALETTE); | |
51 if (pallete_index == -1) | |
52 { | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1168
diff
changeset
|
53 wsprintfA(pTmpBuf.data(), "Unable to open %s", pFontPalette); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1168
diff
changeset
|
54 Abortf(pTmpBuf.data()); |
1160 | 55 } |
56 pFont->pFontPalettes[palletes_count] = pIcons_LOD->pTextures[pallete_index].pPalette16; | |
57 ++palletes_count; | |
58 } | |
59 va_end(palettes_ptr); | |
60 pFont->palletes_count = palletes_count; | |
61 return pFont; | |
62 } | |
0 | 63 |
64 | |
65 | |
66 //----- (0044D2FD) -------------------------------------------------------- | |
1168 | 67 void GUIFont::_44D2FD_prolly_draw_credits_entry( GUIFont *pSecondFont, int uFrameX, int uFrameY, unsigned int w, unsigned int h, |
68 unsigned __int16 firstColor, unsigned __int16 secondColor, const char *pString, | |
69 unsigned __int16 *pPixels, unsigned int uPixelsWidth ) | |
70 { | |
71 char *work_string; // eax@1 | |
72 unsigned __int16 *curr_pixel_pos; // esi@1 | |
73 GUIFont *currentFont; // edi@4 | |
74 signed int start_str_pos; // ecx@4 | |
75 signed int line_w; // eax@6 | |
76 GUIWindow draw_window; // [sp+Ch] [bp-5Ch]@ | |
77 int currentColor; // [sp+74h] [bp+Ch]@4 | |
78 int half_frameX; // [sp+80h] [bp+18h]@2 | |
0 | 79 |
1168 | 80 draw_window.uFrameHeight = h; |
81 draw_window.uFrameW = uFrameY + h - 1; | |
82 draw_window.uFrameWidth = w; | |
83 draw_window.uFrameZ = uFrameX + w - 1; | |
84 ui_current_text_color = firstColor; | |
85 draw_window.uFrameX = uFrameX; | |
86 draw_window.uFrameY = uFrameY; | |
87 | |
88 work_string = GUIFont::FitTwoFontStringINWindow(pString, this, pSecondFont, &draw_window, 0, 1); | |
89 work_string = strtok(work_string, "\n"); | |
90 curr_pixel_pos = &pPixels[uPixelsWidth * uFrameY]; | |
91 if ( work_string ) | |
0 | 92 { |
1168 | 93 half_frameX = uFrameX >> 1; |
0 | 94 while ( 1 ) |
95 { | |
1168 | 96 currentFont = this; |
97 ui_current_text_color = firstColor; | |
98 start_str_pos = 0; | |
99 currentColor = firstColor; | |
100 if ( *work_string == '_' ) | |
0 | 101 { |
1168 | 102 currentFont = pSecondFont; |
103 currentColor = secondColor; | |
104 ui_current_text_color = secondColor; | |
105 start_str_pos = 1; | |
0 | 106 } |
1168 | 107 line_w = (signed int)(w - currentFont->GetLineWidth(&work_string[start_str_pos]))/2; |
108 if ( line_w < 0 ) | |
109 line_w = 0; | |
110 currentFont->DrawTextLineToBuff(currentColor, secondColor, &curr_pixel_pos[line_w + half_frameX], work_string, uPixelsWidth); | |
111 curr_pixel_pos += uPixelsWidth * (currentFont->uFontHeight - 3); | |
112 work_string = strtok(0, "\n"); | |
113 if ( !work_string ) | |
0 | 114 break; |
115 } | |
116 } | |
117 } | |
1168 | 118 |
0 | 119 |
120 | |
121 //----- (0044D1E7) -------------------------------------------------------- | |
1160 | 122 void GUIFont::DrawTextLine( unsigned int uDefaultColor, signed int uX, signed int uY, |
123 const char *text, int max_len_pix ) | |
0 | 124 { |
1160 | 125 signed int uX_pos; // edi@3 |
126 unsigned char c; // cl@4 | |
127 unsigned __int16 draw_color; // cx@12 | |
128 unsigned __int8 *pCharPixels; // eax@12 | |
129 char color_code[20]; // [sp+Ch] [bp-1Ch]@16 | |
130 int text_length; // [sp+20h] [bp-8h]@2 | |
131 int text_color; // [sp+24h] [bp-4h]@1 | |
132 int uCharWidth; // [sp+30h] [bp+8h]@9 | |
0 | 133 |
1160 | 134 if ( !text ) |
135 return; | |
136 text_color = ui_current_text_color; | |
137 text_length = strlen(text); | |
138 uX_pos=uX; | |
139 for (int i=0; i<text_length; ++i ) | |
0 | 140 { |
1160 | 141 c = text[i]; |
142 if ( IsCharValid(c) ) | |
0 | 143 { |
1160 | 144 switch (c) |
0 | 145 { |
1160 | 146 case '\n': //Line Feed 0A 10: |
147 return; | |
148 break; | |
149 case '\f': //Form Feed, page eject 0C 12 | |
150 strncpy(color_code, &text[i + 1], 5); | |
151 color_code[5] = 0; | |
152 text_color = atoi(color_code); | |
153 ui_current_text_color = text_color; | |
154 i += 5; | |
155 break; | |
156 case '\t': // Horizontal tab 09 | |
157 case '\r': //Carriage Return 0D 13 | |
158 break; | |
159 default: | |
160 uCharWidth = pMetrics[c].uWidth; | |
161 if ( uCharWidth ) | |
162 { | |
163 if ( i > 0 ) | |
164 uX_pos += pMetrics[c].uLeftSpacing; | |
165 draw_color = text_color; | |
166 pCharPixels = &pFontData[font_pixels_offset[c]]; | |
167 if ( !text_color ) | |
168 draw_color = -1; | |
169 pRenderer->DrawText(uX_pos, uY, pCharPixels, uCharWidth, uFontHeight, pFontPalettes[0], draw_color, 0); | |
170 uX_pos += uCharWidth; | |
171 if ( i < text_length ) | |
172 uX_pos += pMetrics[c].uRightSpacing; | |
173 } | |
0 | 174 } |
175 } | |
1160 | 176 } |
177 | |
178 } | |
179 | |
180 //----- (0040F845) -------------------------------------------------------- | |
181 void DrawCharToBuff( unsigned short* uXpos,unsigned char* pCharPixels, int uCharWidth, int uCharHeight, | |
182 unsigned __int16* pFontPalette, __int16 draw_color, int line_width ) | |
183 { | |
184 unsigned __int16* draw_buff; // edi@1 | |
185 unsigned char* pPixels; // esi@1 | |
186 unsigned char char_pxl; // eax@3 | |
187 | |
188 draw_buff = uXpos; | |
189 pPixels = pCharPixels; | |
190 for(int i=0; i<uCharHeight; ++i) | |
191 { | |
192 for(int j=0; j<uCharWidth; ++j) | |
0 | 193 { |
1160 | 194 char_pxl = *pPixels++; |
195 if ( char_pxl ) | |
196 { | |
197 if ( char_pxl == 1 ) | |
198 *draw_buff = pFontPalette[1]; | |
199 else | |
200 *draw_buff = draw_color; | |
201 } | |
202 ++draw_buff; | |
0 | 203 } |
1160 | 204 draw_buff+=line_width-uCharWidth; |
0 | 205 } |
1160 | 206 |
0 | 207 } |
208 | |
209 //----- (0044D0B5) -------------------------------------------------------- | |
1160 | 210 void GUIFont::DrawTextLineToBuff( int uColor, int a3, unsigned short* uX_buff_pos, const char *text, int line_width ) |
211 { | |
212 | |
213 unsigned short* uX_pos; // edi@3 | |
214 unsigned char c; // cl@4 | |
215 unsigned __int16 draw_color; // cx@12 | |
216 unsigned __int8 *pCharPixels; // eax@12 | |
217 char color_code[20]; // [sp+Ch] [bp-1Ch]@16 | |
218 int text_length; // [sp+20h] [bp-8h]@2 | |
219 int text_color; // [sp+24h] [bp-4h]@1 | |
220 int uCharWidth; // [sp+30h] [bp+8h]@9 | |
0 | 221 |
1160 | 222 if ( !text ) |
223 return; | |
224 text_color = ui_current_text_color; | |
225 text_length = strlen(text); | |
226 uX_pos=uX_buff_pos; | |
227 for (int i=0; i<text_length; ++i ) | |
0 | 228 { |
1160 | 229 c = text[i]; |
230 if ( IsCharValid(c) ) | |
0 | 231 { |
1160 | 232 switch (c) |
233 { | |
234 case '\n': //Line Feed 0A 10: | |
0 | 235 return; |
1160 | 236 break; |
237 case '\f': //Form Feed, page eject 0C 12 | |
238 strncpy(color_code, &text[i + 1], 5); | |
239 color_code[5] = 0; | |
240 text_color = atoi(color_code); | |
241 ui_current_text_color = text_color; | |
242 i += 5; | |
243 break; | |
244 case '\t': // Horizontal tab 09 | |
1168 | 245 case '_': |
1160 | 246 break; |
247 default: | |
248 uCharWidth = pMetrics[c].uWidth; | |
249 if ( uCharWidth ) | |
0 | 250 { |
1160 | 251 if ( i > 0 ) |
252 uX_pos += pMetrics[c].uLeftSpacing; | |
253 draw_color = text_color; | |
254 pCharPixels = &pFontData[font_pixels_offset[c]]; | |
255 if ( !text_color ) | |
256 draw_color = -1; | |
257 DrawCharToBuff(uX_pos, pCharPixels, uCharWidth, uFontHeight, pFontPalettes[0], draw_color, line_width); | |
258 uX_pos += uCharWidth; | |
259 if ( i < text_length ) | |
260 uX_pos += pMetrics[c].uRightSpacing; | |
0 | 261 } |
262 } | |
263 } | |
264 } | |
265 } | |
1160 | 266 |
0 | 267 |
268 | |
269 //----- (0044C933) -------------------------------------------------------- | |
1168 | 270 char * GUIFont::FitTwoFontStringINWindow( const char *pString, GUIFont *pFontMain, GUIFont *pFontSecond, GUIWindow* pWindow, int startPixlOff, int a6 ) |
271 { | |
272 | |
273 GUIFont *currentFont; // esi@3 | |
274 unsigned char c; | |
275 int uInStrLen; | |
276 char digits[4]; | |
277 int possible_transition_point; | |
278 int string_pixel_Width; | |
279 int start_pixel_offset; | |
280 | |
281 if (!pString) | |
282 { | |
283 MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:445", 0); | |
284 return 0; | |
285 } | |
286 currentFont=pFontMain; // esi@3 | |
287 uInStrLen = strlen(pString); | |
288 assert(uInStrLen < sizeof(pTmpBuf3)); | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1168
diff
changeset
|
289 strcpy(pTmpBuf3.data(), pString); |
1168 | 290 if (uInStrLen==0) |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1168
diff
changeset
|
291 return pTmpBuf3.data(); |
0 | 292 |
1168 | 293 start_pixel_offset=string_pixel_Width=startPixlOff; |
294 possible_transition_point=0; | |
295 for(int i=0; i<uInStrLen; ++i) | |
296 { | |
297 c=pTmpBuf3[i]; | |
298 if (pFontMain->IsCharValid(c)) | |
299 { | |
300 switch (c) | |
301 { | |
302 case '\t': // Horizontal tab 09 | |
303 { | |
304 strncpy(digits, &pTmpBuf3[i+1],3); | |
305 digits[3]=0; | |
306 string_pixel_Width = atoi(digits)+startPixlOff; | |
307 i+=3; | |
308 break; | |
309 } | |
310 case '\n': //Line Feed 0A 10 | |
311 { | |
312 string_pixel_Width=start_pixel_offset; | |
313 possible_transition_point=i; | |
314 currentFont=pFontMain; | |
315 break; | |
316 } | |
317 case '\f': //Form Feed, page eject 0C 12 | |
318 { | |
319 i+=5; | |
320 break; | |
321 } | |
322 case '\r': //Carriage Return 0D 13 | |
323 { | |
324 if (!a6) | |
325 return (char*)pString; | |
326 break; | |
327 } | |
328 case ' ' : | |
329 { | |
330 string_pixel_Width+=currentFont->pMetrics[c].uWidth; | |
331 possible_transition_point=i; | |
332 break; | |
333 } | |
334 case '_' : | |
335 currentFont=pFontSecond; | |
336 break; | |
337 default: | |
200 | 338 |
1168 | 339 if ((string_pixel_Width+currentFont->pMetrics[c].uWidth+ currentFont->pMetrics[c].uLeftSpacing+ |
340 currentFont->pMetrics[c].uRightSpacing)<pWindow->uFrameWidth) | |
0 | 341 { |
1168 | 342 if(i>possible_transition_point) |
343 string_pixel_Width+=currentFont->pMetrics[c].uLeftSpacing; | |
344 string_pixel_Width+=currentFont->pMetrics[c].uWidth; | |
345 if (i<uInStrLen) | |
346 string_pixel_Width+=currentFont->pMetrics[c].uRightSpacing; | |
347 } | |
348 else | |
349 { | |
350 pTmpBuf3[possible_transition_point]='\n'; | |
351 | |
352 if ( currentFont== pFontSecond) | |
0 | 353 { |
1168 | 354 |
355 for(int k=uInStrLen-1; k>=possible_transition_point+1; --k) | |
356 pTmpBuf3[k] = pTmpBuf3[k-1]; | |
357 | |
358 ++uInStrLen; | |
359 ++possible_transition_point; | |
360 pTmpBuf3[possible_transition_point] = '_'; | |
361 | |
0 | 362 } |
1168 | 363 string_pixel_Width=start_pixel_offset; |
364 | |
365 for(int j=possible_transition_point;j<i; ++j ) | |
366 { | |
367 c=pTmpBuf3[j]; | |
368 if (pFontMain->IsCharValid(c)) | |
369 { | |
370 if(j>possible_transition_point) | |
371 string_pixel_Width+=pFontMain->pMetrics[c].uLeftSpacing; | |
372 string_pixel_Width+=pFontMain->pMetrics[c].uWidth; | |
373 if (j<i) | |
374 string_pixel_Width+=pFontMain->pMetrics[c].uRightSpacing; | |
375 | |
376 } | |
377 } | |
0 | 378 } |
379 } | |
380 } | |
381 } | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1168
diff
changeset
|
382 return pTmpBuf3.data(); |
1168 | 383 |
0 | 384 } |
385 | |
386 | |
387 //----- (0044C6C2) -------------------------------------------------------- | |
1160 | 388 char* GUIFont::_44C6C2( const char *pInString, GUIWindow *pWindow, unsigned int uX, int a5 ) |
389 { | |
390 int text_height; // edi@1 | |
391 char *text_str; // ebx@3 | |
392 int i; | |
393 unsigned char c; // cl@4 | |
394 int text_length; | |
0 | 395 |
1160 | 396 text_height = 0; |
397 | |
0 | 398 if ( !pInString ) |
399 return 0; | |
1160 | 400 text_str = FitTextInAWindow(pInString, this, pWindow, uX, 0); |
401 text_length = strlen(text_str); | |
402 for (i=0; i<text_length; ++i ) | |
403 { | |
404 c = text_str[i]; | |
405 if ( IsCharValid(c) ) | |
406 { | |
407 switch (c) | |
408 { | |
409 case '\n': //Line Feed 0A 10: | |
410 text_height = text_height + uFontHeight - 3; | |
411 if ( text_height >= (signed int)(a5 * pWindow->uFrameHeight) ) | |
412 return &text_str[i+1]; | |
413 break; | |
414 case '\f': //Form Feed, page eject 0C 12 | |
415 i += 5; | |
416 break; | |
417 case '\t': // Horizontal tab 09 | |
418 case '\r': //Carriage Return 0D 13 | |
419 i += 3; | |
420 break; | |
421 } | |
422 if ( text_height >= (signed int)(a5 * pWindow->uFrameHeight) ) | |
1166 | 423 break; |
1160 | 424 } |
425 } | |
426 return &text_str[i]; | |
0 | 427 } |
428 | |
429 | |
430 | |
431 //----- (0044C62E) -------------------------------------------------------- | |
1168 | 432 int GUIFont::GetStringHeight2( GUIFont *secondFont, const char *text_str, GUIWindow* pWindow, int startX, int a6 ) |
433 { | |
1166 | 434 |
435 int uAllHeght; | |
436 int uStringLen; | |
437 unsigned char c; | |
438 char *test_string; | |
0 | 439 |
1168 | 440 if ( !text_str ) |
0 | 441 return 0; |
1168 | 442 uAllHeght = uFontHeight - 3; |
443 test_string = FitTwoFontStringINWindow(text_str, this, secondFont, pWindow, startX, 0); | |
1166 | 444 uStringLen = strlen(test_string); |
445 for (int i = 0; i < uStringLen; ++i) | |
0 | 446 { |
1166 | 447 c = test_string[i]; |
448 if (IsCharValid(c)) | |
0 | 449 { |
1166 | 450 switch (c) |
451 { | |
452 case '\n': //Line Feed 0A 10: | |
1168 | 453 uAllHeght+= uFontHeight - 3; |
1166 | 454 break; |
455 case '\f': //Form Feed, page eject 0C 12 | |
456 i += 5; | |
457 break; | |
458 case '\t': // Horizontal tab 09 | |
459 case '\r': //Carriage Return 0D 13 | |
460 if (a6 != 1) | |
461 i += 3; | |
462 break; | |
463 } | |
0 | 464 } |
465 } | |
1166 | 466 |
467 return uAllHeght; | |
0 | 468 } |
469 | |
470 //----- (0044C59D) -------------------------------------------------------- | |
1160 | 471 int GUIFont::CalcTextHeight( const char *pString, struct GUIWindow *pWindow, int uXOffset, int a5 ) |
472 { | |
189 | 473 int uAllHeght; |
1160 | 474 int uStringLen; |
475 unsigned char c; | |
189 | 476 char *test_string; |
0 | 477 |
180 | 478 if (!pString) |
479 return 0; | |
1168 | 480 uAllHeght = uFontHeight - 3; |
180 | 481 test_string = FitTextInAWindow(pString, this, pWindow, uXOffset, 0); |
482 uStringLen = strlen(pString); | |
483 for (int i = 0; i < uStringLen; ++i) | |
484 { | |
485 c = test_string[i]; | |
486 if (IsCharValid(c)) | |
487 { | |
488 switch (c) | |
489 { | |
490 case '\n': //Line Feed 0A 10: | |
1168 | 491 uAllHeght+= uFontHeight - 3; |
180 | 492 break; |
493 case '\f': //Form Feed, page eject 0C 12 | |
494 i += 5; | |
495 break; | |
496 case '\t': // Horizontal tab 09 | |
497 case '\r': //Carriage Return 0D 13 | |
498 if (a5 != 1) | |
499 i += 3; | |
500 break; | |
501 } | |
502 } | |
503 } | |
504 return uAllHeght; | |
505 } | |
0 | 506 |
507 | |
508 //----- (0044C51E) -------------------------------------------------------- | |
509 int GUIFont::GetLineWidth(const char *pString) | |
180 | 510 { |
1160 | 511 int str_len; // ebp@3 |
180 | 512 int string_line_width; // esi@3 |
513 unsigned char c; | |
0 | 514 |
180 | 515 if (!pString) |
516 return 0; | |
517 str_len = strlen(pString); | |
518 string_line_width = 0; | |
519 for ( int i = 0; i < str_len; ++i ) | |
520 { | |
521 c = pString[i]; | |
522 if (IsCharValid(c)) | |
523 { | |
524 switch (c) | |
525 { | |
526 case '\t': | |
527 case '\n': | |
528 case '\r': | |
529 return string_line_width; | |
530 case '\f': | |
531 i += 5; | |
532 break; | |
533 default: | |
534 if (i > 0) | |
1168 | 535 string_line_width += pMetrics[c].uLeftSpacing; |
536 string_line_width += pMetrics[c].uWidth; | |
180 | 537 if (i < str_len) |
1168 | 538 string_line_width +=pMetrics[c].uRightSpacing; |
180 | 539 } |
540 } | |
541 } | |
542 return string_line_width; | |
543 } | |
0 | 544 |
545 | |
546 //----- (0044C502) -------------------------------------------------------- | |
547 int GUIFont::AlignText_Center(unsigned int uCenterX, const char *pString) | |
548 { | |
180 | 549 signed int position; // esi@1 |
550 | |
551 position = (signed int)(uCenterX - GetLineWidth(pString)) >> 1; | |
552 if ( position >= 0 ) | |
553 return position; | |
554 else | |
555 return 0; | |
178 | 556 |
0 | 557 } |
558 | |
180 | 559 //----- (0044C768) -------------------------------------------------------- |
688 | 560 char * FitTextInAWindow( const char *pInString, GUIFont *pFont, GUIWindow *pWindow, signed int uX, int a5 ) |
561 { | |
189 | 562 unsigned char c; |
1160 | 563 int uInStrLen; |
189 | 564 char digits[4]; |
565 int possible_transition_point; | |
566 int string_pixel_Width; | |
567 int start_pixel_offset; | |
0 | 568 |
189 | 569 if (!pInString) |
180 | 570 { |
571 MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:445", 0); | |
572 return 0; | |
573 } | |
189 | 574 uInStrLen = strlen(pInString); |
575 strcpy(&temp_string[0], pInString); | |
576 if (uInStrLen==0) | |
577 return &temp_string[0]; | |
578 | |
579 start_pixel_offset=string_pixel_Width=uX; | |
580 possible_transition_point=0; | |
581 for(int i=0; i<uInStrLen; ++i) | |
180 | 582 { |
189 | 583 c=temp_string[i]; |
584 if (pFont->IsCharValid(c)) | |
180 | 585 { |
189 | 586 switch (c) |
587 { | |
588 case '\t': // Horizontal tab 09 | |
589 { | |
590 strncpy(digits, &temp_string[i+1],3); | |
591 digits[3]=0; | |
592 string_pixel_Width= atoi(digits)+uX; | |
593 i+=3; | |
594 break; | |
595 } | |
596 case '\n': //Line Feed 0A 10 | |
597 { | |
598 string_pixel_Width=start_pixel_offset; | |
599 possible_transition_point=i; | |
600 break; | |
601 } | |
602 case '\f': //Form Feed, page eject 0C 12 | |
180 | 603 { |
189 | 604 i+=5; |
605 break; | |
180 | 606 } |
189 | 607 case '\r': //Carriage Return 0D 13 |
608 { | |
609 if (!a5) | |
610 return (char*)pInString; | |
180 | 611 break; |
189 | 612 } |
613 case ' ' : | |
180 | 614 { |
189 | 615 string_pixel_Width+=pFont->pMetrics[c].uWidth; |
616 possible_transition_point=i; | |
617 break; | |
180 | 618 } |
189 | 619 default: |
620 | |
621 if ((string_pixel_Width+pFont->pMetrics[c].uWidth+ pFont->pMetrics[c].uLeftSpacing+ | |
622 pFont->pMetrics[c].uRightSpacing)<pWindow->uFrameWidth) | |
180 | 623 { |
189 | 624 if(i>possible_transition_point) |
625 string_pixel_Width+=pFont->pMetrics[c].uLeftSpacing; | |
626 string_pixel_Width+=pFont->pMetrics[c].uWidth; | |
627 if (i<uInStrLen) | |
628 string_pixel_Width+=pFont->pMetrics[c].uRightSpacing; | |
629 } | |
630 else | |
631 { | |
632 temp_string[possible_transition_point]='\n'; | |
633 string_pixel_Width=start_pixel_offset; | |
634 if (i>possible_transition_point) | |
180 | 635 { |
189 | 636 for(int j=possible_transition_point;j<i; ++j ) |
180 | 637 { |
189 | 638 c=temp_string[j]; |
639 if (pFont->IsCharValid(c)) | |
180 | 640 { |
189 | 641 if(j>possible_transition_point) |
642 string_pixel_Width+=pFont->pMetrics[c].uLeftSpacing; | |
643 string_pixel_Width+=pFont->pMetrics[c].uWidth; | |
644 if (j<i) | |
645 string_pixel_Width+=pFont->pMetrics[c].uRightSpacing; | |
646 | |
180 | 647 } |
189 | 648 } |
180 | 649 } |
650 } | |
651 } | |
652 } | |
653 } | |
189 | 654 return &temp_string[0]; |
180 | 655 } |
1297 | 656 //----- (00414162) -------------------------------------------------------- |
657 void uGameUIFontMain_initialize() | |
658 { | |
659 uGameUIFontMain = TargetColor(0xAu, 0, 0); | |
660 } | |
661 | |
662 //----- (00414174) -------------------------------------------------------- | |
663 void uGameUIFontShadow_initialize() | |
664 { | |
665 uGameUIFontShadow = TargetColor(0xE6u, 214u, 193u); | |
666 } |