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