annotate GUI/GUIFont.cpp @ 2514:16bae6fd06e1

.
author Ritor1
date Thu, 02 Oct 2014 19:40:13 +0600
parents a77c34acdbc9
children a902abdfc7f2
rev   line source
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1 #define _CRTDBG_MAP_ALLOC
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2 #include <stdlib.h>
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
3 #include <crtdbg.h>
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
4
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
5 #define _CRT_SECURE_NO_WARNINGS
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
6 #include <string>
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
7 #include "Engine/ErrorHandling.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
8
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
9 #include "Engine/LOD.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
10 #include "GUIFont.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
11 #include "GUIWindow.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
12 #include "Engine/Graphics/Render.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
13
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
14 #include "Engine/mm7_data.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
15
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
16
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
17 extern LODFile_IconsBitmaps *pIcons_LOD;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
18
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
19
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
20 struct GUIFont *pAutonoteFont;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
21 struct GUIFont *pSpellFont;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
22 struct GUIFont *pFontArrus;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
23 struct GUIFont *pFontLucida;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
24 struct GUIFont *pBook2Font;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
25 struct GUIFont *pBookFont;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
26 struct GUIFont *pFontCreate;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
27 struct GUIFont *pFontCChar;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
28 struct GUIFont *pFontComic;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
29 struct GUIFont *pFontSmallnum;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
30
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
31 char temp_string[2048];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
32
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
33 std::array<char, 10000> pTmpBuf3;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
34
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
35 void DrawCharToBuff(unsigned short* uXpos,unsigned char* pCharPixels, int uCharWidth, int uCharHeight, unsigned __int16* pFontPalette, __int16 draw_color, int line_width);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
36
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
37
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
38 //----- (0044C448) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
39 GUIFont *LoadFont(const char *pFontFile, const char *pFontPalette, ...)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
40 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
41 int pallete_index; // eax@3
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
42 GUIFont *pFont;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
43 unsigned int palletes_count =0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
44 va_list palettes_ptr;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
45
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
46 pFont = (GUIFont *)pIcons_LOD->LoadRaw(pFontFile, 0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
47 va_start(palettes_ptr, pFontFile);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
48
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
49 while (NULL!=(pFontPalette=va_arg(palettes_ptr, const char *)))
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
50 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
51 pallete_index =pIcons_LOD->LoadTexture(pFontPalette, TEXTURE_16BIT_PALETTE);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
52 if (pallete_index == -1)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
53 Error("Unable to open %s", pFontPalette);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
54
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
55 pFont->pFontPalettes[palletes_count] = pIcons_LOD->pTextures[pallete_index].pPalette16;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
56 ++palletes_count;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
57 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
58 va_end(palettes_ptr);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
59 pFont->palletes_count = palletes_count;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
60 return pFont;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
61 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
62
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
63 //----- (0044D2FD) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
64 void GUIFont::_44D2FD_prolly_draw_credits_entry( GUIFont *pSecondFont, int uFrameX, int uFrameY, unsigned int w, unsigned int h,
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
65 unsigned __int16 firstColor, unsigned __int16 secondColor, const char *pString,
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
66 unsigned __int16 *pPixels, unsigned int uPixelsWidth )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
67 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
68 char *work_string; // eax@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
69 unsigned __int16 *curr_pixel_pos; // esi@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
70 GUIFont *currentFont; // edi@4
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
71 signed int start_str_pos; // ecx@4
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
72 signed int line_w; // eax@6
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
73 GUIWindow draw_window; // [sp+Ch] [bp-5Ch]@
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
74 int currentColor; // [sp+74h] [bp+Ch]@4
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
75 int half_frameX; // [sp+80h] [bp+18h]@2
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
76
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
77 draw_window.uFrameHeight = h;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
78 draw_window.uFrameW = uFrameY + h - 1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
79 draw_window.uFrameWidth = w;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
80 draw_window.uFrameZ = uFrameX + w - 1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
81 ui_current_text_color = firstColor;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
82 draw_window.uFrameX = uFrameX;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
83 draw_window.uFrameY = uFrameY;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
84
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
85 work_string = GUIFont::FitTwoFontStringINWindow(pString, this, pSecondFont, &draw_window, 0, 1);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
86 work_string = strtok(work_string, "\n");
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
87 curr_pixel_pos = &pPixels[uPixelsWidth * uFrameY];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
88 if ( work_string )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
89 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
90 half_frameX = uFrameX >> 1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
91 while ( 1 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
92 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
93 currentFont = this;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
94 ui_current_text_color = firstColor;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
95 start_str_pos = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
96 currentColor = firstColor;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
97 if ( *work_string == '_' )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
98 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
99 currentFont = pSecondFont;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
100 currentColor = secondColor;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
101 ui_current_text_color = secondColor;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
102 start_str_pos = 1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
103 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
104 line_w = (signed int)(w - currentFont->GetLineWidth(&work_string[start_str_pos]))/2;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
105 if ( line_w < 0 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
106 line_w = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
107 currentFont->DrawTextLineToBuff(currentColor, secondColor, &curr_pixel_pos[line_w + half_frameX], work_string, uPixelsWidth);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
108 curr_pixel_pos += uPixelsWidth * (currentFont->uFontHeight - 3);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
109 work_string = strtok(0, "\n");
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
110 if ( !work_string )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
111 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
112 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
113 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
114 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
115
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
116 //----- (0044D1E7) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
117 void GUIFont::DrawTextLine( unsigned int uDefaultColor, signed int uX, signed int uY,
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
118 const char *text, int max_len_pix )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
119 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
120 signed int uX_pos; // edi@3
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
121 unsigned char c; // cl@4
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
122 unsigned __int16 draw_color; // cx@12
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
123 unsigned __int8 *pCharPixels; // eax@12
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
124 char color_code[20]; // [sp+Ch] [bp-1Ch]@16
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
125 int text_length; // [sp+20h] [bp-8h]@2
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
126 int text_color; // [sp+24h] [bp-4h]@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
127 int uCharWidth; // [sp+30h] [bp+8h]@9
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
128
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
129 if ( !text )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
130 return;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
131 text_color = ui_current_text_color;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
132 text_length = strlen(text);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
133 uX_pos=uX;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
134 for (int i=0; i<text_length; ++i )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
135 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
136 c = text[i];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
137 if ( IsCharValid(c) )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
138 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
139 switch (c)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
140 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
141 case '\n': //Line Feed 0A 10:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
142 return;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
143 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
144 case '\f': //Form Feed, page eject 0C 12
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
145 strncpy(color_code, &text[i + 1], 5);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
146 color_code[5] = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
147 text_color = atoi(color_code);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
148 ui_current_text_color = text_color;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
149 i += 5;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
150 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
151 case '\t': // Horizontal tab 09
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
152 case '\r': //Carriage Return 0D 13
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
153 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
154 default:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
155 uCharWidth = pMetrics[c].uWidth;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
156 if ( uCharWidth )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
157 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
158 if ( i > 0 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
159 uX_pos += pMetrics[c].uLeftSpacing;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
160 draw_color = text_color;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
161 pCharPixels = &pFontData[font_pixels_offset[c]];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
162 if ( !text_color )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
163 draw_color = -1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
164 pRenderer->DrawText(uX_pos, uY, pCharPixels, uCharWidth, uFontHeight, pFontPalettes[0], draw_color, 0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
165 uX_pos += uCharWidth;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
166 if ( i < text_length )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
167 uX_pos += pMetrics[c].uRightSpacing;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
168 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
169 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
170 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
171 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
172
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
173 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
174
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
175 //----- (0040F845) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
176 void DrawCharToBuff( unsigned short* uXpos,unsigned char* pCharPixels, int uCharWidth, int uCharHeight,
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
177 unsigned __int16* pFontPalette, __int16 draw_color, int line_width )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
178 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
179 unsigned __int16* draw_buff; // edi@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
180 unsigned char* pPixels; // esi@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
181 unsigned char char_pxl; // eax@3
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
182
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
183 draw_buff = uXpos;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
184 pPixels = pCharPixels;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
185 for(int i=0; i<uCharHeight; ++i)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
186 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
187 for(int j=0; j<uCharWidth; ++j)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
188 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
189 char_pxl = *pPixels++;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
190 if ( char_pxl )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
191 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
192 if ( char_pxl == 1 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
193 *draw_buff = pFontPalette[1];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
194 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
195 *draw_buff = draw_color;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
196 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
197 ++draw_buff;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
198 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
199 draw_buff+=line_width-uCharWidth;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
200 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
201
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
202 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
203
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
204 //----- (0044D0B5) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
205 void GUIFont::DrawTextLineToBuff( int uColor, int a3, unsigned short* uX_buff_pos, const char *text, int line_width )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
206 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
207
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
208 unsigned short* uX_pos; // edi@3
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
209 unsigned char c; // cl@4
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
210 unsigned __int16 draw_color; // cx@12
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
211 unsigned __int8 *pCharPixels; // eax@12
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
212 char color_code[20]; // [sp+Ch] [bp-1Ch]@16
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
213 int text_length; // [sp+20h] [bp-8h]@2
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
214 int text_color; // [sp+24h] [bp-4h]@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
215 int uCharWidth; // [sp+30h] [bp+8h]@9
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
216
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
217 if ( !text )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
218 return;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
219 text_color = ui_current_text_color;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
220 text_length = strlen(text);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
221 uX_pos=uX_buff_pos;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
222 for (int i=0; i<text_length; ++i )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
223 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
224 c = text[i];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
225 if ( IsCharValid(c) )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
226 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
227 switch (c)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
228 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
229 case '\n': //Line Feed 0A 10:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
230 return;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
231 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
232 case '\f': //Form Feed, page eject 0C 12
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
233 strncpy(color_code, &text[i + 1], 5);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
234 color_code[5] = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
235 text_color = atoi(color_code);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
236 ui_current_text_color = text_color;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
237 i += 5;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
238 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
239 case '\t': // Horizontal tab 09
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
240 case '_':
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
241 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
242 default:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
243 uCharWidth = pMetrics[c].uWidth;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
244 if ( uCharWidth )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
245 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
246 if ( i > 0 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
247 uX_pos += pMetrics[c].uLeftSpacing;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
248 draw_color = text_color;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
249 pCharPixels = &pFontData[font_pixels_offset[c]];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
250 if ( !text_color )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
251 draw_color = -1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
252 DrawCharToBuff(uX_pos, pCharPixels, uCharWidth, uFontHeight, pFontPalettes[0], draw_color, line_width);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
253 uX_pos += uCharWidth;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
254 if ( i < text_length )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
255 uX_pos += pMetrics[c].uRightSpacing;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
256 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
257 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
258 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
259 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
260 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
261
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
262
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
263
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
264 //----- (0044C933) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
265 char * GUIFont::FitTwoFontStringINWindow( const char *pString, GUIFont *pFontMain, GUIFont *pFontSecond, GUIWindow* pWindow, int startPixlOff, int a6 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
266 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
267
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
268 GUIFont *currentFont; // esi@3
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
269 unsigned char c;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
270 int uInStrLen;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
271 char digits[4];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
272 int possible_transition_point;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
273 int string_pixel_Width;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
274 int start_pixel_offset;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
275
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
276 if (!pString)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
277 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
278 MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:445", 0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
279 return 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
280 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
281 currentFont=pFontMain; // esi@3
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
282 uInStrLen = strlen(pString);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
283 Assert(uInStrLen < sizeof(pTmpBuf3));
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
284 strcpy(pTmpBuf3.data(), pString);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
285 if (uInStrLen==0)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
286 return pTmpBuf3.data();
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
287
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
288 start_pixel_offset=string_pixel_Width=startPixlOff;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
289 possible_transition_point=0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
290 for(int i=0; i<uInStrLen; ++i)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
291 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
292 c=pTmpBuf3[i];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
293 if (pFontMain->IsCharValid(c))
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
294 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
295 switch (c)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
296 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
297 case '\t': // Horizontal tab 09
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
298 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
299 strncpy(digits, &pTmpBuf3[i+1],3);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
300 digits[3]=0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
301 string_pixel_Width = atoi(digits)+startPixlOff;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
302 i+=3;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
303 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
304 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
305 case '\n': //Line Feed 0A 10
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
306 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
307 string_pixel_Width=start_pixel_offset;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
308 possible_transition_point=i;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
309 currentFont=pFontMain;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
310 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
311 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
312 case '\f': //Form Feed, page eject 0C 12
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
313 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
314 i+=5;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
315 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
316 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
317 case '\r': //Carriage Return 0D 13
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
318 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
319 if (!a6)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
320 return (char*)pString;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
321 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
322 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
323 case ' ' :
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
324 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
325 string_pixel_Width+=currentFont->pMetrics[c].uWidth;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
326 possible_transition_point=i;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
327 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
328 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
329 case '_' :
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
330 currentFont=pFontSecond;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
331 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
332 default:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
333
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
334 if ((string_pixel_Width+currentFont->pMetrics[c].uWidth+ currentFont->pMetrics[c].uLeftSpacing+
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
335 currentFont->pMetrics[c].uRightSpacing)<pWindow->uFrameWidth)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
336 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
337 if(i>possible_transition_point)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
338 string_pixel_Width+=currentFont->pMetrics[c].uLeftSpacing;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
339 string_pixel_Width+=currentFont->pMetrics[c].uWidth;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
340 if (i<uInStrLen)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
341 string_pixel_Width+=currentFont->pMetrics[c].uRightSpacing;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
342 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
343 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
344 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
345 pTmpBuf3[possible_transition_point]='\n';
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
346
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
347 if ( currentFont== pFontSecond)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
348 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
349
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
350 for(int k=uInStrLen-1; k>=possible_transition_point+1; --k)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
351 pTmpBuf3[k] = pTmpBuf3[k-1];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
352
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
353 ++uInStrLen;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
354 ++possible_transition_point;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
355 pTmpBuf3[possible_transition_point] = '_';
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
356
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
357 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
358 string_pixel_Width=start_pixel_offset;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
359
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
360 for(int j=possible_transition_point;j<i; ++j )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
361 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
362 c=pTmpBuf3[j];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
363 if (pFontMain->IsCharValid(c))
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
364 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
365 if(j>possible_transition_point)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
366 string_pixel_Width+=pFontMain->pMetrics[c].uLeftSpacing;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
367 string_pixel_Width+=pFontMain->pMetrics[c].uWidth;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
368 if (j<i)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
369 string_pixel_Width+=pFontMain->pMetrics[c].uRightSpacing;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
370
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
371 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
372 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
373 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
374 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
375 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
376 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
377 return pTmpBuf3.data();
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
378
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
379 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
380
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
381
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
382 //----- (0044C6C2) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
383 char* GUIFont::GetPageTop( const char *pInString, GUIWindow *pWindow, unsigned int uX, int a5 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
384 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
385 int text_height; // edi@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
386 char *text_str; // ebx@3
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
387 unsigned char c; // cl@4
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
388 int text_length;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
389
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
390 text_height = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
391
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
392 if ( !pInString )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
393 return 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
394 text_str = FitTextInAWindow(pInString, this, pWindow, uX, 0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
395 text_length = strlen(text_str);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
396 for ( int i = 0; i < text_length; ++i )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
397 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
398 c = text_str[i];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
399 if ( IsCharValid(c) )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
400 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
401 switch (c)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
402 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
403 case '\n': //Line Feed 0A 10:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
404 text_height = text_height + (uFontHeight - 3);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
405 if ( text_height >= (signed int)(a5 * (pWindow->uFrameHeight - (uFontHeight - 3))) )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
406 return &text_str[i];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
407 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
408 case '\f': //Form Feed, page eject 0C 12
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
409 i += 5;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
410 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
411 case '\t': // Horizontal tab 09
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
412 case '\r': //Carriage Return 0D 13
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
413 i += 3;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
414 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
415 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
416 if ( text_height >= (signed int)(a5 * pWindow->uFrameHeight) )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
417 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
418 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
419 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
420 return &text_str[0];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
421 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
422
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
423 //----- (0044C62E) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
424 int GUIFont::GetStringHeight2( GUIFont *secondFont, const char *text_str, GUIWindow* pWindow, int startX, int a6 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
425 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
426
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
427 int uAllHeght;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
428 int uStringLen;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
429 unsigned char c;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
430 char *test_string;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
431
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
432 if ( !text_str )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
433 return 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
434 uAllHeght = uFontHeight - 3;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
435 test_string = FitTwoFontStringINWindow(text_str, this, secondFont, pWindow, startX, 0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
436 uStringLen = strlen(test_string);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
437 for (int i = 0; i < uStringLen; ++i)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
438 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
439 c = test_string[i];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
440 if (IsCharValid(c))
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
441 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
442 switch (c)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
443 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
444 case '\n': //Line Feed 0A 10:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
445 uAllHeght+= uFontHeight - 3;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
446 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
447 case '\f': //Form Feed, page eject 0C 12
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
448 i += 5;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
449 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
450 case '\t': // Horizontal tab 09
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
451 case '\r': //Carriage Return 0D 13
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
452 if (a6 != 1)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
453 i += 3;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
454 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
455 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
456 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
457 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
458
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
459 return uAllHeght;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
460 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
461
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
462 //----- (0044C59D) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
463 int GUIFont::CalcTextHeight( const char *pString, struct GUIWindow *pWindow, int uXOffset, int a5 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
464 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
465 int uAllHeght;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
466 int uStringLen;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
467 unsigned char c;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
468 char *test_string;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
469
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
470 if (!pString)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
471 return 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
472 uAllHeght = uFontHeight - 6;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
473 test_string = FitTextInAWindow(pString, this, pWindow, uXOffset, 0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
474 uStringLen = strlen(pString);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
475 for (int i = 0; i < uStringLen; ++i)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
476 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
477 c = test_string[i];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
478 if (IsCharValid(c))
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
479 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
480 switch (c)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
481 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
482 case '\n': //Line Feed 0A 10:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
483 uAllHeght += uFontHeight - 3;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
484 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
485 case '\f': //Form Feed, page eject 0C 12
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
486 i += 5;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
487 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
488 case '\t': // Horizontal tab 09
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
489 case '\r': //Carriage Return 0D 13
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
490 if (a5 != 1)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
491 i += 3;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
492 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
493 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
494 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
495 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
496 return uAllHeght;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
497 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
498
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
499 //----- (0044C51E) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
500 int GUIFont::GetLineWidth(const char *pString)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
501 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
502 int str_len; // ebp@3
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
503 int string_line_width; // esi@3
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
504 unsigned char c;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
505
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
506 if (!pString)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
507 return 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
508 str_len = strlen(pString);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
509 string_line_width = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
510 for ( int i = 0; i < str_len; ++i )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
511 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
512 c = pString[i];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
513 if (IsCharValid(c))
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
514 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
515 switch (c)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
516 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
517 case '\t':
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
518 case '\n':
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
519 case '\r':
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
520 return string_line_width;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
521 case '\f':
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
522 i += 5;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
523 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
524 default:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
525 if (i > 0)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
526 string_line_width += pMetrics[c].uLeftSpacing;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
527 string_line_width += pMetrics[c].uWidth;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
528 if (i < str_len)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
529 string_line_width +=pMetrics[c].uRightSpacing;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
530 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
531 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
532 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
533 return string_line_width;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
534 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
535
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
536
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
537 //----- (0044C502) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
538 int GUIFont::AlignText_Center(unsigned int uCenterX, const char *pString)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
539 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
540 signed int position; // esi@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
541
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
542 position = (signed int)(uCenterX - GetLineWidth(pString)) >> 1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
543 if ( position >= 0 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
544 return position;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
545 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
546 return 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
547 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
548
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
549 //----- (0044C768) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
550 char * FitTextInAWindow( const char *pInString, GUIFont *pFont, GUIWindow *pWindow, signed int uX, int a5 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
551 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
552 unsigned char c;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
553 int uInStrLen;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
554 char digits[4];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
555 int possible_transition_point;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
556 int string_pixel_Width;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
557 int start_pixel_offset;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
558
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
559 if (!pInString)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
560 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
561 MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:445", 0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
562 return 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
563 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
564 uInStrLen = strlen(pInString);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
565 strcpy(&temp_string[0], pInString);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
566 if (uInStrLen == 0)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
567 return &temp_string[0];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
568
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
569 start_pixel_offset = string_pixel_Width=uX;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
570 possible_transition_point = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
571 for ( int i = 0; i < uInStrLen; ++i )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
572 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
573 c = temp_string[i];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
574 if (pFont->IsCharValid(c))
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
575 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
576 switch (c)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
577 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
578 case '\t': // Horizontal tab 09
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
579 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
580 strncpy(digits, &temp_string[i + 1],3);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
581 digits[3] = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
582 string_pixel_Width = atoi(digits)+uX;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
583 i += 3;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
584 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
585 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
586 case '\n': //Line Feed 0A 10 (конец строки)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
587 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
588 string_pixel_Width = start_pixel_offset;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
589 possible_transition_point = i;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
590 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
591 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
592 case '\f': //Form Feed, page eject 0C 12
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
593 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
594 i += 5;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
595 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
596 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
597 case '\r': //Carriage Return 0D 13
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
598 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
599 if ( !a5 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
600 return (char*)pInString;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
601 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
602 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
603 case ' '://пробел
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
604 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
605 string_pixel_Width += pFont->pMetrics[c].uWidth;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
606 possible_transition_point = i;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
607 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
608 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
609 default:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
610 if ((string_pixel_Width + pFont->pMetrics[c].uWidth + pFont->pMetrics[c].uLeftSpacing +
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
611 pFont->pMetrics[c].uRightSpacing) < pWindow->uFrameWidth )//наращивание длины строки или перенос
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
612 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
613 if ( i > possible_transition_point )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
614 string_pixel_Width += pFont->pMetrics[c].uLeftSpacing;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
615 string_pixel_Width += pFont->pMetrics[c].uWidth;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
616 if (i < uInStrLen)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
617 string_pixel_Width += pFont->pMetrics[c].uRightSpacing;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
618 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
619 else//перенос строки и слова
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
620 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
621 temp_string[possible_transition_point] ='\n';
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
622 string_pixel_Width = start_pixel_offset;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
623 if ( i > possible_transition_point )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
624 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
625 for ( int j = possible_transition_point; j < i; ++j )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
626 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
627 c = temp_string[j];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
628 if (pFont->IsCharValid(c))
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
629 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
630 if ( j > possible_transition_point )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
631 string_pixel_Width += pFont->pMetrics[c].uLeftSpacing;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
632 string_pixel_Width += pFont->pMetrics[c].uWidth;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
633 if ( j < i )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
634 string_pixel_Width += pFont->pMetrics[c].uRightSpacing;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
635 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
636 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
637 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
638 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
639 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
640 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
641 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
642 return &temp_string[0];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
643 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
644 //----- (00414162) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
645 void uGameUIFontMain_initialize()
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
646 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
647 uGameUIFontMain = Color16(0xAu, 0, 0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
648 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
649
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
650 //----- (00414174) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
651 void uGameUIFontShadow_initialize()
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
652 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
653 uGameUIFontShadow = Color16(0xE6u, 214, 193);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
654 }