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