Mercurial > mm7
annotate GUIFont.cpp @ 176:05682713195c
Обращённый набор изменений: 91fa025e6ca6
author | Ritor1 |
---|---|
date | Fri, 15 Feb 2013 10:32:09 +0600 |
parents | 91fa025e6ca6 |
children | c10509e439f1 |
rev | line source |
---|---|
0 | 1 #include <string> |
176 | 2 |
0 | 3 #include "GUIFont.h" |
4 #include "GUIWindow.h" | |
5 #include "Render.h" | |
6 | |
7 #include "mm7_data.h" | |
8 | |
9 | |
176 | 10 |
0 | 11 |
12 | |
13 struct GUIFont *pAutonoteFont; | |
14 struct GUIFont *pSpellFont; | |
15 struct GUIFont *pFontArrus; | |
16 struct GUIFont *pFontLucida; | |
17 struct GUIFont *pBook2Font; | |
18 struct GUIFont *pBookFont; | |
19 struct GUIFont *pFontCreate; | |
20 struct GUIFont *pFontCChar; | |
21 struct GUIFont *pFontComic; | |
22 struct GUIFont *pFontSmallnum; | |
23 | |
24 | |
25 | |
26 | |
27 //----- (0044D2FD) -------------------------------------------------------- | |
28 void GUIFont::_44D2FD_prolly_draw_credits_entry(GUIFont *pFont, int Str, int a4, unsigned int w, unsigned int h, unsigned __int16 a7, unsigned __int16 a8, const char *pString, unsigned __int16 *pPixels, unsigned int uPixelsWidth) | |
29 { | |
30 int v11; // ebx@1 | |
31 int v12; // edi@1 | |
32 char *v13; // eax@1 | |
33 char *v14; // eax@1 | |
34 unsigned __int16 *v15; // esi@1 | |
35 GUIFont *v16; // edi@4 | |
36 signed int v17; // ecx@4 | |
37 signed int v18; // eax@6 | |
38 int v19; // [sp+Ch] [bp-5Ch]@1 | |
39 int v20; // [sp+10h] [bp-58h]@1 | |
40 unsigned int v21; // [sp+14h] [bp-54h]@1 | |
41 unsigned int v22; // [sp+18h] [bp-50h]@1 | |
42 unsigned int v23; // [sp+1Ch] [bp-4Ch]@1 | |
43 unsigned int v24; // [sp+20h] [bp-48h]@1 | |
44 GUIFont *v25; // [sp+60h] [bp-8h]@1 | |
45 GUIFont *v26; // [sp+64h] [bp-4h]@1 | |
46 char *Stra; // [sp+70h] [bp+8h]@1 | |
47 int a4a; // [sp+74h] [bp+Ch]@4 | |
48 int a7a; // [sp+80h] [bp+18h]@2 | |
49 | |
50 v11 = a7; | |
51 v22 = h; | |
52 v12 = Str; | |
53 v26 = this; | |
54 v24 = a4 + h - 1; | |
55 v21 = w; | |
56 v25 = pFont; | |
57 v23 = Str + w - 1; | |
58 ui_current_text_color = a7; | |
59 v19 = Str; | |
60 v20 = a4; | |
61 v13 = GUIFont::_44C933(pString, this, pFont, (int)&v19, 0, 1); | |
62 v14 = strtok(v13, "\n"); | |
63 Stra = v14; | |
64 v15 = &pPixels[uPixelsWidth * a4]; | |
65 if ( v14 ) | |
66 { | |
67 a7a = v12 >> 1; | |
68 while ( 1 ) | |
69 { | |
70 v16 = v26; | |
71 ui_current_text_color = v11; | |
72 v17 = 0; | |
73 a4a = v11; | |
74 if ( *v14 == '_' ) | |
75 { | |
76 v16 = v25; | |
77 a4a = a8; | |
78 ui_current_text_color = a8; | |
79 v17 = 1; | |
80 } | |
81 v18 = (signed int)(w - v16->GetLineWidth(&v14[v17])) >> 1; | |
82 if ( v18 < 0 ) | |
83 v18 = 0; | |
84 v16->_44D0B5(a4a, a8, (int)&v15[v18 + a7a], Stra, uPixelsWidth); | |
85 v15 += uPixelsWidth * (LOBYTE(v16->uFontHeight) - 3); | |
86 Stra = strtok(0, "\n"); | |
87 if ( !Stra ) | |
88 break; | |
89 v14 = Stra; | |
90 } | |
91 } | |
92 } | |
93 // 5C6DB4: using guessed type int ui_current_text_color; | |
94 | |
95 | |
96 //----- (0044D1E7) -------------------------------------------------------- | |
97 void GUIFont::DrawTextLine(unsigned int uDefaultColor, signed int uX, signed int uY, const char *Str, int a6) | |
98 { | |
99 size_t v6; // ebx@1 | |
47 | 100 GUIFont *pFont; // esi@1 |
0 | 101 signed int v8; // edi@3 |
102 unsigned __int8 v9; // cl@4 | |
103 int v10; // eax@5 | |
104 int v11; // ecx@5 | |
105 int v12; // ecx@6 | |
106 int v13; // ecx@7 | |
107 int v14; // ecx@9 | |
108 unsigned int v15; // edx@9 | |
109 unsigned __int16 v16; // cx@12 | |
110 unsigned __int8 *v17; // eax@12 | |
71 | 111 char Dest[20]; // [sp+Ch] [bp-1Ch]@16 |
112 //char v19; // [sp+11h] [bp-17h]@16 | |
0 | 113 size_t v20; // [sp+20h] [bp-8h]@2 |
114 int v21; // [sp+24h] [bp-4h]@1 | |
115 int uXa; // [sp+30h] [bp+8h]@9 | |
116 | |
117 v6 = 0; | |
118 v21 = uDefaultColor; | |
47 | 119 pFont = this; |
0 | 120 if ( Str ) |
121 { | |
122 v21 = ui_current_text_color; | |
123 v20 = strlen(Str); | |
124 if ( (signed int)v20 > 0 ) | |
125 { | |
126 v8 = uX; | |
127 do | |
128 { | |
47 | 129 if ( pFont->IsCharValid(v9 = Str[v6]) ) |
0 | 130 { |
131 v10 = v9; | |
132 v11 = v9 - 9; | |
133 if ( v11 ) | |
134 { | |
135 v12 = v11 - 1; | |
136 if ( !v12 ) | |
137 return; | |
138 v13 = v12 - 2; | |
139 if ( v13 ) | |
140 { | |
141 if ( v13 != 1 ) | |
142 { | |
143 v14 = 3 * v10 + 9; | |
47 | 144 v15 = *((int *)&pFont->cFirstChar + v14); |
145 uXa = *((int *)&pFont->cFirstChar + v14); | |
0 | 146 if ( v15 ) |
147 { | |
148 if ( (signed int)v6 > 0 ) | |
47 | 149 v8 += pFont->pMetrics[v10].uLeftSpacing; |
0 | 150 v16 = v21; |
47 | 151 v17 = (unsigned __int8 *)((char *)&pFont[1] + pFont->field_C20[v10]); |
0 | 152 if ( !v21 ) |
153 v16 = -1; | |
47 | 154 pRenderer->DrawText(v8, uY, v17, v15, pFont->uFontHeight, pFont->pFontPalettes[0], v16, 0); |
0 | 155 v8 += uXa; |
156 if ( (signed int)v6 < (signed int)v20 ) | |
47 | 157 v8 += pFont->pMetrics[(unsigned __int8)Str[v6]].uRightSpacing; |
0 | 158 } |
159 } | |
160 } | |
161 else | |
162 { | |
71 | 163 strncpy(Dest, &Str[v6 + 1], 5u); |
164 Dest[5] = 0; | |
165 v21 = atoi(Dest); | |
0 | 166 ui_current_text_color = v21; |
167 v6 += 5; | |
168 } | |
169 } | |
170 } | |
171 ++v6; | |
172 } | |
173 while ( (signed int)v6 < (signed int)v20 ); | |
174 } | |
175 } | |
176 } | |
177 // 5C6DB4: using guessed type int ui_current_text_color; | |
178 | |
179 | |
180 //----- (0044D0B5) -------------------------------------------------------- | |
181 void GUIFont::_44D0B5(int a2, int a3, int a4, const char *pString, int a6) | |
182 { | |
183 int v6; // ebx@1 | |
184 GUIFont *v7; // esi@1 | |
185 int v8; // edi@3 | |
186 unsigned __int8 v9; // cl@4 | |
187 int v10; // eax@5 | |
188 int v11; // ecx@5 | |
189 int v12; // ecx@6 | |
190 int v13; // ecx@7 | |
191 int v14; // ecx@8 | |
192 int v15; // ebx@10 | |
193 int v16; // edx@13 | |
194 __int16 v17; // ax@13 | |
195 char Dest; // [sp+Ch] [bp-20h]@17 | |
196 char v19; // [sp+11h] [bp-1Bh]@17 | |
197 size_t v20; // [sp+20h] [bp-Ch]@2 | |
198 int v21; // [sp+24h] [bp-8h]@1 | |
199 int v22; // [sp+28h] [bp-4h]@2 | |
200 const char *v23; // [sp+38h] [bp+Ch]@4 | |
201 | |
202 v6 = 0; | |
203 v21 = a2; | |
204 v7 = this; | |
205 if ( pString ) | |
206 { | |
207 v21 = ui_current_text_color; | |
208 v20 = strlen(pString); | |
209 v22 = 0; | |
210 if ( (signed int)v20 > 0 ) | |
211 { | |
212 v8 = a4; | |
213 do | |
214 { | |
215 v23 = &pString[v6]; | |
216 if ( v7->IsCharValid(v9 = pString[v6]) ) | |
217 { | |
218 v10 = v9; | |
219 v11 = v9 - 9; | |
220 if ( v11 ) | |
221 { | |
222 v12 = v11 - 1; | |
223 if ( !v12 ) | |
224 return; | |
225 v13 = v12 - 2; | |
226 if ( v13 ) | |
227 { | |
228 v14 = v13 - 1; | |
229 if ( v14 ) | |
230 { | |
231 if ( v14 != 82 ) | |
232 { | |
233 v15 = *((int *)&v7->cFirstChar + 3 * v10 + 9); | |
234 if ( v15 ) | |
235 { | |
236 if ( v22 > 0 ) | |
237 v8 += 2 * v7->pMetrics[v10].uLeftSpacing; | |
238 v16 = (int)((char *)&v7[1] + v7->field_C20[v10]); | |
239 v17 = v21; | |
240 if ( !v21 ) | |
241 v17 = -1; | |
242 sub_40F845(v8, v16, v15, LOBYTE(v7->uFontHeight), (int)v7->pFontPalettes[0], v17, 2 * a6); | |
243 v8 += 2 * v15; | |
244 if ( v22 < (signed int)v20 ) | |
245 v8 += 2 * v7->pMetrics[(unsigned __int8)*v23].uRightSpacing; | |
246 } | |
247 } | |
248 } | |
249 } | |
250 else | |
251 { | |
252 strncpy(&Dest, &pString[v6 + 1], 5u); | |
253 v19 = 0; | |
254 v21 = atoi(&Dest); | |
255 ui_current_text_color = v21; | |
256 v22 = v6 + 5; | |
257 } | |
258 } | |
259 } | |
260 v6 = v22++ + 1; | |
261 } | |
262 while ( v22 < (signed int)v20 ); | |
263 } | |
264 } | |
265 } | |
266 // 5C6DB4: using guessed type int ui_current_text_color; | |
267 | |
268 | |
269 //----- (0044C933) -------------------------------------------------------- | |
176 | 270 char *__fastcall GUIFont::_44C933(const char *pString, GUIFont *pFont, GUIFont *a3, int a4, int a5, int a6) |
0 | 271 { |
272 const char *v6; // esi@1 | |
273 size_t v8; // eax@3 | |
274 size_t v9; // edi@3 | |
275 int v10; // eax@3 | |
276 GUIFont *v11; // esi@3 | |
277 int v12; // ebx@3 | |
278 char v13; // cl@5 | |
279 int v14; // edx@11 | |
280 int v15; // ecx@11 | |
281 int v16; // edx@12 | |
282 int v17; // edx@13 | |
283 int v18; // edx@14 | |
284 int v19; // edx@15 | |
285 int v20; // edi@17 | |
286 int v21; // edx@17 | |
287 int v22; // ecx@17 | |
288 int v23; // edi@18 | |
289 char v24; // zf@18 | |
290 int v25; // ecx@19 | |
291 int v26; // eax@19 | |
292 char v27; // dl@24 | |
293 int v28; // eax@46 | |
294 std::string v29; // [sp-18h] [bp-48h]@2 | |
295 const char *v30; // [sp-8h] [bp-38h]@2 | |
296 int v31; // [sp-4h] [bp-34h]@2 | |
297 const char *v32; // [sp+Ch] [bp-24h]@1 | |
298 char Str; // [sp+10h] [bp-20h]@46 | |
299 char v34; // [sp+13h] [bp-1Dh]@46 | |
300 GUIFont *v35; // [sp+14h] [bp-1Ch]@1 | |
301 int v36; // [sp+18h] [bp-18h]@3 | |
302 int v37; // [sp+1Ch] [bp-14h]@3 | |
303 int v38; // [sp+20h] [bp-10h]@4 | |
304 int v39; // [sp+24h] [bp-Ch]@3 | |
305 int v40; // [sp+28h] [bp-8h]@3 | |
306 int i; // [sp+2Ch] [bp-4h]@17 | |
307 std::string *v42; // [sp+38h] [bp+8h]@2 | |
308 | |
309 v6 = pString; | |
310 v35 = pFont; | |
311 v32 = pString; | |
312 if ( !pString ) | |
313 { | |
314 MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:558", 0); | |
315 return 0; | |
316 } | |
317 v8 = strlen(pString); | |
318 v9 = v8; | |
319 v39 = v8; | |
320 strcpy(pTmpBuf3, v6); | |
321 v10 = a5; | |
322 v11 = v35; | |
323 v12 = 0; | |
324 v40 = 0; | |
325 v37 = a5; | |
326 v36 = 0; | |
327 if ( (signed int)v9 > 0 ) | |
328 { | |
329 v38 = v9 - 1; | |
330 do | |
331 { | |
332 v13 = pTmpBuf3[v12]; | |
333 if ( (unsigned __int8)v13 >= v11->cFirstChar && (unsigned __int8)v13 <= v11->cLastChar | |
334 || v13 == '\f' | |
335 || v13 == '\r' | |
336 || v13 == '\t' | |
337 || v13 == '\n' ) | |
338 { | |
339 v14 = (unsigned __int8)v13 - 9; | |
340 v15 = (int)&v11->pMetrics[(unsigned __int8)v13]; | |
341 if ( v14 ) | |
342 { | |
343 v16 = v14 - 1; | |
344 if ( v16 ) | |
345 { | |
346 v17 = v16 - 2; | |
347 if ( v17 ) | |
348 { | |
349 v18 = v17 - 1; | |
350 if ( v18 ) | |
351 { | |
352 v19 = v18 - 19; | |
353 if ( v19 ) | |
354 { | |
355 if ( v19 == 63 ) | |
356 { | |
357 v11 = a3; | |
358 } | |
359 else | |
360 { | |
361 v20 = *(int *)(v15 + 8); | |
362 v21 = *(int *)(v15 + 4); | |
363 v22 = *(int *)v15; | |
364 i = v20; | |
365 if ( (unsigned int)(v10 + v20 + v22 + v21) < *(int *)(a4 + 8) ) | |
366 { | |
367 v12 = v36; | |
368 if ( v36 > v40 ) | |
369 v10 += v22; | |
370 v10 += v21; | |
371 if ( v36 < v39 ) | |
372 v10 += i; | |
373 } | |
374 else | |
375 { | |
376 v23 = v40; | |
377 v24 = v11 == a3; | |
378 pTmpBuf3[v40] = 10; | |
379 if ( v24 ) | |
380 { | |
381 v25 = v38; | |
382 v26 = v23 + 1; | |
383 while ( v25 >= v26 ) | |
384 { | |
385 pTmpBuf3[v25] = byte_5C45AF[v25]; | |
386 --v25; | |
387 } | |
388 ++v39; | |
389 ++v38; | |
390 pTmpBuf3[v23++ + 1] = 95; | |
391 v40 = v26; | |
392 } | |
393 v12 = v36; | |
394 v10 = v37; | |
395 for ( i = v23; i <= v36; ++i ) | |
396 { | |
397 v27 = pTmpBuf3[i]; | |
398 if ( (unsigned __int8)v27 >= v11->cFirstChar && (unsigned __int8)v27 <= v11->cLastChar | |
399 || v27 == 12 | |
400 || v27 == 13 | |
401 || v27 == 9 | |
402 || v27 == 10 ) | |
403 { | |
404 if ( i > v23 ) | |
405 v10 += v11->pMetrics[(unsigned __int8)v27].uLeftSpacing; | |
406 v10 += *((int *)&v11->cFirstChar + 3 * (unsigned __int8)v27 + 9); | |
407 if ( i < v36 ) | |
408 v10 += v11->pMetrics[(unsigned __int8)v27].uRightSpacing; | |
409 } | |
410 } | |
411 } | |
412 } | |
413 } | |
414 else | |
415 { | |
416 v10 += *(int *)(v15 + 4); | |
417 v40 = v12; | |
418 } | |
419 } | |
420 else | |
421 { | |
422 if ( !a6 ) | |
423 return (char *)v32; | |
424 } | |
425 } | |
426 else | |
427 { | |
428 v12 += 5; | |
429 } | |
430 } | |
431 else | |
432 { | |
433 v10 = v37; | |
434 v11 = v35; | |
435 v40 = v12; | |
436 } | |
437 } | |
438 else | |
439 { | |
440 strncpy(&Str, &pTmpBuf3[v12 + 1], 3u); | |
441 v34 = 0; | |
442 v28 = atoi(&Str); | |
443 v10 = a5 + v28; | |
444 v12 += 3; | |
445 v37 = v10; | |
446 } | |
447 } | |
448 ++v12; | |
449 v36 = v12; | |
450 } | |
451 while ( v12 < v39 ); | |
452 } | |
453 return pTmpBuf3; | |
454 } | |
455 | |
456 | |
457 //----- (0044C6C2) -------------------------------------------------------- | |
458 int GUIFont::_44C6C2(const char *pInString, GUIWindow *pWindow, unsigned int uX, int a5) | |
459 { | |
460 const char *v5; // esi@1 | |
461 int v6; // edi@1 | |
462 unsigned __int8 *v8; // ebx@3 | |
463 size_t v9; // eax@3 | |
464 signed int v10; // esi@3 | |
465 int v11; // edx@4 | |
92 | 466 unsigned int v12; // cl@4 |
0 | 467 GUIFont *v13; // [sp+Ch] [bp-4h]@1 |
468 size_t uXa; // [sp+1Ch] [bp+Ch]@3 | |
469 | |
470 auto pFont = this; | |
471 v5 = pInString; | |
472 v6 = 0; | |
473 v13 = pFont; | |
474 if ( !pInString ) | |
475 return 0; | |
476 v8 = (unsigned __int8 *)FitTextInAWindow(pInString, pFont, pWindow, uX, 0); | |
477 v9 = strlen(v5); | |
478 v10 = 0; | |
479 uXa = v9; | |
480 if ( (signed int)v9 > 0 ) | |
481 { | |
93 | 482 while ( v10 < (signed int)uXa ) |
0 | 483 { |
93 | 484 if(IsCharValid(*v8)) |
485 { | |
486 v12=(unsigned int)v8; | |
487 if ( v12 != 9 ) | |
488 { | |
489 if ( v12 == 10 ) | |
490 { | |
491 v6 = v6 + *(char *)(v11 + 5) - 3; | |
492 if ( v6 >= (signed int)(a5 * pWindow->uFrameHeight) ) | |
493 return (int)(v8 + 1); | |
494 if ( v6 >= (signed int)(a5 * pWindow->uFrameHeight) ) | |
495 return (int)v8; | |
496 } | |
497 else if ( v12 == 12 ) | |
498 { | |
499 v8 += 5; | |
500 v10 += 5; | |
501 if ( v6 >= (signed int)(a5 * pWindow->uFrameHeight) ) | |
502 return (int)v8; | |
503 } | |
504 else if ( v12 != 13 ) | |
505 { | |
506 if ( v6 >= (signed int)(a5 * pWindow->uFrameHeight) ) | |
507 return (int)v8; | |
508 } | |
509 } | |
510 if(v12 == 13 || v12 == 9) | |
511 { | |
512 v8 += 3; | |
513 v10 += 3; | |
514 } | |
515 if ( v6 >= (signed int)(a5 * pWindow->uFrameHeight) ) | |
516 return (int)v8; | |
517 } | |
0 | 518 ++v10; |
519 ++v8; | |
520 } | |
521 } | |
522 return (int)v8; | |
523 } | |
524 | |
525 | |
526 | |
527 //----- (0044C62E) -------------------------------------------------------- | |
528 int GUIFont::GetStringHeight2(GUIFont *a2, const char *Str, int a4, int a5, int a6) | |
529 { | |
530 GUIFont *v6; // edi@1 | |
531 int v8; // esi@3 | |
532 unsigned __int8 *v9; // ebx@3 | |
533 size_t v10; // eax@3 | |
534 unsigned __int8 v11; // cl@4 | |
535 signed int Stra; // [sp+Ch] [bp+8h]@3 | |
536 size_t v13; // [sp+14h] [bp+10h]@3 | |
537 | |
538 auto a1 = this; | |
539 v6 = a1; | |
540 if ( !Str ) | |
541 return 0; | |
542 v8 = LOBYTE(a1->uFontHeight) - 3; | |
543 v9 = (unsigned __int8 *)GUIFont::_44C933(Str, a1, a2, a4, a5, 0); | |
544 v10 = strlen(Str); | |
545 Stra = 0; | |
546 v13 = v10; | |
547 while ( Stra < (signed int)v13 ) | |
548 { | |
549 if ( GUIFont::IsCharValid(v11 = *v9) ) | |
550 { | |
551 if ( v11 == 9 ) | |
552 goto LABEL_9; | |
553 switch ( v11 ) | |
554 { | |
555 case 0xAu: | |
556 v8 = v8 + LOBYTE(v6->uFontHeight) - 3; | |
557 break; | |
558 case 0xCu: | |
559 v9 += 5; | |
560 Stra += 5; | |
561 break; | |
562 case 0xDu: | |
563 LABEL_9: | |
564 if ( a6 != 1 ) | |
565 { | |
566 v9 += 3; | |
567 Stra += 3; | |
568 } | |
569 break; | |
570 } | |
571 } | |
572 ++Stra; | |
573 ++v9; | |
574 } | |
575 return v8; | |
576 } | |
577 | |
578 //----- (0044C59D) -------------------------------------------------------- | |
176 | 579 int GUIFont::CalcTextHeight(const char *pString, GUIWindow *pWindow, int a4, int a5) |
580 { | |
581 const char *v5; // ebx@1 | |
582 GUIFont *v6; // edi@1 | |
583 int v8; // esi@3 | |
584 size_t v9; // eax@3 | |
585 signed int v10; // ebx@3 | |
586 unsigned __int8 v11; // cl@4 | |
587 size_t pWindowa; // [sp+10h] [bp+8h]@3 | |
588 unsigned __int8 *uX; // [sp+14h] [bp+Ch]@3 | |
0 | 589 |
176 | 590 v5 = pString; |
591 v6 = this; | |
592 if ( !pString ) | |
593 return 0; | |
594 v8 = LOBYTE(this->uFontHeight) - 3; | |
595 uX = (unsigned __int8 *)FitTextInAWindow(pString, this, pWindow, a4, 0); | |
596 v9 = strlen(v5); | |
597 v10 = 0; | |
598 pWindowa = v9; | |
599 while ( v10 < (signed int)pWindowa ) | |
600 { | |
601 if ( v6->IsCharValid(v11 = *uX) ) | |
602 { | |
603 if ( v11 == 9 ) | |
604 goto LABEL_9; | |
605 switch ( v11 ) | |
606 { | |
607 case 0xAu: | |
608 v8 = v8 + LOBYTE(v6->uFontHeight) - 3; | |
609 break; | |
610 case 0xCu: | |
611 uX += 5; | |
612 v10 += 5; | |
613 break; | |
614 case 0xDu: | |
615 LABEL_9: | |
616 if ( a5 != 1 ) | |
617 { | |
618 uX += 3; | |
619 v10 += 3; | |
620 } | |
621 break; | |
622 } | |
623 } | |
624 ++v10; | |
625 ++uX; | |
626 } | |
627 return v8; | |
628 } | |
0 | 629 |
630 | |
631 //----- (0044C51E) -------------------------------------------------------- | |
632 int GUIFont::GetLineWidth(const char *pString) | |
176 | 633 { |
634 GUIFont *pFont; // edi@1 | |
635 size_t pNumLen; // ebp@3 | |
636 int v5; // esi@3 | |
637 signed int i; // ebx@3 | |
638 unsigned __int8 v7; // cl@4 | |
639 const char *pStr; // [sp+0h] [bp-4h]@1 | |
0 | 640 |
176 | 641 pStr = pString; |
642 pFont = this; | |
643 if ( !pString ) // == 0 | |
644 return 0; | |
645 pNumLen = strlen(pString); | |
646 v5 = 0; | |
647 for ( i = 0; i < (signed int)pNumLen; ++i ) | |
648 { | |
649 if ( IsCharValid(v7 = pStr[i]) ) | |
650 { | |
651 if ( v7 < 9u ) | |
652 { | |
653 if ( i > 0 ) | |
654 v5 += pFont->pMetrics[v7].uLeftSpacing; | |
655 v5 += *((int *)&pFont->cFirstChar + 3 * v7 + 9); | |
656 if ( i < (signed int)pNumLen ) | |
657 v5 += pFont->pMetrics[v7].uRightSpacing; | |
658 continue; | |
659 } | |
660 if ( v7 <= 0xAu ) | |
661 return v5; | |
662 if ( v7 != '\f' ) | |
663 { | |
664 if ( v7 == '\r' ) | |
665 return v5; | |
666 if ( i > 0 ) | |
667 v5 += pFont->pMetrics[v7].uLeftSpacing; | |
668 v5 += *((int *)&pFont->cFirstChar + 3 * v7 + 9); | |
669 if ( i < (signed int)pNumLen ) | |
670 v5 += pFont->pMetrics[v7].uRightSpacing; | |
671 continue; | |
672 } | |
673 i += 5; | |
674 } | |
675 } | |
676 return v5; | |
677 } | |
678 | |
679 | |
0 | 680 |
681 | |
682 //----- (0044C502) -------------------------------------------------------- | |
683 int GUIFont::AlignText_Center(unsigned int uCenterX, const char *pString) | |
684 { | |
176 | 685 signed int v3; // esi@1 |
686 signed int result; // eax@2 | |
687 | |
688 v3 = (signed int)(uCenterX - GetLineWidth(pString)) >> 1; | |
689 if ( v3 >= 0 ) | |
690 result = v3; | |
170
91fa025e6ca6
font cleaning code
C:\Documents and Settings\Administrator.SDF-1\Application Data\The Bat!
parents:
93
diff
changeset
|
691 else |
176 | 692 result = 0; |
693 return result; | |
0 | 694 } |
695 | |
696 | |
176 | 697 //----- (0044C4DE) -------------------------------------------------------- |
698 bool GUIFont::IsCharValid(char _c) | |
699 { | |
700 unsigned char c = _c; | |
701 return c >= cFirstChar && c <= cLastChar || c == '\f' || c == '\r' || c == '\t' || c == '\n'; | |
702 } |