annotate GUIFont.cpp @ 189:038a4d09406f

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