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