45 static std::string whichdockedfont =
vs_config->
getVariable(
"graphics",
"basefont",
"helvetica12" );
49 static bool lastinside = inside;
50 if (lastinside != inside) {
53 }
else {changed =
false; }
return inside ? whichdockedfont : whichfont;
59 static std::string whichdockedfont =
vs_config->
getVariable(
"graphics",
"basefont",
"helvetica12" );
61 static bool lastinside = inside;
62 if (lastinside != inside) {
65 }
else {changed =
false; }
return inside ? whichdockedfont : whichfont;
68 void *
getFont(
bool forceinside =
false,
bool whichinside =
false )
71 std::string whichfont =
getStringFont( changed, forceinside, whichinside );
72 static void *retval = NULL;
73 if (changed) retval = NULL;
75 if (whichfont ==
"helvetica10")
76 retval = GLUT_BITMAP_HELVETICA_10;
77 else if (whichfont ==
"helvetica18")
78 retval = GLUT_BITMAP_HELVETICA_18;
79 else if (whichfont ==
"times24")
80 retval = GLUT_BITMAP_TIMES_ROMAN_24;
81 else if (whichfont ==
"times10")
82 retval = GLUT_BITMAP_TIMES_ROMAN_10;
83 else if (whichfont ==
"fixed13")
84 retval = GLUT_BITMAP_8_BY_13;
85 else if (whichfont ==
"fixed15")
86 retval = GLUT_BITMAP_9_BY_15;
88 retval = GLUT_BITMAP_HELVETICA_12;
97 static float point = 0;
101 if (whichfont ==
"helvetica10")
103 else if (whichfont ==
"helvetica18")
105 else if (whichfont ==
"times24")
107 else if (whichfont ==
"times10")
109 else if (whichfont ==
"fixed13")
111 else if (whichfont ==
"fixed15")
125 myFontMetrics.Set( .06, .08, 0 );
133 return Draw( myText, offset,
true,
false,
true );
138 static unsigned int lists[256] = {0};
139 void *fnt0 =
getFont(
true,
false );
140 void *fnt1 =
getFont(
true,
true );
143 if (use_display_lists) {
144 for (
unsigned int i = 32;
i < 256;
i++)
145 if ( (
i < 128) || (
i >= 128+32) ) {
148 glutBitmapCharacter(
i < 128 ? fnt0 : fnt1,
i%128 );
150 glutStrokeCharacter( GLUT_STROKE_ROMAN,
i%128 );
160 if (a >=
'0' && a <=
'9')
162 else if (a >=
'a' && a <=
'f')
164 else if (a >=
'A' && a <=
'F')
179 void DrawSquare(
float left,
float right,
float top,
float bot )
196 void *fnt = use_bit ?
getFont() : GLUT_STROKE_ROMAN;
197 float charwid = use_bit ? glutBitmapWidth( fnt, c ) : glutStrokeWidth( fnt, c );
198 float dubyawid = use_bit ? glutBitmapWidth( fnt,
'W' ) : glutStrokeWidth( fnt,
'W' );
199 return charwid*myFontMetrics/dubyawid;
203 string::const_iterator end,
211 if (*begin ==
' ' && !last_row) {
214 for (; begin != end && cur_pos <= end_pos && !isspace( *begin ); begin++)
216 return cur_pos > end_pos;
218 return cur_pos+( (begin+1 != end) ?
charWidth( *begin, metrics ) : 0 ) >= end_pos;
221 int TextPlane::Draw(
const string &newText,
int offset,
bool startlower,
bool force_highquality,
bool automatte )
224 bool drawbg = (
bgcol.
a != 0);
225 static unsigned int *display_lists =
CreateLists();
227 string::const_iterator text_it = newText.begin();
228 static bool use_bit = force_highquality
233 static float std_wid = glutStrokeWidth( GLUT_STROKE_ROMAN,
'W' );
234 myFontMetrics.i = font_point*std_wid/(119.05+33.33);
236 myFontMetrics.i = glutBitmapWidth( fnt,
'W' );
237 myFontMetrics.j = font_point;
245 myFontMetrics.j = rowheight;
250 if (!use_bit && font_antialias) {
253 glEnable( GL_LINE_SMOOTH );
257 glDisable( GL_LINE_SMOOTH );
267 if (!automatte && drawbg) {
269 DrawSquare( col, this->myDims.i, row-rowheight*.25, row+rowheight );
273 for (; entercount < offset && text_it != newText.end(); text_it++)
274 if (*text_it ==
'\n')
276 glTranslatef( col, row, 0 );
277 glRasterPos2f( 0, 0 );
280 int potentialincrease = 0;
286 scalex = numplayers*myFontMetrics.i/std_wid;
287 scaley = myFontMetrics.j/(119.05+33.33);
289 glScalef( scalex, scaley, 1 );
290 bool firstThroughLoop =
true;
292 while ( text_it != newText.end() && (firstThroughLoop || row > myDims.j-rowheight*.25) ) {
293 unsigned char myc = *text_it;
303 shadowlen = myFontMetrics.i*glutStrokeWidth( GLUT_STROKE_ROMAN, myc )/std_wid;
305 if (*text_it ==
'#') {
306 if (newText.end()-text_it > 6) {
311 if (r == 0 && g == 0 && b == 0)
312 currentCol = this->
col;
314 currentCol =
GFXColor( r, g, b, this->col.a );
316 static bool setRasterPos =
318 if (use_bit && setRasterPos)
319 glRasterPos2f( col-origcol, 0 );
326 }
else if (*text_it >= 32) {
330 DrawSquare( col-origcol, col-origcol+shadowlen/scalex, -rowheight*.25/scaley, rowheight*.75/scaley );
334 retval += potentialincrease;
335 potentialincrease = 0;
336 int lists = display_lists[myc+(
isInside() ? 128 : 0)];
341 glutBitmapCharacter( fnt, myc );
343 glutStrokeCharacter( GLUT_STROKE_ROMAN, myc );
346 if (*text_it ==
'\t') {
351 -rowheight*.25/scaley,
352 rowheight*.75/scaley );
356 glutBitmapCharacter( fnt,
' ' );
357 glutBitmapCharacter( fnt,
' ' );
358 glutBitmapCharacter( fnt,
' ' );
359 glutBitmapCharacter( fnt,
' ' );
360 glutBitmapCharacter( fnt,
' ' );
364 if (
doNewLine( text_it, newText.end(),
col, myDims.i, myFontMetrics.i, row-rowheight <= myDims.j ) ) {
366 firstThroughLoop =
false;
371 if (!automatte && drawbg) {
373 DrawSquare( col, this->myDims.i, row-rowheight*.25, row+rowheight*.75 );
375 if (*text_it ==
'\n')
376 currentCol = this->
col;
378 glTranslatef( col, row, 0 );
379 glScalef( scalex, scaley, 1 );
380 glRasterPos2f( 0, 0 );
386 glDisable( GL_LINE_SMOOTH );