From e481c86ba24d8da6b8e49c8a58b04e4b1adae4f0 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Wed, 15 Feb 2023 05:53:39 +0300 Subject: [PATCH] engine: client: console: fix NXPrintf newlines, small refactoring --- engine/client/console.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/engine/client/console.c b/engine/client/console.c index 615142a0..742b10b9 100644 --- a/engine/client/console.c +++ b/engine/client/console.c @@ -1732,30 +1732,37 @@ Custom debug messages */ int Con_DrawDebugLines( void ) { + notify_t *notify = con.notify; int i, count = 0; int defaultX; int y = 20; + int fontTall; + + if( !con.curFont || !con.curFont->valid ) + return 0; defaultX = refState.width / 4; + fontTall = con.curFont->charHeight + 1; - for( i = 0; i < MAX_DBG_NOTIFY; i++ ) + for( i = 0; i < ARRAYSIZE( con.notify ); i++, notify++ ) { - if( host.realtime < con.notify[i].expire && con.notify[i].key_dest == cls.key_dest ) - { - int x, len; - int fontTall = 0; + int x, len; + + if( host.realtime > notify->expire ) + continue; + + if( notify->key_dest != cls.key_dest ) + continue; - Con_DrawStringLen( con.notify[i].szNotify, &len, &fontTall ); - x = refState.width - Q_max( defaultX, len ) - 10; - fontTall += 1; + Con_DrawStringLen( notify->szNotify, &len, NULL ); + x = refState.width - Q_max( defaultX, len ) - 10; - if( y + fontTall > refState.height - 20 ) - return count; + if( y + fontTall > refState.height - 20 ) + return count; - count++; - y = 20 + fontTall * i; - Con_DrawString( x, y, con.notify[i].szNotify, con.notify[i].color ); - } + count++; + y += fontTall; + CL_DrawString( x, y, notify->szNotify, notify->color, con.curFont, FONT_DRAW_UTF8 | FONT_DRAW_NOLF ); } return count;