@@ -43,7 +43,9 @@ If you have questions concerning this license or the applicable additional terms
4343struct overlayText_t {
4444 idStr text;
4545 justify_t justify;
46+ textSize_t size;
4647 int time;
48+ bool showbackground = false ;
4749};
4850
4951// the console will query the cvar and command systems for
@@ -61,7 +63,7 @@ class idConsoleLocal : public idConsole {
6163 virtual void Print ( const char *text );
6264 virtual void Draw ( bool forceFullScreen );
6365
64- virtual void PrintOverlay ( idOverlayHandle &handle, justify_t justify, const char *text, ... );
66+ virtual void PrintOverlay ( idOverlayHandle &handle, justify_t justify, const char *text, bool showbackground, textSize_t size, ... );
6567
6668 void Dump ( const char *toFile );
6769 void Clear ();
@@ -87,8 +89,10 @@ class idConsoleLocal : public idConsole {
8789 void SetDisplayFraction ( float frac );
8890 void UpdateDisplayFraction ( void );
8991
90- void DrawTextLeftAlign ( float x, float &y, const char *text, ... );
91- void DrawTextRightAlign ( float x, float &y, const char *text, ... );
92+ void DrawTextSmallLeftAlign ( float x, float &y, const char *text, ... );
93+ void DrawTextSmallRightAlign ( float x, float &y, const char *text, ... );
94+ void DrawTextBigLeftAlign ( float x, float &y, const char *text, ... );
95+ void DrawTextBigRightAlign ( float x, float &y, const char *text, ... );
9296
9397 float DrawFPS ( float y );
9498 float DrawMemoryUsage ( float y );
@@ -188,34 +192,64 @@ idCVar idConsoleLocal::con_noBackground( "con_noBackground", "0", CVAR_BOOL | CV
188192
189193/*
190194==================
191- idConsoleLocal::DrawTextLeftAlign
195+ idConsoleLocal::DrawSmallTextLeftAlign
192196==================
193197*/
194- void idConsoleLocal::DrawTextLeftAlign ( float x, float &y, const char *text, ... ) {
198+ void idConsoleLocal::DrawTextSmallLeftAlign ( float x, float &y, const char *text, ... ) {
195199 char string[MAX_STRING_CHARS];
196200 va_list argptr;
197201 va_start ( argptr, text );
198202 idStr::vsnPrintf ( string, sizeof ( string ), text, argptr );
199203 va_end ( argptr );
200- renderSystem->DrawSmallStringExt ( x, y + 2 , string, colorWhite, true , localConsole.charSetShader );
204+ renderSystem->DrawSmallStringExt ( x, y + 2 , string, colorWhite, true , true , idStr::Length ( string ), localConsole.charSetShader );
201205 y += SMALLCHAR_HEIGHT + 4 ;
202206}
203207
204208/*
205209==================
206- idConsoleLocal::DrawTextRightAlign
210+ idConsoleLocal::DrawTextSmallRightAlign
207211==================
208212*/
209- void idConsoleLocal::DrawTextRightAlign ( float x, float &y, const char *text, ... ) {
213+ void idConsoleLocal::DrawTextSmallRightAlign ( float x, float &y, const char *text, ... ) {
210214 char string[MAX_STRING_CHARS];
211215 va_list argptr;
212216 va_start ( argptr, text );
213217 int i = idStr::vsnPrintf ( string, sizeof ( string ), text, argptr );
214218 va_end ( argptr );
215- renderSystem->DrawSmallStringExt ( x - i * SMALLCHAR_WIDTH, y + 2 , string, colorWhite, true , localConsole.charSetShader );
219+ renderSystem->DrawSmallStringExt ( x - i * SMALLCHAR_WIDTH, y + 2 , string, colorWhite, true , true , idStr::Length ( string ), localConsole.charSetShader );
216220 y += SMALLCHAR_HEIGHT + 4 ;
217221}
218222
223+ /*
224+ ==================
225+ idConsoleLocal::DrawTextBigLeftAlign
226+ ==================
227+ */
228+ void idConsoleLocal::DrawTextBigLeftAlign ( float x, float &y, const char *text, ... ) {
229+ char string[MAX_STRING_CHARS];
230+ va_list argptr;
231+ va_start ( argptr, text );
232+ idStr::vsnPrintf ( string, sizeof ( string ), text, argptr );
233+ va_end ( argptr );
234+ renderSystem->DrawBigStringExt ( x, y + 2 , string, colorWhite, true , true , idStr::Length ( string ), localConsole.charSetShader );
235+ y += BIGCHAR_HEIGHT + 4 ;
236+ }
237+
238+ /*
239+ ==================
240+ idConsoleLocal::DrawTextBigRightAlign
241+ ==================
242+ */
243+ void idConsoleLocal::DrawTextBigRightAlign ( float x, float &y, const char *text, ... ) {
244+ char string[MAX_STRING_CHARS];
245+ va_list argptr;
246+ va_start ( argptr, text );
247+ int i = idStr::vsnPrintf ( string, sizeof ( string ), text, argptr );
248+ va_end ( argptr );
249+ renderSystem->DrawBigStringExt ( x - i * BIGCHAR_WIDTH, y + 2 , string, colorWhite, true , true , idStr::Length ( string ), localConsole.charSetShader );
250+ y += BIGCHAR_HEIGHT + 4 ;
251+ }
252+
219253/*
220254==================
221255idConsoleLocal::DrawFPS
@@ -248,9 +282,9 @@ float idConsoleLocal::DrawFPS( float y ) {
248282 fps = ( fps + 500 ) / 1000 ;
249283
250284 const char * s = va ( " %ifps" , fps );
251- int w = strlen ( s ) * BIGCHAR_WIDTH;
252285
253- renderSystem->DrawBigStringExt ( LOCALSAFE_RIGHT - w, idMath::Ftoi ( y ) + 2 , s, colorWhite, true , localConsole.charSetShader );
286+ static idOverlayHandle handle;
287+ PrintOverlay ( handle, JUSTIFY_RIGHT, s, false , TEXTSIZE_LARGE );
254288 }
255289
256290 return y + BIGCHAR_HEIGHT + 4 ;
@@ -265,14 +299,17 @@ float idConsoleLocal::DrawMemoryUsage( float y ) {
265299 memoryStats_t allocs, frees;
266300
267301 Mem_GetStats ( allocs );
268- DrawTextRightAlign ( LOCALSAFE_RIGHT, y, " total allocated memory: %4d, %4dkB" , allocs.num , allocs.totalSize >> 10 );
302+ idStr s = va ( " total allocated memory: %4d, %4dkB\n " , allocs.num , allocs.totalSize >> 10 );
269303
270304 Mem_GetFrameStats ( allocs, frees );
271- DrawTextRightAlign ( LOCALSAFE_RIGHT, y, " frame alloc: %4d, %4dkB frame free: %4d, %4dkB" , allocs.num , allocs.totalSize >>10 , frees.num , frees.totalSize >>10 );
305+ s += va ( " frame alloc: %4d, %4dkB frame free: %4d, %4dkB" , allocs.num , allocs.totalSize >>10 , frees.num , frees.totalSize >>10 );
272306
273307 Mem_ClearFrameStats ();
274308
275- return y;
309+ static idOverlayHandle handle;
310+ PrintOverlay ( handle, JUSTIFY_LEFT, s.c_str (), false , TEXTSIZE_SMALL );
311+
312+ return y + BIGCHAR_HEIGHT + 4 ;
276313}
277314
278315/*
@@ -283,12 +320,13 @@ idConsoleLocal::DrawAsyncStats
283320float idConsoleLocal::DrawAsyncStats ( float y ) {
284321 int i, outgoingRate, incomingRate;
285322 float outgoingCompression, incomingCompression;
323+ idStr s;
286324
287325 if ( idAsyncNetwork::server.IsActive () ) {
288326
289- DrawTextRightAlign ( LOCALSAFE_RIGHT, y, " server delay = %d msec" , idAsyncNetwork::server.GetDelay () );
290- DrawTextRightAlign ( LOCALSAFE_RIGHT, y, " total outgoing rate = %d KB/s" , idAsyncNetwork::server.GetOutgoingRate () >> 10 );
291- DrawTextRightAlign ( LOCALSAFE_RIGHT, y, " total incoming rate = %d KB/s" , idAsyncNetwork::server.GetIncomingRate () >> 10 );
327+ s = va ( " server delay = %d msec\n " , idAsyncNetwork::server.GetDelay () );
328+ s += va ( " total outgoing rate = %d KB/s\n " , idAsyncNetwork::server.GetOutgoingRate () >> 10 );
329+ s += va ( " total incoming rate = %d KB/s\n " , idAsyncNetwork::server.GetIncomingRate () >> 10 );
292330
293331 for ( i = 0 ; i < MAX_ASYNC_CLIENTS; i++ ) {
294332
@@ -298,14 +336,14 @@ float idConsoleLocal::DrawAsyncStats( float y ) {
298336 incomingCompression = idAsyncNetwork::server.GetClientIncomingCompression ( i );
299337
300338 if ( outgoingRate != -1 && incomingRate != -1 ) {
301- DrawTextRightAlign ( LOCALSAFE_RIGHT, y, " client %d: out rate = %d B/s (% -2.1f%%), in rate = %d B/s (% -2.1f%%)" ,
302- i, outgoingRate, outgoingCompression, incomingRate, incomingCompression );
339+ s += va ( " client %d: out rate = %d B/s (% -2.1f%%), in rate = %d B/s (% -2.1f%%)\n " ,
340+ i, outgoingRate, outgoingCompression, incomingRate, incomingCompression );
303341 }
304342 }
305343
306344 idStr msg;
307345 idAsyncNetwork::server.GetAsyncStatsAvgMsg ( msg );
308- DrawTextRightAlign ( LOCALSAFE_RIGHT, y, " %s" , msg.c_str () );
346+ s += va ( " %s" , msg.c_str () );
309347
310348 } else if ( idAsyncNetwork::client.IsActive () ) {
311349
@@ -315,18 +353,20 @@ float idConsoleLocal::DrawAsyncStats( float y ) {
315353 incomingCompression = idAsyncNetwork::client.GetIncomingCompression ();
316354
317355 if ( outgoingRate != -1 && incomingRate != -1 ) {
318- DrawTextRightAlign ( LOCALSAFE_RIGHT, y, " out rate = %d B/s (% -2.1f%%), in rate = %d B/s (% -2.1f%%)" ,
319- outgoingRate, outgoingCompression, incomingRate, incomingCompression );
356+ s += va ( " out rate = %d B/s (% -2.1f%%), in rate = %d B/s (% -2.1f%%)\n " ,
357+ outgoingRate, outgoingCompression, incomingRate, incomingCompression );
320358 }
321359
322- DrawTextRightAlign ( LOCALSAFE_RIGHT, y, " packet loss = %d%%, client prediction = %d" ,
323- (int )idAsyncNetwork::client.GetIncomingPacketLoss (), idAsyncNetwork::client.GetPrediction () );
360+ s += va ( " packet loss = %d%%, client prediction = %d\n " ,
361+ (int )idAsyncNetwork::client.GetIncomingPacketLoss (), idAsyncNetwork::client.GetPrediction () );
324362
325- DrawTextRightAlign ( LOCALSAFE_RIGHT, y, " predicted frames: %d" , idAsyncNetwork::client.GetPredictedFrames () );
363+ s += va ( " predicted frames: %d\n " , idAsyncNetwork::client.GetPredictedFrames () );
326364
365+ static idOverlayHandle handle;
366+ PrintOverlay ( handle, JUSTIFY_LEFT, s.c_str (), false , TEXTSIZE_SMALL );
327367 }
328368
329- return y;
369+ return y + BIGCHAR_HEIGHT + 4 ;
330370}
331371
332372/*
@@ -335,6 +375,7 @@ idConsoleLocal::DrawSoundDecoders
335375==================
336376*/
337377float idConsoleLocal::DrawSoundDecoders ( float y ) {
378+ const char * decoder;
338379 int index, numActiveDecoders;
339380 soundDecoderInfo_t decoderInfo;
340381
@@ -353,10 +394,14 @@ float idConsoleLocal::DrawSoundDecoders( float y ) {
353394 } else {
354395 percent = localTime * 100 / sampleTime;
355396 }
356- DrawTextLeftAlign ( LOCALSAFE_RIGHT, y, " %3d: %3d%% (%1.2f) %s: %s (%dkB)" , numActiveDecoders, percent, decoderInfo.lastVolume , decoderInfo.format .c_str (), decoderInfo.name .c_str (), decoderInfo.numBytes >> 10 );
397+ decoder = va ( " %3d: %3d%% (%1.2f) %s: %s (%dkB)" , numActiveDecoders, percent, decoderInfo.lastVolume , decoderInfo.format .c_str (), decoderInfo.name .c_str (), decoderInfo.numBytes >> 10 );
398+
399+ static idOverlayHandle handle;
400+ PrintOverlay ( handle, JUSTIFY_LEFT, decoder, false , TEXTSIZE_SMALL );
401+
357402 numActiveDecoders++;
358403 }
359- return y;
404+ return y + BIGCHAR_HEIGHT + 4 ;
360405}
361406
362407// =========================================================================
@@ -1553,7 +1598,7 @@ void idConsoleLocal::Draw( bool forceFullScreen ) {
15531598idConsoleLocal::PrintOverlay
15541599========================
15551600*/
1556- void idConsoleLocal::PrintOverlay ( idOverlayHandle &handle, justify_t justify, const char *text, ... ) {
1601+ void idConsoleLocal::PrintOverlay ( idOverlayHandle &handle, justify_t justify, const char *text, bool showbackground, textSize_t size, ... ) {
15571602 if ( handle.index >= 0 && handle.index < overlayText.Num () ) {
15581603 if ( overlayText[handle.index ].time == handle.time ) {
15591604 return ;
@@ -1562,14 +1607,16 @@ void idConsoleLocal::PrintOverlay( idOverlayHandle &handle, justify_t justify, c
15621607
15631608 char string[MAX_PRINT_MSG];
15641609 va_list argptr;
1565- va_start ( argptr, text );
1610+ va_start ( argptr, size );
15661611 idStr::vsnPrintf ( string, sizeof ( string ), text, argptr );
15671612 va_end ( argptr );
15681613
15691614 overlayText_t &overlay = overlayText.Alloc ();
15701615 overlay.text = string;
15711616 overlay.justify = justify;
1617+ overlay.size = size;
15721618 overlay.time = Sys_Milliseconds ();
1619+ overlay.showbackground = showbackground;
15731620
15741621 handle.index = overlayText.Num () - 1 ;
15751622 handle.time = overlay.time ;
@@ -1597,25 +1644,28 @@ void idConsoleLocal::DrawOverlayText( float & leftY, float & rightY, float & cen
15971644 }
15981645 }
15991646
1600- idVec4 bgColor ( 0 .0f , 0 .0f , 0 .0f , 0 .75f );
1601-
16021647 const float width = maxWidth * SMALLCHAR_WIDTH;
16031648 const float height = numLines * ( SMALLCHAR_HEIGHT + 4 );
1604- const float bgAdjust = - 0 .5f * SMALLCHAR_WIDTH;
1605- if ( overlayText[i].justify == JUSTIFY_LEFT ) {
1606- renderSystem->SetColor ( bgColor );
1607- renderSystem->DrawStretchPic ( LOCALSAFE_LEFT + bgAdjust, leftY, width, height, 0 , 0 , 0 , 0 , whiteShader );
1608- renderSystem->SetColor ( bgColor );
1609- } else if ( overlayText[i].justify == JUSTIFY_RIGHT ) {
1610- renderSystem->SetColor ( bgColor );
1611- renderSystem->DrawStretchPic ( LOCALSAFE_RIGHT - width + bgAdjust, rightY, width, height, 0 , 0 , 0 , 0 , whiteShader );
1612- renderSystem->SetColor ( bgColor );
1613- } else if ( overlayText[i].justify == JUSTIFY_CENTER_LEFT || overlayText[i].justify == JUSTIFY_CENTER_RIGHT ) {
1614- renderSystem->SetColor ( bgColor );
1615- renderSystem->DrawStretchPic ( LOCALSAFE_LEFT + ( LOCALSAFE_WIDTH - width + bgAdjust ) * 0 .5f , centerY, width, height, 0 , 0 , 0 , 0 , whiteShader );
1616- renderSystem->SetColor ( bgColor );
1617- } else {
1618- assert ( false );
1649+
1650+ if ( overlayText[i].showbackground ) {
1651+ idVec4 bgColor ( 0 .0f , 0 .0f , 0 .0f , 0 .75f );
1652+
1653+ const float bgAdjust = - 0 .5f * SMALLCHAR_WIDTH;
1654+ if ( overlayText[i].justify == JUSTIFY_LEFT ) {
1655+ renderSystem->SetColor ( bgColor );
1656+ renderSystem->DrawStretchPic ( LOCALSAFE_LEFT + bgAdjust, leftY, width, height, 0 , 0 , 0 , 0 , whiteShader );
1657+ renderSystem->SetColor ( bgColor );
1658+ } else if ( overlayText[i].justify == JUSTIFY_RIGHT ) {
1659+ renderSystem->SetColor ( bgColor );
1660+ renderSystem->DrawStretchPic ( LOCALSAFE_RIGHT - width + bgAdjust, rightY, width, height, 0 , 0 , 0 , 0 , whiteShader );
1661+ renderSystem->SetColor ( bgColor );
1662+ } else if ( overlayText[i].justify == JUSTIFY_CENTER_LEFT || overlayText[i].justify == JUSTIFY_CENTER_RIGHT ) {
1663+ renderSystem->SetColor ( bgColor );
1664+ renderSystem->DrawStretchPic ( LOCALSAFE_LEFT + ( LOCALSAFE_WIDTH - width + bgAdjust ) * 0 .5f , centerY, width, height, 0 , 0 , 0 , 0 , whiteShader );
1665+ renderSystem->SetColor ( bgColor );
1666+ } else {
1667+ assert ( false );
1668+ }
16191669 }
16201670
16211671 idStr singleLine;
@@ -1624,16 +1674,30 @@ void idConsoleLocal::DrawOverlayText( float & leftY, float & rightY, float & cen
16241674 for ( int k = j; k < text.Length () && text[k] != ' \n ' ; k++ ) {
16251675 singleLine.Append ( text[k] );
16261676 }
1627- if ( overlayText[i].justify == JUSTIFY_LEFT ) {
1628- DrawTextLeftAlign ( LOCALSAFE_LEFT, leftY, " %s" , singleLine.c_str () );
1629- } else if ( overlayText[i].justify == JUSTIFY_RIGHT ) {
1630- DrawTextRightAlign ( LOCALSAFE_RIGHT, rightY, " %s" , singleLine.c_str () );
1631- } else if ( overlayText[i].justify == JUSTIFY_CENTER_LEFT ) {
1632- DrawTextLeftAlign ( LOCALSAFE_LEFT + ( LOCALSAFE_WIDTH - width ) * 0 .5f , centerY, " %s" , singleLine.c_str () );
1633- } else if ( overlayText[i].justify == JUSTIFY_CENTER_RIGHT ) {
1634- DrawTextRightAlign ( LOCALSAFE_LEFT + ( LOCALSAFE_WIDTH + width ) * 0 .5f , centerY, " %s" , singleLine.c_str () );
1677+ if ( overlayText[i].size == TEXTSIZE_SMALL ) {
1678+ if ( overlayText[i].justify == JUSTIFY_LEFT ) {
1679+ DrawTextSmallLeftAlign ( LOCALSAFE_LEFT, leftY, " %s" , singleLine.c_str () );
1680+ } else if ( overlayText[i].justify == JUSTIFY_RIGHT ) {
1681+ DrawTextSmallRightAlign ( LOCALSAFE_RIGHT, rightY, " %s" , singleLine.c_str () );
1682+ } else if ( overlayText[i].justify == JUSTIFY_CENTER_LEFT ) {
1683+ DrawTextSmallLeftAlign ( LOCALSAFE_LEFT + ( LOCALSAFE_WIDTH - width ) * 0 .5f , centerY, " %s" , singleLine.c_str () );
1684+ } else if ( overlayText[i].justify == JUSTIFY_CENTER_RIGHT ) {
1685+ DrawTextSmallRightAlign ( LOCALSAFE_LEFT + ( LOCALSAFE_WIDTH + width ) * 0 .5f , centerY, " %s" , singleLine.c_str () );
1686+ } else {
1687+ assert ( false );
1688+ }
16351689 } else {
1636- assert ( false );
1690+ if ( overlayText[i].justify == JUSTIFY_LEFT ) {
1691+ DrawTextBigLeftAlign ( LOCALSAFE_LEFT, leftY, " %s" , singleLine.c_str () );
1692+ } else if ( overlayText[i].justify == JUSTIFY_RIGHT ) {
1693+ DrawTextBigRightAlign ( LOCALSAFE_RIGHT, rightY, " %s" , singleLine.c_str () );
1694+ } else if ( overlayText[i].justify == JUSTIFY_CENTER_LEFT ) {
1695+ DrawTextBigLeftAlign ( LOCALSAFE_LEFT + ( LOCALSAFE_WIDTH - width ) * 0 .5f , centerY, " %s" , singleLine.c_str () );
1696+ } else if ( overlayText[i].justify == JUSTIFY_CENTER_RIGHT ) {
1697+ DrawTextBigRightAlign ( LOCALSAFE_LEFT + ( LOCALSAFE_WIDTH + width ) * 0 .5f , centerY, " %s" , singleLine.c_str () );
1698+ } else {
1699+ assert ( false );
1700+ }
16371701 }
16381702 }
16391703 }
0 commit comments