Mercurial > mm7
annotate GUIFont.cpp @ 1463:b330df6a2183
Слияние
author | Ritor1 |
---|---|
date | Sun, 11 Aug 2013 12:09:33 +0600 |
parents | dfc9484ed94c |
children | c4ab816fcc5e |
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) -------------------------------------------------------- | |
1453 | 388 char* GUIFont::GetPageTop( const char *pInString, GUIWindow *pWindow, unsigned int uX, int a5 ) |
389 { | |
1160 | 390 int text_height; // edi@1 |
391 char *text_str; // ebx@3 | |
392 unsigned char c; // cl@4 | |
393 int text_length; | |
0 | 394 |
1160 | 395 text_height = 0; |
396 | |
0 | 397 if ( !pInString ) |
398 return 0; | |
1160 | 399 text_str = FitTextInAWindow(pInString, this, pWindow, uX, 0); |
400 text_length = strlen(text_str); | |
1453 | 401 for ( int i = 0; i < text_length; ++i ) |
402 { | |
403 c = text_str[i]; | |
404 if ( IsCharValid(c) ) | |
405 { | |
406 switch (c) | |
1160 | 407 { |
1453 | 408 case '\n': //Line Feed 0A 10: |
409 text_height = text_height + (uFontHeight - 3); | |
410 if ( text_height >= (signed int)(a5 * (pWindow->uFrameHeight - (uFontHeight - 3))) ) | |
411 return &text_str[i]; | |
412 break; | |
413 case '\f': //Form Feed, page eject 0C 12 | |
414 i += 5; | |
415 break; | |
416 case '\t': // Horizontal tab 09 | |
417 case '\r': //Carriage Return 0D 13 | |
418 i += 3; | |
419 break; | |
1160 | 420 } |
1453 | 421 if ( text_height >= (signed int)(a5 * pWindow->uFrameHeight) ) |
422 break; | |
423 } | |
424 } | |
425 return &text_str[0]; | |
0 | 426 } |
427 | |
428 //----- (0044C62E) -------------------------------------------------------- | |
1168 | 429 int GUIFont::GetStringHeight2( GUIFont *secondFont, const char *text_str, GUIWindow* pWindow, int startX, int a6 ) |
430 { | |
1166 | 431 |
432 int uAllHeght; | |
433 int uStringLen; | |
434 unsigned char c; | |
435 char *test_string; | |
0 | 436 |
1168 | 437 if ( !text_str ) |
0 | 438 return 0; |
1168 | 439 uAllHeght = uFontHeight - 3; |
440 test_string = FitTwoFontStringINWindow(text_str, this, secondFont, pWindow, startX, 0); | |
1166 | 441 uStringLen = strlen(test_string); |
442 for (int i = 0; i < uStringLen; ++i) | |
0 | 443 { |
1166 | 444 c = test_string[i]; |
445 if (IsCharValid(c)) | |
0 | 446 { |
1166 | 447 switch (c) |
448 { | |
449 case '\n': //Line Feed 0A 10: | |
1168 | 450 uAllHeght+= uFontHeight - 3; |
1166 | 451 break; |
452 case '\f': //Form Feed, page eject 0C 12 | |
453 i += 5; | |
454 break; | |
455 case '\t': // Horizontal tab 09 | |
456 case '\r': //Carriage Return 0D 13 | |
457 if (a6 != 1) | |
458 i += 3; | |
459 break; | |
460 } | |
0 | 461 } |
462 } | |
1166 | 463 |
464 return uAllHeght; | |
0 | 465 } |
466 | |
467 //----- (0044C59D) -------------------------------------------------------- | |
1160 | 468 int GUIFont::CalcTextHeight( const char *pString, struct GUIWindow *pWindow, int uXOffset, int a5 ) |
1453 | 469 { |
470 int uAllHeght; | |
471 int uStringLen; | |
472 unsigned char c; | |
473 char *test_string; | |
0 | 474 |
1453 | 475 if (!pString) |
476 return 0; | |
477 uAllHeght = uFontHeight - 6; | |
478 test_string = FitTextInAWindow(pString, this, pWindow, uXOffset, 0); | |
479 uStringLen = strlen(pString); | |
480 for (int i = 0; i < uStringLen; ++i) | |
481 { | |
482 c = test_string[i]; | |
483 if (IsCharValid(c)) | |
484 { | |
485 switch (c) | |
486 { | |
487 case '\n': //Line Feed 0A 10: | |
488 uAllHeght += uFontHeight - 3; | |
489 break; | |
490 case '\f': //Form Feed, page eject 0C 12 | |
491 i += 5; | |
492 break; | |
493 case '\t': // Horizontal tab 09 | |
494 case '\r': //Carriage Return 0D 13 | |
495 if (a5 != 1) | |
496 i += 3; | |
497 break; | |
498 } | |
499 } | |
500 } | |
501 return uAllHeght; | |
502 } | |
0 | 503 |
504 //----- (0044C51E) -------------------------------------------------------- | |
505 int GUIFont::GetLineWidth(const char *pString) | |
180 | 506 { |
1160 | 507 int str_len; // ebp@3 |
180 | 508 int string_line_width; // esi@3 |
509 unsigned char c; | |
0 | 510 |
180 | 511 if (!pString) |
512 return 0; | |
513 str_len = strlen(pString); | |
514 string_line_width = 0; | |
515 for ( int i = 0; i < str_len; ++i ) | |
516 { | |
517 c = pString[i]; | |
518 if (IsCharValid(c)) | |
519 { | |
520 switch (c) | |
521 { | |
522 case '\t': | |
523 case '\n': | |
524 case '\r': | |
525 return string_line_width; | |
526 case '\f': | |
527 i += 5; | |
528 break; | |
529 default: | |
530 if (i > 0) | |
1168 | 531 string_line_width += pMetrics[c].uLeftSpacing; |
532 string_line_width += pMetrics[c].uWidth; | |
180 | 533 if (i < str_len) |
1168 | 534 string_line_width +=pMetrics[c].uRightSpacing; |
180 | 535 } |
536 } | |
537 } | |
538 return string_line_width; | |
539 } | |
0 | 540 |
541 | |
542 //----- (0044C502) -------------------------------------------------------- | |
543 int GUIFont::AlignText_Center(unsigned int uCenterX, const char *pString) | |
544 { | |
180 | 545 signed int position; // esi@1 |
546 | |
547 position = (signed int)(uCenterX - GetLineWidth(pString)) >> 1; | |
548 if ( position >= 0 ) | |
549 return position; | |
550 else | |
551 return 0; | |
0 | 552 } |
553 | |
180 | 554 //----- (0044C768) -------------------------------------------------------- |
688 | 555 char * FitTextInAWindow( const char *pInString, GUIFont *pFont, GUIWindow *pWindow, signed int uX, int a5 ) |
1453 | 556 { |
557 unsigned char c; | |
558 int uInStrLen; | |
559 char digits[4]; | |
560 int possible_transition_point; | |
561 int string_pixel_Width; | |
562 int start_pixel_offset; | |
0 | 563 |
1453 | 564 if (!pInString) |
565 { | |
566 MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:445", 0); | |
567 return 0; | |
568 } | |
569 uInStrLen = strlen(pInString); | |
570 strcpy(&temp_string[0], pInString); | |
571 if (uInStrLen == 0) | |
572 return &temp_string[0]; | |
189 | 573 |
1453 | 574 start_pixel_offset = string_pixel_Width=uX; |
575 possible_transition_point = 0; | |
576 for ( int i = 0; i < uInStrLen; ++i ) | |
577 { | |
578 c = temp_string[i]; | |
579 if (pFont->IsCharValid(c)) | |
580 { | |
581 switch (c) | |
582 { | |
583 case '\t': // Horizontal tab 09 | |
584 { | |
585 strncpy(digits, &temp_string[i + 1],3); | |
586 digits[3] = 0; | |
587 string_pixel_Width = atoi(digits)+uX; | |
588 i += 3; | |
589 break; | |
590 } | |
591 case '\n': //Line Feed 0A 10 ( ) | |
592 { | |
593 string_pixel_Width = start_pixel_offset; | |
594 possible_transition_point = i; | |
595 break; | |
596 } | |
597 case '\f': //Form Feed, page eject 0C 12 | |
598 { | |
599 i += 5; | |
600 break; | |
601 } | |
602 case '\r': //Carriage Return 0D 13 | |
603 { | |
604 if ( !a5 ) | |
605 return (char*)pInString; | |
606 break; | |
607 } | |
608 case ' ':// | |
609 { | |
610 string_pixel_Width += pFont->pMetrics[c].uWidth; | |
611 possible_transition_point = i; | |
612 break; | |
613 } | |
614 default: | |
615 if ((string_pixel_Width + pFont->pMetrics[c].uWidth + pFont->pMetrics[c].uLeftSpacing + | |
616 pFont->pMetrics[c].uRightSpacing) < pWindow->uFrameWidth )// | |
617 { | |
618 if ( i > possible_transition_point ) | |
619 string_pixel_Width += pFont->pMetrics[c].uLeftSpacing; | |
620 string_pixel_Width += pFont->pMetrics[c].uWidth; | |
621 if (i < uInStrLen) | |
622 string_pixel_Width += pFont->pMetrics[c].uRightSpacing; | |
623 } | |
624 else// | |
625 { | |
626 temp_string[possible_transition_point] ='\n'; | |
627 string_pixel_Width = start_pixel_offset; | |
628 if ( i > possible_transition_point ) | |
629 { | |
630 for ( int j = possible_transition_point; j < i; ++j ) | |
631 { | |
632 c = temp_string[j]; | |
633 if (pFont->IsCharValid(c)) | |
634 { | |
635 if ( j > possible_transition_point ) | |
636 string_pixel_Width += pFont->pMetrics[c].uLeftSpacing; | |
637 string_pixel_Width += pFont->pMetrics[c].uWidth; | |
638 if ( j < i ) | |
639 string_pixel_Width += pFont->pMetrics[c].uRightSpacing; | |
640 } | |
641 } | |
642 } | |
643 } | |
644 } | |
645 } | |
646 } | |
647 return &temp_string[0]; | |
648 } | |
1297 | 649 //----- (00414162) -------------------------------------------------------- |
650 void uGameUIFontMain_initialize() | |
651 { | |
652 uGameUIFontMain = TargetColor(0xAu, 0, 0); | |
653 } | |
654 | |
655 //----- (00414174) -------------------------------------------------------- | |
656 void uGameUIFontShadow_initialize() | |
657 { | |
658 uGameUIFontShadow = TargetColor(0xE6u, 214u, 193u); | |
659 } |