annotate GUIFont.cpp @ 1165:29a8defbad9e

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